/* warthex dashboard — the only stylesheet of dashboard.html.
   mobile first: bottom tab bar + sheets on phones, sidebar + dialogs from 960px.
   rules: lowercase text only (no text-transform), svg icons only, no external images. */

:root {
  color-scheme: dark;
  --bg: #0e0f11;
  --surface: #16171a;
  --surface-2: #1c1d21;
  --surface-3: #25262b;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #ececee;
  --text-2: #a3a3ab;
  --text-3: #707079;
  --accent: #4b94f0;
  --accent-ink: #06121f;
  --accent-text: #7fb4f5;
  --accent-soft: rgba(75, 148, 240, 0.14);
  --ok: #4fbf8b;
  --ok-soft: rgba(79, 191, 139, 0.13);
  --warn: #e0a54e;
  --warn-soft: rgba(224, 165, 78, 0.13);
  --danger: #ea6767;
  --danger-soft: rgba(234, 103, 103, 0.12);
  --scrim: rgba(5, 6, 8, 0.6);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);

  --font: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --r-ctl: 10px;
  --r-group: 14px;
  --r-sheet: 20px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --fast: 120ms;
  --enter: 220ms;

  --tabbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --page-x: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f2f2f4;
    --surface: #ffffff;
    --surface-2: #f6f6f8;
    --surface-3: #ebebef;
    --line: rgba(16, 16, 22, 0.08);
    --line-strong: rgba(16, 16, 22, 0.15);
    --text: #17171b;
    --text-2: #55555e;
    --text-3: #85858f;
    --accent: #1f6fd1;
    --accent-ink: #ffffff;
    --accent-text: #1a62bb;
    --accent-soft: rgba(31, 111, 209, 0.1);
    --ok: #1d8657;
    --ok-soft: rgba(29, 134, 87, 0.1);
    --warn: #a2650f;
    --warn-soft: rgba(162, 101, 15, 0.1);
    --danger: #c73b3b;
    --danger-soft: rgba(199, 59, 59, 0.08);
    --scrim: rgba(20, 20, 26, 0.38);
    --shadow: 0 12px 32px rgba(20, 20, 30, 0.14);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.sheet-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--accent-text); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.svg-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- shell ---------- */
.app { min-height: 100dvh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 56px; padding: var(--safe-t) var(--page-x) 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
}
.brand-mark .svg-icon { width: 18px; height: 18px; stroke-width: 2; }

.avatar-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  margin-right: -4px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text); font-weight: 600; font-size: 14px;
}

/* bottom tab bar on phones */
.rail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.rail .brand, .rail-foot { display: none; }
.nav { display: flex; height: var(--tabbar-h); }
.nav-btn {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 11px; font-weight: 500; position: relative;
  transition: color var(--fast) var(--ease);
}
.nav-btn .svg-icon { width: 22px; height: 22px; }
.nav-btn.active { color: var(--accent-text); }
.nav-count {
  position: absolute; top: 6px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--surface-3); color: var(--text-2);
  font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}

.main {
  padding: 4px var(--page-x) calc(var(--tabbar-h) + var(--safe-b) + 24px);
  max-width: 1120px; margin: 0 auto;
}
body.has-savebar .main { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 96px); }

.view { animation: enter var(--enter) var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- page head ---------- */
.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; padding: 8px 0 16px; }
.page-head > div:first-child { display: contents; }
.page-head h1 { grid-column: 1; grid-row: 1; font-size: 24px; font-weight: 600; line-height: 1.2; }
.page-sub { grid-column: 1 / -1; grid-row: 2; color: var(--text-2); font-size: 14px; margin-top: 4px; }
.head-actions { grid-column: 2; grid-row: 1; display: flex; gap: 8px; align-items: center; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: var(--r-ctl);
  font-size: 14px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn-block { width: 100%; height: 48px; font-size: 15px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-ctl); display: inline-grid; place-items: center; flex-shrink: 0;
  color: var(--text-2); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.boxed { border: 1px solid var(--line); background: var(--surface); }
@media (max-width: 559px) { .btn .lbl-wide { display: none; } }

/* ---------- summary numbers ---------- */
.summary {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-group);
  margin-bottom: 16px;
}
.summary > div { padding: 12px 12px 10px; min-width: 0; }
.summary > div + div { border-left: 1px solid var(--line); }
.sum-val { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.sum-lbl { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-val.tone-danger { color: var(--danger); }

/* ---------- search ---------- */
.search {
  position: sticky; top: 0; z-index: 20;
  padding: 8px 0; margin: -8px 0 8px;
  background: var(--bg);
}
.search-field { position: relative; display: flex; align-items: center; }
.search-field .svg-icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.search-field input { padding-left: 40px; }
.kbd {
  position: absolute; right: 10px; font-family: var(--mono); font-size: 11px; color: var(--text-3);
  border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 6px; line-height: 18px; pointer-events: none;
}
.search-field input:focus ~ .kbd, .search-field input:not(:placeholder-shown) ~ .kbd { display: none; }
@media (hover: none) { .kbd { display: none; } }

/* ---------- inputs ---------- */
.input {
  width: 100%; height: 44px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  font-size: 16px; /* 16px keeps ios from zooming in */
  transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease);
  appearance: none; -webkit-appearance: none;
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
textarea.input { height: auto; min-height: 112px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
textarea.input.tall { min-height: 160px; }
textarea.input.mono { font-family: var(--mono); font-size: 14px; }
select.input {
  padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888891' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input.narrow { max-width: 160px; }
@media (min-width: 960px) { .input { font-size: 14px; height: 40px; } textarea.input { font-size: 14px; } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field + .field { margin-top: 16px; }
.field-label { font-size: 13px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-hint { font-size: 12px; color: var(--text-3); }
.field-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.field-grid > .field + .field { margin-top: 0; }
.field-grid .span-2 { grid-column: 1 / -1; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 48px; }
.input-wrap .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 16px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2);
  font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.mono { font-family: var(--mono); font-size: 12px; }
.chips-label { font-size: 12px; color: var(--text-3); margin-right: 2px; }

/* ---------- groups and rows (settings lists) ---------- */
.group-label { font-size: 13px; font-weight: 500; color: var(--text-2); padding: 20px 4px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel > .group-label:first-child, .view > .group-label:first-child { padding-top: 4px; }
.group {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-group);
  overflow: hidden;
}
.group-note { font-size: 13px; color: var(--text-3); padding: 8px 4px 0; }
.group-pad { padding: 16px; }
.group-pad + .row, .row + .group-pad { border-top: 1px solid var(--line); }

.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 12px 16px; position: relative;
}
.row + .row { border-top: 1px solid var(--line); }
label.row, .row.tappable { cursor: pointer; transition: background-color var(--fast) var(--ease); }
label.row:hover, .row.tappable:hover { background: var(--surface-2); }
.row-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex-shrink: 0; transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.row-text { flex: 1; min-width: 0; }
.row-title { display: block; font-size: 15px; font-weight: 500; }
.row-desc { display: block; font-size: 13px; color: var(--text-3); margin-top: 1px; }
.row-stack { flex-direction: column; align-items: stretch; gap: 10px; }
.row-stack .input.narrow { max-width: 200px; }
@media (min-width: 720px) {
  .row-stack.inline { flex-direction: row; align-items: center; }
  .row-stack.inline .input { width: 180px; flex-shrink: 0; }
}

/* lock rows: a locked type tints its icon */
.lock-row:has(input:checked) .row-ico { background: var(--danger-soft); color: var(--danger); }
.lock-row .lock-act { width: 132px; flex-shrink: 0; margin-left: 12px; height: 36px; }
.locks-list { display: grid; grid-template-columns: 1fr; }
.locks-list .row { border-top: 1px solid var(--line); }
@media (min-width: 720px) {
  .locks-list { grid-template-columns: 1fr 1fr; }
  .locks-list .row:nth-child(-n+2) { border-top: 0; }
  .locks-list .row:nth-child(even) { border-left: 1px solid var(--line); }
}
@media (max-width: 719px) { .locks-list .row:first-child { border-top: 0; } }

/* switch */
.switch { position: relative; width: 44px; height: 26px; flex-shrink: 0; display: inline-block; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.knob {
  position: absolute; inset: 0; border-radius: 13px; background: var(--surface-3);
  transition: background-color var(--fast) var(--ease);
}
.knob::before {
  content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform var(--enter) var(--ease);
}
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::before { transform: translateX(18px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
.lock-row .switch input:checked + .knob { background: var(--danger); }
@media (prefers-color-scheme: light) { .knob { background: #d6d6dc; } }

/* radio and checkbox marks */
.radio, .check {
  width: 22px; height: 22px; flex-shrink: 0; position: relative; display: inline-grid; place-items: center;
}
.radio input, .check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.radio i { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line-strong); transition: border-color var(--fast) var(--ease), border-width var(--fast) var(--ease); }
.radio input:checked + i { border-color: var(--accent); border-width: 6px; }
.check i { width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--line-strong); display: grid; place-items: center; transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
.check i::after { content: ''; width: 10px; height: 5px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); opacity: 0; }
.check input:checked + i { background: var(--accent); border-color: var(--accent); }
.check input:checked + i::after { opacity: 1; }
.radio input:focus-visible + i, .check input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* callouts */
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5;
  background: var(--surface-2); color: var(--text-2);
}
.callout .svg-icon { width: 16px; height: 16px; margin-top: 2px; }
.callout.danger { background: var(--danger-soft); color: var(--danger); }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.accent { background: var(--accent-soft); color: var(--text); }
.group > .callout { border-radius: 0; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

/* ---------- chat list ---------- */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-group); overflow: hidden; }
.list:empty { display: none; }
.chat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 8px 12px 16px; min-height: 68px; cursor: pointer;
  transition: background-color var(--fast) var(--ease);
}
.chat-row + .chat-row { border-top: 1px solid var(--line); }
.chat-row:hover { background: var(--surface-2); }
.chat-row:active { background: var(--surface-3); }
.chat-ava {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: hsl(var(--hue) 28% 26%); color: hsl(var(--hue) 60% 86%);
  font-weight: 600; font-size: 17px;
}
@media (prefers-color-scheme: light) { .chat-ava { background: hsl(var(--hue) 55% 90%); color: hsl(var(--hue) 45% 30%); } }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.chat-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-id { font-family: var(--mono); font-size: 12px; color: var(--text-3); display: none; }
.chat-tags { display: flex; flex-wrap: wrap; gap: 4px 12px; min-height: 18px; }
.chat-side { display: flex; align-items: center; color: var(--text-3); }
.pin-btn { color: var(--text-3); opacity: 0; }
.pin-btn.active { opacity: 1; color: var(--accent-text); }
.chat-row:hover .pin-btn, .pin-btn:focus-visible { opacity: 1; }
@media (hover: none) { .pin-btn { opacity: 1; } .pin-btn:not(.active) { color: var(--text-3); opacity: 0.55; } }
.chat-row .chev { width: 16px; height: 16px; margin-right: 4px; }
@media (min-width: 720px) {
  .chat-row { padding-left: 20px; }
  .chat-head { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
  .chat-id { display: inline; flex-shrink: 0; }
}

/* status tag: a dot and a word. the dot is the dashboard's signature */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.tag.ok::before { background: var(--ok); }
.tag.warn::before { background: var(--warn); }
.tag.danger { color: var(--danger); }
.tag.danger::before { background: var(--danger); }
.tag.muted { color: var(--text-3); }
.tag.skeleton { width: 72px; height: 10px; border-radius: 5px; background: var(--surface-3); }
.tag.skeleton::before { display: none; }

.empty { text-align: center; padding: 40px 16px; color: var(--text-3); font-size: 14px; }
.empty .svg-icon { width: 28px; height: 28px; margin-bottom: 8px; color: var(--text-3); }
.empty b { display: block; color: var(--text); font-weight: 500; font-size: 15px; margin-bottom: 2px; }
.loading { padding: 24px 16px; color: var(--text-3); font-size: 14px; display: flex; align-items: center; gap: 8px; }

/* ---------- single chat ---------- */
.single-head {
  position: sticky; top: 0; z-index: 25; background: var(--bg);
  margin: 0 calc(-1 * var(--page-x)); padding: 4px var(--page-x) 0;
}
.single-top { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.single-top .icon-btn { margin-left: -8px; }
.single-title { flex: 1; min-width: 0; }
.single-title h1 { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.id-copy { font-family: var(--mono); font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; padding: 2px 0; }
.id-copy:hover { color: var(--text-2); }
.id-copy .svg-icon { width: 13px; height: 13px; }

.seg {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--page-x)); padding: 8px var(--page-x) 10px;
  border-bottom: 1px solid var(--line);
  scroll-padding: 0 var(--page-x);
}
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  height: 36px; padding: 0 14px; border-radius: 18px; flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 500; color: var(--text-2); white-space: nowrap;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.seg-btn .svg-icon { width: 16px; height: 16px; }
.seg-btn:hover { color: var(--text); background: var(--surface-2); }
.seg-btn.active { background: var(--surface-3); color: var(--text); }
.panel { padding-top: 8px; }
.panel:not(.active) { display: none; }

.danger-zone { margin-top: 32px; }

/* save bar: appears only with unsaved changes */
.savebar {
  position: fixed; z-index: 45; left: 8px; right: 8px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 16px; border-radius: 16px;
  background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  transform: translateY(16px); opacity: 0; pointer-events: none;
  transition: transform var(--enter) var(--ease), opacity var(--enter) var(--ease);
}
.savebar.show { transform: none; opacity: 1; pointer-events: auto; }
.savebar-text { flex: 1; min-width: 0; font-size: 14px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.savebar-text::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex-shrink: 0; }
.savebar-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- global ---------- */
.pick-list { max-height: 320px; overflow-y: auto; overscroll-behavior: contain; }
.pick-row { min-height: 52px; }
.pick-row .row-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-row .row-desc { font-family: var(--mono); font-size: 12px; }
.touched-mark { font-size: 12px; color: var(--accent-text); font-weight: 500; }

/* ---------- users ---------- */
.user-row { display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start; flex-wrap: wrap; }
.user-row + .user-row { border-top: 1px solid var(--line); }
.user-main { flex: 1; min-width: 200px; display: flex; gap: 12px; }
.user-info { min-width: 0; flex: 1; }
.user-name { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role { font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }
.role.owner { background: var(--warn-soft); color: var(--warn); }
.role.admin { background: var(--accent-soft); color: var(--accent-text); }
.user-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; font-size: 13px; color: var(--text-3); }
.user-meta span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.user-meta .svg-icon { width: 14px; height: 14px; }
.user-meta .warn { color: var(--warn); }
.user-chats { margin-top: 6px; font-size: 13px; color: var(--text-2); }
.user-actions { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.user-actions .btn { height: 34px; padding: 0 8px; gap: 6px; font-size: 13px; }
.user-actions .btn .svg-icon { width: 16px; height: 16px; }
@media (max-width: 559px) {
  .user-actions { width: calc(100% - 36px); margin: 0 0 0 36px; }
}

/* ---------- audit ---------- */
.audit-row { padding: 12px 16px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
.audit-row + .audit-row { border-top: 1px solid var(--line); }
.audit-act { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.audit-act.bad { color: var(--danger); }
.audit-time { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.audit-who { grid-column: 1 / -1; font-size: 13px; color: var(--text-2); word-break: break-word; }
.audit-who .muted { color: var(--text-3); }

/* ---------- federations ---------- */
.fed-row { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; min-height: 56px; }
.fed-row + .fed-row { border-top: 1px solid var(--line); }
.fed-row.tappable { cursor: pointer; transition: background-color var(--fast) var(--ease); }
.fed-row.tappable:hover { background: var(--surface-2); }
.fed-row.tappable:active { background: var(--surface-3); }
.fed-row .chev { width: 16px; height: 16px; color: var(--text-3); }
.fed-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.fed-name { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.fed-name .mono, .fed-value .mono { color: var(--text-3); font-weight: 400; }
.fed-name.mono { font-size: 14px; }
.fed-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; color: var(--text-3); }
.fed-meta .warn { color: var(--warn); }
.fed-reason { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.fed-reason .muted { color: var(--text-3); }
.fed-value { overflow-wrap: anywhere; }
.fed-row .btn { height: 34px; padding: 0 10px; gap: 6px; font-size: 13px; flex-shrink: 0; }
.fed-row .btn .svg-icon { width: 16px; height: 16px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0; font-size: 13px; color: var(--text-3); }
.pager .btn { height: 34px; padding: 0 10px; }
#fed-bans .search { position: static; margin: 0 0 8px; }

/* ---------- sheets (bottom sheet on phones, dialog on desktop) ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
  background: var(--scrim);
  animation: fade var(--enter) var(--ease);
}
.sheet-wrap.locked { z-index: 70; background: var(--bg); }
.sheet {
  width: 100%; max-height: calc(100dvh - 24px - var(--safe-t));
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  border: 1px solid var(--line); border-bottom: 0;
  animation: rise var(--enter) var(--ease);
}
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 20px; min-height: 56px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.sheet-head h2 { flex: 1; font-size: 17px; font-weight: 600; }
.sheet-body { padding: 16px 20px 20px; overflow-y: auto; overscroll-behavior: contain; flex: 1; }
.sheet-body .group { background: var(--surface-2); }
.sheet-body .group .row + .row { border-top-color: var(--line); }
.sheet-body .input { background: var(--surface); }
.sheet-foot {
  display: flex; gap: 8px; padding: 12px 20px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line); flex-shrink: 0;
}
.sheet-foot .btn { flex: 1; height: 48px; font-size: 15px; }
.sheet-section + .sheet-section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.sheet-section-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status { font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.bind-box { margin-top: 12px; padding: 12px; border-radius: 12px; border: 1px dashed var(--line-strong); }
.bind-box .row-desc { margin: 8px 0 0; }
.code-copy { font-family: var(--mono); font-size: 12px; background: var(--surface-3); color: var(--text); padding: 2px 6px; border-radius: 5px; user-select: all; cursor: pointer; }
.err { padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px; margin-bottom: 12px; }
.lock-hero { text-align: center; padding: 8px 0 20px; }
.lock-hero .row-ico { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 12px; background: var(--warn-soft); color: var(--warn); }
.lock-hero .svg-icon { width: 24px; height: 24px; }
.lock-hero h2 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.lock-hero p { color: var(--text-2); font-size: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 80; left: 50%; top: calc(12px + var(--safe-t));
  transform: translate(-50%, -8px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 10px;
  width: max-content; max-width: min(92vw, 440px); padding: 10px 16px 10px 12px; border-radius: 12px;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  font-size: 14px;
  transition: transform var(--enter) var(--ease), opacity var(--enter) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .svg-icon { color: var(--ok); }
.toast.error .svg-icon { color: var(--danger); }
.toast.info .svg-icon { color: var(--text-2); }

/* ---------- desktop ---------- */
@media (min-width: 960px) {
  :root { --page-x: 32px; }
  body { font-size: 14px; }
  .app { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .topbar { display: none; }
  .rail {
    position: sticky; top: 0; height: 100dvh; z-index: 30;
    display: flex; flex-direction: column; gap: 16px;
    padding: 16px 12px; background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .rail .brand { display: flex; padding: 4px 8px 8px; }
  .nav { flex-direction: column; height: auto; gap: 2px; }
  .nav-btn {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 10px;
    height: 36px; padding: 0 10px; border-radius: 8px;
    font-size: 14px; color: var(--text-2);
  }
  .nav-btn .svg-icon { width: 18px; height: 18px; }
  .nav-btn:hover { background: var(--surface-2); color: var(--text); }
  .nav-btn.active { background: var(--surface-3); color: var(--text); }
  .nav-btn.active .svg-icon { color: var(--accent-text); }
  .nav-count { position: static; margin-left: auto; background: transparent; color: var(--text-3); padding: 0; font-family: var(--mono); font-size: 12px; }
  .rail-foot { display: block; margin-top: auto; }
  .account {
    width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
    padding: 8px; border-radius: 10px; transition: background-color var(--fast) var(--ease);
  }
  .account:hover { background: var(--surface-2); }
  .account-text { min-width: 0; flex: 1; }
  .account-name { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .account-role { display: block; font-size: 12px; color: var(--text-3); }

  .main { padding: 24px var(--page-x) 64px; width: 100%; }
  body.has-savebar .main { padding-bottom: 120px; }
  .page-head { padding: 8px 0 20px; }
  .page-head h1 { font-size: 26px; }
  .summary > div { padding: 16px 20px 14px; }
  .sum-val { font-size: 24px; }
  .sum-lbl { font-size: 13px; }

  .savebar { left: calc(248px + var(--page-x)); right: var(--page-x); bottom: 20px; max-width: 720px; margin: 0 auto; }
  .single-head { padding-top: 8px; }
  .single-title h1 { font-size: 22px; }
  .panel { max-width: 880px; }

  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { max-width: 520px; max-height: calc(100dvh - 48px); border-radius: var(--r-sheet); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  .sheet-foot { justify-content: flex-end; padding-bottom: 12px; }
  .sheet-foot .btn { flex: none; height: 40px; font-size: 14px; }
  .toast { top: auto; bottom: 24px; transform: translate(-50%, 8px); }
}
@media (max-width: 400px) {
  .summary > div { padding: 10px 8px 8px; }
  .sum-val { font-size: 18px; }
}
@media (max-width: 359px) {
  .field-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
