﻿/* Self-hosted Amiri -- was loaded live from Google Fonts (App.razor) with no local fallback.
   Same already-verified files AthanSync.Stories ships. */
@font-face{font-family:'Amiri';font-weight:400;font-style:normal;font-display:swap;src:url('../fonts/Amiri-Regular.woff2') format('woff2');}
@font-face{font-family:'Amiri';font-weight:700;font-style:normal;font-display:swap;src:url('../fonts/Amiri-Bold.woff2') format('woff2');}
/* Arabic letters only, larger: put first in a font stack so Arabic inside English text reads at a
   comfortable size while the English keeps the normal face (story text editors, recording review). */
@font-face{font-family:'ArabicText';font-weight:400;font-display:swap;size-adjust:135%;src:url('../fonts/Amiri-Regular.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF;}
@font-face{font-family:'ArabicText';font-weight:700;font-display:swap;size-adjust:135%;src:url('../fonts/Amiri-Bold.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF;}

/* ── AthanSync Admin — light theme (mirrors AthanSync brand) ─────── */
:root {
    /* ── Light palette — --t-* names let AthanSync.UI controls render correctly ── */
    --t-bg-page:       #f0f2f7;
    --t-bg-surface:    #ffffff;
    --t-bg-surface-2:  #e8eaf2;
    --t-bg-elevated:   #ffffff;
    --t-text:          #1c2237;
    --t-text-muted:    #64728f;
    --t-text-subtle:   #9aa3b8;
    --t-brand:         #f8b84c;
    --t-brand-strong:  #d9920a;
    --t-brand-soft:    rgba(248,184,76,.18);
    --t-brand-on:      #160e00;
    --t-ring:          rgba(28,34,55,.12);
    --t-ring-strong:   rgba(28,34,55,.22);
    --t-panel-bg:      rgba(255,255,255,.95);
    --t-panel-border:  rgba(60,80,130,.15);
    --t-danger:        #d93025;
    --t-danger-soft:   rgba(217,48,37,.12);
    --t-warn:          #c47b0b;
    --t-warn-soft:     rgba(196,123,11,.14);
    --t-success:       #1e7a42;
    --t-success-soft:  rgba(30,122,66,.12);
    --t-info:          #2563a8;
    --t-info-soft:     rgba(37,99,168,.12);
    --t-shadow:        0 4px 16px rgba(28,34,55,.10);
    color-scheme: light;

    /* SimpleButton text/icon variables */
    --text:  var(--t-text);
    --acc:   var(--t-brand);

    /* ── Legacy --adm-* aliases (existing CSS continues to work) ── */
    --adm-bg:       var(--t-bg-page);
    --adm-surface:  var(--t-bg-surface);
    /* Was referenced by the takes panel, the captions editor and the story cover tiles but
       never defined, so every one of them fell back to transparent. */
    --adm-surface-2: var(--t-bg-surface-2);
    --adm-panel:          #edf0f7;
    --adm-panel-elevated: var(--t-bg-elevated);
    --adm-border:   rgba(60,80,130,.18);
    --adm-text:     var(--t-text);
    --adm-muted:    var(--t-text-muted);
    --adm-amber:    var(--t-brand);
    --adm-electric: var(--t-info);
    --adm-green:    var(--t-success);
    --adm-red:      var(--t-danger);
    --adm-tab-active: var(--t-brand-strong);
    --adm-radius:   14px;

    /* ── UI-03: the variables AthanSync.UI's shared controls expect ──────────
       TabBar (and anything else pulled in from AthanSync.UI) reads --surface,
       --border, --text-muted, --accent, --accent-glow and --font-sm. manage
       defined none of them, so every one fell back to the literal in the shared
       stylesheet — and those fallbacks are the kiosk's dark palette. On manage's
       light theme that renders a dark panel with pale grey text on it.

       Mapped onto the theme tokens rather than written as hex: colours must come
       from CSS variables, so a hardcoded value here would be a rule violation as
       well as a second palette to keep in step. This is also why the fix is not
       an !important override — that would paper over the missing definitions and
       leave the next shared control just as broken. */
    --border:      var(--t-panel-border);
    --text-muted:  var(--t-text-muted);
    --accent:      var(--t-brand-strong);
    --accent-glow: var(--t-brand-soft);

    /* No fallback on this one in the shared stylesheet — undefined makes the
       whole declaration invalid, so compact tab icons silently kept the regular
       size instead of shrinking. */
    --font-sm:     0.78rem;

    /* Used across pages but never defined, so each fell back to its own literal (or, for
       --adm-warning's var(--gold), to nothing) and could not follow the theme. */
    --adm-danger:  var(--t-danger);
    --adm-success: var(--t-success);
    --adm-warning: var(--t-warn);
    --adm-cyan:    var(--t-info);
    --adm-bg-alt:  var(--t-bg-surface-2);

    /* Tints that used to be inline literals — dark-on-light, so they vanish on the dark theme. */
    --adm-hover:       rgba(0,0,0,.04);
    --adm-border-soft: rgba(60,80,130,.12);
    --adm-input-bg:    #ffffff;
    --adm-shadow-rgb:  28,34,55;

    /* Story suggestions (the Suggestions tab and the Story suggestions page): the redesign's palette.
       Teal for actions and accepted, amber for waiting, grey for rejected; a colour per kind of source. */
    --sg-accent:        #0F5E57;
    --sg-accent-strong: #0A403B;
    --sg-accent-soft:   #EEF7F5;
    --sg-accent-line:   #9CCBC3;
    --sg-on-accent:     #FFFFFF;
    --sg-ink:           #18212C;
    --sg-ink-2:         #3A4452;
    --sg-muted:         #5A6473;
    --sg-line:          #DDE1E6;
    --sg-line-2:        #C4CAD2;
    --sg-line-3:        #AEB6C1;
    --sg-surface:       #FFFFFF;
    --sg-surface-2:     #F7F8FA;
    --sg-chip:          #EEF0F3;
    --sg-pending:       #B45309;
    --sg-pending-soft:  #FDF0D5;
    --sg-pending-ink:   #7A3E06;
    --sg-pending-line:  #E3B25B;
    --sg-accepted-soft: #DCF1EC;
    --sg-rejected:      #8A93A0;
    --sg-now:           #FBF3F0;
    --sg-now-ink:       #8A3412;
    --sg-del:           #A23B12;
    --sg-del-soft:      #FBE7E1;
    --sg-ai:            #6D28D9;
    --sg-ai-soft:       #F3EEFC;
    --sg-fact:          #1D4ED8;
    --sg-fact-soft:     #EEF2FD;
    --sg-fact-ink:      #1E3A8A;
    --sg-fact-line:     #C9D4F2;
    --sg-import:        #B45309;
    --sg-import-soft:   #FDF0D5;
    --sg-shadow:        0 -4px 16px rgba(24,33,44,.06);
    --sg-card-shadow:   0 1px 2px rgba(24,33,44,.08), 0 4px 12px rgba(24,33,44,.06);
    --sg-ring:          rgba(15,94,87,.15);
}

/* ── Night mode — toggled by ThemeToggle (data-bs-theme also flips Bootstrap) ── */
:root[data-bs-theme="dark"] {
    --t-bg-page:       #0e131d;
    --t-bg-surface:    #161c29;
    --t-bg-surface-2:  #1f2738;
    --t-bg-elevated:   #1b2232;
    --t-text:          #e4e8f1;
    --t-text-muted:    #9ba6bf;
    --t-text-subtle:   #6b7590;
    --t-brand:         #f8b84c;
    --t-brand-strong:  #f8b84c;
    --t-brand-soft:    rgba(248,184,76,.16);
    --t-brand-on:      #160e00;
    --t-ring:          rgba(255,255,255,.10);
    --t-ring-strong:   rgba(255,255,255,.20);
    --t-panel-bg:      rgba(22,28,41,.95);
    --t-panel-border:  rgba(255,255,255,.10);
    --t-danger:        #ff6b5e;
    --t-danger-soft:   rgba(255,107,94,.16);
    --t-warn:          #f0a43a;
    --t-warn-soft:     rgba(240,164,58,.16);
    --t-success:       #4cc47f;
    --t-success-soft:  rgba(76,196,127,.16);
    --t-info:          #6aa8ff;
    --t-info-soft:     rgba(106,168,255,.16);
    --t-shadow:        0 4px 16px rgba(0,0,0,.45);
    color-scheme: dark;

    --adm-panel:       #1a2030;
    --adm-border:      rgba(255,255,255,.12);
    --adm-hover:       rgba(255,255,255,.05);
    --adm-border-soft: rgba(255,255,255,.07);
    --adm-input-bg:    #111724;
    --adm-shadow-rgb:  0,0,0;

    --sg-accent:        #4FB3A6;
    --sg-accent-strong: #8FD6CC;
    --sg-accent-soft:   rgba(79,179,166,.14);
    --sg-accent-line:   rgba(79,179,166,.45);
    --sg-on-accent:     #0B1A18;
    --sg-ink:           #E4E8F1;
    --sg-ink-2:         #C3CAD8;
    --sg-muted:         #9BA6BF;
    --sg-line:          rgba(255,255,255,.12);
    --sg-line-2:        rgba(255,255,255,.22);
    --sg-line-3:        rgba(255,255,255,.30);
    --sg-surface:       #161C29;
    --sg-surface-2:     #1F2738;
    --sg-chip:          #252E42;
    --sg-pending:       #F0A43A;
    --sg-pending-soft:  rgba(240,164,58,.16);
    --sg-pending-ink:   #F5C27A;
    --sg-pending-line:  rgba(240,164,58,.5);
    --sg-accepted-soft: rgba(79,179,166,.18);
    --sg-rejected:      #6B7590;
    --sg-now:           rgba(255,107,94,.10);
    --sg-now-ink:       #FF9C8F;
    --sg-del:           #FF8A75;
    --sg-del-soft:      rgba(255,138,117,.14);
    --sg-ai:            #A78BFA;
    --sg-ai-soft:       rgba(167,139,250,.14);
    --sg-fact:          #6AA8FF;
    --sg-fact-soft:     rgba(106,168,255,.14);
    --sg-fact-ink:      #A9C8FF;
    --sg-fact-line:     rgba(106,168,255,.35);
    --sg-import:        #F0A43A;
    --sg-import-soft:   rgba(240,164,58,.16);
    --sg-shadow:        0 -4px 16px rgba(0,0,0,.4);
    --sg-card-shadow:   0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
    --sg-ring:          rgba(79,179,166,.25);

    /* Bootstrap's own dark surfaces, aligned to ours so cards/inputs don't sit a shade off. */
    --bs-body-bg:        var(--t-bg-page);
    --bs-body-color:     var(--t-text);
    --bs-secondary-bg:   var(--t-bg-surface-2);
    --bs-tertiary-bg:    var(--t-bg-surface);
    --bs-border-color:   var(--adm-border);
}
[data-bs-theme="dark"] .card { --bs-card-bg: var(--t-bg-surface); }
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select { background-color: var(--adm-input-bg); }

html, body { background: var(--adm-bg); color: var(--adm-text); margin: 0; padding: 0; height: 100%; }

/* The shell (sidebar, app bar, content) is the kit's: admin-kit.css (.m-app, .m-nav, .m-appbar, .m-content). */

/* ── Page header ──────────────────────────────────────── */
.page-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 1.35rem; font-weight: 800; margin: 0; }
.page-header__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Search row ───────────────────────────────────────── */
.list-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* SearchBox override for light admin */
.searchbox-root { flex: 1; width: 100%; }
.searchbox-input { background: var(--adm-surface) !important; color: var(--adm-text) !important;
    border: 1px solid var(--adm-border) !important; border-radius: 10px !important; }
.searchbox-input::placeholder { color: var(--adm-muted) !important; opacity: .8; }
.searchbox-input:focus { border-color: rgba(248,184,76,.55) !important; box-shadow: 0 0 0 3px rgba(248,184,76,.12) !important; }
.searchbox > i { color: var(--adm-muted) !important; }

/* ── Admin tabs (nav-tabs override) ──────────────────── */
.nav-tabs, .admin-tabs { border-bottom: 1px solid var(--adm-border); margin-bottom: 18px; }
.nav-tabs .nav-link, .admin-tabs .nav-link {
    color: var(--adm-muted); font-size: .83rem; font-weight: 600; border: none;
    border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 16px;
    background: none; transition: color .12s, border-color .12s;
}
.nav-tabs .nav-link:hover, .admin-tabs .nav-link:hover { color: var(--adm-text); border-color: color-mix(in oklab, var(--adm-tab-active) 35%, transparent); }
.nav-tabs .nav-link.active, .admin-tabs .nav-link.active { color: var(--adm-tab-active); border-bottom-color: var(--adm-tab-active); }
/* UI-05: the "this tab has an empty required field" marker the two hand-rolled tab bars carried
   inline. Kept as a class so the colour comes from the theme rather than a style attribute. */
.admin-tabs__alert { color: var(--adm-red); font-weight: 700; }
.admin-tabs__status { display: inline-flex; align-items: center; gap: 2px; font-size: .8em; }
.admin-tabs__status-text { font-size: .85em; font-weight: 700; }
.nav-tabs .nav-link.active i, .admin-tabs .nav-link.active i { color: var(--adm-tab-active); }
.admin-tabs .nav-item.badge-count { font-size: .7rem; background: rgba(248,184,76,.15); color: var(--adm-amber); border-radius: 6px; padding: 1px 6px; margin-left: 5px; }

/* ── Stat cards ───────────────────────────────────────── */
.stat-grid { display: flex; flex-wrap: wrap; gap: 28px; margin-bottom: 24px; }
.stat-card { /* legacy — kept for compat */ }

/* ── Tables ───────────────────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; padding: 9px 12px; border-bottom: 2px solid var(--adm-border); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--adm-muted); }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--adm-border-soft); font-size: .87rem; vertical-align: middle; }
.admin-table tr:hover td { background: var(--adm-hover); }
.admin-table .col-actions { white-space: nowrap; text-align: right; }
.table .col-actions { white-space: nowrap; text-align: right; display: flex; gap: 2px; align-items: center; justify-content: flex-end; }
/* Bootstrap table tweaks for light admin */
.table { --bs-table-color: var(--t-text); --bs-table-hover-bg: var(--adm-hover); }
.table th { border-color: var(--adm-border) !important; color: var(--adm-muted); }
.table td { border-color: var(--adm-border-soft) !important; }

/* ── Forms (inside dialogs and pages) ────────────────── */
.admin-field { margin-bottom: 14px; }
.admin-field label { display: block; font-size: .74rem; font-weight: 700; color: var(--adm-muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 5px; }
.admin-panel {
    background: var(--adm-panel);
    border: 1px solid var(--adm-border);
    border-radius: 14px;
    padding: 18px;
}
.admin-input {
    width: 100%; padding: 9px 12px;
    background: var(--adm-input-bg); border: 1px solid var(--adm-border); border-radius: 10px;
    color: var(--adm-text); font-size: .88rem;
    transition: border-color .12s;
}
.admin-input:focus { outline: none; border-color: rgba(248,184,76,.6); box-shadow: 0 0 0 3px rgba(248,184,76,.12); }
.admin-input[disabled] { opacity: .4; cursor: not-allowed; }

/* A <select> carrying .admin-input kept the browser's own arrow, which sits hard against the
   border and ignores the 10px radius. Replaced with a drawn chevron inset 14px, and the text
   padded clear of it so a long option cannot run underneath. */
select.admin-input {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364728f'%3E%3Cpath d='M3.2 5.6a1 1 0 0 1 1.4 0L8 9l3.4-3.4a1 1 0 1 1 1.4 1.4l-4.1 4.1a1 1 0 0 1-1.4 0L3.2 7a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 13px 13px;
}

/* Right-to-left puts the chevron on the other side, and the padding with it. */
[dir="rtl"] select.admin-input {
    padding-right: 12px;
    padding-left: 34px;
    background-position: left 14px center;
}
.admin-textarea { min-height: 120px; resize: vertical; }
.code-editor {
    font-family: 'Cascadia Code','Fira Code',Consolas,monospace;
    font-size: .83rem; line-height: 1.55; min-height: 300px; tab-size: 2;
    white-space: pre-wrap; background: var(--code-bg, #1e1e2e) !important; color: var(--code-fg, #cdd6f4) !important;
    border-color: var(--adm-border) !important;
}

/* ── Bootstrap form controls (light theme) ──────────────── */
.form-control, .form-select {
    border-color: var(--adm-border);
    color: var(--t-text);
}
.form-control:focus, .form-select:focus {
    border-color: var(--t-brand);
    box-shadow: 0 0 0 0.2rem var(--t-brand-soft);
    color: var(--t-text);
}
.form-label { color: var(--adm-text); }
.form-text { color: var(--adm-muted); }
.form-check-input:checked { background-color: var(--t-brand); border-color: var(--t-brand-strong); }

/* Bootstrap card */
.card { border-color: var(--adm-border-soft); }

/* Bootstrap btn-link (inline table row actions) */
.btn-link { color: var(--adm-text); text-decoration: none; }
.btn-link:hover { color: var(--t-brand-strong); text-decoration: none; }
.btn-link.text-danger, .btn-link.text-danger:hover { color: var(--adm-red) !important; }
.btn-link.text-success { color: var(--adm-green) !important; }
.btn-link.text-warning { color: var(--t-warn) !important; }

/* Bootstrap outline buttons */
.btn-outline-primary { --bs-btn-color: var(--t-brand-strong); --bs-btn-border-color: var(--t-brand); --bs-btn-hover-bg: var(--t-brand); --bs-btn-hover-border-color: var(--t-brand-strong); --bs-btn-hover-color: var(--t-brand-on); --bs-btn-active-bg: var(--t-brand-strong); --bs-btn-active-color: var(--t-brand-on); }
.btn-outline-secondary { --bs-btn-color: var(--adm-text); --bs-btn-border-color: var(--adm-border); --bs-btn-hover-bg: var(--adm-panel); --bs-btn-hover-color: var(--adm-text); }
.btn-outline-danger { --bs-btn-color: var(--adm-red); --bs-btn-border-color: var(--adm-red); --bs-btn-hover-bg: var(--adm-red); --bs-btn-hover-color: #fff; }

/* Bootstrap pagination */
.pagination .page-link { background-color: var(--t-bg-surface); border-color: var(--adm-border); color: var(--adm-text); }
.pagination .page-link:hover { background-color: var(--adm-panel); color: var(--t-brand-strong); border-color: var(--adm-border); }
.pagination .page-item.active .page-link { background-color: var(--t-brand); border-color: var(--t-brand); color: var(--t-brand-on); }
.pagination .page-item.disabled .page-link { color: var(--adm-muted); background-color: var(--t-bg-surface); }

/* Bootstrap modal */
.modal-content { background-color: var(--t-bg-surface); border-color: var(--adm-border); color: var(--adm-text); }
.modal-header { border-bottom-color: var(--adm-border); }
.modal-footer { border-top-color: var(--adm-border); }

/* ── Inline admin modal ───────────────────────────────── */
.admin-modal-overlay {
    position: fixed; inset: 0; z-index: 200010;
    display: flex; align-items: flex-start; justify-content: center;
    overflow-y: auto; padding: 16px;
}
.admin-modal-backdrop {
    /* fixed so it covers the full viewport even when the overlay scrolls */
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
}
.admin-modal-panel {
    position: relative; background: var(--t-bg-surface);
    border: 1px solid var(--adm-border); border-radius: 18px;
    box-shadow: 0 12px 40px rgba(var(--adm-shadow-rgb),.16), 0 0 0 1px var(--adm-border);
    padding: 22px 22px 18px; width: min(92vw, 560px);
    /* overflow:visible lets dropdown menus escape the panel boundary */
    overflow: visible; flex-shrink: 0; margin: auto 0;
    animation: adm-pop .16s ease-out both; display: grid; gap: 14px;
}
.admin-modal-panel.wide { width: min(92vw, 820px); }
.admin-modal-panel.voice-modal { width: min(92vw, 660px); }
.admin-modal-header { display: flex; align-items: center; gap: 10px; }
.admin-modal-icon { font-size: 1.3rem; color: var(--adm-amber); }
.admin-modal-title { margin: 0; font-size: 1.1rem; font-weight: 800; }
.admin-modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; border-top: 1px solid var(--adm-border); margin-top: 4px; }
@keyframes adm-pop { from { opacity:0; transform: translateY(-6px) scale(.97); } to { opacity:1; transform: none; } }

/* ── Language tabs (story texts) ─────────────────────── */
/* UI-05: the .tab-bar / .tab-btn rules that styled the two hand-rolled tab bars are gone with
   them — both editors now use AdminTabBar. Worth noting because the audit believed this rule was
   masking AthanSync.UI's shared TabBar. It never could: Blazor scoped CSS compiles to
   .tab-bar[b-xxxxx], which outranks a bare class selector. It only ever styled manage's own
   markup, and there is none left. */

/* ── Empty state ──────────────────────────────────────── */
.empty-state { text-align: center; padding: 52px 24px; color: var(--adm-muted); }
.empty-state i { font-size: 2.8rem; margin-bottom: 10px; display: block; opacity: .5; }
.empty-state p { font-size: .9rem; margin: 0; }

/* ── Pills / badges ───────────────────────────────────── */
.adm-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; }
.adm-badge-green  { background: rgba(30,122,66,.10); color: var(--adm-green); border: 1px solid rgba(30,122,66,.25); }
.adm-badge-amber  { background: rgba(248,184,76,.12); color: var(--t-brand-strong); border: 1px solid rgba(248,184,76,.3); }
.adm-badge-red    { background: rgba(217,48,37,.10); color: var(--adm-red);  border: 1px solid rgba(217,48,37,.22); }
.adm-badge-muted  { background: rgba(100,114,143,.10); color: var(--adm-muted); border: 1px solid rgba(100,114,143,.2); }
.adm-badge-blue,
.adm-badge-electric { background: rgba(37,99,168,.10); color: var(--adm-electric); border: 1px solid rgba(37,99,168,.2); }

/* ── TTS log ──────────────────────────────────────────── */
.tts-log { max-height: 280px; overflow-y: auto; font-family: 'Cascadia Code',Consolas,monospace; font-size: .76rem; background: var(--code-bg, #1e1e2e); color: var(--code-fg, #cdd6f4); border: 1px solid var(--adm-border); border-radius: 10px; padding: 10px 12px; }
.tts-log-line { margin: 0; padding: 1px 0; line-height: 1.5; }
.tts-log-line.error { color: #f38ba8; }
.tts-log-line.ok    { color: #a6e3a1; }
.tts-log-line.text  { color: #6c757d; font-size: 0.82em; word-break: break-all; font-family: monospace; white-space: pre-wrap; }

/* ── Controls override (light admin) ── */
.ctl-row { background: var(--adm-hover) !important; border-color: var(--adm-border) !important; }

/* ── Spin animation for TTS worker ───────────────────── */
.spin { animation: spin 1.5s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Story two-panel text layout ──────────────────────── */
.story-text-layout { display: grid; grid-template-columns: 200px 1fr; gap: 16px; min-height: 320px; }
.story-lang-list { border: 1px solid var(--adm-border); border-radius: 12px; overflow: hidden; }
.story-lang-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--adm-border-soft); font-size: .83rem; transition: background .1s, color .1s; }
.story-lang-item:last-child { border-bottom: none; }
.story-lang-item:hover { background: var(--adm-hover); }
.story-lang-item.active { background: rgba(248,184,76,.10); color: var(--t-brand-strong); border-left: 2px solid var(--adm-amber); }
.story-lang-item .iso { font-size: .7rem; color: var(--adm-muted); font-family: monospace; margin-right: auto; }
.story-lang-item .check { color: var(--adm-green); font-size: .85rem; }
.adm-badge-pink { background: rgba(244,114,182,.1); color: #db2777; border: 1px solid rgba(244,114,182,.2); }
.adm-badge-purple { background: rgba(168,85,247,.1); color: #a855f7; border: 1px solid rgba(168,85,247,.25); }

audio { max-width: 320px; }
code { font-size: .8rem; color: var(--adm-electric); }

/* ── Flatten 3D buttons in admin context ──────────────────────────── */
.as-btn-3d {
    background: var(--t-bg-surface) !important;
    border-color: var(--adm-border) !important;
    box-shadow: 0 1px 3px rgba(var(--adm-shadow-rgb),.08) !important;
}
.as-btn-3d::before { display: none !important; }
.as-btn-3d:hover {
    background: var(--adm-panel) !important;
    border-color: rgba(248,184,76,.4) !important;
    box-shadow: 0 2px 8px rgba(var(--adm-shadow-rgb),.12) !important;
    transform: translateY(-1px) !important;
}
.as-btn-3d:active { transform: none !important; box-shadow: 0 1px 2px rgba(var(--adm-shadow-rgb),.06) !important; }

/* ── Stat card grid ───────────────────────────────────────────────── */
.adm-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.adm-stat {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    padding: 18px 20px;
}
.adm-stat__label { font-size:.72rem; font-weight:700; text-transform:uppercase; letter-spacing:.5px; color:var(--adm-muted); margin-bottom:8px; }
.adm-stat__value { font-size:2rem; font-weight:800; color:var(--adm-text); line-height:1; margin-bottom:6px; }
.adm-stat__value.stat-success { color:var(--adm-green); }
.adm-stat__value.stat-danger  { color:var(--adm-red); }
.adm-stat__footer { margin-top:8px; }
.adm-stat__link  { font-size:.78rem; font-weight:600; color:var(--t-info); text-decoration:none; }
.adm-stat__link:hover { color:var(--t-brand-strong); }

/* ── Dashboard content panels ────────────────────────────────────── */
.adm-dash-panel {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.adm-dash-panel--danger { border-color: var(--adm-red); }
.adm-dash-panel__header {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--adm-border);
    background: var(--adm-panel);
}
.adm-dash-panel--danger .adm-dash-panel__header { border-bottom-color: rgba(217,48,37,.3); background: rgba(217,48,37,.04); }
.adm-dash-panel__title { font-size:.93rem; font-weight:800; color:var(--adm-text); flex:1; margin:0; }
.adm-dash-panel--danger .adm-dash-panel__title { color:var(--adm-red); }
.adm-dash-panel__body { padding:0; }
.adm-dash-panel__body .table { margin:0; }
.adm-dash-panel__body .table th,
.adm-dash-panel__body .table td { padding:9px 18px; }

/* ── SimpleDropDown: light admin overrides ────────────────────────── */
.sdd-field {
    --dropdown-fg: var(--t-text);
    --dropdown-field-bg: none;
    --dropdown-field-base: var(--t-bg-surface);
    --dropdown-border: var(--adm-border);
    --dropdown-focus-border: rgba(248,184,76,.55);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.sdd-field:focus, .sdd-field:focus-within {
    box-shadow: 0 0 0 3px rgba(248,184,76,.12) !important;
    border-color: rgba(248,184,76,.55) !important;
}
.sdd-menu {
    background: var(--t-bg-surface) !important;
    border: 1px solid var(--adm-border) !important;
    box-shadow: 0 8px 24px rgba(var(--adm-shadow-rgb),.14) !important;
}
.sdd-item { color: var(--t-text) !important; }
.sdd-item.active, .sdd-item:hover {
    background: rgba(248,184,76,.10) !important;
    color: var(--t-brand-strong) !important;
}
.sdd-ph { color: var(--adm-muted) !important; }
.sdd-value { color: var(--t-text) !important; }

/* ── Accent palette: override for light theme readability ─────────── */
/* Keyed on roles, not hues. `brand` takes what `electric` used to be: it was the library
   default and by far the most common value here, so ordinary actions keep the portal's
   familiar blue rather than turning gold. */
[data-accent="brand"]   { --acc: var(--adm-electric);   --acc-soft: var(--t-info-soft); }
[data-accent="success"] { --acc: var(--adm-green);      --acc-soft: var(--t-success-soft); }
[data-accent="danger"]  { --acc: var(--adm-red);        --acc-soft: var(--t-danger-soft); }
[data-accent="warning"] { --acc: var(--t-brand-strong); --acc-soft: var(--t-brand-soft); }
[data-accent="info"]    { --acc: var(--t-info);         --acc-soft: var(--t-info-soft); }
[data-accent="muted"]   { --acc: var(--adm-muted);      --acc-soft: rgba(100,114,143,.10); }

/* ── Audio upload button ──────────────────────────────── */
.adm-upload-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 10px; cursor: pointer;
    font-size: .84rem; font-weight: 700; user-select: none;
    background: rgba(37,99,168,.08); color: var(--adm-electric);
    border: 1px solid rgba(37,99,168,.22); transition: background .15s, border-color .15s;
}
.adm-upload-btn:hover { background: rgba(37,99,168,.16); border-color: rgba(37,99,168,.4); }
.adm-upload-btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.adm-upload-file { display: none !important; }

/* ── JSON Viewer ──────────────────────────────────────── */
.json-viewer { position: relative; }
.json-viewer--empty { color: var(--adm-muted); font-size: .85rem; }
.json-viewer__empty { opacity: .6; }
.json-viewer__toolbar {
    display: flex; align-items: center; gap: 8px; justify-content: flex-end;
    margin-bottom: 4px;
}
.json-viewer__label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--adm-muted); margin-right: auto; }
.json-viewer__copy {
    background: none; border: 1px solid var(--adm-border); border-radius: 6px;
    padding: 3px 8px; font-size: .75rem; color: var(--adm-muted); cursor: pointer;
    transition: background .1s, color .1s;
}
.json-viewer__copy:hover { background: var(--adm-panel); color: var(--adm-text); }
.json-viewer__pre {
    background: var(--code-bg, #1e1e2e); color: var(--code-fg, #cdd6f4);
    border: 1px solid var(--adm-border); border-radius: 10px;
    padding: 14px 16px; margin: 0; overflow-x: auto; max-height: 480px; overflow-y: auto;
    font-family: 'Cascadia Code','Fira Code',Consolas,monospace;
    font-size: .78rem; line-height: 1.6; white-space: pre;
}
.json-viewer__pre code { all: unset; white-space: inherit; }
.json-viewer__pre--plain { white-space: pre-wrap; word-break: break-word; }
/* Syntax token colours */
.jv-key  { color: #89b4fa; }
.jv-str  { color: #a6e3a1; }
.jv-num  { color: #fab387; }
.jv-bool { color: #f38ba8; }

/* ── Device management ───────────────────────────────── */
.device-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.device-status-dot--online  { background: var(--adm-green); box-shadow: 0 0 0 2px rgba(30,122,66,.2); }
.device-status-dot--recent  { background: var(--t-brand); box-shadow: 0 0 0 2px rgba(248,184,76,.2); }
.device-status-dot--stale   { background: var(--adm-red); opacity: .7; }
.device-status-dot--never   { background: var(--adm-border); }
.device-status-dot--inactive{ background: var(--adm-red); opacity: .55; }

.device-uuid { font-family: 'Cascadia Code',Consolas,monospace; font-size: .77rem; color: var(--adm-muted); }
.device-row-link { cursor: pointer; }
.device-row-link:hover td { background: rgba(248,184,76,.05) !important; }

.detail-card {
    background: var(--adm-surface); border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius); padding: 20px 22px; margin-bottom: 18px;
}
.detail-card__title { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--adm-muted); margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 24px; }
.detail-field { display: flex; flex-direction: column; gap: 3px; }
.detail-field__label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--adm-muted); }
.detail-field__value { font-size: .88rem; color: var(--adm-text); word-break: break-all; }
.detail-field__value--mono { font-family: 'Cascadia Code',Consolas,monospace; font-size: .78rem; }
.detail-field__value--muted { color: var(--adm-muted); }

.tracked-push-list { display: flex; flex-direction: column; gap: 10px; }
.tracked-push-item {
    width: 100%;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px 14px;
    align-items: center;
    text-align: left;
    background: linear-gradient(180deg, rgba(248,184,76,.07), rgba(248,184,76,.02));
    border: 1px solid rgba(248,184,76,.18);
    border-radius: 14px;
    padding: 12px 14px;
    color: var(--adm-text);
}
.tracked-push-item:hover { border-color: rgba(248,184,76,.35); transform: translateY(-1px); }
.tracked-push-item--active { box-shadow: 0 0 0 1px rgba(248,184,76,.22) inset; }
.tracked-push-item__main { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.tracked-push-item__title { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tracked-push-item__id { font-family: monospace; font-size: .78rem; color: var(--adm-text); }
.tracked-push-item__meta { font-size: .76rem; color: var(--adm-muted); display: flex; flex-wrap: wrap; gap: 10px; }
.tracked-push-item__duration { font-size: .8rem; color: var(--adm-text); text-align: right; }
.tracked-push-item__status { justify-self: end; }

.push-summary-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.push-diff-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}
.push-diff-item {
    border: 1px solid rgba(148,163,184,.16);
    border-radius: 12px;
    padding: 12px;
    background: rgba(15,23,42,.34);
    box-shadow: none;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.push-diff-item:hover {
    border-color: rgba(96,165,250,.30);
    background: rgba(15,23,42,.46);
}
.push-diff-item__path-wrap {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    min-width: 0;
}
.push-diff-item__path {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--adm-text);
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(30,41,59,.55);
    border: 1px solid rgba(148,163,184,.24);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.push-diff-item__values { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.push-diff-item__value {
    min-width: 0;
    border-radius: 10px;
    padding: 8px;
    border: 1px solid rgba(148,163,184,.22);
    background: rgba(2,6,23,.22);
}
.push-diff-item__value--from { border-left: 3px solid rgba(251,146,60,.85); }
.push-diff-item__value--to { border-left: 3px solid rgba(56,189,248,.85); }
.push-diff-item__label { display: block; font-size: .67rem; text-transform: uppercase; letter-spacing: .5px; color: var(--adm-muted); margin-bottom: 2px; }
.push-diff-item__text {
    display: block;
    font-family: monospace;
    font-size: .72rem;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--adm-text);
    line-height: 1.4;
}
.push-timeline {
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 14px;
    padding: 14px;
    background: rgba(15,23,42,.25);
}
.push-timeline__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    justify-content: space-between;
    margin-top: 10px;
    font-size: .76rem;
    color: var(--adm-muted);
}
.push-timeline__diagram {
    overflow-x: auto;
    border-radius: 12px;
    background: rgba(2,6,23,.3);
    border: 1px solid rgba(148,163,184,.12);
    padding: 8px;
}
.push-timeline__diagram .mermaid { min-height: 80px; }

.event-flow {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
}
.event-flow__diagram {
    overflow-x: auto;
    border-radius: 12px;
    background: rgba(2,6,23,.3);
    border: 1px solid rgba(148,163,184,.12);
    padding: 8px;
}
.event-flow__diagram .mermaid { min-height: 90px; }
.event-flow__details {
    border: 1px solid rgba(148,163,184,.18);
    border-radius: 12px;
    padding: 10px;
    background: rgba(15,23,42,.30);
}
.event-flow__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}
.event-flow__time { font-size: .74rem; color: var(--adm-muted); }
.event-flow__json {
    margin: 0;
    font-family: monospace;
    font-size: .72rem;
    line-height: 1.35;
    color: #cbd5e1;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 900px) {
    .push-diff-list {
        grid-template-columns: 1fr;
    }
    .push-diff-item__values {
        grid-template-columns: 1fr;
    }
}

.settings-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .settings-compare { grid-template-columns: 1fr; } }

/* KRG-02: the raw desired/actual blobs, kept for engineers but folded away by default now that
   LabeledSettingsView is the primary reading surface. */
.raw-json-collapsed { margin-top: 16px; }
.raw-json-collapsed > summary {
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid var(--t-panel-border);
    border-radius: 6px;
    background: var(--t-bg-surface-2);
    color: var(--t-text-muted);
    font-size: .85rem;
    user-select: none;
}
.raw-json-collapsed > summary:hover { color: var(--t-text); }
.raw-json-collapsed[open] > summary { margin-bottom: 12px; }

.audit-timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.audit-entry {
    display: grid; grid-template-columns: 140px 1fr;
    gap: 0 16px; padding: 10px 0;
    border-bottom: 1px solid var(--adm-border-soft);
    align-items: start;
}
.audit-entry:last-child { border-bottom: none; }
.audit-entry__time { font-size: .75rem; color: var(--adm-muted); font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 2px; }
.audit-entry__body { min-width: 0; }
.audit-entry__action { font-size: .86rem; font-weight: 700; color: var(--adm-text); }
.audit-entry__meta { font-size: .75rem; color: var(--adm-muted); margin-top: 2px; }
.audit-entry__payload { margin-top: 8px; }
.audit-expand-btn { background: none; border: none; font-size: .75rem; color: var(--adm-electric); cursor: pointer; padding: 0; margin-top: 4px; }
.audit-expand-btn:hover { text-decoration: underline; }

.companion-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--adm-border-soft); }
.companion-row:last-child { border-bottom: none; }
.companion-row__icon { width: 36px; height: 36px; border-radius: 10px; background: var(--adm-panel); display: grid; place-items: center; font-size: 1rem; color: var(--adm-muted); flex-shrink: 0; }
.companion-row__name { font-weight: 700; font-size: .88rem; }
.companion-row__meta { font-size: .76rem; color: var(--adm-muted); }

.session-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--adm-border-soft); }
.session-row:last-child { border-bottom: none; }
.session-row__time { font-size: .78rem; color: var(--adm-muted); min-width: 140px; }
.session-row__detail { font-size: .83rem; color: var(--adm-text); flex: 1; }

/* The audio player is the kit's (admin-kit.css, .m-player / .m-rowplayer). */

/* ── Command Activity Pipeline ─────────────────────────────────────── */
.cmd-pipeline {
    display: flex;
    align-items: flex-start;
    padding: 8px 0 4px;
    overflow-x: auto;
}
.cmd-stage {
    flex: 1;
    min-width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.cmd-stage + .cmd-stage::before {
    content: '';
    position: absolute;
    top: 15px;
    right: calc(50% + 16px);
    left: calc(-50% + 16px);
    height: 2px;
    background: var(--adm-border);
    z-index: 0;
}
.cmd-stage--done + .cmd-stage::before,
.cmd-stage--active + .cmd-stage::before     { background: var(--t-success); }
.cmd-stage--failed + .cmd-stage::before     { background: var(--t-danger); }

.cmd-stage__dot {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: .9rem; position: relative; z-index: 1;
    border: 2px solid var(--adm-border);
    background: var(--adm-surface);
    color: var(--adm-muted);
    flex-shrink: 0;
}
.cmd-stage--done   .cmd-stage__dot { background: var(--t-success-soft); border-color: var(--t-success); color: var(--t-success); }
.cmd-stage--active .cmd-stage__dot { background: var(--t-brand-soft);   border-color: var(--t-brand);   color: var(--t-brand-strong); animation: pulse-stage .9s ease-in-out infinite alternate; }
.cmd-stage--failed .cmd-stage__dot { background: var(--t-danger-soft);  border-color: var(--t-danger);  color: var(--t-danger); }

@keyframes pulse-stage {
    from { box-shadow: 0 0 0 0   rgba(248,184,76,.4); }
    to   { box-shadow: 0 0 0 6px rgba(248,184,76,.0); }
}
.cmd-stage__label {
    margin-top: 8px;
    font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .4px;
    text-align: center; color: var(--adm-muted);
}
.cmd-stage--done   .cmd-stage__label { color: var(--t-success); }
.cmd-stage--active .cmd-stage__label { color: var(--t-brand-strong); }
.cmd-stage--failed .cmd-stage__label { color: var(--t-danger); }

.cmd-stage__time     { margin-top: 4px; font-size: .7rem; color: var(--adm-muted); text-align: center; font-variant-numeric: tabular-nums; }
.cmd-stage__relative { font-size: .66rem; color: var(--adm-muted); text-align: center; opacity: .75; }

/* Command/result list rows */
.cmd-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid var(--adm-border-soft);
}
.cmd-row:last-child { border-bottom: none; }
.cmd-row__badge { min-width: 120px; text-align: center; flex-shrink: 0; }
.cmd-row__desc  { font-size: .82rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd-row__time  { font-size: .72rem; color: var(--adm-muted); flex-shrink: 0; text-align: right; }

/* Story version-history diff (BlazorTextDiff) — mapped onto the admin theme tokens
   instead of the library's own hex defaults. Not scoped to a dark-mode media query:
   manage has no dark theme (App.razor is hardcoded data-bs-theme="light"), so this
   overrides the library's own `prefers-color-scheme: dark` block unconditionally
   rather than letting the diff go dark while the rest of the page stays light. */
.story-history-diff {
    --diff-bg-primary:      var(--adm-surface);
    --diff-bg-secondary:    var(--adm-panel);
    --diff-bg-tertiary:     var(--t-bg-surface-2);
    --diff-border-primary:  var(--adm-border);
    --diff-border-secondary: var(--adm-border);
    --diff-text-primary:    var(--adm-text);
    --diff-text-secondary:  var(--adm-muted);
    --diff-text-muted:      var(--adm-muted);
    --diff-text-accent:     var(--adm-electric);
    --diff-addition-bg:          var(--t-success-soft);
    --diff-addition-border:      var(--adm-green);
    --diff-addition-highlight:   var(--t-success-soft);
    --diff-deletion-bg:          var(--t-danger-soft);
    --diff-deletion-border:      var(--adm-red);
    --diff-deletion-highlight:   var(--t-danger-soft);
    --diff-modification-bg:        var(--t-warn-soft);
    --diff-modification-border:    var(--adm-amber);
    --diff-modification-highlight: var(--t-warn-soft);
    --stats-primary-bg: var(--adm-electric); --stats-primary-text: #fff;
    --stats-success-bg: var(--adm-green);    --stats-success-text: #fff;
    --stats-danger-bg:  var(--adm-red);      --stats-danger-text: #fff;
    --stats-warning-bg: var(--adm-amber);    --stats-warning-text: #fff;
    --stats-info-bg:    var(--adm-electric); --stats-info-text: #fff;
    font-size: .78rem;
}
.story-history-diff .diff-stats-badge:not(.primary):not(.success):not(.danger):not(.warning):not(.info) {
    background: var(--adm-panel); color: var(--adm-muted); border-color: var(--adm-border);
}
/* Scroll-cap the diff instead of BlazorTextDiff's own collapse toggle — its
   internal "Show more" state resets on every parent re-render (its
   OnParametersSet unconditionally rewrites isCollapsed from CollapseContent
   on every parameter pass, not just the first), so the button visibly snaps
   back shut. CollapseContent is left off entirely and this wrapper reproduces
   the same capped-height look with plain CSS instead. */
.story-history-diff-scroll {
    max-height: 680px;
    overflow-y: auto;
    border-radius: 8px;
}

/* Auto-refresh indicator */
.refresh-indicator {
    font-size: .72rem; color: var(--adm-muted);
    display: inline-flex; align-items: center; gap: 4px;
}

/* ─── AdminActionMenu — split button ─────────────────────────────────────────
   Global, not a scoped .razor.css, and that is not a shortcut. Blazor stamps its
   scope attribute at compile time onto the elements written in a component's own
   file: .adm-actmenu__caret and __panel belong to AdminActionMenu, while the
   __item buttons inside them are written by the HOST page and carry the host's
   scope instead. No single scoped stylesheet can reach both halves, so a scoped
   sheet would ship, match nothing, and leave an unstyled menu with no error
   anywhere - the same silent failure as :global() in a .razor.css. */

.adm-actmenu { position: relative; display: inline-flex; }

.adm-actmenu__pair { display: inline-flex; align-items: stretch; }

.adm-actmenu__caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    margin-left: 2px;
    padding: 0;
    font-size: .62rem;
    cursor: pointer;
    color: var(--adm-text);
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: 6px;
}

.adm-actmenu__caret:hover:not(:disabled) {
    background: var(--adm-surface-2);
    border-color: var(--adm-electric);
}

.adm-actmenu__caret:disabled { opacity: .5; cursor: default; }

.adm-actmenu__panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 40;
    min-width: 252px;
    padding: 6px;
    border-radius: 8px;
    border: 1px solid var(--adm-border);
    background: var(--adm-panel);
    box-shadow: 0 12px 40px rgba(var(--adm-shadow-rgb),.16), 0 0 0 1px var(--adm-border);
}

.adm-actmenu__title {
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--adm-muted);
    padding: 4px 8px 6px;
}

.adm-actmenu__item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    padding: 7px 8px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--adm-text);
    font-size: .8rem;
    text-align: left;
    cursor: pointer;
}

.adm-actmenu__item:hover:not(:disabled) { background: var(--adm-surface-2); }

.adm-actmenu__item:disabled { opacity: .5; cursor: default; }

.adm-actmenu__item--on { color: var(--adm-electric); }

.adm-actmenu__item > i { padding-top: 2px; font-size: .8rem; }

.adm-actmenu__item small {
    display: block;
    font-size: .68rem;
    color: var(--adm-muted);
    margin-top: 1px;
}

/* ── AI story generator (/stories/generate) ─────────────────────────────── */
.sg-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.sg-step { font-size: .78rem; padding: 4px 11px; border-radius: 999px; background: var(--adm-surface-2); color: var(--adm-muted); }
.sg-step--on { background: var(--adm-text); color: var(--adm-surface); font-weight: 600; }
.sg-step--done { background: var(--adm-surface-2); color: var(--adm-green); }
.sg-panel { padding: 16px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.sg-panel h2 { font-size: 1rem; margin: 0; }
.sg-panel h3 { font-size: .9rem; margin: 0; }
.sg-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sg-row--between { justify-content: space-between; }
.sg-row--end { justify-content: flex-end; }
.sg-actions { white-space: nowrap; display: flex; gap: 6px; }
/* The run's cost panel: one bar, opening to a group per story, each opening to its calls. */
.sg-cost { padding: 0; margin-bottom: 10px; }
.sg-cost__bar, .sg-cost__group-head {
    width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
    background: transparent; border: 0; color: var(--adm-text); cursor: pointer; font: inherit;
}
.sg-cost__bar { padding: 10px 14px; }
.sg-cost__bar:hover, .sg-cost__group-head:hover { background: var(--adm-surface-2); }
.sg-cost__groups { border-top: 1px solid var(--adm-border); padding: 4px 14px 0; }
.sg-cost__group { border-bottom: 1px solid var(--adm-border); }
.sg-cost__group:last-child { border-bottom: 0; }
.sg-cost__group-head { padding: 8px 4px; }
.sg-cost__group-name { font-weight: 600; }
.sg-cost__group-total { margin-left: auto; }
/* Model pickers: the shared dropdown clamps its field and menu to a fixed lane (240px, or
   RightWidth); model names with prices need the whole row, so the field takes all but the label. */
.ctl-row.sg-ddl-wide { grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) !important; }
.ctl-row.sg-ddl-wide .ctl-row__right.ddl-right { flex: 1 1 auto !important; width: 100% !important; min-width: 0 !important; max-width: none !important; }
/* Plan step: the Use switch sits alone in its cell, and a story title gets the whole column. */
.sg-use .ctl-row { grid-template-columns: 0 auto; padding: 4px 0; }
.sg-use .ctl-row__left { display: none; }
/* The shared switch is drawn for the apps' dark theme (white knob, near-transparent track), which
   all but disappears on manage's light panels; here it uses manage's own colours in both states. */
.sg-use .switchy input[type="checkbox"] { background: var(--adm-surface-2); border: 1px solid var(--adm-muted); box-shadow: none; }
.sg-use .switchy input[type="checkbox"]::after { background: var(--adm-muted); border: none; box-shadow: none; }
.sg-use .switchy input[type="checkbox"]:checked { background: var(--acc); border-color: var(--acc); box-shadow: none; }
.sg-use .switchy input[type="checkbox"]:checked::after { background: var(--adm-surface); }
.sg-use .switchy .state { color: var(--adm-muted); }
.sg-use .switchy input[type="checkbox"]:checked + .state { color: var(--acc); }
.sg-title-input .ctl-row { grid-template-columns: auto minmax(0, 1fr) !important; }
.sg-title-input .ctl-input .simple-input { width: 100%; font-size: 1rem; min-height: 40px; }
.ctl-row.sg-ddl-wide .ctl-dropdown .ddl .ddl-menu { width: 100% !important; min-width: 100% !important; max-width: none !important; }
.sg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.sg-tile { background: var(--adm-surface-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 5px; }
.sg-k { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--adm-muted); }
.sg-muted { font-size: .78rem; color: var(--adm-muted); }
.sg-err { font-size: .78rem; color: var(--adm-red); }
.sg-ok { color: var(--adm-green); }
.sg-ar { font-family: 'Amiri', serif; font-size: 1.25rem; direction: rtl; }
.sg-note { border-radius: 10px; padding: 10px 14px; font-size: .84rem; line-height: 1.5; background: var(--adm-surface-2); }
.sg-note--warn { border-left: 3px solid var(--adm-amber); }
.sg-note--bad { border-left: 3px solid var(--adm-red); }
.sg-note--info { border-left: 3px solid var(--adm-electric); }
.sg-table { width: 100%; }
.sg-table td, .sg-table th { vertical-align: top; }
.sg-table td.sg-c, .sg-table th.sg-c { text-align: center; }
.sg-struck { text-decoration: line-through; color: var(--adm-muted); }
.sg-thin { background: var(--adm-surface-2); }
.sg-bar { height: 7px; background: var(--adm-surface-2); border-radius: 99px; overflow: hidden; min-width: 120px; }
.sg-bar > span { display: block; height: 100%; background: var(--adm-electric); }
.sg-bar--good > span { background: var(--adm-green); }
.sg-bar--thin > span { background: var(--adm-amber); }
.sg-verse { font-size: .8rem; color: var(--adm-muted); font-style: italic; border-left: 3px solid var(--adm-border); padding-left: 10px; white-space: pre-wrap; }
.sg-text { white-space: pre-wrap; font-size: .9rem; line-height: 1.7; border: 1px solid var(--adm-border); border-radius: 10px; padding: 14px 16px; background: var(--adm-surface); max-height: 640px; overflow-y: auto; }
.sg-layout { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.sg-layout__main { flex: 999 1 560px; min-width: 0; }
.sg-layout__side { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.sg-finding { border: 1px solid var(--adm-border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--adm-surface); }
.sg-finding--blocking { border-color: var(--adm-red); }
.sg-finding--done { opacity: .6; }
.sg-snippet { font-size: .82rem; border-radius: 8px; padding: 7px 10px; background: var(--adm-surface-2); white-space: pre-wrap; }
.sg-snippet--old { text-decoration: line-through; }
.sg-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sg-stats > div { background: var(--adm-surface-2); border-radius: 8px; padding: 8px 10px; font-size: .78rem; }
.sg-stats strong { display: block; font-size: 1.05rem; }
.sg-log { font-family: 'Cascadia Code', Consolas, monospace; font-size: .74rem; line-height: 1.6; max-height: 260px; overflow-y: auto; }
