/* ==========================================================================
   Orbit UI — design system (prototype)
   Layout: tmavý "ink" sidebar + sticky topbar + plynulý obsah (max 1360px)
   ========================================================================== */

:root {
  --font-sans: "Onest", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #F2F4F8;
  --surface: #FFFFFF;
  --surface-2: #F6F7FA;
  --line: #E1E5ED;
  --line-strong: #CBD2DE;
  --fg: #131926;
  --muted: #5B6578;
  --faint: #8A93A4;

  --accent: #2C59E8;
  --accent-hover: #1F48CC;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7EDFE;
  --accent-line: #BFCDFA;

  --ok: #148A55;
  --ok-soft: #E1F4EA;
  --warn: #AD6A06;
  --warn-soft: #FCF0DA;
  --bad: #CF3434;
  --bad-soft: #FCE5E5;

  --side-bg: #0F1523;
  --side-fg: #C6CEDD;
  --side-strong: #F2F5FA;
  --side-muted: #75819A;
  --side-hover: #172033;
  --side-active: #1E2945;
  --side-line: #1C2538;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-pop: 0 16px 40px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .08);
  --overlay: rgba(9, 13, 22, .48);
  --skeleton: #E8EBF1;
  --skeleton-hi: #F4F6F9;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --side-w: 256px;
  --top-h: 60px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --scroll-thumb: rgba(19, 25, 38, .2);
  --scroll-thumb-hover: rgba(19, 25, 38, .36);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D111A;
    --surface: #141A26;
    --surface-2: #19202E;
    --line: #242D3F;
    --line-strong: #323D53;
    --fg: #E5E9F1;
    --muted: #949EB1;
    --faint: #6B7489;
    --accent: #7090FF;
    --accent-hover: #8AA4FF;
    --accent-ink: #0A0F1E;
    --accent-soft: #1A2448;
    --accent-line: #2F3F78;
    --ok: #3CC487;
    --ok-soft: #10291E;
    --warn: #E5A63E;
    --warn-soft: #2E220E;
    --bad: #F26B6B;
    --bad-soft: #351516;
    --side-bg: #0A0E16;
    --side-fg: #B9C2D3;
    --side-strong: #F2F5FA;
    --side-muted: #66728A;
    --side-hover: #121926;
    --side-active: #18223A;
    --side-line: #161D2B;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-pop: 0 18px 44px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
    --overlay: rgba(3, 5, 10, .62);
    --skeleton: #1C2331;
    --skeleton-hi: #252E40;
    --scroll-thumb: rgba(229, 233, 241, .16);
    --scroll-thumb-hover: rgba(229, 233, 241, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0D111A;
  --surface: #141A26;
  --surface-2: #19202E;
  --line: #242D3F;
  --line-strong: #323D53;
  --fg: #E5E9F1;
  --muted: #949EB1;
  --faint: #6B7489;
  --accent: #7090FF;
  --accent-hover: #8AA4FF;
  --accent-ink: #0A0F1E;
  --accent-soft: #1A2448;
  --accent-line: #2F3F78;
  --ok: #3CC487;
  --ok-soft: #10291E;
  --warn: #E5A63E;
  --warn-soft: #2E220E;
  --bad: #F26B6B;
  --bad-soft: #351516;
  --side-bg: #0A0E16;
  --side-fg: #B9C2D3;
  --side-strong: #F2F5FA;
  --side-muted: #66728A;
  --side-hover: #121926;
  --side-active: #18223A;
  --side-line: #161D2B;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-pop: 0 18px 44px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
  --overlay: rgba(3, 5, 10, .62);
  --skeleton: #1C2331;
  --skeleton-hi: #252E40;
  --scroll-thumb: rgba(229, 233, 241, .16);
  --scroll-thumb-hover: rgba(229, 233, 241, .3);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11";
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-size: .92em; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Thin scrollbars in the theme colours; :where() keeps them overridable (e.g. .tabs hides its own) */
:where(*) { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
:where(*):hover { scrollbar-color: var(--scroll-thumb-hover) transparent; }
/* Browsers without scrollbar-color (older Safari) */
@supports not (scrollbar-color: red transparent) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--scroll-thumb); background-clip: padding-box; border: 2px solid transparent; border-radius: 10px; }
  ::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
  .tabs::-webkit-scrollbar { display: none; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }

/* ---------- Top progress bar (loader) ---------- */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 200; pointer-events: none;
  opacity: 0; transition: opacity .3s;
}
.progress.is-active { opacity: 1; }
.progress > span {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  transition: width .25s var(--ease);
}

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--side-bg); color: var(--side-fg);
  border-right: 1px solid var(--side-line);
  z-index: 60;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; color: var(--side-strong); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.image-field { display: flex; align-items: center; gap: 14px; }
.image-preview { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2, var(--bg)); padding: 6px; flex: none; }
.color-field { display: flex; align-items: center; gap: 10px; max-width: 260px; }
.color-field input[type="color"] { width: 42px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; flex: none; }
.brand-logo { height: 34px; width: auto; max-width: 180px; object-fit: contain; flex: none; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.02em; line-height: 1.1; }
.brand-site { font-size: 12px; color: var(--side-muted); font-weight: 400; letter-spacing: 0; }

.nav {
  flex: 1; overflow-y: auto; padding: 6px 10px 16px; display: flex; flex-direction: column; gap: 18px;
  /* The sidebar stays dark in both themes */
  --scroll-thumb: rgba(198, 206, 221, .14);
  --scroll-thumb-hover: rgba(198, 206, 221, .28);
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  padding: 0 10px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--side-muted);
}
.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--side-fg); font-weight: 500; position: relative;
}
.nav-link:hover { background: var(--side-hover); color: var(--side-strong); text-decoration: none; }
.nav-link.is-active { background: var(--side-active); color: var(--side-strong); }
.nav-link.is-active .i { color: var(--accent); }
.nav-link .i { color: var(--side-muted); }
.nav-badge {
  margin-left: auto; min-width: 20px; padding: 0 6px; height: 19px; border-radius: 10px;
  display: inline-grid; place-items: center; font-size: 11px; font-weight: 600;
  background: var(--side-active); color: var(--side-fg); font-variant-numeric: tabular-nums;
}
.nav-badge.is-accent { background: var(--accent); color: var(--accent-ink); }
.nav-plugin { font-size: 10px; font-family: var(--font-mono); color: var(--side-muted); margin-left: auto; }

.side-foot {
  border-top: 1px solid var(--side-line); padding: 12px 18px 16px;
  display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--side-muted);
}
.side-foot a { color: var(--side-fg); display: inline-flex; align-items: center; gap: 6px; }
.env-chip {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px;
}
.env-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40;
  height: var(--top-h); display: flex; align-items: center; gap: 10px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; color: var(--muted); }
.crumbs strong { color: var(--fg); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .i { width: 14px; height: 14px; color: var(--faint); }
.top-spacer { flex: 1; }
.search-trigger {
  display: inline-flex; align-items: center; gap: 10px; height: 36px; padding: 0 8px 0 12px;
  min-width: 220px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--faint); cursor: pointer;
}
.search-trigger:hover { border-color: var(--line-strong); }
.search-trigger span { flex: 1; text-align: left; }
.kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
}
.top-actions { display: flex; align-items: center; gap: 4px; }
.has-dot { position: relative; }
.has-dot::after {
  content: ""; position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--bad); box-shadow: 0 0 0 2px var(--bg);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12px;
}
.user-btn { display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 20px; border: 0; background: none; cursor: pointer; }
.user-btn:hover { background: var(--surface); }
.user-btn .meta { text-align: left; line-height: 1.2; }
.user-btn .meta b { display: block; font-size: 13px; font-weight: 600; }
.user-btn .meta small { font-size: 11px; color: var(--muted); }

.content { width: 100%; max-width: 1360px; margin: 0 auto; padding: 28px 28px 56px; display: flex; flex-direction: column; gap: 22px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.025em; line-height: 1.15; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-head .eyebrow { margin-bottom: 6px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eyebrow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--fg); --btn-bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 500; font-size: 14px; white-space: nowrap; cursor: pointer; position: relative;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { border-color: var(--line-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-bd: var(--accent); }
.btn-primary:hover { --btn-bg: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface); color: var(--fg); border-color: var(--line); }
.btn-danger { --btn-bg: var(--bad); --btn-fg: #fff; --btn-bd: var(--bad); }
.btn-danger-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--bad); }
.btn-danger-ghost:hover { background: var(--bad-soft); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; height: 42px; font-size: 15px; }
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--btn-fg); border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.seg { display: inline-flex; padding: 3px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.seg button {
  border: 0; background: none; height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  color: var(--muted); font-weight: 500; font-size: 13px;
}
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--fg); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--bad); display: flex; align-items: center; gap: 5px; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
  font: inherit; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 86px; padding: 10px 12px; resize: vertical; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.has-error .input { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .i { position: absolute; left: 11px; color: var(--faint); pointer-events: none; }
.input-wrap > .input { padding-left: 36px; }
.input-wrap > .input-action {
  position: absolute; right: 4px; height: 30px; width: 30px; border: 0; background: none; border-radius: 5px;
  display: grid; place-items: center; color: var(--muted); cursor: pointer;
}
.input-wrap > .input-action:hover { background: var(--surface-2); color: var(--fg); }
.input-wrap > .input-action + .input, .input-wrap .input.has-action { padding-right: 40px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; user-select: none; }
.check input {
  appearance: none; width: 17px; height: 17px; margin: 0; border-radius: 5px; flex: none;
  border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; display: grid; place-items: center;
}
.check input:checked, .check input:indeterminate { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
  content: ""; width: 9px; height: 5px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}
.check input:indeterminate::after { content: ""; width: 8px; height: 2px; background: var(--accent-ink); border-radius: 1px; }
/* radio buttons: a round control with a dot */
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked::after { width: 7px; height: 7px; border: 0; border-radius: 50%; background: var(--accent-ink); transform: none; }
/* fieldsets group fields without the browser's frame */
fieldset.field, fieldset.stack { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset > legend.label { padding: 0; margin-bottom: 6px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch .switch-text b { display: block; font-weight: 500; font-size: 14px; }
.switch .switch-text small { color: var(--muted); font-size: 12px; }
.switch input {
  appearance: none; flex: none; width: 38px; height: 22px; margin: 0; border-radius: 11px; cursor: pointer;
  background: var(--line-strong); position: relative; transition: background .2s;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- Cards & stats ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; font-weight: 600; }
.card-head p { font-size: 12px; color: var(--muted); }
.card-body { padding: 16px 18px 18px; }
/* a table right under the card heading has no padding of its own */
.card-head + .table-wrap, .card-head + .table { margin-top: 14px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-label .i { width: 16px; height: 16px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 15px; color: var(--faint); font-weight: 500; letter-spacing: 0; }
.stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.spark { width: 76px; height: 30px; flex: none; display: block; }
.stat [data-spark] { position: absolute; top: 14px; right: 16px; }
.stat-value { white-space: nowrap; }
.card-fill { display: flex; flex-direction: column; }
.card-fill > .card-body { flex: 1; display: flex; flex-direction: column; }
.card-fill .chart { flex: 1; height: auto; min-height: 240px; }
.chart svg { position: absolute; inset: 0; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.spark path.area { fill: var(--accent-soft); stroke: none; }
.spark circle { fill: var(--accent); }
.spark.is-warn path.line { stroke: var(--warn); }
.spark.is-warn path.area { fill: var(--warn-soft); }
.spark.is-warn circle { fill: var(--warn); }

.grid { display: grid; gap: 16px; }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.no-dot::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(--accent-soft); color: var(--accent); }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 11px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
}

/* ---------- Chart ---------- */
.chart { position: relative; width: 100%; height: 240px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--faint); font: 500 11px var(--font-sans); font-variant-numeric: tabular-nums; }
.chart .area { fill: url(#chartFill); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .end { fill: var(--accent); stroke: var(--surface); stroke-width: 3; }
.chart .cursor { stroke: var(--line-strong); stroke-dasharray: 3 3; }
.chart .cursor-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.chart-stop-a { stop-color: var(--accent); stop-opacity: .22; }
.chart-stop-b { stop-color: var(--accent); stop-opacity: 0; }
.chart-tip {
  position: absolute; top: 0; pointer-events: none; padding: 6px 10px; border-radius: 8px;
  background: var(--fg); color: var(--bg); font-size: 12px; white-space: nowrap; transform: translate(-50%, -110%);
  box-shadow: var(--shadow-pop);
}
.chart-tip b { font-variant-numeric: tabular-nums; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); min-width: 0; }
.list-item:first-child { border-top: 0; padding-top: 2px; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item time { font-size: 12px; color: var(--faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ico-tile {
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.ico-tile.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.ico-tile.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.ico-tile.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.ico-tile.info { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; min-width: 0; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }

/* ---------- Skeleton loader ---------- */
.skel-wrap { position: relative; }
.skel-wrap .skel { display: none; }
.skel-wrap.is-loading > :not(.skel) { visibility: hidden; }
.skel-wrap.is-loading .skel { display: flex; position: absolute; inset: 0; flex-direction: column; gap: 12px; padding: inherit; }
.skel-line, .skel-block {
  border-radius: 6px; height: 12px;
  background: linear-gradient(90deg, var(--skeleton) 25%, var(--skeleton-hi) 45%, var(--skeleton) 65%);
  background-size: 300% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
.skel-block { flex: 1; border-radius: 10px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- Tabs / toolbar ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; padding: 10px 12px 11px; cursor: pointer; color: var(--muted); font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11px; padding: 0 6px; border-radius: 9px; background: var(--surface-2); color: var(--muted); font-variant-numeric: tabular-nums; border: 1px solid var(--line); }
.tabs button[aria-selected="true"] .count { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; flex-wrap: wrap; }
.toolbar .input-wrap { flex: 1 1 240px; max-width: 360px; }
.toolbar .select { width: auto; min-width: 150px; }
.bulkbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--accent-soft);
  border-top: 1px solid var(--accent-line); border-bottom: 1px solid var(--accent-line); font-size: 13px; flex-wrap: wrap;
}
.bulkbar b { color: var(--accent); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 10px 14px;
  background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:has(> .check), .table td:has(> .check) { width: 1%; }
.table th:last-child, .table td:last-child { padding-right: 18px; text-align: right; }
.table .num { text-align: right; }
.srv { display: flex; align-items: center; gap: 11px; }
.srv b { font-weight: 600; display: block; }
.srv small { color: var(--muted); font-size: 12px; }
.flag {
  display: inline-grid; place-items: center; width: 26px; height: 18px; border-radius: 3px;
  font: 600 10px var(--font-mono); background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.slots { display: flex; align-items: center; gap: 10px; }
.slots .meter { width: 70px; }
.empty { padding: 48px 18px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty .ico-tile { width: 44px; height: 44px; }
.pager { display: flex; align-items: center; gap: 4px; }
.pager button { min-width: 30px; }
.pager button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------- Dropdown menu ---------- */
.menu-host { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 80; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; gap: 1px; text-align: left;
  animation: pop .14s var(--ease);
}
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; border: 0; background: none;
  color: var(--fg); font-size: 13.5px; cursor: pointer; text-align: left; width: 100%;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu .danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu .menu-head { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); }
.menu-wide { width: min(340px, calc(100vw - 32px)); }
.notif { display: flex; gap: 10px; padding: 9px 10px; border-radius: 6px; }
.notif p { font-size: 13px; }
.table td > .check { vertical-align: middle; } /* a tick changes the checkbox's baseline */
.notif-bell { position: relative; }
.notif-count {
  position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; line-height: 1;
  background: var(--bad); color: #fff; font-variant-numeric: tabular-nums; pointer-events: none;
}
.notif-count[hidden] { display: none; }
.notif-menu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; font-size: 13.5px; }
.menu .notif-menu-head button { width: auto; padding: 3px 6px; font-size: 12px; color: var(--accent); }
.notif-list { max-height: min(420px, 60vh); overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.menu a.notif { align-items: flex-start; padding: 9px 10px; }
.notif .ico-tile { flex: none; }
.notif-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.notif-main b { font-weight: 500; }
.notif-main small { font-size: 12px; color: var(--muted); }
.notif-text { font-size: 12.5px; color: var(--muted); }
.notif.is-unread .notif-main b, .notif-row.is-unread .title { font-weight: 650; }
.notif-empty { padding: 28px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.notif-row .title { display: block; white-space: normal; }
.notif-row .notif-text { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .menu.notif-menu { position: fixed; top: 58px; left: 16px; right: 16px; width: auto; }
}
.notif small { color: var(--faint); font-size: 12px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- Dialogs: modal, drawer, palette ---------- */
dialog { padding: 0; border: 0; color: var(--fg); background: var(--surface); max-width: none; max-height: none; }
dialog::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.modal {
  width: min(440px, calc(100vw - 32px)); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  border: 1px solid var(--line);
}
.modal[open] { animation: pop .18s var(--ease); }
.modal-body { padding: 22px 22px 8px; display: flex; gap: 14px; }
.modal-body h3 { font-size: 17px; margin-bottom: 6px; }
.modal-body p { color: var(--muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; flex-wrap: wrap; }

.drawer {
  margin: 0 0 0 auto; height: 100%; width: min(520px, 100vw); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop); display: none; flex-direction: column;
}
.drawer[open] { display: flex; animation: slide-in .26s var(--ease); }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 22px 16px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { font-size: 18px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 24px; display: flex; flex-direction: column; gap: 22px; }
.drawer-foot {
  display: flex; align-items: center; gap: 8px; padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); background: var(--surface-2);
}
.drawer-foot .spacer { flex: 1; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 10px; }
.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mini-stats > div { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--surface-2); min-width: 0; }
.mini-stats small { display: block; font-size: 11px; color: var(--muted); }
.mini-stats b { font-size: 16px; font-variant-numeric: tabular-nums; }
.uptime { display: grid; grid-template-columns: repeat(30, 1fr); gap: 3px; height: 28px; }
.uptime span { border-radius: 2px; background: var(--ok); opacity: .85; }
.uptime span.w { background: var(--warn); }
.uptime span.b { background: var(--bad); }
.uptime-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--faint); margin-top: 6px; }
.copy-line { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }

.palette {
  margin: 12vh auto auto; width: min(560px, calc(100vw - 32px)); border-radius: var(--r-lg);
  border: 1px solid var(--line); box-shadow: var(--shadow-pop); overflow: hidden;
}
.palette[open] { animation: pop .16s var(--ease); }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-search input { flex: 1; height: 52px; border: 0; background: none; font: inherit; font-size: 15px; color: var(--fg); outline: none; }
.palette-list { max-height: 340px; overflow-y: auto; padding: 6px; }
.palette-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; }
.palette-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.palette-item small { margin-left: auto; color: var(--faint); font-size: 12px; }
.palette-item > .i { flex: none; }
.palette-text { display: flex; flex-direction: column; min-width: 0; }
.palette-text > span, .palette-item .palette-text small { margin-left: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-note { padding: 8px 10px; font-size: 12px; color: var(--faint); }
.palette-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); background: var(--surface-2); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 150;
  display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex; gap: 11px; align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop);
  animation: toast-in .28s var(--ease);
}
.toast.is-leaving { animation: toast-out .2s ease forwards; }
.toast .body { flex: 1; min-width: 0; }
.toast b { display: block; font-size: 13.5px; }
.toast p { font-size: 13px; color: var(--muted); }
.toast .t-ico { color: var(--ok); margin-top: 1px; }
.toast.warn .t-ico { color: var(--warn); }
.toast.bad .t-ico { color: var(--bad); }
.toast.info .t-ico { color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ---------- Content swap (partial navigation) ---------- */
.content.is-entering { animation: enter .3s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > :last-child { grid-column: 1 / -1; }
  .search-trigger { min-width: 0; }
  .search-trigger span, .search-trigger .kbd { display: none; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, var(--side-w));
    /* 100vh reaches under the mobile browser toolbar and hides the end of the menu */
    height: 100dvh;
    padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateX(-102%); transition: transform .28s var(--ease);
  }
  .nav { padding-bottom: 48px; overscroll-behavior: contain; }
  .nav-link { padding: 10px; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .user-btn .meta { display: none; }
}
@media (min-width: 961px) { .only-mobile { display: none !important; } }
@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 6px; }
  .content { padding: 20px 16px 48px; gap: 18px; }
  .page-head h1 { font-size: 22px; }
  .stats { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { padding: 12px 16px; }
  .toolbar .input-wrap { max-width: none; flex-basis: 100%; }
  .toolbar .select { flex: 1; min-width: 0; }
  .crumbs > :not(strong):not(:last-child) { display: none; }
  .toasts { right: 16px; }
  .hide-sm { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--r);
  font-size: 13px; border: 1px solid var(--line); background: var(--surface-2);
}
.alert .i { margin-top: 1px; }
.alert.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.alert.bad p { color: var(--fg); }
.alert.info { background: var(--accent-soft); border-color: transparent; }
.alert.info .i { color: var(--accent); }
.alert.warn { background: var(--warn-soft); border-color: transparent; }
.alert.warn .i { color: var(--warn); }

/* ---------- Auth layout (login, 2FA, reset) ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.auth-aside {
  position: relative; overflow: hidden; background: var(--side-bg); color: var(--side-fg);
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px; padding: 32px 40px;
}
.auth-aside .brand { padding: 0; }
.auth-aside h2 { color: var(--side-strong); font-size: clamp(26px, 3vw, 36px); font-weight: 700; letter-spacing: -.03em; line-height: 1.1; max-width: 15ch; }
.auth-aside p { max-width: 42ch; color: var(--side-fg); margin-top: 12px; }
.orbit-art { position: relative; width: min(100%, 440px); aspect-ratio: 1; max-width: 100%; align-self: center; }
.orbit-art svg { width: 100%; height: 100%; overflow: visible; }
.orbit-art .ring { fill: none; stroke: var(--side-line); stroke-width: 1.2; }
.orbit-art .ring-strong { stroke: var(--side-active); stroke-dasharray: 2 6; }
.orbit-art .core { fill: var(--accent); }
.orbit-art .core-glow { fill: var(--accent); opacity: .16; }
.orbit-art .core-text { fill: var(--accent-ink); font: 700 15px var(--font-mono); letter-spacing: .02em; }
.orbit-art .sat rect { fill: var(--side-hover); stroke: var(--side-active); }
.orbit-art .sat text { fill: var(--side-fg); font: 500 12px var(--font-mono); }
.orbit-art .sat circle { fill: var(--ok); }
.orbit-art .spin { transform-origin: 220px 220px; animation: orbit 90s linear infinite; }
.orbit-art .spin-rev { transform-origin: 220px 220px; animation: orbit 140s linear infinite reverse; }
.orbit-art .spin .sat > g, .orbit-art .spin-rev .sat > g { transform-box: fill-box; transform-origin: center; }
.orbit-art .spin .sat > g { animation: orbit 90s linear infinite reverse; }
.orbit-art .spin-rev .sat > g { animation: orbit 140s linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }
.auth-status { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 12px; color: var(--side-muted); flex-wrap: wrap; }
.auth-status .env-chip { color: var(--side-fg); }

.auth-main { display: flex; flex-direction: column; padding: 24px 40px; background: var(--bg); }
.auth-top { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.lang button { border: 0; background: none; padding: 5px 10px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.auth-form-wrap { flex: 1; display: grid; place-items: center; padding: 32px 0; }
.auth-form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 18px; }
.auth-form h1 { font-size: 26px; font-weight: 700; letter-spacing: -.025em; }
.auth-form .lead { color: var(--muted); margin-top: 6px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.otp { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.otp input {
  width: 100%; height: 52px; text-align: center; font: 600 22px var(--font-mono); border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg);
}
.otp input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.otp input:nth-child(3) { margin-right: 6px; }
.auth-note { font-size: 12px; color: var(--faint); display: flex; gap: 8px; align-items: flex-start; }
.auth-note .i { width: 15px; height: 15px; margin-top: 1px; }
.auth-foot { font-size: 12px; color: var(--faint); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { padding: 20px 16px; gap: 0; }
  .auth-aside .auth-copy, .auth-aside .orbit-art, .auth-aside .auth-status { display: none; }
  .auth-main { padding: 16px 16px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .orbit-art .spin, .orbit-art .spin-rev, .orbit-art .sat > g { animation: none !important; }
}

/* ---------- Dashboard widgets ---------- */
.widgets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.widgets > .span-2 { grid-column: span 2; }
.widgets > .span-3 { grid-column: 1 / -1; }
@media (max-width: 1180px) { .widgets { grid-template-columns: repeat(2, minmax(0, 1fr)); } .widgets > .span-3 { grid-column: 1 / -1; } }
@media (max-width: 640px) { .widgets { grid-template-columns: minmax(0, 1fr); } .widgets > .span-2 { grid-column: auto; } }
/* masonry (set by dashboard.js): fine rows, each slot spans its own height, the gap goes into the span */
.widgets.is-masonry { grid-auto-rows: 4px; row-gap: 0; align-items: start; }
/* widget slots and the layout editor (/admin?edit=1) */
.widget-slot { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.widget-body { min-width: 0; }
.widget-body > .stats { margin: 0; }
.widgets.is-editing .widget-slot { padding: 8px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); }
.widgets.is-editing .widget-body { pointer-events: none; user-select: none; }
.widgets.is-editing .widget-slot.is-hidden .widget-body { opacity: .35; filter: grayscale(1); }
.widgets.is-editing .widget-slot.is-hidden { border-style: dotted; }
.widgets.is-sorting { cursor: grabbing; }
.widget-slot.is-dragging { border-color: var(--accent); border-style: solid; box-shadow: 0 10px 30px rgb(0 0 0 / .18); opacity: .92; }
.widget-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.widget-handle { display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding: 4px 8px; border: 0; border-radius: 6px; background: none; color: var(--fg); font: inherit; font-size: 13px; cursor: grab; touch-action: none; }
.widget-handle b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.widget-handle:hover, .widget-handle:focus-visible { background: var(--accent-soft); color: var(--accent); }
.widgets.is-sorting .widget-handle { cursor: grabbing; }
.widget-tools-actions { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.widget-sizes { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.widget-sizes button { padding: 3px 7px; border: 0; background: var(--surface); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.widget-sizes button + button { border-left: 1px solid var(--line); }
.widget-sizes button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.widget-slot.is-hidden [data-dash-toggle] { color: var(--accent); }
.empty-card { border-style: dashed; box-shadow: none; background: transparent; }
.code { font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }

/* ---------- Error / blank layout ---------- */
.blank { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.error-card { width: min(520px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.error-code { font: 700 56px/1 var(--font-sans); letter-spacing: -.04em; color: var(--accent); font-variant-numeric: tabular-nums; }
.error-card h1 { font-size: 22px; }
.error-card p { color: var(--muted); }
.error-meta { font-size: 12px; color: var(--faint); }
.error-stack { margin: 0; max-height: 280px; overflow: auto; padding: 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font: 12px/1.5 var(--font-mono); color: var(--muted); white-space: pre; }

/* ---------- Settings pages ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.settings { padding: 0; }
.settings-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 28px; padding: 22px; border-top: 1px solid var(--line); }
.settings-row:first-child { border-top: 0; }
.settings-label { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.settings-label h2 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.settings-label h2 .i { color: var(--accent); }
.settings-label p { color: var(--muted); font-size: 13px; max-width: 46ch; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.form-actions .hint { margin-right: auto; font-size: 12px; color: var(--muted); }
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.passkey-add { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); }
.steps { margin: 0; padding-left: 20px; color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.totp-setup { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: start; }
.qr { width: 184px; height: 184px; padding: 8px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; display: block; }
.secret { font-size: 13px; letter-spacing: .06em; }
.recovery-card { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.codes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.codes li { padding: 8px 10px; border-radius: 6px; background: var(--surface); border: 1px dashed var(--line-strong); font-size: 14px; text-align: center; }
.perms { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.perms .check { align-items: flex-start; }
.perms .check input { margin-top: 2px; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.perm-group { border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.perm-group legend { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 0 4px; font-weight: 600; }
.perm-group legend .check { font-weight: 400; font-size: 12px; color: var(--muted); }
.perm-group .check { align-items: flex-start; }
.table.static tbody tr { cursor: default; }
.table .srv, .table a.srv { color: inherit; }
.table a.srv:hover { text-decoration: none; }
.table .srv small { display: block; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
@media (max-width: 860px) {
  .settings-row { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 18px 16px; }
  .totp-setup { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Plugins ---------- */
.plugin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.plugin-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.plugin-card.is-off { background: var(--surface-2); }
.plugin-card.is-off .plugin-top .ico-tile { opacity: .6; }
.plugin-top { display: flex; align-items: flex-start; gap: 12px; }
.plugin-top .body { flex: 1; min-width: 0; }
.plugin-top h2 { font-size: 15px; }
.plugin-top h2 a { color: var(--fg); }
.plugin-top .sub { font-size: 12px; color: var(--muted); }
.plugin-desc { color: var(--muted); font-size: 13px; flex: 1; }
.plugin-error { font-size: 12px; color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 6px; word-break: break-word; }
.plugin-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.plugin-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

/* ---------- System pages ---------- */
.tabs .tab-link { display: inline-flex; align-items: center; gap: 8px; padding: 10px 12px 11px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs .tab-link:hover { color: var(--fg); text-decoration: none; }
.tabs .tab-link[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.outbox-item > summary { cursor: pointer; }
.mail-preview { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; margin: 4px 0 12px; }
.lang-menu a[aria-current="true"] { color: var(--accent); font-weight: 600; }
.lang .lang-btn { display: inline-block; padding: 5px 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.lang .lang-btn:hover { text-decoration: none; color: var(--fg); }
.lang .lang-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---------- API docs ---------- */
.api-intro { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.api-intro > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.api-intro .code { overflow-wrap: anywhere; }
.api-group { display: flex; flex-direction: column; gap: 8px; }
.api-group > h2 { font-size: 15px; margin: 6px 0 2px; }
.api-op { box-shadow: none; }
.api-op > summary { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; flex-wrap: wrap; }
.api-op > summary .method { min-width: 62px; justify-content: center; font-family: var(--font-mono); }
.api-path { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; }
.api-summary { color: var(--muted); font-size: 13px; flex: 1; min-width: 160px; }
.api-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.api-params td { vertical-align: top; }
.api-params td:first-child { width: auto; }
.input-sm { height: 30px; font-size: 12.5px; min-width: 120px; }
.api-try { display: flex; align-items: center; gap: 12px; }
.api-result, .api-schema pre { margin: 0; max-height: 360px; overflow: auto; padding: 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font: 12px/1.5 var(--font-mono); white-space: pre; }
.api-result.is-ok { border-color: var(--accent-line); }
.api-result.is-error { border-color: var(--bad); }
.api-schema > summary { cursor: pointer; font-size: 12px; margin-bottom: 8px; }

/* ---------- Data table ---------- */
.sort-btn { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; border-radius: 4px; }
.sort-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sort-btn .i { opacity: 0; transition: transform .15s, opacity .15s; }
th:hover .sort-btn .i { opacity: .45; }
th[aria-sort="descending"] .sort-btn, th[aria-sort="ascending"] .sort-btn { color: var(--fg); }
th[aria-sort="descending"] .sort-btn .i { opacity: 1; }
th[aria-sort="ascending"] .sort-btn .i { opacity: 1; transform: rotate(180deg); }
.table th.num .sort-btn { flex-direction: row-reverse; }
[data-table] tbody { transition: opacity .15s; }
[data-table].is-loading-data tbody:not(:has(.table-skel)) { opacity: .55; }
.table-skel td { padding-top: 16px; padding-bottom: 16px; }
.table-skel .skel-line { height: 10px; }
.table-msg td { cursor: default; }
.table tbody tr.table-msg:hover, .table tbody tr.table-skel:hover { background: none; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.restart-bar { align-items: center; }
.restart-bar p { flex: 1; }
.repo-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.repo-meta .pill .i { width: 13px; height: 13px; }
.plugin-changelog { font-size: 12.5px; }
.form-widget { display: flex; justify-content: center; min-height: 65px; }
