/* ============================================================
   RetailForge Design System — dark dense tooling aesthetic
   ============================================================ */

:root {
    --bg:           #0f1117;
    --surface:      #1a1d27;
    --surface2:     #222536;
    --border:       #2e3148;
    --text:         #e2e4f0;
    --text-muted:   #7c82a0;
    --accent:       #5b6af0;
    --red:          #e05252;
    --red-bg:       #2a1a1a;
    --orange:       #e09352;
    --orange-bg:    #2a2010;
    --green:        #52c08a;
    --radius:       8px;
    --font-mono:    'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;   /* no page-level scroll — each region scrolls itself */
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 12px; }

code, pre { font-family: var(--font-mono); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg); }

/* ── Nav ──────────────────────────────────────────────────── */
.page-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 24px;
}
.page-nav-brand {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--text);
    white-space: nowrap;
}
.page-nav-links { display: flex; gap: 4px; }
.page-nav-link {
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.15s, background 0.15s;
    cursor: pointer;
    border: none;
    background: none;
}
.page-nav-link:hover { color: var(--text); background: var(--surface2); }
.page-nav-link.active { color: var(--accent); background: rgba(91, 106, 240, 0.12); }

/* ── Dashboard container ──────────────────────────────────── */
.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px;
    /* Fill the viewport below the sticky nav and scroll internally —
       this prevents page-level scroll on every page. */
    height: calc(100vh - 48px);
    overflow: auto;
    box-sizing: border-box;
}

/* When the dashboard is acting as a bare layout shell (wrapping a sidebar
   layout), strip the content-area centering so the sidebar layout owns width. */
.dashboard:has(> .layout-with-sidebar) {
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;   /* children handle their own scroll */
}

/* ── Summary cards ────────────────────────────────────────── */
.summary-cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    min-width: 140px;
    border-left-width: 3px;
}
.card-total   { border-left-color: var(--accent); }
.card.status-5xx { border-left-color: var(--red); }
.card.status-4xx { border-left-color: var(--orange); }
.card-avg     { border-left-color: var(--orange); }
.card-p95     { border-left-color: var(--green); }
.card-value   { font-size: 28px; font-weight: 700; line-height: 1; }
.card-label   { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

/* ── Badges ───────────────────────────────────────────────── */
.status-badge {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
}
.status-badge.status-5xx   { background: var(--red-bg);    color: var(--red);        }
.status-badge.status-4xx   { background: var(--orange-bg); color: var(--orange);     }
.status-badge.status-3xx   { background: rgba(91,106,240,0.12); color: var(--accent); }
.status-badge.status-other { background: var(--surface2);  color: var(--text-muted); }

/* ── Filters ──────────────────────────────────────────────── */
.filter-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ── Audit error detail ───────────────────────────────────── */
.audit-error-detail {
    background: var(--red-bg);
    color: var(--red);
    font-size: 12px;
    padding: 10px 16px;
    border-top: 1px solid rgba(224,82,82,0.2);
    word-break: break-word;
}

.source-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid;
}
.source-portal { background: #1a2040; color: #7b9ef0; border-color: #2e3f80; }
.source-v1     { background: #1a2e2a; color: var(--green); border-color: #1e5040; }

/* ── Data table ───────────────────────────────────────────── */
.error-table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    overflow-x: auto;
    /* height is controlled by flex: .sidebar-content > .error-table-wrapper
       expands to fill the remaining vertical space exactly — no magic calc. */
}
/* border-collapse:collapse breaks position:sticky on <th> in Chromium.
   Use separate + spacing:0 and restore borders manually. */
.error-table { width: 100%; border-collapse: separate; border-spacing: 0; }

/* Stick the entire thead as one unit — avoids fragile per-row top offsets
   that break when rendered heights drift from the magic numbers. */
.error-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* Column header row */
.error-table thead tr:first-child th {
    background: var(--surface2);
    padding: 10px 14px;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: normal;
    color: var(--text-muted);
    letter-spacing: 0.6px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

/* Filter rows inherit the thead sticky — individual top values no longer needed.
   Must have an opaque background so body rows don't bleed through. */
.filter-toggle-row th {
    border-bottom: 1px solid var(--border);
}
.col-filter-row th {
    border-bottom: 1px solid var(--border);
}

/* Restore the row separator that border-collapse used to give us for free */
.summary-row {
    cursor: pointer;
    transition: background 0.1s;
}
.summary-row td { border-bottom: 1px solid var(--border); }
.summary-row:hover { background: var(--surface2); }
.summary-row.status-5xx:hover { background: var(--red-bg); }
.summary-row.status-4xx:hover { background: var(--orange-bg); }
.error-table td { padding: 12px 14px; font-size: 13px; }
.num-col { text-align: right; white-space: nowrap; cursor: pointer; }
.num-col.sorted { color: var(--accent); }

/* ── Durations ────────────────────────────────────────────── */
.duration-warn { color: var(--orange); }
.duration-slow { color: var(--red); }

/* ── Error rates ──────────────────────────────────────────── */
.rate-good { color: var(--green); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 760px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
}
.modal-header {
    position: sticky;
    top: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

/* ── Loading / empty / error states ──────────────────────── */
.loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 40px;
    color: var(--text-muted);
    justify-content: center;
}
.loading.inner { padding: 20px; }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { padding: 48px; text-align: center; color: var(--text-muted); }
.empty-state.inner { padding: 20px; }

.error-state {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--red-bg);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin: 12px 0;
    color: var(--red);
}
.error-state.inner { margin: 0; }
.error-icon { color: var(--red); font-size: 16px; }

/* ── Blazor error UI ──────────────────────────────────────── */
#blazor-error-ui {
    background: var(--red-bg);
    border-top: 1px solid var(--red);
    color: var(--red);
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 10px 20px;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 13px;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}
.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}
.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    color: var(--text-muted);
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}
.loading-progress-text::after { content: var(--blazor-load-percentage-text, "Loading"); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover  { background: #4a58d8; border-color: #4a58d8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: var(--red-bg);
    color: var(--red);
    border-color: var(--red);
}
.btn-danger:hover   { background: #3a1a1a; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-icon:hover { color: var(--text); background: var(--border); }
.btn-icon-danger:hover { color: var(--red); background: var(--red-bg); border-color: var(--red); }

/* ── Form controls ────────────────────────────────────────── */
.rf-input, .rf-select, .rf-textarea {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    padding: 7px 10px;
    width: 100%;
    transition: border-color 0.15s;
    outline: none;
}
.rf-input:focus, .rf-select:focus, .rf-textarea:focus {
    border-color: var(--accent);
}
.rf-input::placeholder, .rf-textarea::placeholder {
    color: var(--text-muted);
}
.rf-select option { background: var(--surface2); }
.rf-textarea {
    font-family: var(--font-mono);
    font-size: 12px;
    resize: vertical;
    min-height: 120px;
}

.field-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* ── Tab strip ────────────────────────────────────────────── */
.env-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.env-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.env-tab:hover { color: var(--text); }
.env-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Role badges ──────────────────────────────────────────── */
.role-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid;
}
.role-client_admin { background: rgba(91,106,240,0.15); color: var(--accent);    border-color: rgba(91,106,240,0.4); }
.role-tenant_admin { background: rgba(82,192,138,0.12); color: var(--green);     border-color: rgba(82,192,138,0.35); }
.role-admin        { background: rgba(224,147,82,0.12); color: var(--orange);    border-color: rgba(224,147,82,0.35); }
.role-user         { background: var(--surface2);       color: var(--text-muted); border-color: var(--border); }

/* ── Reports sidebar layout ───────────────────────────── */
.layout-with-sidebar {
    /* sidebar is position:fixed so this just reserves the gutter */
    margin-left: 220px;
    height: 100%;
}

.reports-sidebar {
    position: fixed;
    top: 48px;          /* sits flush under the sticky nav */
    left: 0;
    width: 220px;
    height: calc(100vh - 48px);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 12px 0;
    overflow-y: auto;
    z-index: 90;        /* below nav (100) but above page content */
}

.sidebar-heading {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: 4px 16px 10px;
}

.sidebar-tenant-switcher {
    padding: 6px 12px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.impersonation-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: color-mix(in srgb, var(--orange) 15%, transparent);
    border: 1px solid var(--orange);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 12px;
    color: var(--orange);
    font-weight: 600;
}

.sidebar-category {
    margin-bottom: 2px;
}

.sidebar-cat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
}
.sidebar-cat-btn:hover { background: var(--surface2); }

.sidebar-cat-arrow {
    font-size: 9px;
    color: var(--text-muted);
    transition: transform 0.15s;
    display: inline-block;
}
.sidebar-cat-arrow.open { transform: rotate(90deg); }

.sidebar-reports {
    display: flex;
    flex-direction: column;
}

.sidebar-report-link {
    display: block;
    padding: 5px 16px 5px 34px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}
.sidebar-report-link:hover { background: var(--surface2); color: var(--text); }
.sidebar-report-link.active { color: var(--accent); background: rgba(91,106,240,0.1); }

.sidebar-content {
    /* sidebar is fixed, so content fills remaining width naturally */
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Every direct child is a fixed-size header/params/meta strip — except the
   table wrapper which grows to fill whatever vertical space remains. */
.sidebar-content > * { flex-shrink: 0; }
.sidebar-content > .error-table-wrapper {
    flex: 1;
    min-height: 0;  /* override the default min-height:auto so it can shrink */
}

/* ── Parameter builder (query management modals) ──────── */
.param-builder-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
}

.param-builder-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 110px;
}

.param-builder-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.param-builder-input {
    font-size: 12px;
    padding: 3px 7px;
    height: 28px;
}

/* ── Report parameter inputs ─────────────────────────── */
.report-params {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 14px;
}

.report-param-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.report-param-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.report-param-input {
    min-width: 160px;
}

.report-param-between {
    display: flex;
    align-items: center;
    gap: 6px;
}

.report-param-between .report-param-input {
    min-width: 120px;
}

.report-param-between-sep {
    color: var(--text-muted);
    flex-shrink: 0;
}

.report-param-actions {
    display: flex;
    align-items: flex-end;
    padding-bottom: 2px;
}

/* ── Report result meta row ───────────────────────────── */
.report-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.report-filter-input {
    max-width: 220px;
    padding: 4px 10px;
    font-size: 12px;
    height: 28px;
}

.report-col-filters-btn {
    padding: 3px 10px;
    font-size: 12px;
    height: 28px;
    white-space: nowrap;
}

.report-meta-count { color: var(--text-muted); white-space: nowrap; }

/* Filter toggle row — thin clickable strip */
.filter-toggle-row {
    cursor: pointer;
    user-select: none;
}
.filter-toggle-cell {
    padding: 2px 8px !important;
    font-size: 11px;
    font-weight: normal;
    color: var(--text-muted);
    background: var(--surface2);   /* required — sticky rows must be opaque */
    background: var(--surface2);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.filter-toggle-row:hover .filter-toggle-cell {
    color: var(--text);
    background: var(--surface);
}

/* Per-column filter row */
.col-filter-row th {
    background: var(--surface2);
    padding: 3px 4px;
    border-bottom: 2px solid var(--accent);
}

/* Wrapper so the ✕ button can sit inside the input */
.col-filter-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.col-filter-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 2px 22px 2px 6px; /* right padding reserves space for ✕ */
    font-size: 11px;
    height: 24px;
    background: var(--surface);
    color: var(--text);
}
.col-filter-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ✕ clear button inside the filter input */
.col-filter-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0 2px;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}
.col-filter-clear:hover { color: var(--text); }

/* ── Scorecard report ────────────────────────────────────────────── */

/* Totals strip */
.sc-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}
.sc-total-chip {
    flex: 1;
    min-width: 100px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.sc-total-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
}
.sc-total-value {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.02em;
}
.sc-total-accent { color: var(--accent); }

/* Card grid */
.sc-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 10px;
}

/* Individual card */
.sc-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-left-width: 3px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.sc-rank-1 { border-left-color: var(--accent); }
.sc-rank-2 { border-left-color: var(--green); }
.sc-rank-3 { border-left-color: var(--orange); }
.sc-rank-other { border-left-color: var(--border); }

/* Card header row: badge · identity · big number */
.sc-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sc-rank-badge {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}
.sc-rank-1 .sc-rank-badge { background: rgba(91,106,240,.18); color: var(--accent); }
.sc-rank-2 .sc-rank-badge { background: rgba(82,192,138,.15); color: var(--green); }
.sc-rank-3 .sc-rank-badge { background: rgba(224,147,82,.15); color: var(--orange); }
.sc-rank-other .sc-rank-badge { background: var(--surface2); color: var(--text-muted); }

.sc-card-identity {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.sc-card-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sc-card-code {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.sc-card-rank-value {
    text-align: right;
    flex-shrink: 0;
}
.sc-rank-big {
    display: block;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.02em;
}
.sc-rank-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
}

/* Metric chips row */
.sc-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}
.sc-metric {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.sc-metric-value {
    font-size: 13px;
    font-weight: 600;
}
.sc-metric-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* Relative bar */
.sc-bar-track {
    height: 4px;
    background: var(--surface2);
    border-radius: 2px;
    overflow: hidden;
}
.sc-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width .4s ease;
}
.sc-rank-1 .sc-bar-fill { background: var(--accent); }
.sc-rank-2 .sc-bar-fill { background: var(--green); }
.sc-rank-3 .sc-bar-fill { background: var(--orange); }
.sc-rank-other .sc-bar-fill { background: var(--text-muted); }

/* Compact table layout */
.sc-table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}
.sc-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.sc-table thead th {
    background: var(--surface2);
    padding: 9px 14px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.sc-th-rank { width: 40px; }
.sc-th-bar  { width: 120px; }
.sc-th-rank-col { color: var(--accent); }
.sc-th-metric { text-align: right; }

.sc-row { border-bottom: 1px solid var(--border); transition: background .1s; }
.sc-row:hover { background: var(--surface2); }
.sc-row td { padding: 10px 14px; font-size: 13px; }

.sc-td-rank {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}
.sc-rank-1 .sc-td-rank { color: var(--accent); }
.sc-rank-2 .sc-td-rank { color: var(--green); }
.sc-rank-3 .sc-td-rank { color: var(--orange); }

.sc-td-name { min-width: 160px; }
.sc-td-label { display: block; font-weight: 500; }
.sc-td-code  { display: block; font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

.sc-td-metric { text-align: right; white-space: nowrap; }
.sc-td-rank-col { font-weight: 600; }

.sc-td-bar { width: 120px; padding-right: 16px !important; }
.sc-td-bar .sc-bar-track { width: 100%; }

/* ── Nav user (display name + sign out) ─────────────────────────── */
.page-nav {
    display: flex;
    align-items: center;
}
.page-nav-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 24px;
    flex-shrink: 0;
}
.page-nav-display-name {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}
.page-nav-signout {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.page-nav-signout:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

/* ── Login page ──────────────────────────────────────────────────── */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 36px 36px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.login-brand {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
    text-align: center;
}
.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.login-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.login-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    padding: 9px 12px;
    outline: none;
    transition: border-color 0.15s;
}
.login-input:focus {
    border-color: var(--accent);
}
.login-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.login-input:-webkit-autofill,
.login-input:-webkit-autofill:hover,
.login-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    transition: background-color 9999s ease-in-out 0s;
}
.login-remember {
    display: flex;
    align-items: center;
}
.login-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.login-check-label input[type="checkbox"] {
    accent-color: var(--accent);
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.login-error {
    font-size: 13px;
    color: var(--red);
    background: rgba(224, 82, 82, 0.08);
    border: 1px solid rgba(224, 82, 82, 0.25);
    border-radius: 6px;
    padding: 8px 12px;
}
.login-btn {
    width: 100%;
    margin-top: 4px;
    padding: 10px;
    font-size: 14px;
}
