:root {
  --bg: #0e1015; --surface: #161922; --surface-2: #1d212c; --line: #2a2f3c; --text: #e8eaf0; --muted: #98a1b3;
  --accent: #5865f2; --accent-2: #4752c4; --accent-soft: rgba(88, 101, 242, .16);
  --good: #3ba55d; --warn: #f0b232; --bad: #ed4245; --good-soft: rgba(59, 165, 93, .16); --warn-soft: rgba(240, 178, 50, .16); --bad-soft: rgba(237, 66, 69, .16);
  --radius: 12px; --shadow: 0 6px 24px rgba(0, 0, 0, .28);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f9; --surface: #fff; --surface-2: #f0f2f7; --line: #dfe3ec; --text: #1a1e29; --muted: #5d6679;
    --accent-soft: rgba(88, 101, 242, .12); --shadow: 0 6px 24px rgba(30, 40, 80, .1);
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, p { margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin-bottom: 14px; }
code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.bad-text { color: var(--bad); }
.right { text-align: right; }
.boot { padding: 48px 24px; text-align: center; color: var(--muted); }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex: none; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand div { display: flex; flex-direction: column; line-height: 1.2; }
.brand.big { justify-content: center; margin-bottom: 20px; font-size: 1.2rem; }
.logo { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 500; }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.on { background: var(--accent-soft); color: var(--text); }
.sidebar nav a.on .icon { color: var(--accent); }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.me span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; min-width: 0; }
.scrim { display: none; }
.topbar { display: none; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.page { max-width: 1040px; margin: 0 auto; padding: 32px 28px 120px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; max-width: 62ch; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card > .muted:first-of-type { margin-bottom: 12px; }
.card > .actions { margin-top: 16px; }

/* banner, toasts, overlay */
#banner:not(:empty) { position: sticky; top: 0; z-index: 25; background: var(--bg); padding: 16px 28px 0; }
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--warn-soft); border: 1px solid var(--warn); box-shadow: 0 4px 16px rgba(0, 0, 0, .18); }
.banner > div { flex: 1; }
.banner p { color: var(--muted); font-size: .9rem; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow); max-width: min(380px, calc(100vw - 32px)); animation: rise .2s ease-out; }
.toast.ok .icon { color: var(--good); } .toast.bad .icon { color: var(--bad); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.overlay { position: fixed; inset: 0; background: rgba(8, 10, 14, .82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; z-index: 200; color: #fff; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .25); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.round { width: 36px; height: 36px; padding: 0; border-radius: 50%; flex: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .8s linear infinite; }
.input { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.small { max-width: 260px; padding: 7px 10px; }
.input.short { max-width: 140px; }
textarea.input { resize: vertical; }
select.input { appearance: auto; }
.stack { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.stack .input { font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.note { font-size: .85rem; color: var(--muted); font-weight: 400; min-height: 0; }
.note:empty { display: none; }
.note.warn { color: var(--warn); } .note.bad { color: var(--bad); }

/* settings rows */
.field { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.4fr); gap: 8px 24px; padding: 14px 0; border-top: 1px solid var(--line); }
.field:first-of-type { border-top: 0; padding-top: 4px; }
.field.dirty { box-shadow: -4px 0 0 var(--accent); padding-left: 12px; margin-left: -16px; }
.field-label p { font-size: .88rem; margin-top: 2px; }
.field-control { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.req, .tag { margin-left: 8px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 99px; vertical-align: 2px; }
.req { background: var(--bad-soft); color: var(--bad); }
.tag { background: var(--accent-soft); color: var(--accent); margin-left: 0; display: inline-block; margin-top: 6px; }
.field-label .tag { margin-left: 8px; margin-top: 0; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.track { width: 42px; height: 24px; border-radius: 99px; background: var(--line); position: relative; transition: background .15s; flex: none; }
.track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip-list, .chips-row, .tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.texts { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.text-row { display: flex; gap: 8px; width: 100%; }
.savebar { position: fixed; left: 248px; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 28px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(0, 0, 0, .2); z-index: 30; }
.savebar[hidden] { display: none; }

/* small pieces */
.pill { display: inline-block; padding: 3px 11px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar.blank { display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.person { display: flex; align-items: center; gap: 12px; }
.person.tight { gap: 10px; }
.person > div { flex: 1; min-width: 0; }
.person .btn { margin-left: auto; }
.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0 16px; }
.meter.small { margin: 0 0 4px; min-width: 90px; }
.meter span { display: block; height: 100%; border-radius: 99px; }
.meter .good { background: var(--good); } .meter .warn { background: var(--warn); } .meter .bad { background: var(--bad); }

/* overview */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat strong { font-size: 1.35rem; overflow: hidden; text-overflow: ellipsis; }
.stat small { display: flex; align-items: center; gap: 8px; word-break: break-word; }
.checks { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-direction: column; }
.check { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check p { font-size: .88rem; }
.mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.mark .icon { width: 15px; height: 15px; stroke-width: 3; }
.check.ok .mark { background: var(--good-soft); color: var(--good); }
.check.warn .mark { background: var(--warn-soft); color: var(--warn); }
.check.error .mark { background: var(--bad-soft); color: var(--bad); }

/* voice */
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.voice { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; }
.voice:hover { border-color: var(--muted); }
.voice.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.voice p { font-size: .85rem; }
.tabs button, .segmented button { padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: .88rem; cursor: pointer; }
.tabs button.on, .segmented button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.search { position: relative; margin-top: 14px; }
.results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 10; max-height: 320px; overflow-y: auto; }
.results:empty { display: none; }
.result { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.result:hover { background: var(--accent-soft); }
.pad { padding: 12px; }

/* tables and lists */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.emoji { font-size: 1.3rem; width: 1%; }
td.url { color: var(--muted); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
td.rank { font-weight: 700; color: var(--muted); width: 1%; }
td.bar-cell { min-width: 140px; }
.accordion { border-top: 1px solid var(--line); }
.accordion:first-of-type { border-top: 0; }
.accordion summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; cursor: pointer; list-style-position: outside; }
.plain { margin: 0 0 12px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .input { flex: 1; }
.logs { margin: 0; height: 60vh; min-height: 280px; overflow: auto; background: #0a0c10; color: #cfd5e3; border-radius: 10px; padding: 12px 14px; font: .8rem/1.55 var(--mono); }
.logs .line { white-space: pre-wrap; word-break: break-word; }
.logs .line.warn { color: var(--warn); } .logs .line.bad { color: #ff7b7e; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(440px, 100%); padding: 32px; box-shadow: var(--shadow); }
.login h1 { margin-bottom: 14px; }
.steps { padding-left: 22px; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; }
  .page { padding: 20px 16px 120px; }
  #banner:not(:empty) { top: 58px; padding: 12px 16px 0; }
  .banner { flex-wrap: wrap; }
  .scrim { display: none; }
  .sidebar.open + .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 40; }
  .savebar { left: 0; padding: 12px 16px; }
  .field { grid-template-columns: 1fr; }
  .field.dirty { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
