:root {
  --bg: #F4F7FC;
  --surface: #FFFFFF;
  --surface-2: #F7F9FD;
  --hover: #EEF3FB;
  --text: #0F1B33;
  --text-2: #51607E;
  --text-3: #8391AD;
  --line: #E3E9F3;
  --brand: #2EA8F0;
  --brand-ink: #FFFFFF;
  --brand-soft: #E3F3FD;
  --navy: #1B3470;
  --ok: #12A150;
  --ok-soft: #E2F6EA;
  --warn: #D97706;
  --warn-soft: #FEF3E2;
  --bad: #DC2626;
  --bad-soft: #FDE8E8;
  --shadow: 0 1px 2px rgba(15, 27, 51, .04), 0 8px 24px rgba(15, 27, 51, .06);
  --shadow-lg: 0 24px 64px rgba(15, 27, 51, .22);
  --radius: 18px;
  --sidebar: 264px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1426;
    --surface: #121E36;
    --surface-2: #17253F;
    --hover: #1B2B49;
    --text: #EEF3FC;
    --text-2: #A9B7D3;
    --text-3: #7787A8;
    --line: #22324F;
    --brand: #4BB8F5;
    --brand-ink: #06121F;
    --brand-soft: #14324D;
    --navy: #EEF3FC;
    --ok: #3DD68C;
    --ok-soft: #123526;
    --warn: #F5B544;
    --warn-soft: #3A2C12;
    --bad: #F87171;
    --bad-soft: #3B1A1D;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 400 15px/1.55 Inter, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
a, a:visited { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { font-family: Sora, Inter, sans-serif; letter-spacing: -.02em; margin: 0; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 22px 16px; background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: var(--navy) !important; text-decoration: none !important; }
.logo img { width: 34px; height: 34px; }
.logo .w { font: 600 20px Sora, sans-serif; letter-spacing: -.02em; }
.logo .w b { color: var(--brand); font-weight: 700; }
.logo .tag { margin-left: auto; font: 600 11px Inter, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.side .co { padding: 12px 12px 14px; margin-bottom: 6px; border-radius: 14px; background: var(--surface-2); }
.side .co small { display: block; color: var(--text-3); font-size: 12px; }
.side .co strong { display: block; font-size: 15px; line-height: 1.3; }
.side .back { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2) !important; padding: 0 10px 10px; }
.nav-i { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--text-2) !important; font-weight: 500; text-decoration: none !important; transition: background .15s, color .15s; }
.nav-i svg.i { width: 22px; height: 22px; }
.nav-i:hover { background: var(--hover); color: var(--text) !important; }
.nav-i.on { background: var(--brand-soft); color: var(--brand) !important; font-weight: 600; }
.side .grow { flex: 1; }
.me { display: flex; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid var(--line); margin-top: 8px; }
.me .who { min-width: 0; flex: 1; }
.me .who div { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who a { font-size: 12px; color: var(--text-2) !important; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.main { min-width: 0; padding: 32px 40px 96px; max-width: 1200px; }
.tabbar { display: none; }

/* ---------- page header ---------- */
.ph { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.ph .t { flex: 1; min-width: 220px; }
.ph h1 { font-size: 28px; line-height: 1.2; }
.ph .sub { color: var(--text-2); margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.ph .sub span { display: inline-flex; align-items: center; gap: 6px; }
.ph .sub svg.i { width: 16px; height: 16px; }
.crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2) !important; font-size: 14px; margin-bottom: 10px; }
.crumb svg.i { width: 16px; height: 16px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent; font: 600 15px Inter, sans-serif; cursor: pointer; text-decoration: none !important; transition: transform .08s, filter .15s, background .15s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink) !important; box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--surface); color: var(--text) !important; border-color: var(--line); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--bad-soft); color: var(--bad) !important; }
.btn.sm { height: 38px; padding: 0 14px; border-radius: 11px; font-size: 14px; }
.btn.block { width: 100%; }
form.inline { display: inline; margin: 0; }

/* ---------- cards, stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.card-h { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-h h2 { font-size: 17px; flex: 1; display: flex; align-items: center; gap: 10px; }
.card-h h2 .count { font: 600 13px Inter, sans-serif; color: var(--text-3); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.grid2 > .card { margin-bottom: 0; }
.stack-gap > * + * { margin-top: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text) !important; text-decoration: none !important; transition: transform .15s; }
.stat:hover { transform: translateY(-2px); }
.stat .ic { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); }
.stat .ic svg.i { width: 26px; height: 26px; }
.stat .v { font: 700 26px Sora, sans-serif; line-height: 1.1; }
.stat .k { color: var(--text-2); font-size: 13px; }
.stat.ok .ic { background: var(--ok-soft); color: var(--ok); }
.stat.warn .ic { background: var(--warn-soft); color: var(--warn); }
.stat.bad .ic { background: var(--bad-soft); color: var(--bad); }

/* ---------- lists ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.list .head, .list .row { display: grid; grid-template-columns: var(--cols); gap: 16px; align-items: center; padding: 14px 20px; }
.list .head { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.list .row { border-bottom: 1px solid var(--line); color: var(--text) !important; text-decoration: none !important; transition: background .12s; min-height: 72px; }
.list .row:last-child { border-bottom: 0; }
.list a.row:hover, .list .row.click:hover { background: var(--hover); cursor: pointer; }
.list .row.off { opacity: .55; }
.cell-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.cell-main .txt { min-width: 0; }
.cell-main strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-main small { display: block; color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-end { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.list .lbl { display: none; }
.av { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none; font: 700 15px Sora, sans-serif; color: #fff; }
.av svg.i { width: 22px; height: 22px; }
.av.ic { background: var(--brand-soft); color: var(--brand); }
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty .big { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; background: var(--brand-soft); color: var(--brand); margin-bottom: 14px; }
.empty .big svg.i { width: 34px; height: 34px; }
.empty h3 { color: var(--text); font-size: 18px; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

/* ---------- pills, chips ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- status switch ---------- */
.sw { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; border: 0; background: none; padding: 0; font: 600 14px Inter, sans-serif; color: var(--text-2); }
.sw .track { position: relative; width: 56px; height: 32px; border-radius: 999px; background: var(--line); transition: background .2s; flex: none; }
.sw .track::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .2s; }
.sw.on { color: var(--ok); }
.sw.on .track { background: var(--ok); }
.sw.on .track::after { transform: translateX(24px); }
.sw.busy { opacity: .6; pointer-events: none; }
.sw .lab { min-width: 62px; text-align: left; }

/* ---------- forms ---------- */
.fields { display: grid; gap: 16px; }
.fields.two { grid-template-columns: 1fr 1fr; }
.f { display: flex; flex-direction: column; gap: 6px; }
.f.full { grid-column: 1 / -1; }
.f > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px; width: 100%; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--brand); }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 500; }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: inline-flex; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; gap: 4px; }
.seg label { padding: 9px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
[hidden] { display: none !important; }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; border-radius: 24px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgba(8, 14, 28, .45); backdrop-filter: blur(6px); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.dlg-h { display: flex; align-items: center; gap: 12px; padding: 22px 24px 4px; }
.dlg-h h2 { font-size: 20px; flex: 1; }
.dlg-b { padding: 16px 24px; overflow-y: auto; max-height: calc(100vh - 220px); }
.dlg-f { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px 22px; border-top: 1px solid var(--line); }

/* ---------- misc blocks ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: 16px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500; max-width: calc(100vw - 32px); animation: toast 4.5s forwards; }
.toast.err { background: var(--bad); color: #fff; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 12px); } 6%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 12px); visibility: hidden; } }
.secret { font: 700 30px ui-monospace, monospace; letter-spacing: .08em; padding: 20px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); text-align: center; margin: 8px 0 16px; user-select: all; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.entry { border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 12px; background: var(--surface); }
.entry .top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.entry .top strong { font-size: 16px; flex: 1; }
.entry pre { white-space: pre-wrap; font: inherit; margin: 10px 0 0; color: var(--text); }
.entry .q { color: var(--text-2); font-size: 13px; margin-top: 8px; }
.comment { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment .body { flex: 1; min-width: 0; }
.comment .meta { font-size: 13px; color: var(--text-2); }
.comment p { margin: 4px 0 0; white-space: pre-wrap; }
.msg-row { display: grid; grid-template-columns: 130px 1fr; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.msg-row:last-child { border-bottom: 0; }
.msg-row .when { color: var(--text-2); font-size: 13px; }
.msg-row .what { min-width: 0; }
.msg-row .by { font-weight: 600; font-size: 14px; }
.msg-row .links { display: flex; gap: 10px; margin-top: 4px; font-size: 13px; }
.danger-zone { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: min(440px, 100%); padding: 32px; }
.auth .logo { justify-content: center; padding-bottom: 8px; }
.auth h1 { font-size: 24px; text-align: center; margin: 12px 0 6px; }
.auth p.lead { text-align: center; color: var(--text-2); margin: 0 0 20px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-weight: 500; margin-bottom: 16px; }
.notice.info { background: var(--brand-soft); color: var(--brand); }

/* ---------- phones and app webviews ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 20px 16px calc(110px + env(safe-area-inset-bottom)); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
  .topbar .logo { padding: 0; }
  .topbar .co { margin-left: auto; font-size: 13px; color: var(--text-2); text-align: right; max-width: 45%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px; border-radius: 12px; font-size: 11px; font-weight: 600; color: var(--text-3) !important; text-decoration: none !important; }
  .tabbar a svg.i { width: 24px; height: 24px; }
  .tabbar a.on { color: var(--brand) !important; }
  .ph h1 { font-size: 24px; }
  .ph .btn.primary { width: 100%; }
  .list .head { display: none; }
  .list .row { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .list .row > .hide-m { display: none; }
  .fields.two, .checks { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 24px 24px 0 0; }
  dialog[open] { animation: sheet .22s ease-out; }
  @keyframes sheet { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
  .dlg-f { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  .dlg-f .btn { flex: 1; }
  .msg-row { grid-template-columns: 1fr; gap: 2px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
}
@media (min-width: 901px) { .topbar { display: none; } }

/* ---------- sub-menu tabs, filters ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: -4px 0 24px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border-radius: 12px; font-weight: 600; color: var(--text-2) !important; text-decoration: none !important; white-space: nowrap; }
.tabs a:hover { background: var(--hover); color: var(--text) !important; }
.tabs a.on { background: var(--brand-soft); color: var(--brand) !important; }
.tabs a .n { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); }
.tabs a.on .n { background: var(--surface); color: var(--brand); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters .f { min-width: 150px; }
.filters .f.grow { flex: 1; min-width: 220px; }
.filters input, .filters select { min-height: 46px; padding: 10px 12px; }
.filters .btn { height: 48px; }
.pager { display: flex; gap: 10px; justify-content: center; margin: 10px 0 24px; }
.feed { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 20px; margin-bottom: 20px; }
.feed-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.feed-row:last-child { border-bottom: 0; }
.feed-row .av { width: 44px; height: 44px; }
.feed-row .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.feed-row .top strong { font-weight: 600; }
.feed-row .body { margin-top: 4px; white-space: pre-wrap; word-wrap: break-word; }
.feed-row .links { display: flex; gap: 14px; margin-top: 6px; font-size: 13px; flex-wrap: wrap; }
.feed-row .when { color: var(--text-2); font-size: 13px; text-align: right; white-space: nowrap; }
.feed-row .meta { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.multi-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1.2fr auto; gap: 10px; align-items: end; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px dashed var(--line); }
.multi-row:last-child { border-bottom: 0; }
.setting { display: flex; gap: 16px; align-items: flex-start; padding: 18px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); flex: none; }
.setting .txt { flex: 1; min-width: 0; }
.setting .txt strong { display: block; font-size: 16px; }
.setting .txt .sub { margin-top: 12px; }
.toggle { position: relative; display: inline-block; flex: none; }
.toggle input { position: absolute; opacity: 0; width: 56px; height: 32px; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { display: block; width: 56px; height: 32px; border-radius: 999px; background: var(--line); transition: background .2s; position: relative; }
.toggle span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .2s; }
.toggle input:checked + span { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(24px); }
@media (max-width: 900px) {
  .tabs { margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0; }
  .multi-row { grid-template-columns: 1fr 1fr; }
  .feed-row { grid-template-columns: 44px 1fr; }
  .feed-row .when { grid-column: 2; text-align: left; }
  .filters .f, .filters .f.grow { min-width: calc(50% - 5px); flex: 1; }
}

/* ---------- in-page confirm popup ---------- */
dialog.ask { width: min(440px, calc(100vw - 32px)); }
.ask-b { padding: 26px 24px 8px; text-align: center; }
.ask-b h2 { font-size: 20px; margin: 14px 0 6px; }
.ask-b p { color: var(--text-2); margin: 0; }
.ask-ic { display: inline-grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; background: var(--brand-soft); color: var(--brand); }
.ask-ic.bad { background: var(--bad-soft); color: var(--bad); }
.ask-ic svg.i { width: 28px; height: 28px; }
dialog.ask .dlg-f { border-top: 0; justify-content: center; padding-top: 18px; }
dialog.ask .dlg-f .btn { flex: 1; }
@media (max-width: 900px) { dialog.ask { margin: auto; border-radius: 24px; width: calc(100vw - 32px); } dialog.ask[open] { animation: pop .18s ease-out; } }

/* ---------- auto-saved settings, quick button editor ---------- */
.savebar { position: sticky; top: 8px; z-index: 5; display: flex; justify-content: flex-end; margin: -6px 0 12px; }
.saved { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
.saved.ok { color: var(--ok); border-color: var(--ok); }
.saved.err { color: var(--bad); border-color: var(--bad); }
.setting .help, p.help { color: var(--text-2); font-size: 14px; margin-top: 2px; }
.sub-setting { padding-left: 32px; }
.qb-row { display: grid; grid-template-columns: 44px minmax(0,1.2fr) minmax(0,1fr) minmax(0,1.3fr) minmax(0,.9fr) auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.qb-row:last-child { border-bottom: 0; }
.qb-row input, .qb-row select { min-height: 44px; padding: 8px 10px; }
.qb-row .qb-value[hidden] { display: block !important; visibility: hidden; }
.qb-row.off { opacity: .55; }
.qb-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); }
@media (max-width: 900px) {
  .qb-row { grid-template-columns: 44px 1fr auto auto; }
  .qb-row > select[name=qb_action], .qb-row > .qb-value, .qb-row > select[name=qb_icon] { grid-column: 2 / -1; }
  .qb-row .qb-value[hidden] { display: none !important; }
  .sub-setting { padding-left: 0; }
}

/* ---------- media gallery and viewer ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.tile { position: relative; display: block; aspect-ratio: 1; border-radius: 18px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow); }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.tile:hover img { transform: scale(1.04); }
.tile-type { position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(8,14,28,.65); color: #fff; font-size: 12px; font-weight: 600; }
.tile-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 10px; background: linear-gradient(transparent, rgba(8,14,28,.8)); color: #fff; font-size: 12px; }
.tile-meta strong { display: block; font-size: 14px; }
.viewer-nav { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.viewer-nav .grow { flex: 1; }
.viewer { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.viewer-img { display: grid; place-items: center; background: #000; border-radius: var(--radius); overflow: hidden; min-height: 320px; }
.viewer-img img { max-width: 100%; max-height: 78vh; object-fit: contain; }
.ctx { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
.ctx .when { color: var(--text-2); font-size: 12px; }
.ctx.here { background: var(--brand-soft); }
@media (max-width: 900px) { .media-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } .viewer { grid-template-columns: 1fr; } .ctx { grid-template-columns: 1fr; } }

/* ---------- simple bar chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 8px 0 22px; margin-bottom: 12px; overflow-x: auto; }
.bar { position: relative; flex: 1 0 22px; max-width: 48px; height: 100%; display: flex; align-items: flex-end; }
.bar .fill { width: 100%; border-radius: 8px 8px 3px 3px; background: var(--brand); }
.bar .lbl { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text-3); white-space: nowrap; }

.meter { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin: 6px 0 4px; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.meter.warn span { background: var(--warn); } .meter.bad span { background: var(--bad); }
.budget-form input { min-height: 40px; padding: 6px 10px; max-width: 130px; }

/* ---------- traffic charts ---------- */
.sbars { display: flex; align-items: flex-end; gap: 5px; height: 220px; padding: 8px 0 24px; overflow-x: auto; }
.sbar { position: relative; flex: 1 0 18px; max-width: 46px; height: 100%; display: flex; align-items: flex-end; }
.sbar .stack { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 7px 7px 3px 3px; overflow: hidden; }
.sbar .stack span { display: block; min-height: 2px; }
.sbar .lbl { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-3); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--text-2); margin-top: 8px; }
.legend i, i.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.blist { display: grid; gap: 12px; }
.bl-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.bl-bar { height: 8px; border-radius: 999px; background: var(--surface-2); margin-top: 5px; overflow: hidden; }
.bl-bar span { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
