:root {
    --primary: #1F3A5F;
    --primary-dark: #16293F;
    --primary-light: #EEF2F6;
    --accent: #0F7A5A;
    --accent-dark: #0B5E45;
    --bg: #F3F1EC;
    --surface: #FFFcf8;
    --surface-muted: #F7F5F0;
    --sidebar: #12161C;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --text: #16181D;
    --text-muted: #5E6570;
    --text-light: #8B928A;
    --border: #E4E0D8;
    --success: #0F7A5A;
    --success-bg: #E8F5EF;
    --warning: #A16207;
    --warning-bg: #FBF6E8;
    --danger: #B42318;
    --danger-bg: #FDECEC;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(18, 22, 28, 0.04);
    --shadow: 0 12px 32px rgba(18, 22, 28, 0.06);
    --shadow-lg: 0 24px 48px rgba(18, 22, 28, 0.1);
    --sidebar-width: 260px;
    --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: "Instrument Sans", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Shell */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar);
    color: #F8FAFC;
    padding: 1.35rem 0.9rem 1.1rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.25rem 0.75rem 1.5rem;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.22);
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.04em;
    color: #F6F3EC;
}

.brand-title {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.brand-sub {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    color: var(--text-light);
}

.sidebar-nav { flex: 1; }

.nav-section {
    margin: 1.25rem 0 0.5rem;
    padding: 0 0.85rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #475569;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #94A3B8;
    text-decoration: none;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.25rem;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.18s ease;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-link.active,
a.nav-link.active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    box-shadow: inset 2px 0 0 #E7C98A;
}

.nav-icon {
    width: 1.15rem;
    height: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem 0.5rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.15);
    color: #6EE7B7;
    margin-bottom: 0.75rem;
}

.status-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #34D399;
    animation: live-pulse 2s infinite;
}

.footer-meta {
    margin: 0 0 0.5rem;
    font-size: 0.72rem;
    color: #64748B;
    padding: 0 0.25rem;
}

.footer-link {
    font-size: 0.78rem;
    color: #A5B4FC;
    text-decoration: none;
}

.footer-link:hover { text-decoration: underline; color: #C7D2FE; }

.main-area {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.05rem 2rem;
    background: rgba(243, 241, 236, 0.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-eyebrow {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.topbar-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}

.topbar-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: capitalize;
    padding: 0.5rem 1rem;
    background: var(--surface-muted);
    border-radius: 999px;
    border: 1px solid var(--border);
}

.content {
    padding: 1.75rem 2rem 2.5rem;
    max-width: 1320px;
    width: 100%;
}

/* Dashboard hero */
.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.75rem 2rem;
    margin-bottom: 1.75rem;
    border-radius: var(--radius-lg);
    background: #141920;
    color: #F6F3EC;
    box-shadow: none;
    border: 1px solid #222833;
}

.dashboard-hero h2 {
    margin: 0 0 0.4rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.dashboard-hero p {
    margin: 0;
    color: #CBD5E1;
    font-size: 0.95rem;
    max-width: 520px;
}

.dashboard-hero-badge {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

/* Page header */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    margin: 0 0 0.35rem;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.92rem;
    max-width: 640px;
    line-height: 1.55;
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    box-shadow: var(--shadow);
}

.stat-card.accent-primary,
.stat-card.accent-indigo,
.stat-card.accent-warning,
.stat-card.accent-success {
    background: var(--surface);
    border-color: var(--border);
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--primary-light);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 0.25rem;
    letter-spacing: -0.03em;
}

.stat-sub {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
}

.card-elevated {
    box-shadow: var(--shadow);
}

.card h2, .card h3 {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
    font-weight: 700;
}

.card-desc {
    margin: 0 0 1.1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 1.55;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.card-grid .card { margin-bottom: 0; }

.link-list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    line-height: 2;
}

/* Steps */
.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.step-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    position: relative;
    transition: box-shadow 0.15s;
}

.step-card:hover { box-shadow: var(--shadow-sm); }

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    display: grid;
    place-items: center;
    margin-bottom: 0.85rem;
}

.step-card h3 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
}

.step-card p {
    margin: 0;
    font-size: 0.84rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.code-block {
    background: #0F172A;
    color: #E2E8F0;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    overflow-x: auto;
    margin-top: 0.75rem;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    text-align: left;
    padding: 0.85rem 1rem;
    background: var(--surface-muted);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.95rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFC; }

.cell-strong { font-weight: 600; color: var(--text); }
.cell-muted { color: var(--text-muted); font-size: 0.84rem; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-success { background: var(--success-bg); color: #047857; }
.badge-warning { background: var(--warning-bg); color: #B45309; }
.badge-muted { background: #F1F5F9; color: #64748B; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }

.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.35rem 0.75rem;
    background: var(--surface-muted);
    border-radius: 999px;
    border: 1px solid var(--border);
}

.live-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #22C55E;
    animation: live-pulse 2s infinite;
}

@keyframes live-pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
    70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Login */
.login-screen {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(440px, 1.08fr) minmax(380px, 0.92fr);
    background: #12161C;
    overflow: hidden;
}

.login-aside {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2.5rem;
    padding: 2.25rem 3.25rem 1.75rem;
    color: #F6F3EC;
}

.login-aside::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    right: -80px;
    bottom: -140px;
    background: radial-gradient(circle, rgba(231, 201, 138, 0.16), transparent 68%);
    pointer-events: none;
}

.login-aside-copy,
.login-aside-top,
.login-aside-foot {
    position: relative;
    z-index: 1;
}

.login-kicker {
    margin: 0 0 0.85rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #E7C98A;
}

.login-aside h1 {
    margin: 0;
    max-width: 11em;
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(2.5rem, 3.6vw, 3.35rem);
    line-height: 1.28;
    letter-spacing: 0;
}

.login-points {
    margin: 1.75rem 0 0;
    padding: 0;
    list-style: none;
    max-width: 420px;
}

.login-points li {
    position: relative;
    padding: 0.72rem 0 0.72rem 1.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: #C5CBD4;
    font-size: 0.95rem;
}

.login-points li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 1.15rem;
    width: 6px;
    height: 1px;
    background: #E7C98A;
}

.login-aside-foot {
    margin: 0;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: #8E97A3;
}

.login-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 2rem;
    background: var(--bg);
    border-radius: 28px 0 0 28px;
}

.login-form {
    width: min(100%, 380px);
}

.login-form .login-kicker { color: #8A6A2F; }

.login-form h2 {
    margin: 0 0 0.55rem;
    font-family: var(--serif);
    font-weight: 400;
    font-size: 2.15rem;
    letter-spacing: 0;
    line-height: 1.25;
}

.login-help {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-error {
    margin: 0 0 1rem;
    padding: 0.75rem 0.85rem;
    border-radius: var(--radius-sm);
    background: var(--danger-bg);
    color: #8E1D16;
    font-size: 0.88rem;
}

.login-form input {
    min-height: 48px;
    background: #fff;
}

.login-form button {
    min-height: 48px;
    margin-top: 0.35rem;
    background: #161B22;
}

.login-form button:hover:not(:disabled) {
    background: #000;
}

.sidebar-footer form { margin: 0.15rem 0 0.85rem; }
.sidebar-footer button.secondary {
    width: 100%;
    background: transparent;
    color: #D5DBE3;
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: none;
}
.sidebar-footer button.secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

/* Forms */
label {
    display: block;
    font-weight: 600;
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
    color: var(--text);
}

input, select, textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 42px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #161B22;
    box-shadow: 0 0 0 3px rgba(22, 27, 34, 0.12);
}

input.readonly-input {
    background: var(--surface-muted);
    color: var(--text-muted);
}

.form-row { margin-bottom: 1rem; }

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
}

.form-check input { width: auto; min-height: auto; }

/* Buttons */
button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.65rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    min-height: 42px;
}

button:hover:not(:disabled), .btn:hover {
    background: var(--primary-dark);
    color: #fff;
}

button:active:not(:disabled), .btn:active { transform: translateY(1px); }
button:disabled, .btn.disabled { opacity: 0.55; cursor: not-allowed; }

button.secondary, .btn.secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

button.secondary:hover:not(:disabled), .btn.secondary:hover {
    background: var(--surface-muted);
    color: var(--text);
}

button.success, .btn.success {
    background: var(--accent);
}

button.success:hover:not(:disabled), .btn.success:hover {
    background: var(--accent-dark);
}

.btn-block { width: 100%; }

/* Alerts */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.88rem;
    line-height: 1.45;
}

.alert-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 800;
    flex-shrink: 0;
}

.alert-success {
    background: var(--success-bg);
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-success .alert-icon { background: var(--accent); color: #fff; }

.alert-error {
    background: var(--danger-bg);
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-error .alert-icon { background: var(--danger); color: #fff; }

.info-box {
    background: #F8F4EA;
    border: 1px solid #E7D7B0;
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    font-size: 0.88rem;
    color: #3E3422;
    line-height: 1.55;
    margin-bottom: 1.25rem;
}

.empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.3;
}

.loading {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 2rem 0;
}

/* Version inbox */
.version-inbox {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.version-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.version-card:hover {
    box-shadow: var(--shadow);
    border-color: #E7D7B0;
}

.version-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.version-tag {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
}

.version-summary {
    margin: 0.35rem 0 0.6rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
}

.version-details summary {
    font-size: 0.82rem;
    color: var(--primary);
    cursor: pointer;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.version-notes {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    font-size: 0.82rem;
    white-space: pre-wrap;
    max-height: 200px;
    overflow: auto;
    margin: 0;
}

.version-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.35rem 0 0.5rem;
}

.version-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.assign-select {
    min-width: 220px;
    flex: 1;
}

.btn-link {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.btn-link:hover { text-decoration: underline; }

.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-sm {
    padding: 0.4rem 0.75rem !important;
    font-size: 0.78rem !important;
    min-height: 34px !important;
}

details.card > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.25rem 0;
    list-style: none;
}

details.card > summary::-webkit-details-marker { display: none; }

#blazor-error-ui {
    background: var(--danger-bg);
    color: #991B1B;
    padding: 1rem 1.25rem;
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    border-top: 1px solid #FECACA;
}

@media (max-width: 900px) {
    .sidebar { display: none; }
    .main-area { margin-left: 0; }
    .content { padding: 1rem; }
    .topbar { padding: 1rem; flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .dashboard-hero { flex-direction: column; align-items: flex-start; padding: 1.25rem; }
    .login-screen { grid-template-columns: 1fr; }
    .login-aside { padding: 1.4rem 1.25rem 0.25rem; gap: 1.25rem; }
    .login-aside h1 { max-width: 16ch; font-size: 2.3rem; }
    .login-points { display: none; }
    .login-main { border-radius: 22px 22px 0 0; align-items: flex-start; padding-top: 2rem; min-height: calc(100vh - 220px); }
}
