/* iSIM Admin — design tokens, layout and components. No external fonts or CDNs (the panel
   must load in Iran, where many CDNs are filtered). */

:root {
    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-3: #eef0f4;
    --text: #12141a;
    --text-2: #4a4f5c;
    --muted: #7c8191;
    --line: #e4e6ec;
    --line-strong: #d3d6de;
    --accent: #4f46e5;
    --accent-2: #6366f1;
    --accent-soft: #eef0ff;
    --accent-text: #3730a3;
    --ok: #0f8a4a;
    --ok-soft: #e3f6ec;
    --warn: #b45309;
    --warn-soft: #fff3df;
    --bad: #d92d3a;
    --bad-soft: #fde9eb;
    --info: #0369a1;
    --info-soft: #e0f2fe;
    --neutral-soft: #eef0f4;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .25);
    --radius: 14px;
    --radius-sm: 10px;
    --sidebar: 248px;
    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0c0d11; --surface: #15171d; --surface-2: #1a1c23; --surface-3: #22252e;
        --text: #eef0f5; --text-2: #b9bdc9; --muted: #868b9a; --line: #262932; --line-strong: #333744;
        --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: #23264a; --accent-text: #c7cdff;
        --ok: #4ade80; --ok-soft: #0f2a1b; --warn: #fbbf24; --warn-soft: #2e2410;
        --bad: #f87171; --bad-soft: #341518; --info: #7dd3fc; --info-soft: #0c2533; --neutral-soft: #22252e;
        --shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.6);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0c0d11; --surface: #15171d; --surface-2: #1a1c23; --surface-3: #22252e;
    --text: #eef0f5; --text-2: #b9bdc9; --muted: #868b9a; --line: #262932; --line-strong: #333744;
    --accent: #818cf8; --accent-2: #a5b4fc; --accent-soft: #23264a; --accent-text: #c7cdff;
    --ok: #4ade80; --ok-soft: #0f2a1b; --warn: #fbbf24; --warn-soft: #2e2410;
    --bad: #f87171; --bad-soft: #341518; --info: #7dd3fc; --info-soft: #0c2533; --neutral-soft: #22252e;
    --shadow-sm: none; --shadow: 0 0 0 1px rgba(255,255,255,.02); --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.6);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 10px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
    padding: 18px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #ec4899);
    box-shadow: 0 6px 16px -6px rgba(99, 102, 241, .7);
}
.brand-mark svg.i { width: 19px; height: 19px; }
.brand b { display: block; font-size: 15px; line-height: 1.1; }
.brand b + span { display: block; font-size: 11.5px; color: var(--muted); }
.brand .brand-mark { color: #fff; }
.nav-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 10px 10px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
    color: var(--text-2); font-weight: 550; font-size: 14px;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.nav a.active svg.i { color: var(--accent); }
.nav .count { margin-left: auto; font-size: 11.5px; font-weight: 650; padding: 1px 7px; border-radius: 99px;
              background: var(--bad-soft); color: var(--bad); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.sidebar-foot form { margin: 0; }
.nav-btn {
    width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; border: 0;
    background: none; color: var(--text-2); font: inherit; font-weight: 550; cursor: pointer; text-align: left;
}
.nav-btn:hover { background: var(--surface-3); color: var(--text); }

.main { min-width: 0; }
.topbar { display: none; }
.content { max-width: 1240px; margin: 0 auto; padding: 28px 32px 64px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .tools { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 550; font-size: 13px; margin-bottom: 10px; }
.crumb:hover { color: var(--text); text-decoration: none; }

/* Mobile: top bar + bottom tab bar */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .topbar {
        display: flex; align-items: center; justify-content: space-between; gap: 10px;
        position: sticky; top: 0; z-index: 20; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
        background: color-mix(in srgb, var(--surface) 85%, transparent); backdrop-filter: saturate(1.6) blur(14px);
        -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--line);
    }
    .topbar .brand { padding: 0; }
    .topbar form { margin: 0; }
    .tabbar {
        position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
        padding: 6px 6px max(6px, env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: saturate(1.6) blur(14px);
        -webkit-backdrop-filter: saturate(1.6) blur(14px); border-top: 1px solid var(--line);
    }
    .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px;
                color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
    .tabbar a:hover { text-decoration: none; }
    .tabbar a.active { color: var(--accent); }
    .tabbar svg.i { width: 22px; height: 22px; }
    .tabbar .dot { position: absolute; top: 4px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
    .content { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
    h1 { font-size: 21px; }
}
@media (min-width: 901px) { .tabbar { display: none; } }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1080px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.grid-2 > .card + .card, .grid-3 > * + * { margin-top: 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) {
    .kpis { gap: 10px; }
    .kpi { padding: 13px 13px 12px; }
    .kpi .k-value { font-size: 24px; margin-top: 8px; }
    .kpi .k-sub { font-size: 11.5px; }
}
@media (max-width: 320px) { .kpis { grid-template-columns: 1fr; } }
.kpi { position: relative; padding: 16px 16px 14px; background: var(--surface); border: 1px solid var(--line);
       border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); overflow: hidden; }
a.kpi:hover { text-decoration: none; border-color: var(--line-strong); }
.kpi .k-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .k-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.kpi .k-icon svg.i { width: 16px; height: 16px; }
.kpi .k-value { font-size: 28px; font-weight: 720; letter-spacing: -.02em; margin-top: 10px; line-height: 1.1; }
.kpi .k-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.tone-accent { background: var(--accent-soft); color: var(--accent); }
.tone-ok { background: var(--ok-soft); color: var(--ok); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-neutral { background: var(--neutral-soft); color: var(--text-2); }

/* ---------- Buttons & inputs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; min-height: 36px;
    border: 1px solid transparent; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; font-size: 13.5px;
    background: var(--accent); color: #fff; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn svg.i { width: 16px; height: 16px; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--surface-3); filter: none; }
.btn.subtle { background: transparent; color: var(--text-2); }
.btn.subtle:hover { background: var(--surface-3); color: var(--text); filter: none; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger-ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.danger-ghost:hover { background: var(--bad-soft); filter: none; }
.btn.ok-ghost { background: transparent; color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.btn.ok-ghost:hover { background: var(--ok-soft); filter: none; }
.btn.sm { padding: 5px 10px; min-height: 30px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 0; width: 34px; min-height: 34px; }
.btn.sm.icon { width: 30px; min-height: 30px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.inline-form { display: inline; margin: 0; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--muted); }
.input, input[type=text], input[type=search], input[type=password], input:not([type]), select, textarea {
    width: 100%; padding: 9px 12px; min-height: 38px; border: 1px solid var(--line-strong); border-radius: 10px;
    background: var(--surface); color: var(--text); font: inherit; outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 80px; }
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
         background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%237c8191' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
         background-repeat: no-repeat; background-position: right 12px center; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.search { position: relative; flex: 1 1 260px; max-width: 380px; }
.search svg.i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { padding-left: 34px; }

/* Status choice cards (gateway form) */
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 520px) { .choices { grid-template-columns: 1fr; } }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 10px 12px; border: 1px solid var(--line-strong);
               border-radius: 10px; font-weight: 600; font-size: 13.5px; transition: border-color .12s, background .12s; }
.choice span small { font-weight: 450; color: var(--muted); font-size: 12px; }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Chips, pills, badges ---------- */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13px; white-space: nowrap;
}
.chip:hover { text-decoration: none; background: var(--surface-3); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .n { font-size: 11.5px; padding: 0 6px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); }
.chip.active .n { background: color-mix(in srgb, var(--surface) 22%, transparent); color: var(--surface); }
.chips-scroll { overflow-x: auto; scrollbar-width: none; margin: 0 -2px; padding: 2px; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chips { flex-wrap: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 99px; font-size: 12px;
        font-weight: 650; white-space: nowrap; line-height: 1.6; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.neutral { background: var(--neutral-soft); color: var(--text-2); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--surface-3); color: var(--text-2);
       font-size: 12px; font-weight: 600; white-space: nowrap; }

.presence { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.presence i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.presence.live i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.presence.recent i { background: var(--warn); }
.presence.bad i { background: var(--bad); }

/* ---------- Flash / toast ---------- */
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-bottom: 18px;
         font-weight: 550; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.flash .x { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; padding: 0; opacity: .7; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0;
         padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--surface); font-weight: 600; font-size: 13.5px;
         box-shadow: var(--shadow-lg); transition: opacity .18s, transform .18s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 900px) { .toast { bottom: calc(86px + env(safe-area-inset-bottom)); } }

/* ---------- Tables (become cards on phones) ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; }
table.data th { position: sticky; top: 0; text-align: left; font-size: 11.5px; font-weight: 650; text-transform: uppercase;
                letter-spacing: .05em; color: var(--muted); padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn-row { justify-content: flex-end; flex-wrap: nowrap; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
a.row-link { color: var(--text); font-weight: 600; }

@media (max-width: 760px) {
    table.data.stackable thead { display: none; }
    table.data.stackable, table.data.stackable tbody, table.data.stackable tr, table.data.stackable td { display: block; width: 100%; }
    table.data.stackable tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
    table.data.stackable tr:last-child { border-bottom: 0; }
    table.data.stackable td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
    table.data.stackable td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; flex: none; }
    table.data.stackable td.primary { display: block; text-align: left; padding-bottom: 8px; }
    table.data.stackable td.actions { padding-top: 10px; }
    table.data.stackable td.actions .btn-row { justify-content: flex-start; flex-wrap: wrap; width: 100%; }
    table.data.stackable td.hide-sm { display: none; }
}

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .e-icon { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty .e-icon svg.i { width: 24px; height: 24px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

/* ---------- Lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.list .meta { color: var(--muted); font-size: 12.5px; }
.list a.li-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: inherit; }
.list a.li-link:hover { text-decoration: none; }
.list a.li-link:hover .title { color: var(--accent); }
.avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 13px; }
.avatar svg.i { width: 17px; height: 17px; }

dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; }
dl.facts dt, dl.facts dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
dl.facts dt { color: var(--muted); font-size: 13px; padding-right: 16px; white-space: nowrap; }
dl.facts dd { text-align: right; font-weight: 550; overflow-wrap: anywhere; }
dl.facts > :nth-last-child(-n+2) { border-bottom: 0; }

/* Bars chart */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.bars .bar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.bars .bar span { display: block; border-radius: 4px 4px 2px 2px; background: var(--accent); min-height: 2px; opacity: .85; }
.bars .bar span.zero { background: var(--line-strong); opacity: 1; }
.bars .bar span.crash { background: var(--bad); }
.bars .bar:hover span { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; margin-top: 6px; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; }
.meter span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

/* Drop zone + progress */
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 28px 18px;
        border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; transition: border-color .12s, background .12s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .d-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.drop b { font-size: 14.5px; }
.drop input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.drop.has-file { border-style: solid; border-color: var(--accent); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s; }

/* Channel cards */
.channels { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.channel { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.channel .v { font-size: 26px; font-weight: 720; letter-spacing: -.02em; margin: 8px 0 2px; }

/* Code / log viewer */
.code { margin: 0; padding: 14px 16px; font: 12px/1.55 var(--mono); background: var(--surface-2); color: var(--text);
        overflow: auto; max-height: 640px; white-space: pre; tab-size: 4; }
.code.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-line.err { color: var(--bad); }
.log-line.warn { color: var(--warn); }
mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; border-radius: 2px; }
.viewer-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; padding: 4px; background: var(--surface-3); border-radius: 10px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font: inherit; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.quote { margin: 0; padding: 16px 18px; font-size: 16px; line-height: 1.55; white-space: pre-wrap; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 10px 10px 0; }

/* Dialog */
dialog.modal { width: min(560px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
               color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal::backdrop { background: rgba(10, 12, 20, .45); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 18px 18px; }
@media (max-width: 600px) {
    dialog.modal { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; max-height: 92dvh; }
    .modal-foot { border-radius: 0; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
}

.danger-zone { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.danger-zone .card-head h2 { color: var(--bad); }

.copy { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; vertical-align: middle; }
.copy:hover { color: var(--accent); background: var(--accent-soft); }
.copy svg.i { width: 14px; height: 14px; vertical-align: -2px; }

/* Login */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
        background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
                    radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, #ec4899 16%, transparent), transparent 60%), var(--bg); }
.auth-card { width: min(400px, 100%); padding: 32px 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); }
.auth-card .brand { padding: 0 0 22px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
