/**
 * FlixLog admin panel — design system.
 *
 * Architecture:
 *   1. CSS custom properties drive both themes. The body class
 *      `theme-light` / `theme-dark` flips a single rule set; everything
 *      downstream resolves through `var(--…)`.
 *   2. Spacing + radius + typography scales are tokens, not magic
 *      numbers. Edit the token, every consumer updates.
 *   3. Component styles are flat (no nested selectors deeper than 2)
 *      so dev-tools class lookup is trivial when debugging layout.
 */

/* ───────────────────────────── fonts ───────────────────────────── */

@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 300;
    src: url('/assets/fonts/IRANSansX-Light.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 400;
    src: url('/assets/fonts/IRANSansX-Regular.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 500;
    src: url('/assets/fonts/IRANSansX-Medium.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 600;
    src: url('/assets/fonts/IRANSansX-DemiBold.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'IRANSansX';
    font-style: normal;
    font-weight: 700;
    src: url('/assets/fonts/IRANSansX-Bold.woff2') format('woff2');
    font-display: swap;
}

/* ─────────────────────── design tokens (dark default) ──────────── */

/*
 * Dark theme is the default. Applied via :root so html itself gets the
 * tokens; an `html.theme-dark` selector provides the same vars when the
 * theme is explicit (post-toggle) — covers the case where the html and
 * body classes might temporarily disagree mid-toggle.
 */
:root,
html.theme-dark,
body.theme-dark {
    /* Surfaces — ascending elevation */
    --bg:                 #0a0a0c;
    --surface:            #111114;
    --surface-2:          #17171c;
    --surface-3:          #1f1f26;
    --hover:              rgba(255,255,255,0.04);

    /* Borders */
    --border:             rgba(255,255,255,0.06);
    --border-strong:      rgba(255,255,255,0.10);

    /* Text */
    --text:               #f4f4f5;
    --text-secondary:     #a1a1aa;
    --text-muted:         #71717a;

    /* Brand — purple matching the FlixDrama app */
    --accent:             #8b5cf6;
    --accent-hover:       #a78bfa;
    --accent-tint:        rgba(139, 92, 246, 0.12);
    --accent-strong:      rgba(139, 92, 246, 0.55);

    /* Semantic */
    --success:            #10b981;
    --success-tint:       rgba(16, 185, 129, 0.12);
    --warning:            #f59e0b;
    --warning-tint:       rgba(245, 158, 11, 0.12);
    --danger:             #ef4444;
    --danger-tint:        rgba(239, 68, 68, 0.12);
    --info:               #3b82f6;
    --info-tint:          rgba(59, 130, 246, 0.12);

    /* Effects */
    --shadow-sm:          0 1px 2px rgba(0,0,0,0.20);
    --shadow-md:          0 4px 16px rgba(0,0,0,0.30);
    --shadow-lg:          0 12px 32px rgba(0,0,0,0.40);
    --shadow-glow:        0 0 0 4px rgba(139, 92, 246, 0.18);

    /* Radii */
    --r-sm:               6px;
    --r:                  10px;
    --r-md:               14px;
    --r-lg:               20px;
    --r-pill:             999px;
}

html.theme-light,
body.theme-light {
    --bg:                 #fafafa;
    --surface:            #ffffff;
    --surface-2:          #f4f4f5;
    --surface-3:          #ececef;
    --hover:              rgba(0,0,0,0.04);

    --border:             rgba(0,0,0,0.07);
    --border-strong:      rgba(0,0,0,0.13);

    --text:               #18181b;
    --text-secondary:     #52525b;
    --text-muted:         #a1a1aa;

    --accent:             #6d28d9;
    --accent-hover:       #5b21b6;
    --accent-tint:        rgba(109, 40, 217, 0.10);
    --accent-strong:      rgba(109, 40, 217, 0.45);

    --success:            #059669;
    --success-tint:       rgba(5, 150, 105, 0.10);
    --warning:            #d97706;
    --warning-tint:       rgba(217, 119, 6, 0.10);
    --danger:             #dc2626;
    --danger-tint:        rgba(220, 38, 38, 0.10);
    --info:               #2563eb;
    --info-tint:          rgba(37, 99, 235, 0.10);

    --shadow-sm:          0 1px 2px rgba(0,0,0,0.05);
    --shadow-md:          0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg:          0 12px 32px rgba(0,0,0,0.10);
    --shadow-glow:        0 0 0 4px rgba(109, 40, 217, 0.15);
}

/* ─────────────────────────── reset ─────────────────────────────── */

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'IRANSansX', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.18s ease, color 0.18s ease;
}
html { min-height: 100vh; }  /* fill the viewport even on short pages */
body { min-height: 100vh; }  /* so a content-shorter-than-viewport never reveals html bg */

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.12s ease;
}
a:hover { color: var(--accent-hover); }

button { font-family: inherit; }

::selection { background: var(--accent-tint); color: var(--text); }

/* Mono for ids / fingerprints / code */
.mono {
    font-family: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    direction: ltr;
    unicode-bidi: embed;
    letter-spacing: -0.01em;
}

/*
 * Icon defaults — every <svg class="icon"> gets sane dimensions even if
 * its parent container hasn't matched a more specific selector. Without
 * this default, an SVG with only `viewBox` (no width/height attribute)
 * falls back to the CSS spec's 300x150 default and turns into a giant
 * sticker that takes over the layout.
 *
 * Component-specific rules (`.nav .icon`, `.kpi-icon .icon`, etc) have
 * higher specificity (0,2,0 vs 0,1,0) and override these defaults.
 */
svg { flex-shrink: 0; }  /* don't let any svg balloon inside a flex parent */
.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

/* Numbers should always render LTR + tabular */
.num, .time-cell, .data-table .num {
    font-variant-numeric: tabular-nums;
    direction: ltr;
    text-align: left;
    unicode-bidi: embed;
}

/* ─────────────────────────── topbar ───────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 24px;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.01em;
}
.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    background: linear-gradient(135deg, #a78bfa, #6366f1, #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-md);
}
.brand-name { letter-spacing: -0.02em; }

.nav {
    display: flex;
    gap: 4px;
    flex: 1;
    margin-right: 8px;
}
.nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--r-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: color 0.12s, background 0.12s;
}
.nav a:hover {
    background: var(--hover);
    color: var(--text);
}
.nav a.active {
    background: var(--accent-tint);
    color: var(--accent);
    font-weight: 600;
}
.nav .icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.scope-picker select,
.window-picker select {
    height: 32px;
    padding: 0 28px 0 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='currentColor' stroke-width='1.5'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 14px;
    cursor: pointer;
    transition: border-color 0.12s;
}
.scope-picker select:hover,
.window-picker select:hover {
    border-color: var(--border-strong);
}
.scope-picker select:focus,
.window-picker select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--r-sm);
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.icon-btn:hover {
    background: var(--hover);
    color: var(--text);
    border-color: var(--border-strong);
}
.icon-btn .icon { width: 16px; height: 16px; }

/* Theme toggle: hide one icon depending on theme */
body.theme-dark  .theme-toggle .icon-sun  { display: none; }
body.theme-light .theme-toggle .icon-moon { display: none; }

.logout-btn {
    color: var(--danger);
    border-color: transparent;
}
.logout-btn:hover {
    color: var(--danger);
    background: var(--danger-tint);
    border-color: transparent;
}

/* ─────────────────────────── main ─────────────────────────────── */

.main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.page-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.page-header > form,
.page-header > .header-actions {
    margin-right: auto;
}
.page-header small,
.page-header .muted {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
}
.back-link:hover { color: var(--text); }

/* ───────────────────────── KPI cards ──────────────────────────── */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}
.kpi-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 18px 20px;
    transition: border-color 0.12s, transform 0.12s;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 64px;
    height: 64px;
    background: var(--accent-tint);
    border-radius: 50%;
    transform: translate(30%, -30%);
    opacity: 0.6;
    pointer-events: none;
}
.kpi-card:hover { border-color: var(--border-strong); }
.kpi-icon {
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    border-radius: var(--r-sm);
    background: var(--accent-tint);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.kpi-icon .icon { width: 18px; height: 18px; }
.kpi-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}
.kpi-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.1;
}
.kpi-card-warn .kpi-icon { background: var(--warning-tint); color: var(--warning); }
.kpi-card-warn::before    { background: var(--warning-tint); }
.kpi-card-danger .kpi-icon { background: var(--danger-tint); color: var(--danger); }
.kpi-card-danger::before    { background: var(--danger-tint); }
.kpi-card-success .kpi-icon { background: var(--success-tint); color: var(--success); }
.kpi-card-success::before    { background: var(--success-tint); }

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─────────────────────── panel block / cards ──────────────────── */

.panel-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 18px 20px;
    margin-bottom: 18px;
    transition: border-color 0.12s;
}
.block-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.block-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.005em;
}
.block-header small,
.block-header .muted {
    color: var(--text-muted);
    font-size: 11px;
    margin-right: auto;
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
@media (max-width: 900px) {
    .two-col { grid-template-columns: 1fr; }
}

/* ────────────────────────── data tables ───────────────────────── */

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
}
.data-table thead th {
    text-align: right;
    padding: 8px 10px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr {
    transition: background 0.1s;
}
.data-table tbody tr:hover {
    background: var(--hover);
}
.data-table.dense tbody td { padding: 6px 8px; font-size: 12px; }
.data-table .empty {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
    font-size: 13px;
}
.data-table .time-cell {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
}
.data-table strong { font-weight: 600; }

.row-severity-error { background: var(--danger-tint) !important; }
.row-severity-fatal { background: var(--danger-tint) !important; }
.row-severity-warn  { background: var(--warning-tint) !important; }

/* ─────────────────────── badges / pills ──────────────────────── */

.sev,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.sev-debug { background: var(--surface-3); color: var(--text-muted); }
.sev-info  { background: var(--info-tint);    color: var(--info); }
.sev-warn  { background: var(--warning-tint); color: var(--warning); }
.sev-error { background: var(--danger-tint);  color: var(--danger); }
.sev-fatal { background: var(--danger);       color: white; }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-muted   { background: var(--surface-3);    color: var(--text-muted); }
.badge-accent  { background: var(--accent-tint);  color: var(--accent); }

.error-class {
    display: inline-block;
    color: var(--danger);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11.5px;
    direction: ltr;
    unicode-bidi: embed;
}

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

/* ──────────────────────── filter bars ─────────────────────────── */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px;
    align-items: center;
}
.filters select,
.filters input {
    height: 34px;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 12.5px;
    transition: border-color 0.12s, background 0.12s;
}
.filters select:focus,
.filters input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}
.filters select { cursor: pointer; padding-left: 30px; }
.filters .btn-primary {
    height: 34px;
    padding: 0 16px;
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, transform 0.06s;
}
.filters .btn-primary:hover { background: var(--accent-hover); }
.filters .btn-primary:active { transform: translateY(1px); }
.filters button { /* match older naming used in some views */
    height: 34px;
    padding: 0 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.filters button:hover { background: var(--accent-hover); }

/* ──────────────────────── timeline ────────────────────────────── */

.timeline { list-style: none; padding: 0; margin: 0; }
.tl-row {
    position: relative;
    display: grid;
    grid-template-columns: 86px 18px 1fr;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    align-items: start;
}
.tl-row:last-child { border-bottom: none; }
.tl-time {
    color: var(--text-muted);
    font-size: 11px;
    direction: ltr;
    text-align: left;
    font-variant-numeric: tabular-nums;
    padding-top: 4px;
}
.tl-marker {
    position: relative;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--surface-3);
    margin-top: 6px;
    margin-right: 4px;
    flex-shrink: 0;
}
.tl-marker.tl-sev-info  { background: var(--info); }
.tl-marker.tl-sev-warn  { background: var(--warning); }
.tl-marker.tl-sev-error { background: var(--danger); }
.tl-marker.tl-sev-fatal { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-tint); }
.tl-cat-crash      .tl-marker { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-tint); }
.tl-cat-breadcrumb .tl-marker { background: var(--text-muted); }
.tl-cat-lifecycle  .tl-marker { background: var(--success); }

/* Vertical line connecting markers — only on screens wide enough */
.timeline .tl-row::before {
    content: '';
    position: absolute;
    right: calc(86px + 10px + 4px + 4px);  /* center on marker */
    top: 18px;
    bottom: -10px;
    width: 1px;
    background: var(--border);
}
.timeline .tl-row:last-child::before { display: none; }

.tl-name { font-size: 13px; font-weight: 500; }
.tl-name strong { color: var(--text); font-weight: 600; }
.tl-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.tl-props {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}
.tl-props .kv .k { color: var(--text-muted); }
.tl-props .kv .v {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    direction: ltr;
    unicode-bidi: embed;
}
.tl-stack {
    margin-top: 6px;
    font-size: 11px;
}
.tl-stack summary {
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
    transition: color 0.12s;
}
.tl-stack summary:hover { color: var(--text); }
.tl-stack pre {
    margin-top: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: var(--r-sm);
    overflow: auto;
    font-size: 11px;
    direction: ltr;
    line-height: 1.6;
}
.timeline-compact .tl-row { padding: 6px 0; }

/* ─────────────────────── meta list (key:val) ──────────────────── */

.meta-list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px 18px;
    margin: 0;
    font-size: 13px;
}
.meta-list dt { color: var(--text-muted); font-weight: 500; }
.meta-list dd { margin: 0; color: var(--text); }

pre.stack {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 14px 16px;
    font-size: 11.5px;
    overflow: auto;
    color: var(--text-secondary);
    line-height: 1.65;
    max-height: 480px;
    direction: ltr;
}

/* ─────────────────────── export form ──────────────────────────── */

.export-form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 22px;
    max-width: 760px;
}
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}
.form-row input,
.form-row select {
    height: 38px;
    padding: 0 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.form-row input:focus,
.form-row select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}
.form-actions { grid-column: 1 / -1; margin-top: 6px; display: flex; gap: 10px; }
.form-actions button,
.btn-primary {
    height: 40px;
    padding: 0 22px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, transform 0.06s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.form-actions button:hover,
.btn-primary:hover { background: var(--accent-hover); }
.form-actions button:active { transform: translateY(1px); }

.info-block {
    background: var(--info-tint);
    border: 1px solid color-mix(in srgb, var(--info) 30%, transparent);
}
.info-block h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text); }
.info-block p { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0; line-height: 1.65; }
.info-block code {
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    color: var(--accent);
    direction: ltr;
    unicode-bidi: embed;
}
.ai-guide {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin: 8px 0;
    padding-right: 22px;
    line-height: 1.7;
}
.ai-guide li { margin: 4px 0; }

/* ─────────────────────── paginator ────────────────────────────── */

.paginator {
    display: flex;
    justify-content: center;
    gap: 12px;
    align-items: center;
    margin-top: 18px;
    color: var(--text-muted);
    font-size: 12px;
}
.paginator a {
    padding: 6px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    transition: background 0.12s, border-color 0.12s;
}
.paginator a:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
}

/* ────────────────────────── login ─────────────────────────────── */

.login-body {
    background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--accent) 15%, var(--bg)), var(--bg) 60%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 36px 32px 28px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.login-card .login-mark {
    width: 56px;
    height: 56px;
    border-radius: var(--r-md);
    background: linear-gradient(135deg, #a78bfa, #6366f1, #4f46e5);
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    font-weight: 800;
    box-shadow: var(--shadow-md);
}
.login-card h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.login-card .login-tagline {
    margin: 4px 0 26px;
    color: var(--text-muted);
    font-size: 12px;
}
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input {
    height: 42px;
    padding: 0 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-glow);
}
.login-card button {
    height: 42px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--r-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s;
    margin-top: 2px;
}
.login-card button:hover { background: var(--accent-hover); }
.login-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 6px;
    background: var(--danger-tint);
    padding: 8px 12px;
    border-radius: var(--r-sm);
}

/* ─────────────────── token UI bits ────────────────────────────── */

.token-display {
    background: var(--bg);
    border: 1px dashed var(--accent-strong);
    color: var(--text);
    padding: 14px 18px;
    border-radius: var(--r-sm);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px;
    user-select: all;
    word-break: break-all;
    overflow-wrap: break-word;
    direction: ltr;
    margin: 12px 0;
    line-height: 1.6;
}
.btn-danger {
    height: 30px;
    padding: 0 12px;
    background: transparent;
    color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    border-radius: var(--r-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    transition: background 0.12s;
}
.btn-danger:hover { background: var(--danger-tint); }
.inline-form { display: inline; margin: 0; padding: 0; }

.data-table small {
    display: block;
    color: var(--text-muted);
    font-size: 10.5px;
    margin-top: 2px;
}
.data-table code,
.token-row code {
    background: var(--surface-2);
    padding: 1px 7px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10.5px;
    color: var(--accent);
    direction: ltr;
    unicode-bidi: embed;
}

/* ────────────────────── chart container ───────────────────────── */

canvas {
    max-width: 100%;
}

/* Persian numerals stay LTR but in the same flow */
.dir-ltr { direction: ltr; }
