:root {
    --fs-primary: #255B75;
    --fs-primary-dark: #1e4a60;
    --fs-primary-muted: rgba(255, 255, 255, 0.15);
    --sidebar-width: 220px;
    --text: #1a1a2e;
    --muted: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --heading: #0f172a;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    font-size: 0.9375rem;
    color: var(--text);
    background: var(--bg);
}

/* --- Layout --- */

.page {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--fs-primary);
    color: white;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.main-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 52px;
    padding: 0 4rem 0 4.5rem;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.topbar-spacer {
    flex: 1;
}

.topbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.topbar-btn:hover {
    background: var(--bg);
    color: var(--text);
}

main {
    flex: 1;
    padding: 2rem 2.5rem;
    min-width: 0;
    overflow-y: auto;
}

/* --- Sidebar nav --- */

.navbar-brand {
    display: block;
    padding: 1.25rem 1rem;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    border-bottom: 1px solid var(--fs-primary-muted);
    letter-spacing: -0.01em;
}

.nav-items {
    padding: 0.5rem 0;
}

.nav-link {
    display: block;
    padding: 0.5rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 6px;
    margin: 0.125rem 0.5rem;
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    background: var(--fs-primary-muted);
    color: white;
}

.nav-link.active {
    background: var(--fs-primary-muted);
    color: white;
    font-weight: 600;
}

/* --- Typography --- */

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--heading);
    margin: 0 0 1.5rem;
}

h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--heading);
    margin: 0 0 1rem;
}

a {
    color: var(--fs-primary);
}

/* --- Dashboard --- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
}

.stat-icon {
    color: var(--fs-primary);
    margin-bottom: 0.75rem;
    display: flex;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--heading);
    line-height: 1;
    margin-bottom: 0.375rem;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--muted);
    font-weight: 500;
}

.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 2rem;
}

.panel {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.panel-header {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.activity-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.activity-list li {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.activity-list li:last-child {
    border-bottom: none;
}

.activity-op {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.1875rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.activity-op--create  { background: #dcfce7; color: #16a34a; }
.activity-op--update  { background: #dbeafe; color: #2563eb; }
.activity-op--delete  { background: #fee2e2; color: #dc2626; }

.activity-org {
    font-weight: 500;
    color: var(--text);
    flex: 1;
}

.activity-time {
    color: var(--muted);
    font-size: 0.8125rem;
    flex-shrink: 0;
}

/* --- Buttons --- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.9375rem;
    font-family: inherit;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}

.btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.8125rem;
}

.btn-primary {
    background: var(--fs-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--fs-primary-dark);
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
}

.btn-danger:hover {
    background: #fecaca;
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
    color: var(--text);
}

/* --- Forms --- */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0;
}

.add-form {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.form-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group-inline {
    justify-content: flex-end;
    padding-bottom: 0.5rem;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group-inline label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 400;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}

input[type="email"],
input[type="text"],
input[type="password"] {
    padding: 0.5rem 0.75rem;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--text);
    background: white;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-width: 260px;
}

input[type="email"]:focus,
input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--fs-primary);
    box-shadow: 0 0 0 3px rgba(37, 91, 117, 0.1);
}

.inline-input {
    min-width: 0;
    width: 100%;
    padding: 0.3125rem 0.5rem;
    font-size: 0.9375rem;
}

.form-error {
    color: #dc2626;
    font-size: 0.875rem;
    margin: 0.75rem 0 0;
}

.row-actions {
    white-space: nowrap;
    display: flex;
    gap: 0.375rem;
}

/* --- Table --- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

th {
    text-align: left;
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: #f1f5f9;
}

.muted {
    color: var(--muted);
    font-size: 0.875rem;
    margin: 0 0 1rem;
}

/* --- Spinner --- */

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border);
    border-top-color: var(--fs-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}

.spinner-sm {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

.panel-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.panel-empty {
    padding: 1.25rem 1rem;
    margin: 0;
}

/* --- Login --- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem 2.5rem;
    width: 100%;
    max-width: 380px;
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--fs-primary);
    margin: 0 0 1.5rem;
    letter-spacing: -0.02em;
}

/* --- Blazor plumbing --- */

#blazor-error-ui {
    background: #b32121;
    color: white;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: white;
    font-weight: 600;
    margin-left: 0.5rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.5rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.validation-message {
    color: #dc2626;
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}
