/* Server Monitor — design system (shared with Personal Hub).
   Dark-first, Linear/Vercel tone: restrained surfaces, one accent,
   semantic status colors, 150–220ms motion. */

:root {
  --bg: #0B0D10;
  --surface: #111419;
  --surface-2: #161A20;
  --surface-3: #1C2128;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --text-2: rgba(255, 255, 255, 0.56);
  --text-3: rgba(255, 255, 255, 0.36);
  --accent: #4C8DF6;
  --accent-soft: rgba(76, 141, 246, 0.14);
  --ok: #3FB950;
  --warn: #D29922;
  --err: #F85149;
  --info: #58A6FF;
  --muted: #6E7681;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius-card: 14px;
  --radius-ctl: 9px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --dur: 180ms;
  --font: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F0F2F5;
  --surface-3: #E8EBF0;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: rgba(15, 23, 42, 0.92);
  --text-2: rgba(15, 23, 42, 0.58);
  --text-3: rgba(15, 23, 42, 0.38);
  --accent: #2E6BE6;
  --accent-soft: rgba(46, 107, 230, 0.10);
  --ok: #1A7F37;
  --warn: #9A6700;
  --err: #CF222E;
  --info: #0969DA;
  --muted: #8C959F;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
html { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
a, button, [role="button"] { -webkit-tap-highlight-color: transparent; }
::selection { background: var(--accent-soft); }

/* shared dot used by foot status, badges, event rows */
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

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

/* ---- layout ---- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: var(--s4);
  gap: var(--s4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--s1) var(--s2);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: 0.1px;
}
.brand svg { flex-shrink: 0; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-ctl);
  color: var(--text-2);
  font-weight: 500;
  transition: background var(--dur) ease, color var(--dur) ease;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--text); }
.nav a.active .nav-ico { color: var(--accent); }
.nav-ico { display: inline-flex; color: var(--text-3); }
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--err);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-foot {
  margin-top: auto;
  padding: var(--s2);
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-foot a { color: var(--text-2); }

.main {
  flex: 1;
  min-width: 0;
  padding: var(--s5) var(--s5) calc(48px + env(safe-area-inset-bottom, 0px));
  max-width: 1240px;
}

.topbar {
  display: none;
  align-items: center;
  gap: var(--s3);
  min-height: 54px;
  padding: var(--s2) var(--s3);
  padding-top: calc(var(--s2) + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 30;
}

@media (max-width: 900px) {
  .shell { display: block; }
  .sidebar {
    position: fixed;
    z-index: 50;
    left: 0; top: 0; bottom: 0;
    padding-bottom: calc(var(--s4) + env(safe-area-inset-bottom, 0px));
    transform: translateX(-100%);
    transition: transform var(--dur) ease;
    box-shadow: var(--shadow);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .topbar { display: flex; }
  .main { padding: var(--s4) var(--s3) calc(48px + env(safe-area-inset-bottom, 0px)); }
  .scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 40; border: 0; padding: 0;
  }
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s5);
  flex-wrap: wrap;
}
.page-title { font-size: 20px; }
.page-sub { color: var(--text-2); margin-top: 4px; font-size: 13px; }

/* ---- cards & grids ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--s4);
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: var(--s3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
}

/* clickable cards (metric cards) get a quiet lift */
a.card {
  transition: border-color var(--dur) ease, transform var(--dur) ease, box-shadow var(--dur) ease;
}
a.card:hover {
  border-color: var(--border-strong);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.grid-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s3);
  margin-bottom: var(--s4);
}
@media (max-width: 1100px) { .grid-metrics { grid-template-columns: repeat(2, 1fr); } }

.metric-card { display: block; color: inherit; }
.metric-spark { width: 110px; flex-shrink: 1; min-width: 70px; overflow: hidden; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.grid-2 > *, .grid-metrics > * { min-width: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* chart wall: two columns desktop, single column mobile */
.grid-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s3);
}
.grid-charts > * { min-width: 0; }
@media (max-width: 900px) { .grid-charts { grid-template-columns: 1fr; } }

.chart-meta { display: inline-flex; align-items: baseline; gap: 10px; min-width: 0; }
.chart-now {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chart-range { white-space: nowrap; }

/* page enter transition (router adds .page-in on each navigation) */
.page-in { animation: page-in 200ms ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }

.metric-value {
  font-size: 26px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.3px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.metric-unit { font-size: 14px; font-weight: 500; color: var(--text-2); }
.metric-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.state-ok { color: var(--text); }
.state-warn { color: var(--warn); }
.state-err { color: var(--err); }

/* small screens: 2-up metric cards, value stacked over a full-width spark */
@media (max-width: 560px) {
  .grid-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .metric-card .card-title { margin-bottom: var(--s1); }
  .metric-value { font-size: 21px; }
  .metric-sub { font-size: 11px; }
  .metric-card .spread { flex-direction: column; align-items: stretch; gap: 8px; }
  .metric-spark { width: 100%; min-width: 0; }
  .chart-range { display: none; }
  .card { padding: var(--s3); }
}

/* ---- status badge ---- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.badge.online, .badge.up { color: var(--ok); }
.badge.online .dot, .badge.up .dot { background: var(--ok); }
.badge.warning { color: var(--warn); }
.badge.warning .dot { background: var(--warn); }
.badge.offline, .badge.down { color: var(--err); }
.badge.offline .dot, .badge.down .dot { background: var(--err); }
.badge.maintenance { color: var(--info); }
.badge.maintenance .dot { background: var(--info); }
.badge.unknown { color: var(--muted); }

/* ---- meter bar (Beszel-style) ---- */

.meter {
  width: 100%;
  min-width: 56px;
  height: 5px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width var(--dur) ease;
}
.meter.warn > i { background: var(--warn); }
.meter.crit > i { background: var(--err); }

/* ---- tables ---- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text-2); }
table.data td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--dur) ease; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.cell-main { font-weight: 550; }
.cell-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.cell-sub.trunc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }

/* ---- controls ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 550;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--dur) ease, border-color var(--dur) ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: rgba(248, 81, 73, 0.12); border-color: var(--err); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.input, select.input, .search {
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-ctl);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  min-width: 0;
}
.input:focus, .search:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.search input {
  border: 0; outline: none; background: transparent;
  color: var(--text); height: 100%; width: 100%; font-size: 13px;
}
.search svg { color: var(--text-3); flex-shrink: 0; }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  padding: 4px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--dur) ease, color var(--dur) ease;
  height: auto;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface-3); color: var(--text); }

.toolbar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s4);
  flex-wrap: wrap;
}
.toolbar .grow { flex: 1; }
.toolbar .search { width: 240px; }

/* ---- events list ---- */

.events { display: flex; flex-direction: column; }
.event-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.event-row:last-child { border-bottom: 0; }
.event-ico { margin-top: 2px; flex-shrink: 0; display: inline-flex; }
.event-msg { min-width: 0; overflow-wrap: anywhere; }
.event-time { margin-left: auto; color: var(--text-3); font-size: 12px; flex-shrink: 0; padding-left: 8px; }
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-err { color: var(--err); }
.tone-info { color: var(--info); }
.tone-muted { color: var(--muted); }

/* ---- charts ---- */

.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; }
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  z-index: 5;
  transform: translateX(-50%); /* inside the chart, under its top edge */
}
.chart-tip b { font-variant-numeric: tabular-nums; }
.chart-empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 12.5px;
}

/* ---- heartbeat bar (Uptime Kuma style) ---- */

.heartbeats { display: flex; gap: 2px; align-items: center; }
.heartbeats i {
  flex: 1;
  height: 22px;
  min-width: 4px;
  border-radius: 3px;
  background: var(--surface-3);
  transition: transform var(--dur) ease;
}
.heartbeats i.up { background: var(--ok); }
.heartbeats i.down { background: var(--err); }
.heartbeats i.warn { background: var(--warn); }

/* ---- service status board (status-page style rows) ---- */

.svc-row {
  padding: 14px 2px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--dur) ease;
}
.svc-row:last-child { border-bottom: 0; }
.svc-row:hover { background: var(--surface-2); }
.svc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
}
.svc-name { font-weight: 550; min-width: 0; }
.svc-pct {
  margin-left: auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.svc-pct .cell-sub { display: inline; }
.svc-board { gap: 2px; }
.svc-board i {
  min-width: 1px;
  height: 22px;
  border-radius: 1.5px;
}
.svc-board i.nodata { background: var(--surface-3); }

/* ---- states ---- */

.state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  color: var(--text-2);
  text-align: center;
}
.state-block svg { color: var(--text-3); }
.state-block .hint { font-size: 12.5px; color: var(--text-3); }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- drawer / modal ---- */

.scrim {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  z-index: 40; border: 0; padding: 0; cursor: default;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 96vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 45;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  animation: slide-in var(--dur) ease;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s4);
  border-bottom: 1px solid var(--border);
}
.drawer-body { padding: var(--s4); overflow-y: auto; flex: 1; min-height: 0; }

.modal-wrap {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s4);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  width: min(440px, 100%);
  padding: var(--s5);
  animation: pop var(--dur) ease;
}
@keyframes pop { from { transform: scale(0.97); opacity: 0; } }
.modal h3 { margin-bottom: var(--s4); }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--s4); }
.form-row label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.form-row .input { height: 38px; }
.form-check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-2); margin-bottom: var(--s4); }
.form-actions { display: flex; justify-content: flex-end; gap: var(--s2); }

/* ---- logs page ---- */

.logs-layout { display: flex; gap: var(--s3); height: calc(100vh - 120px); min-height: 420px; }
.logs-side {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  min-height: 0;
}
.logs-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.log-ctr {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 13px;
  transition: background var(--dur) ease;
  border: 0; background: none; text-align: left; width: 100%;
}
.log-ctr:hover { background: var(--surface-2); color: var(--text); }
.log-ctr.active { background: var(--accent-soft); color: var(--text); }
.log-ctr .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-ctr .st { flex-shrink: 0; }

.log-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.log-tools {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.log-tools .search { height: 30px; flex: 1; min-width: 140px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--dur) ease, color var(--dur) ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.log-tools .divider { width: 1px; height: 18px; background: var(--border); }

.log-view {
  flex: 1;
  overflow-y: auto;
  padding: var(--s3);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
  background: var(--bg);
}
.log-view .line { display: flex; gap: 12px; padding: 0 4px; border-radius: 4px; }
.log-view .line:hover { background: var(--surface-2); }
.log-view .line.match { background: rgba(210, 153, 34, 0.15); }
.log-view .ts { color: var(--text-3); flex-shrink: 0; font-size: 11.5px; padding-top: 1px; }
.log-view .stream-err { color: var(--err); }
.log-view .txt { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.log-view .txt.nowrap { white-space: pre; overflow-x: auto; }
.log-view mark { background: rgba(210, 153, 34, 0.45); color: inherit; border-radius: 2px; }
.log-status {
  padding: 6px var(--s3);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: var(--s4);
  align-items: center;
}
.log-follow-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); display: inline-block; margin-right: 5px; }
.log-follow-dot.paused { background: var(--warn); }

@media (max-width: 900px) {
  .logs-layout { height: calc(100vh - 140px); }
  .logs-side { width: 180px; }
}

/* ---- kv list (inspect) ---- */

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--mono); font-size: 11.5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px; color: var(--text-2);
}

/* ---- settings ---- */

.settings-nav { display: flex; flex-direction: column; gap: 0; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s4);
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: 0; }
.setting-name { font-weight: 550; }
.setting-desc { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

.switch {
  position: relative;
  width: 38px; height: 22px;
  border-radius: 11px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background var(--dur) ease;
  flex-shrink: 0;
  padding: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform var(--dur) ease, background var(--dur) ease;
}
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: #fff; }

/* ---- alerts ---- */

.alert-banner {
  border: 1px solid var(--err);
  background: rgba(248, 81, 73, 0.08);
  border-radius: var(--radius-card);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.alert-banner .alert-item { display: flex; gap: 10px; align-items: center; font-size: 13.5px; }
.alert-banner .alert-item b { font-variant-numeric: tabular-nums; }

/* ---- toast ---- */

.toast-wrap {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: pop var(--dur) ease;
  max-width: 90vw;
}
.toast.error { border-color: var(--err); color: var(--err); }

/* ---- misc ---- */

.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mb-s3 { margin-bottom: var(--s3); }
.mt-s3 { margin-top: var(--s3); }
.row-gap { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); }
.hidden { display: none !important; }

/* brand + layout helpers */
.brand-mark { color: var(--accent); display: inline-flex; flex-shrink: 0; }
.flex1 { flex: 1; min-width: 0; }
.foot-gap { gap: 6px; }
.topbar-brand { padding: 0; font-size: 14px; }

/* login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(360px, 100%); }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 16px; justify-content: center; margin-bottom: 28px; }
.login-card .btn { width: 100%; justify-content: center; height: 40px; margin-top: 4px; }
.login-err { color: var(--err); font-size: 13px; min-height: 18px; margin: 10px 0 2px; text-align: center; }
.login-title { text-align: center; color: var(--text-2); font-size: 13.5px; margin-bottom: 18px; }

/* ---- mobile touch polish (phones) ---- */

@media (max-width: 560px) {
  .page-head { margin-bottom: var(--s4); }
  .page-title { font-size: 18px; }
  /* 38px touch targets */
  .btn { height: 38px; }
  .input, .search { height: 38px; }
  .seg button { padding: 6px 11px; }
  .icon-btn { width: 36px; height: 36px; }
  .row-gap { row-gap: var(--s2); }
  .toolbar .search { width: 100%; }
  .modal { width: 100%; }
  .cell-sub.trunc { max-width: 180px; }
}
