/* =========================================================================
   Zeroexport UI — design layer on top of the bundled Bootstrap 5.3.
   Light/dark via [data-bs-theme] on <html>; tokens below drive everything.
   ========================================================================= */

:root,
[data-bs-theme="light"] {
    --zx-bg: #f3f5f9;
    --zx-surface: #ffffff;
    --zx-surface-2: #f8fafc;
    --zx-border: #e6eaf0;
    --zx-text: #0f172a;
    --zx-muted: #64748b;
    --zx-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
    --zx-primary: #2563eb;
    --zx-primary-soft: #e8efff;
    --zx-green: #16a34a;   --zx-green-soft: #e7f7ec;
    --zx-red: #dc2626;     --zx-red-soft: #fdecec;
    --zx-amber: #d97706;   --zx-amber-soft: #fff4e0;
    --zx-violet: #7c3aed;  --zx-violet-soft: #f1eaff;
    --zx-sky: #0284c7;     --zx-sky-soft: #e3f3fc;
    --zx-chart-grid: #e6eaf0;
    --zx-chart-axis: #64748b;

    --bs-body-bg: var(--zx-bg);
    --bs-body-color: var(--zx-text);
    --bs-border-color: var(--zx-border);
    --bs-secondary-color: var(--zx-muted);
    --bs-tertiary-bg: var(--zx-surface-2);
}

[data-bs-theme="dark"] {
    --zx-bg: #0b1120;
    --zx-surface: #111a2e;
    --zx-surface-2: #0f1729;
    --zx-border: #1f2a44;
    --zx-text: #e2e8f0;
    --zx-muted: #94a3b8;
    --zx-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 20px rgba(0, 0, 0, .25);
    --zx-primary: #60a5fa;
    --zx-primary-soft: rgba(96, 165, 250, .14);
    --zx-green: #4ade80;   --zx-green-soft: rgba(74, 222, 128, .12);
    --zx-red: #f87171;     --zx-red-soft: rgba(248, 113, 113, .13);
    --zx-amber: #fbbf24;   --zx-amber-soft: rgba(251, 191, 36, .13);
    --zx-violet: #a78bfa;  --zx-violet-soft: rgba(167, 139, 250, .14);
    --zx-sky: #38bdf8;     --zx-sky-soft: rgba(56, 189, 248, .13);
    --zx-chart-grid: #1f2a44;
    --zx-chart-axis: #94a3b8;

    --bs-body-bg: var(--zx-bg);
    --bs-body-color: var(--zx-text);
    --bs-border-color: var(--zx-border);
    --bs-secondary-color: var(--zx-muted);
    --bs-tertiary-bg: var(--zx-surface-2);
}

html, body { background: var(--zx-bg); }
body {
    font-family: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: .925rem;
    -webkit-font-smoothing: antialiased;
}
pre { white-space: pre-wrap; }
.num, .table td.text-end { font-variant-numeric: tabular-nums; }
.zx-icon { flex-shrink: 0; vertical-align: -0.2em; }
.text-muted { color: var(--zx-muted) !important; }

/* ---------- App shell: sidebar + content ---------- */
.zx-shell { display: flex; min-height: 100vh; }

.zx-sidebar {
    width: 248px; flex-shrink: 0;
    background: #0f172a; color: #cbd5e1;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
    border-right: 1px solid rgba(255, 255, 255, .04);
    z-index: 1040;
}
.zx-brand {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.15rem 1.25rem; color: #fff; text-decoration: none;
    font-weight: 700; font-size: 1.05rem; letter-spacing: .01em;
}
.zx-brand:hover { color: #fff; }
.zx-brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center; color: #0f172a;
    background: linear-gradient(135deg, #fbbf24, #f97316);
    box-shadow: 0 4px 14px rgba(249, 115, 22, .35);
}
.zx-brand small { display: block; font-weight: 500; font-size: .7rem; color: #64748b; letter-spacing: .04em; text-transform: uppercase; }

.zx-nav { padding: .5rem .75rem; overflow-y: auto; flex: 1; }
.zx-nav-group {
    font-size: .68rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: #64748b; padding: 1rem .75rem .4rem;
}
.zx-nav a {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .75rem; margin-bottom: 2px; border-radius: 8px;
    color: #cbd5e1; text-decoration: none; font-weight: 500;
    transition: background .15s, color .15s;
}
.zx-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.zx-nav a.active { background: rgba(96, 165, 250, .16); color: #fff; }
.zx-nav a.active .zx-icon { color: #60a5fa; }
.zx-nav .zx-badge {
    margin-left: auto; min-width: 1.4rem; padding: .05rem .4rem; border-radius: 999px;
    background: #ef4444; color: #fff; font-size: .7rem; font-weight: 700; text-align: center;
}

.zx-sidebar-foot { padding: .9rem; border-top: 1px solid rgba(255, 255, 255, .06); }
.zx-user { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.zx-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; color: #fff;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6); text-transform: uppercase;
}
.zx-user-name { color: #fff; font-weight: 600; line-height: 1.1; }
.zx-user-role { font-size: .72rem; color: #94a3b8; }
.zx-foot-actions { display: flex; gap: .5rem; }
.zx-foot-actions form { flex: 1; display: flex; }
.zx-foot-actions .btn {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); color: #cbd5e1;
    font-size: .8rem; padding: .4rem .5rem; border-radius: 8px;
}
.zx-foot-actions .btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
[data-bs-theme="dark"] .zx-theme-dark,
[data-bs-theme="light"] .zx-theme-light { display: none !important; }

.zx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.zx-topbar {
    display: none; align-items: center; gap: .75rem;
    padding: .7rem 1rem; background: #0f172a; color: #fff;
    position: sticky; top: 0; z-index: 1030;
}
.zx-topbar .zx-brand { padding: 0; }
.zx-burger { color: #fff; cursor: pointer; padding: .25rem; border-radius: 6px; margin: 0; }
.zx-content { padding: 1.75rem 2rem 2.5rem; max-width: 1680px; width: 100%; }
.zx-nav-toggle { display: none; }
.zx-scrim { display: none; }

@media (max-width: 991.98px) {
    .zx-topbar { display: flex; }
    .zx-sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    .zx-nav-toggle:checked ~ .zx-sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
    .zx-nav-toggle:checked ~ .zx-scrim {
        display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1035;
    }
    .zx-content { padding: 1.1rem 1rem 2rem; }
}

/* ---------- Page header ---------- */
.zx-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.4rem; }
.zx-page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.zx-page-head .zx-sub { color: var(--zx-muted); font-size: .85rem; margin-top: .15rem; }
h1.h3, h1.h4 { font-weight: 700; letter-spacing: -.01em; }
h2.h5, h2.h6 { font-weight: 650; }

/* ---------- Cards ---------- */
.card {
    --bs-card-bg: var(--zx-surface);
    --bs-card-border-color: var(--zx-border);
    --bs-card-border-radius: 14px;
    --bs-card-inner-border-radius: 13px;
    border: 1px solid var(--zx-border);
    box-shadow: var(--zx-shadow);
}
.card.shadow-sm { box-shadow: var(--zx-shadow) !important; }
.card-body { padding: 1.15rem 1.25rem; }
.zx-card-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.zx-card-title h2 { font-size: .95rem; font-weight: 650; margin: 0; }

/* ---------- KPI tiles ---------- */
.zx-kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 1.25rem; }
.zx-kpi {
    background: var(--zx-surface); border: 1px solid var(--zx-border); border-radius: 14px;
    box-shadow: var(--zx-shadow); padding: 1.05rem 1.15rem;
    display: flex; gap: .9rem; align-items: flex-start; position: relative; overflow: hidden;
}
.zx-kpi-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.zx-kpi-label { font-size: .78rem; font-weight: 600; color: var(--zx-muted); text-transform: uppercase; letter-spacing: .04em; }
.zx-kpi-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; margin-top: .15rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.zx-kpi-unit { font-size: .85rem; font-weight: 600; color: var(--zx-muted); margin-left: .15rem; }
.zx-kpi-sub { font-size: .8rem; color: var(--zx-muted); margin-top: .2rem; }
.zx-kpi-sub strong { color: var(--zx-text); }
.zx-kpi.is-hero { border-color: transparent; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; }
.zx-kpi.is-hero .zx-kpi-label, .zx-kpi.is-hero .zx-kpi-unit, .zx-kpi.is-hero .zx-kpi-sub { color: rgba(255, 255, 255, .8); }
.zx-kpi.is-hero .zx-kpi-sub strong { color: #fff; }
.zx-kpi.is-hero .zx-kpi-icon { background: rgba(255, 255, 255, .18); color: #fff; }

.tone-blue   { background: var(--zx-primary-soft); color: var(--zx-primary); }
.tone-green  { background: var(--zx-green-soft);   color: var(--zx-green); }
.tone-red    { background: var(--zx-red-soft);     color: var(--zx-red); }
.tone-amber  { background: var(--zx-amber-soft);   color: var(--zx-amber); }
.tone-violet { background: var(--zx-violet-soft);  color: var(--zx-violet); }
.tone-sky    { background: var(--zx-sky-soft);     color: var(--zx-sky); }
.tone-gray   { background: var(--zx-surface-2);    color: var(--zx-muted); }

/* ---------- Status pills ---------- */
.zx-pill {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap;
}
.zx-pill::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.zx-pill.no-dot::before { display: none; }
.zx-pill.live::before { animation: zx-pulse 1.6s ease-in-out infinite; }
@keyframes zx-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Alert banner ---------- */
.zx-alert {
    display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-radius: 12px;
    margin-bottom: 1.1rem; text-decoration: none; font-weight: 500; border: 1px solid transparent;
}
.zx-alert.is-critical { background: var(--zx-red-soft); color: var(--zx-red); border-color: color-mix(in srgb, var(--zx-red) 25%, transparent); }
.zx-alert.is-warning { background: var(--zx-amber-soft); color: var(--zx-amber); border-color: color-mix(in srgb, var(--zx-amber) 25%, transparent); }
.zx-alert:hover { filter: brightness(.98); }
.zx-alert .zx-alert-more { margin-left: auto; font-size: .8rem; opacity: .85; white-space: nowrap; }

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: var(--zx-surface-2);
    --bs-table-hover-bg: var(--zx-surface-2);
    --bs-table-border-color: var(--zx-border);
    margin-bottom: 0;
}
.table > thead th {
    font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
    color: var(--zx-muted); background: var(--zx-surface-2); border-bottom-width: 1px;
    padding-top: .6rem; padding-bottom: .6rem; white-space: nowrap;
}
.table > :not(caption) > * > * { padding-left: .75rem; padding-right: .75rem; }
.table-card { padding: 0; overflow: hidden; }
.table-card .table > thead th:first-child, .table-card .table td:first-child { padding-left: 1.25rem; }
.table-card .table > thead th:last-child, .table-card .table td:last-child { padding-right: 1.25rem; }

.zx-meter { height: 6px; border-radius: 999px; background: var(--zx-surface-2); overflow: hidden; min-width: 80px; border: 1px solid var(--zx-border); }
.zx-meter > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #22c55e, #16a34a); }
.zx-meter > span.is-limited { background: linear-gradient(90deg, #f59e0b, #d97706); }

/* ---------- Buttons & forms ---------- */
.btn { border-radius: 9px; font-weight: 550; }
.btn-sm { border-radius: 7px; }
.btn-primary { --bs-btn-bg: #2563eb; --bs-btn-border-color: #2563eb; --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8; --bs-btn-active-bg: #1e40af; }
.btn-success { --bs-btn-bg: #16a34a; --bs-btn-border-color: #16a34a; --bs-btn-hover-bg: #15803d; --bs-btn-hover-border-color: #15803d; }
.form-control, .form-select { border-radius: 9px; border-color: var(--zx-border); background-color: var(--zx-surface); }
.form-control:focus, .form-select:focus { border-color: #93b4f8; box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15); }
.form-label { font-size: .8rem; font-weight: 600; color: var(--zx-muted); margin-bottom: .3rem; }
.alert { border-radius: 12px; }
.badge { font-weight: 600; }
.list-group-item { background: var(--zx-surface); border-color: var(--zx-border); }

/* ---------- Charts ---------- */
.zx-chart { min-height: 240px; }

/* ---------- Login ---------- */
.zx-login {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(249, 115, 22, .18), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(37, 99, 235, .22), transparent 60%),
        #0b1120;
}
.zx-login-card {
    width: 100%; max-width: 400px; background: #ffffff; color: #0f172a;
    border-radius: 18px; padding: 2rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.zx-login-card .zx-brand { color: #0f172a; padding: 0 0 1.25rem; font-size: 1.2rem; }
.zx-login-card .zx-brand small { color: #64748b; }
.zx-login-card .form-label { color: #475569; }
.zx-login-card .form-control { background: #fff; color: #0f172a; border-color: #e2e8f0; padding: .6rem .8rem; }
.zx-login-card .btn-primary { padding: .65rem; }
.zx-login-foot { text-align: center; color: #94a3b8; font-size: .78rem; margin-top: 1rem; }

/* Blazor moves focus to the page <h1> on navigation (screen readers) — no visible box needed. */
h1:focus, h1:focus-visible { outline: none; }
