/* ============================================================================
   Kassit SEO — design system
   Indigo/Violet · light + dark · Inter (latin) + Vazirmatn (arabic) · RTL-aware
   Single source of truth: tokens + Bootstrap component overrides so every page
   inherits the look without per-page changes.
   ========================================================================== */

/* ----------------------------- fonts ----------------------------- */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 800; font-display: swap; src: url('fonts/inter-800.woff2') format('woff2'); }

@font-face { font-family: 'Vazirmatn'; font-style: normal; font-weight: 400; font-display: swap; src: url('fonts/vazirmatn-400.woff2') format('woff2'); }
@font-face { font-family: 'Vazirmatn'; font-style: normal; font-weight: 500; font-display: swap; src: url('fonts/vazirmatn-500.woff2') format('woff2'); }
@font-face { font-family: 'Vazirmatn'; font-style: normal; font-weight: 600; font-display: swap; src: url('fonts/vazirmatn-600.woff2') format('woff2'); }
@font-face { font-family: 'Vazirmatn'; font-style: normal; font-weight: 700; font-display: swap; src: url('fonts/vazirmatn-700.woff2') format('woff2'); }
@font-face { font-family: 'Vazirmatn'; font-style: normal; font-weight: 800; font-display: swap; src: url('fonts/vazirmatn-800.woff2') format('woff2'); }

/* ----------------------------- tokens ----------------------------- */
:root {
    --font-sans: 'Inter', 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;

    --bg: #F7F8FB;
    --surface: #FFFFFF;
    --surface-2: #F2F4F8;
    --surface-hover: #F4F5FA;
    --text: #0F172A;
    --text-muted: #586679; /* AA: >=4.5:1 on surface-2 (#F2F4F8), not just on white */
    --border: #E6E8EE;
    --border-strong: #D6DAE3;

    --accent: #4F46E5;       /* indigo-600: white-on-accent and accent-on-white both clear AA (was #6366F1 = 4.46:1) */
    --accent-hover: #4338CA; /* indigo-700 */
    --accent-soft: #EEF0FE;
    --accent-contrast: #FFFFFF;

    --success: #16A34A;  --success-soft: #E7F6ec;
    --warn: #D97706;     --warn-soft: #FCF3E3;
    --danger: #DC2626;   --danger-soft: #FDE8E8;
    --info: #0EA5E9;     --info-soft: #E4F4FB;
    /* Darker tone text for use ON the soft backgrounds (chips/badges) — AA on the light soft fills. */
    --success-on-soft: #166534; --warn-on-soft: #92400E; --danger-on-soft: #B91C1C; --info-on-soft: #0369A1;

    --ring: rgba(99, 102, 241, 0.35);
    --radius-xs: 7px;
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 6px 16px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 18px 48px rgba(16, 24, 40, 0.14);

    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0B0F1A;
    --surface: #111726;
    --surface-2: #161D2E;
    --surface-hover: #1A2233;
    --text: #E5E9F0;
    --text-muted: #94A3B8;
    --border: #232B3E;
    --border-strong: #313B52;

    --accent: #818CF8;
    --accent-hover: #A5B4FC;
    --accent-soft: #1B2138;
    --accent-contrast: #0B0F1A;

    --success: #34D399;  --success-soft: #12241C;
    --warn: #FBBF24;     --warn-soft: #2A2010;
    --danger: #F87171;   --danger-soft: #2A1414;
    --info: #38BDF8;     --info-soft: #102230;
    /* On dark soft fills the (light) tone colors already clear AA, so on-soft == tone here. */
    --success-on-soft: #34D399; --warn-on-soft: #FBBF24; --danger-on-soft: #F87171; --info-on-soft: #38BDF8;

    --ring: rgba(129, 140, 248, 0.4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);

    color-scheme: dark;
}

/* ----------------------------- base ----------------------------- */
/* Denser base scale: all rem-based sizing/spacing shrinks uniformly so more fits on screen. */
html { font-size: 14px; }

html, body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body { margin: 0; }

html[dir="rtl"] body { letter-spacing: 0; }

h1, h2, h3, h4, h5, h6 { color: var(--text); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-weight: 800; }

a, .btn-link { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

hr { border-color: var(--border); opacity: 1; }

::selection { background: var(--accent-soft); color: var(--accent-hover); }

*:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); border-radius: var(--radius-xs); }

.text-muted { color: var(--text-muted) !important; }

/* thin, modern scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }

/* ----------------------------- buttons ----------------------------- */
.btn {
    --bs-btn-border-radius: var(--radius-sm);
    border-radius: var(--radius-sm);
    font-weight: 600;
    letter-spacing: -0.01em;
    padding: 0.5rem 1rem;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(0.5px); }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 1rem; }
.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.82rem; }

.btn-primary {
    background-color: var(--accent); border-color: var(--accent); color: var(--accent-contrast);
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover, .btn-primary:focus { background-color: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.btn-primary:disabled { background-color: var(--accent); border-color: var(--accent); opacity: .55; }

.btn-outline-primary { color: var(--accent); border-color: var(--border-strong); background: var(--surface); }
.btn-outline-primary:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }

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

.btn-outline-dark { color: var(--text); border-color: var(--border-strong); background: var(--surface); }
.btn-outline-dark:hover { background: var(--text); border-color: var(--text); color: var(--surface); }

.btn-light { background: var(--surface); border-color: var(--surface); color: var(--text); }
.btn-light:hover { background: var(--surface-2); border-color: var(--surface-2); color: var(--text); }

.btn-link { font-weight: 600; }
.btn-link:hover { text-decoration: none; color: var(--accent-hover); }

/* ----------------------------- cards ----------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--text);
}
.card-body { padding: 1rem; }
.card-title { font-weight: 700; }

/* ----------------------------- forms ----------------------------- */
.form-control, .form-select {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    padding: 0.6rem 0.85rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-control::placeholder { color: var(--text-muted); opacity: .8; }
.form-control:focus, .form-select:focus {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: 0 0 0 3px var(--ring);
}
.form-label { color: var(--text); font-weight: 500; }
.form-check-input { border-color: var(--border-strong); background-color: var(--surface); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.form-floating > label { color: var(--text-muted); }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--ring);
}

.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-muted); }

/* ----------------------------- tables ----------------------------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    color: var(--text);
    border-color: var(--border);
}
.table > thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding: 0.55rem 0.65rem;
}
.table > tbody td { padding: 0.55rem 0.65rem; border-color: var(--border); vertical-align: middle; }
.table-hover > tbody > tr:hover > * { background: var(--surface-hover); --bs-table-accent-bg: var(--surface-hover); }
.table th.num, .table td.num { text-align: end; font-variant-numeric: tabular-nums; }
html[dir="rtl"] .table th.num, html[dir="rtl"] .table td.num { text-align: start; }
.nowrap { white-space: nowrap; }
.proj-name { font-weight: 600; color: var(--text); text-decoration: none; }
.proj-name:hover { color: var(--accent); }

/* ----------------------------- AI Center ----------------------------- */
.ai-nav-wrap { margin-bottom: 1.25rem; }
.ai-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.ai-card { padding: 1.1rem 1.25rem; }
.ai-card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }
.ai-card-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.ai-summary { grid-column: 1 / -1; }
.ai-lead { font-size: 1.02rem; color: var(--text); line-height: 1.6; }
.ai-impact { color: var(--text-muted); }
.ai-confidence { font-size: 0.78rem; font-weight: 700; color: var(--accent-hover); background: var(--accent-soft); padding: 0.15rem 0.6rem; border-radius: 999px; }
.ai-meta { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.5rem; }
.ai-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.ai-list li { display: flex; gap: 0.55rem; align-items: flex-start; }
/* Title + description stack beside the priority badge; min-width:0 lets long mixed-script text wrap instead of overflowing. */
.ai-li-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; flex: 1 1 auto; }
.ai-sub { color: var(--text-muted); font-size: 0.86rem; margin-top: 0.1rem; }
/* Dynamic, possibly mixed-direction content (engine descriptions, labels, URLs, AI text) appears across every
   module's .ai-sub. unicode-bidi: plaintext is the CSS form of dir="auto": each run is isolated AND picks its own
   base direction from its first strong character, so Persian + Latin + numbers never visually scramble in RTL. */
.ai-sub, .ai-list li strong { unicode-bidi: plaintext; text-align: start; }
.ai-dot { flex: 0 0 auto; width: 0.6rem; height: 0.6rem; border-radius: 999px; margin-top: 0.35rem; background: var(--text-muted); }
.ai-dot-danger { background: var(--danger); }
.ai-dot-success { background: var(--success); }
.ai-actions { padding-inline-start: 1.1rem; margin: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.ai-actions li { color: var(--text); }
.ai-tag { font-size: 0.7rem; font-weight: 600; padding: 0.08rem 0.45rem; border-radius: 999px; margin-inline-start: 0.4rem; }
.ai-tag-impact { background: var(--accent-soft); color: var(--accent-hover); }
.ai-tag-effort { background: var(--surface-2); color: var(--text-muted); }
.ai-prio { font-size: 0.74rem; font-weight: 700; padding: 0.1rem 0.5rem; border-radius: 999px; white-space: nowrap; }
.ai-prio-critical { background: var(--danger-soft); color: var(--danger); }
.ai-prio-high { background: var(--warn-soft); color: var(--warn); }
.ai-prio-medium { background: var(--info-soft); color: var(--info); }
.ai-prio-low { background: var(--surface-2); color: var(--text-muted); }
.ai-usage-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
.ai-usage-num { font-size: 1.4rem; font-weight: 800; }
.ai-usage-lbl { font-size: 0.76rem; color: var(--text-muted); }
.ai-h3 { font-size: 0.82rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 0.9rem 0 0.4rem; }
.ai-row-active > * { background: var(--accent-soft) !important; }
.ai-report-section { margin-bottom: 1.1rem; }
.ai-report-section h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.4rem; }
@media (max-width: 860px) { .ai-grid { grid-template-columns: 1fr; } .ai-usage-grid { grid-template-columns: repeat(2,1fr); } }

/* ----------------------------- badges ----------------------------- */
.badge { font-weight: 600; border-radius: 999px; padding: 0.35em 0.7em; letter-spacing: 0.01em; }
.badge.bg-success, .bg-success { background-color: var(--success-soft) !important; color: var(--success) !important; }
.badge.bg-danger, .bg-danger   { background-color: var(--danger-soft) !important;  color: var(--danger) !important; }
.badge.bg-warning, .bg-warning { background-color: var(--warn-soft) !important;    color: var(--warn) !important; }
.badge.bg-info, .bg-info       { background-color: var(--info-soft) !important;    color: var(--info) !important; }
.badge.bg-secondary            { background-color: var(--surface-2) !important;    color: var(--text-muted) !important; }
.badge.bg-dark                 { background-color: var(--text) !important;         color: var(--surface) !important; }

/* ----------------------------- alerts ----------------------------- */
.alert { border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.alert-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert-danger  { background: var(--danger-soft);  border-color: transparent; color: var(--danger); }
.alert-warning { background: var(--warn-soft);    border-color: transparent; color: var(--warn); }
.alert-info    { background: var(--info-soft);    border-color: transparent; color: var(--info); }

/* ----------------------------- dropdowns / misc ----------------------------- */
.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
}
.dropdown-item { border-radius: var(--radius-xs); color: var(--text); padding: 0.5rem 0.75rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-hover); color: var(--text); }
.dropdown-item.active, .dropdown-item:active { background: var(--accent); color: var(--accent-contrast); }
.dropdown-divider { border-color: var(--border); }

code { color: var(--accent-hover); background: var(--accent-soft); padding: 0.1rem 0.4rem; border-radius: var(--radius-xs); }

/* validation */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: 0.85rem; }

/* ----------------------------- shared layout helpers ----------------------------- */
.content { padding-top: 1.25rem; }
h1:focus { outline: none; }

/* page section title used across redesigned pages */
.page-title { font-size: 1.5rem; font-weight: 800; margin: 0; }
.surface-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

/* error UI (kept functional, restyled) */
.blazor-error-boundary {
    background: var(--danger); padding: 1rem 1rem 1rem 3.7rem; color: #fff; border-radius: var(--radius);
}
.blazor-error-boundary::after { content: "An error has occurred." }

#blazor-error-ui {
    color-scheme: light only;
    background: #fff7d6;
    border-top: 1px solid #f0d97a;
    box-shadow: var(--shadow-md);
    display: none;
    inset-inline: 0; bottom: 0; position: fixed;
    padding: 0.7rem 1.25rem;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; inset-inline-end: 0.75rem; top: 0.5rem; }

.darker-border-checkbox.form-check-input { border-color: var(--border-strong); }

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder { color: var(--text-muted); text-align: end; }
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { text-align: start; }

/* ----------------------------- auth pages (Login / Register) ----------------------------- */
.auth-head { margin-bottom: 1.5rem; }
.auth-head h1 { font-size: 1.7rem; font-weight: 800; margin-bottom: 0.3rem; }
.auth-head p { color: var(--text-muted); margin: 0; }

.auth-field { margin-bottom: 1rem; }
.auth-field .form-label { font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }

.auth-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0.25rem 0 1.25rem;
    font-size: 0.88rem;
}
.auth-check { display: inline-flex; align-items: center; gap: 0.45rem; margin: 0; color: var(--text); cursor: pointer; }
.auth-check .form-check-input { margin: 0; }
.auth-row a { font-weight: 600; }

.auth-divider { display: flex; align-items: center; text-align: center; color: var(--text-muted); font-size: 0.8rem; margin: 1.25rem 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-divider span { padding: 0 0.75rem; }

.auth-external { margin-top: 0.75rem; }

.auth-alt { text-align: center; margin: 1.5rem 0 0; color: var(--text-muted); font-size: 0.92rem; }
.auth-alt a { font-weight: 700; }
.auth-alt-sm { text-align: center; margin: 0.35rem 0 0; font-size: 0.82rem; }
.auth-terms { font-size: 0.88rem; color: var(--text-muted); margin: 0.25rem 0 1.1rem; display: flex; gap: 0.5rem; align-items: flex-start; }
.auth-terms .form-check-input { margin-top: 0.15rem; }

/* ── Revenue Intelligence (Phase AI-2) ───────────────────────────────── */
.biz-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.85rem; }
.biz-kpi { padding: 1rem 1.1rem; }
.biz-kpi-lbl { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.biz-kpi-val { font-size: 1.7rem; font-weight: 800; line-height: 1.1; margin: 0.2rem 0; letter-spacing: -0.01em; }
.biz-kpi-unit { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); }
.biz-kpi-sub { font-size: 0.76rem; color: var(--text-muted); line-height: 1.35; }
.biz-kpi-risk { box-shadow: inset 3px 0 0 var(--danger); }
.biz-kpi-opp { box-shadow: inset 3px 0 0 var(--success); }
.biz-form { padding: 1.1rem 1.25rem; }
.biz-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.85rem 1.1rem; }
.biz-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.biz-form input, .biz-form select, .biz-form textarea { padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 0.9rem; font-weight: 500; }
.biz-form .biz-hint { font-weight: 500; color: var(--text-muted); font-size: 0.72rem; }
.biz-notes { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.85rem; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.biz-filters { display: flex; gap: 0.45rem; margin: 0.25rem 0 1rem; flex-wrap: wrap; }
.biz-filters .proj-chip { cursor: pointer; border: 1px solid var(--border); background: var(--surface); }
.biz-assumptions { margin-top: 0.5rem; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }
.biz-link { font-size: 0.78rem; cursor: pointer; }

/* ── Topical Authority (Phase AI-3) ──────────────────────────────────── */
.biz-meter { display: inline-block; width: 70px; height: 7px; border-radius: 4px; background: var(--surface-2); vertical-align: middle; overflow: hidden; }
.biz-meter > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.biz-bar-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.3rem 0; }
.biz-bar-label { flex: 0 0 200px; font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.biz-bar { flex: 1; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.biz-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-hover), var(--accent)); }
.biz-bar-val { flex: 0 0 32px; text-align: end; font-weight: 700; font-size: 0.85rem; }
.topo-map { width: 100%; height: auto; display: block; }
.topo-bubble { opacity: 0.85; stroke: var(--surface); stroke-width: 2; }
.topo-green { fill: var(--success); }
.topo-yellow { fill: var(--warn); }
.topo-red { fill: var(--danger); }
.topo-label { font-size: 11px; fill: var(--text-muted); }
.topo-num { font-size: 12px; font-weight: 700; fill: var(--accent-contrast); }
.topo-legend { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Phase AI-4: link workspace — compact action buttons + status badge */
.btn-xs { padding: 0.1rem 0.4rem; font-size: 0.72rem; line-height: 1.3; border-radius: 4px; }
.badge-status { display: inline-block; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: var(--surface-2, #eef2f7); color: var(--text-muted); }
.badge-open { background: var(--accent-soft, #e0f2fe); color: var(--accent, #0369a1); }
.badge-approved { background: var(--success-soft, #dcfce7); color: var(--success, #16a34a); }
.badge-implemented { background: var(--success-soft, #dcfce7); color: var(--success, #15803d); }
.badge-ignored { background: var(--surface-2, #eef2f7); color: var(--text-muted); }
.badge-rejected { background: var(--danger-soft, #fee2e2); color: var(--danger, #dc2626); }

/* ============================================================================
   Charts — self-contained inline-SVG chart library (Components/Charts).
   Pure tokens so every chart tracks light/dark/RTL. SVG content stays LTR by
   design (time/axes read left→right) even under [dir="rtl"]; only the HTML
   chrome (legends) flips. tabular-nums keeps axis/value labels aligned.
   ========================================================================== */
.ch { margin: 0; width: 100%; }
.ch svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch text { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }

.ch-empty {
    display: flex; align-items: center; justify-content: center;
    min-height: 80px; padding: 1rem;
    color: var(--text-muted); font-size: 0.85rem; font-style: italic;
    background: var(--surface-2); border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
}

/* axes + grid */
.ch-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ch-axisline { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ch-axis { fill: var(--text-muted); font-size: 10px; }

/* legends (HTML chrome — flips correctly under RTL) */
.ch-legend { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin: 0 0 0.5rem; padding: 0; }
.ch-leg { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; color: var(--text-muted); }
.ch-leg i { width: 0.65rem; height: 0.65rem; border-radius: 3px; flex: 0 0 auto; }

/* line points — CSS hover layer (native <title> supplies the tooltip text) */
.ch-pt { transition: r 0.1s ease; cursor: pointer; }
.ch-line svg:hover .ch-pt { r: 3.2; }
.ch-pt:hover { r: 5; }

/* bars — hover highlight */
.ch-barrect { transition: opacity 0.1s ease; cursor: pointer; }
.ch-barrect:hover { opacity: 0.78; }

/* donut */
.ch-donut { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.ch-donut-track { stroke: var(--surface-2); }
.ch-donut-arc { transition: stroke-width 0.12s ease; cursor: pointer; }
.ch-donut-arc:hover { stroke-width: 34; }
.ch-donut-total { fill: var(--text); font-size: 22px; font-weight: 800; }
.ch-donut-cap { fill: var(--text-muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.ch-donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.3rem; min-width: 140px; }
.ch-donut-legend li { display: flex; align-items: center; gap: 0.45rem; font-size: 0.8rem; }
.ch-donut-legend i { width: 0.7rem; height: 0.7rem; border-radius: 3px; flex: 0 0 auto; }
.ch-donut-legend .ch-leg-name { color: var(--text); flex: 1 1 auto; }
.ch-donut-legend .ch-leg-val { color: var(--text-muted); font-variant-numeric: tabular-nums; font-weight: 600; }

/* gauge */
.ch-gauge-track { stroke: var(--surface-2); }
.ch-gauge-val { font-size: 28px; font-weight: 800; }
.ch-gauge-cap { fill: var(--text-muted); font-size: 11px; }

/* heatmap */
.ch-heat-cell { transition: stroke 0.1s ease; cursor: pointer; }
.ch-heat-cell:hover { stroke: var(--text); stroke-width: 1.5; }
.ch-heat-col, .ch-heat-row { fill: var(--text-muted); font-size: 10px; }

/* --------------------------- reduced motion --------------------------- */
/* Honour the OS "reduce motion" setting (WCAG 2.3.3): kill transitions/animations and the
   KPI-card lift so nothing moves for users who asked for stillness. Focus rings stay intact. */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .kc-link:hover { transform: none !important; }
    .reveal { opacity: 1 !important; transform: none !important; }
}

/* ===================================================================== */
/* Shared design layer — promoted from the dashboard so EVERY page/component */
/* can reuse the same chrome (glass cards, reveal motion, KPI grid, filters). */
/* Page-specific decoration (aurora, health ring, exec bands) stays scoped.   */
/* ===================================================================== */

/* frosted "material" surface — matte, neutral, heavy blur, hairline border */
.glass {
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border: 1px solid color-mix(in srgb, var(--text) 6%, transparent);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 1px rgba(16, 24, 40, 0.04), 0 10px 30px rgba(16, 24, 40, 0.06);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    backdrop-filter: blur(30px) saturate(180%);
    position: relative;
    z-index: 1;
}
[data-theme="dark"] .glass {
    background: color-mix(in srgb, var(--surface) 62%, transparent);
    border-color: color-mix(in srgb, #fff 8%, transparent);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.35);
}

/* staggered entrance reveal (delay via inline --d) */
.reveal { animation: reveal .55s cubic-bezier(.22,.7,.3,1) both; animation-delay: var(--d, 0ms); }
@keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* vertical rhythm for a page's top-level blocks */
.page-stack > * { margin-bottom: 1.1rem; }
.page-stack > *:last-child { margin-bottom: 0; }

/* responsive KPI grid (cards reflow on narrow screens) */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 0.85rem; align-items: stretch; }

/* Responsive two-up layout for side-by-side Sections (collapses to one column on narrow screens). */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; align-items: start; }

/* wrapper for a page's module sub-nav (ProjectNav/TopicsNav/etc.) under the header */
.page-nav-wrap { margin-bottom: 1.1rem; position: relative; z-index: 1; }

/* segment-filter bar + compact selects (device/country/etc.) */
.filter-bar { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.filter-select { width: auto; min-width: 7rem; font-size: 0.78rem; padding: 0.2rem 1.6rem 0.2rem 0.5rem; }
