/* ── Tokens ─────────────────────────── */
:root {
  --bg: #050505;
  --surface: #0d0d0d;
  --surface-2: #141414;
  --surface-3: #1a1a1a;
  --border: #1f1f1f;
  --border-strong: #2c2c2c;
  --text: #f5f5f5;
  --text-2: #c9c9c9;
  --muted: #8a8a8a;
  --faint: #555555;
  --accent: #ffffff;
  --accent-ink: #050505;
  --danger: #ff4d4d;
  --danger-soft: rgba(255, 77, 77, .1);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset;
  --radius: 16px;
  --radius-sm: 10px;
  --gutter: clamp(16px, 2.4vw, 32px);
  --gap: clamp(10px, 1.2vw, 16px);
  --topbar-h: 64px;
  --sidebar-w: clamp(300px, 24vw, 380px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f6f5;
  --surface: #ffffff;
  --surface-2: #f4f4f3;
  --surface-3: #ececea;
  --border: #e7e7e5;
  --border-strong: #d6d6d3;
  --text: #0b0b0b;
  --text-2: #333333;
  --muted: #6e6e6e;
  --faint: #a8a8a8;
  --accent: #0b0b0b;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, .07);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  color-scheme: light;
}

/* ── Base ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.5 var(--font);
  font-feature-settings: "ss01" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background .3s var(--ease), color .3s var(--ease);
}
button, input, select { font: inherit; color: inherit; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 15px; font-weight: 700; margin: 0 0 4px; }
.num, .mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.muted { color: var(--muted); }
.dim { color: var(--faint); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.error { color: var(--danger); min-height: 1em; margin: 8px 0 0; font-size: 13px; }

/* ── Top bar ─────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(150%) blur(16px);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 28px; height: 28px; flex: none; }
.logo rect { fill: var(--accent); }
.logo path { fill: none; stroke: var(--accent-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand-name span { font-weight: 500; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.clock { color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
.status {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.status.ok { color: var(--text); }
.status.ok .dot { background: var(--accent); animation: pulse 2s infinite; }
.status.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.status.bad .dot { background: var(--danger); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--text);
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .15s var(--ease);
}
.btn:hover { border-color: var(--text); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn svg { width: 17px; height: 17px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; flex: none; cursor: pointer;
  border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm); color: var(--muted);
  transition: color .2s, border-color .2s, background .2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── Navigation ─────────────────────────── */
.nav { display: flex; gap: 4px; margin-left: 14px; padding-left: 14px; border-left: 1px solid var(--border); }
.nav a {
  padding: 7px 12px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--muted);
  text-decoration: none; white-space: nowrap; transition: color .2s, background .2s;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); background: var(--surface-2); }

/* ── Layout ─────────────────────────── */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  min-height: calc(100vh - var(--topbar-h));
}
.main { padding: var(--gutter); display: flex; flex-direction: column; gap: clamp(24px, 3vw, 40px); min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head .muted { font-size: 14px; font-weight: 600; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: clamp(16px, 1.6vw, 22px); box-shadow: var(--shadow); min-width: 0;
  transition: border-color .25s var(--ease), transform .25s var(--ease), background .3s var(--ease);
}
.card > h2 { margin-bottom: 16px; }

/* ── Warnings ─────────────────────────── */
.warnings { display: flex; flex-direction: column; gap: 8px; }
.warnings:empty { display: none; }
.warning {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft);
  font-size: 14px; animation: slideIn .5s var(--ease);
}
.warning b { font-weight: 800; }
.warning .countdown { margin-left: auto; font-size: 15px; font-weight: 800; color: var(--danger); font-variant-numeric: tabular-nums; }

/* ── Summary ─────────────────────────── */
.summary { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--gap); }
.stat { display: flex; flex-direction: column; }
.stat.today { grid-column: span 2; }
.stat .label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.stat .value {
  font-size: clamp(22px, 2vw, 30px); font-weight: 800; letter-spacing: -.03em; line-height: 1.15;
  margin-top: 10px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.stat.today .value { font-size: clamp(28px, 2.6vw, 38px); }
.stat .sub { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 6px; }
.stat.hero { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stat.hero .label, .stat.hero .sub { color: color-mix(in srgb, var(--accent-ink) 60%, transparent); }
.compare { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.delta {
  font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  border: 1px solid currentColor; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.delta.down { color: var(--danger); }
.delta.flat { color: var(--muted); border-color: var(--border-strong); }
.stat.hero .delta.up, .stat.hero .delta.flat { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent-ink) 25%, transparent); }
.target { margin-top: auto; padding-top: 16px; }
.target-bar { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--accent-ink) 14%, transparent); overflow: hidden; }
.target-bar i { display: block; height: 100%; background: var(--accent-ink); border-radius: 99px; transition: width .8s var(--ease); }
.target-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 700; margin-top: 8px; color: color-mix(in srgb, var(--accent-ink) 60%, transparent); }

/* ── Account cards ─────────────────────────── */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: var(--gap); }
.account { container-type: inline-size; cursor: pointer; display: flex; flex-direction: column; gap: 16px; }
.account:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.account.offline { background: linear-gradient(180deg, var(--danger-soft), transparent 45%), var(--surface); }
.acc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.acc-name { font-weight: 800; font-size: 19px; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-seen { font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.acc-seen .last-msg { display: block; font-weight: 500; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.badge {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  font-size: 12px; font-weight: 800; letter-spacing: .02em;
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border-strong); white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.on { color: var(--text); }
.badge.on::before { animation: pulse 2s infinite; }
.badge.off { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.acc-alert {
  font-size: 13px; font-weight: 600; color: var(--danger); border-radius: var(--radius-sm); padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
}
.acc-alert b { font-variant-numeric: tabular-nums; }
.acc-income {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.acc-income > div { background: var(--surface-2); padding: 10px 12px; min-width: 0; }
.acc-income .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.acc-income .v { font-size: 15px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.acc-income .r { font-size: 12px; font-weight: 600; color: var(--faint); }
.acc-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.tag b { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }
.tag.down b { color: var(--danger); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; }
.spark i { flex: 1; background: var(--text); opacity: .9; border-radius: 3px 3px 1px 1px; min-height: 2px; transition: height .5s var(--ease); }
.spark i.zero { background: var(--border-strong); opacity: 1; }
.spark-label { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; color: var(--faint); margin-top: 6px; }
.acc-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
.acc-meta span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acc-meta b { color: var(--text); font-size: 15px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }

@container (max-width: 380px) {
  .acc-income, .acc-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spark { gap: 2px; }
}

/* ── Segmented control ─────────────────────────── */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 3px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 9px; white-space: nowrap;
  font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; transition: all .2s var(--ease);
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }

/* ── Room analytics ─────────────────────────── */
.room-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 12px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.heat { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; }
.heat i { aspect-ratio: 1 / 1.8; border-radius: 4px; background: var(--text); }
.heat-labels { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 11px; font-weight: 600; color: var(--faint); margin-top: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.heat-labels span { overflow: visible; white-space: nowrap; }
.heat-note { font-size: 14px; font-weight: 600; color: var(--muted); margin-top: 16px; }
.heat-note b { color: var(--text); font-weight: 800; }
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rank li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; font-size: 14px; font-weight: 600; }
.rank .pos { font-size: 13px; font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.rank .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .n { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank .amt { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.rank li.me .who { font-weight: 800; }
.rank li.me .who::after { content: "●"; font-size: 8px; margin-left: 6px; vertical-align: middle; }
.bar-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13px; margin-bottom: 12px; }
.bar-row .cur { font-weight: 800; }
.bar-row .track { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--text); border-radius: 99px; transition: width .6s var(--ease); }
.bar-row .amt { font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.health {
  display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13px; font-weight: 500; color: var(--faint);
  border-top: 1px solid var(--border); padding-top: 18px;
}
.health b { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Rain log sidebar ─────────────────────────── */
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h));
  border-left: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; min-width: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 20px 14px; border-bottom: 1px solid var(--border); }
.rain-log { list-style: none; margin: 0; padding: 10px; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.rain-item { padding: 14px; border-radius: 14px; display: grid; gap: 6px; border: 1px solid transparent; transition: background .2s, border-color .2s; }
.rain-item + .rain-item { margin-top: 4px; }
.rain-item:hover { background: var(--surface-2); }
.rain-item.hit { border-color: var(--border-strong); background: var(--surface-2); }
.rain-item.miss { opacity: .6; }
.rain-item.new { animation: slideIn .6s var(--ease); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } }
.ri-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.ri-tags { display: flex; gap: 6px; }
.ri-room, .ri-cur { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.ri-room { color: var(--muted); background: var(--surface-3); }
.ri-cur { border: 1px solid var(--border-strong); color: var(--text); }
.ri-who { font-weight: 800; font-size: 15px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.ri-who.none { font-weight: 600; color: var(--muted); font-size: 14px; }
.ri-amt { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.ri-amt b { font-size: 17px; font-weight: 800; color: var(--text); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ri-ago { font-size: 12px; color: var(--faint); white-space: nowrap; }
.empty { color: var(--faint); text-align: center; padding: 36px 12px; font-size: 14px; font-weight: 600; }

/* ── Drawer ─────────────────────────── */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); z-index: 30; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 31;
  background: var(--surface); border-left: 1px solid var(--border-strong);
  transform: translateX(100%); transition: transform .4s var(--ease);
  overflow-y: auto; overscroll-behavior: contain; padding: clamp(18px, 3vw, 28px);
}
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 24px; }
.drawer-head h3 { font-size: 26px; font-weight: 800; margin: 0 0 8px; letter-spacing: -.03em; overflow-wrap: anywhere; }
.drawer-head .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.drawer section { margin-bottom: 26px; }
.drawer section > h2 { font-size: 15px; margin-bottom: 12px; }
.bars7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: end; height: 140px; }
.bars7 .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; min-width: 0; }
.bars7 .b { width: 100%; background: var(--text); border-radius: 6px 6px 2px 2px; min-height: 2px; transition: height .6s var(--ease); }
.bars7 .b.zero { background: var(--border-strong); }
.bars7 .d { font-size: 12px; font-weight: 600; color: var(--faint); }
.bars7 .val { font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chat-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.chat-list li { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 12px; font-size: 14px; overflow-wrap: anywhere; }
.chat-list time { font-size: 13px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 1px; }
.chat-list b { font-weight: 800; }
.mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mini-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mini { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; min-width: 0; }
.mini .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.mini .v { font-size: 18px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.people li { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border-strong); }
.people li span { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }

/* ── Modal ─────────────────────────── */
.modal {
  border: 1px solid var(--border-strong); border-radius: 20px; padding: 0;
  background: var(--surface); color: var(--text);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
.modal::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); }
.modal[open] { animation: pop .3s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }
.modal-inner { padding: clamp(18px, 3vw, 26px); max-height: calc(100dvh - 26px); overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.modal-head h2 { font-size: 20px; }
.modal-section { padding: 20px 0; border-top: 1px solid var(--border); }
.modal-section:first-of-type { border-top: 0; padding-top: 8px; }
.modal-section .muted { margin: 0; }
.watchlist-items { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; }
.watchlist-items li {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 6px 6px 6px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); font-weight: 700;
}
.input-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.input-prefix { font-size: 14px; font-weight: 700; color: var(--muted); }
.button-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
select, .input-row input, #adminToken {
  flex: 1; min-width: 0; height: 42px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; outline: none; transition: border-color .2s;
}
#adminToken { width: 100%; margin-top: 12px; }
select:focus, .input-row input:focus, #adminToken:focus { border-color: var(--text); }
.recap-preview {
  white-space: pre-wrap; font: 600 13px/1.7 var(--font); font-variant-numeric: tabular-nums;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 12px 0;
}

.whatsapp-status { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
.whatsapp-status .state { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--text); }
.whatsapp-status .state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.whatsapp-status .state.connected::before { background: var(--text); }
.whatsapp-status .state.problem { color: var(--danger); }
.whatsapp-status .state.problem::before { background: var(--danger); }
.whatsapp-qr { margin-top: 14px; background: #fff; border-radius: 14px; padding: 12px; width: min(260px, 100%); }
.whatsapp-qr svg { display: block; width: 100%; height: auto; }

/* ── Toasts ─────────────────────────── */
.toasts { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 40; pointer-events: none; width: min(460px, calc(100vw - 24px)); }
.toast {
  background: var(--accent); color: var(--accent-ink); border-radius: 14px; padding: 14px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45); font-size: 14px; font-weight: 600;
  animation: toastIn .45s var(--ease);
}
.toast b { font-weight: 800; }
.toast.warning-toast { background: var(--danger); color: #fff; }
.toast.mention-toast { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .35s var(--ease); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* ── Skeleton ─────────────────────────── */
.skel { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Responsive ─────────────────────────── */
/* Large laptop / small desktop */
@media (max-width: 1440px) {
  .summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat.today { grid-column: 1 / -1; }
}
/* Tablet & small laptop: rain log moves below the main content */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; border-left: 0; border-top: 1px solid var(--border); }
  .rain-log { max-height: 640px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 6px; align-content: start; }
  .rain-item + .rain-item { margin-top: 0; }
}
/* Large phone / small tablet */
@media (max-width: 860px) {
  .room-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  :root { --topbar-h: 58px; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clock { display: none; }
}
/* Phone */
@media (max-width: 480px) {
  body { font-size: 14px; }
  .status { width: 32px; padding: 0; justify-content: center; }
  .status #statusText { display: none; }
  #settingsBtn .label { display: none; }
  #settingsBtn { width: 38px; padding: 0; }
  .topbar-right { gap: 4px; }
  .stat .value { font-size: 21px; }
  .stat.today .value { font-size: 30px; }
  .sidebar-head { padding: 16px; }
  .rain-log { max-height: 520px; }
  .chat-list li { grid-template-columns: 60px minmax(0, 1fr); }
  .heat-labels { font-size: 10px; }
}
@media (max-width: 560px) {
  .brand-name { display: none; }
  .nav { margin-left: 4px; padding-left: 0; border-left: 0; }
}
/* Very small phone */
@media (max-width: 360px) {
  .summary { grid-template-columns: minmax(0, 1fr); }
  .mini-grid, .mini-grid.three { grid-template-columns: minmax(0, 1fr); }
  .brand-name { font-size: 15px; }
}

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

/* ── Server page ─────────────────────────── */
.server-main { max-width: 1680px; margin: 0 auto; width: 100%; }
.server-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--gap); }
.meter { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 14px; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--text); transition: width .6s var(--ease); }
.meter i.high { background: var(--danger); }
.server-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.server-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.chart-head h2 { margin: 0; }
.chart-now { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 18px; height: 0; border-top: 2px solid var(--text); }
.chart-legend i.dashed { border-top-style: dashed; }
.chart { position: relative; height: 160px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.chart .axis text { fill: var(--faint); font-size: 10px; font-weight: 600; font-family: var(--font); }
.chart .series { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart .series.dashed { stroke-dasharray: 5 4; }
.chart .area { fill: var(--text); opacity: .06; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.chart-tooltip {
  position: absolute; top: 0; pointer-events: none; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; z-index: 2;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); font-variant-numeric: tabular-nums;
}
.chart-tooltip b { font-weight: 800; }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--faint); font-size: 14px; font-weight: 600; }
.core-bars { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 10px; }
.core { font-size: 12px; font-weight: 600; color: var(--muted); }
.core b { display: block; color: var(--text); font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.core .meter { margin-top: 6px; height: 6px; }
.stack-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--surface-3); gap: 2px; margin: 6px 0 14px; }
.stack-bar i { display: block; height: 100%; }
.stack-bar i.used { background: var(--text); }
.stack-bar i.cache { background: var(--muted); }
.legend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.legend-list li { display: flex; justify-content: space-between; gap: 12px; }
.legend-list li span { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.legend-list li b { font-weight: 800; font-variant-numeric: tabular-nums; }
.swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--surface-3); border: 1px solid var(--border-strong); }
.swatch.used { background: var(--text); border-color: var(--text); }
.swatch.cache { background: var(--muted); border-color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 0 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 0; border-bottom: 1px solid var(--border); font-weight: 600; }
.table th + th, .table td + td { padding-left: 14px; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-weight: 800; }
.table th.num { font-weight: 700; }
.badge-state { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.badge-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text); }
.badge-state.bad { color: var(--danger); }
.badge-state.bad::before { background: var(--danger); }

@media (max-width: 1280px) {
  .server-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .server-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .server-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .server-grid, .server-grid.two { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 360px) {
  .server-tiles { grid-template-columns: minmax(0, 1fr); }
}

/* ── Login (dashboard + worker portal) ─────────────────────────── */
.login { min-height: calc(100dvh - var(--topbar-h)); display: grid; place-items: center; padding: 24px 16px; }
body > .login:first-child { min-height: 100dvh; }
.login-card { width: min(400px, 100%); }
.login-card .brand { margin-bottom: 24px; }
.login-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 6px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.login-card input, .login-card select {
  height: 46px; padding: 0 14px; border-radius: 10px; outline: none; width: 100%;
  background: var(--surface-2); border: 1px solid var(--border-strong); font-size: 15px; font-weight: 600;
}
.login-card input:focus, .login-card select:focus { border-color: var(--text); }
.login-card .btn { height: 46px; }

/* ── Forms ─────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field input, .field select {
  height: 44px; padding: 0 14px; border-radius: 10px; outline: none; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); font-size: 15px; font-weight: 600;
}
.field input:focus, .field select:focus { border-color: var(--text); }
.field.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.field.check input { width: 18px; height: 18px; accent-color: var(--text); }
.modal form > .btn { width: 100%; margin-top: 16px; height: 44px; }
.seg.full { display: flex; width: 100%; margin-top: 14px; }
.seg.full .seg-btn { flex: 1; }
.settle-amount { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 12px 0 4px; font-variant-numeric: tabular-nums; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.small-btn { height: 32px; padding: 0 12px; font-size: 13px; }
.neg { color: var(--danger); }

/* ── Workers ─────────────────────────── */
.worker-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--gap); }
.portal-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--gap); }
.claim-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: var(--gap); }
.claim-card { display: flex; flex-direction: column; gap: 14px; }
.claim-card.claimed, .claim-card.mine { border-color: var(--border-strong); }
.claim-card.mine { box-shadow: inset 0 0 0 1px var(--text); }
.claim-card .input-row { margin-top: 0; }
.claim-card > .btn { width: 100%; }
.kv.compact { gap: 8px 12px; font-size: 13px; }
.table-card { padding: 0; overflow: hidden; }
.table-card .table th, .table-card .table td { padding-left: 16px; padding-right: 16px; }
.table-card .table th { padding-top: 14px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .table { min-width: 640px; }
.table td .small { font-weight: 500; }
tr[data-worker] { cursor: pointer; transition: background .15s; }
tr[data-worker]:hover { background: var(--surface-2); }
tr.inactive td { opacity: .5; }
.pill-status { display: inline-flex; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); white-space: nowrap; }
.pill-status.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill-status.pending { color: var(--text); }
.pill-status.paid { color: var(--muted); }
.pill-status.debt { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.drawer .section-head { margin-bottom: 10px; }
.drawer .table-scroll .table { min-width: 560px; }

@media (max-width: 1280px) {
  .worker-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .portal-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .worker-tiles, .portal-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-row .btn { flex: 1 1 calc(50% - 8px); }
}
@media (max-width: 360px) {
  .worker-tiles, .portal-tiles { grid-template-columns: minmax(0, 1fr); }
}

/* ── Toggle switch ─────────────────────────── */
.toggle-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
}
.toggle span { display: flex; flex-direction: column; gap: 2px; }
.toggle b { font-size: 15px; font-weight: 800; }
.toggle small { font-size: 12px; font-weight: 600; color: var(--muted); }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle i { position: relative; width: 44px; height: 26px; flex: none; border-radius: 99px; background: var(--border-strong); transition: background .2s var(--ease); }
.toggle i::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--surface); transition: transform .25s var(--ease);
}
.toggle input:checked + i { background: var(--accent); }
.toggle input:checked + i::after { transform: translateX(18px); background: var(--accent-ink); }
.toggle input:focus-visible + i { outline: 2px solid var(--text); outline-offset: 2px; }

/* ── Worker extras ─────────────────────────── */
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline-setting { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--muted); flex-wrap: wrap; }
.inline-setting input {
  width: 72px; height: 32px; padding: 0 10px; border-radius: 8px; outline: none; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); font-size: 14px; font-weight: 700; text-align: center;
}
.inline-setting input:focus { border-color: var(--text); }
tr.canceled .amount { text-decoration: line-through; opacity: .6; }
.share { display: inline-block; vertical-align: middle; width: 60px; height: 6px; margin-right: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.share i { display: block; height: 100%; background: var(--text); }
.drawer .section-head select {
  height: 34px; padding: 0 10px; border-radius: 8px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong); font-size: 13px; font-weight: 700;
}
.drawer .recap-preview { margin: 0 0 12px; }

/* ── Custom form controls (no native browser UI) ─────────────────────────── */
.native-select { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; border: 0 !important; opacity: 0; overflow: hidden; clip-path: inset(50%); pointer-events: none; }
.dropdown { position: relative; flex: 1; min-width: 0; }
.dropdown-button {
  width: 100%; height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 12px 0 14px; border-radius: var(--radius-sm); cursor: pointer; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  font-size: 14px; font-weight: 700; transition: border-color .2s var(--ease);
}
.dropdown-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-button svg { width: 16px; height: 16px; flex: none; color: var(--muted); transition: transform .2s var(--ease); }
.dropdown-button:hover, .dropdown.open .dropdown-button { border-color: var(--text); }
.dropdown.open .dropdown-button svg { transform: rotate(180deg); }
.dropdown-button:disabled { opacity: .5; cursor: not-allowed; }
.dropdown-list {
  position: fixed; z-index: 60; display: none; flex-direction: column; gap: 2px;
  max-height: 260px; overflow-y: auto; padding: 6px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  animation: pop .18s var(--ease);
}
.dropdown.open .dropdown-list { display: flex; }
.dropdown-list [role="option"] {
  border: 0; background: transparent; text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.dropdown-list [role="option"]:hover { background: var(--surface-2); color: var(--text); }
.dropdown-list [role="option"].active { background: var(--accent); color: var(--accent-ink); }
.field .dropdown-button { height: 44px; font-size: 15px; }
.drawer .section-head .dropdown, .input-row .dropdown { flex: 1; }
.drawer .section-head .dropdown { flex: none; width: 170px; }
.drawer .section-head .dropdown-button { height: 34px; font-size: 13px; }

input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; flex: none; cursor: pointer;
  border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--surface-2);
  display: inline-grid; place-items: center; transition: background .15s, border-color .15s; vertical-align: middle;
}
input[type="checkbox"]::after {
  content: ""; width: 9px; height: 5px; border-left: 2px solid var(--accent-ink); border-bottom: 2px solid var(--accent-ink);
  transform: rotate(-45deg) translate(1px, -1px); opacity: 0;
}
input[type="checkbox"]:checked { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after { opacity: 1; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.toggle input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }

input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.confirm-modal { width: min(420px, calc(100vw - 24px)); }
.confirm-message { font-size: 15px; font-weight: 500; color: var(--text-2); margin: 10px 0 20px; line-height: 1.55; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-actions .btn { min-width: 110px; }

.claim-actions { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.claim-actions > .btn { width: 100%; }
.claim-control { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.claim-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.claim-control .input-row { margin-top: 0; }
.claim-control .btn { flex: none; min-width: 104px; height: 42px; }

.security-warnings { margin: 12px 0 4px; padding: 12px 14px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.security-warnings p { margin: 0; font-size: 13px; font-weight: 600; color: var(--danger); }
.security-warnings p + p { margin-top: 4px; }

.uptime-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.uptime-tiles .meter { margin-top: 10px; height: 6px; }
@media (max-width: 480px) { .uptime-tiles { grid-template-columns: minmax(0, 1fr); } }

/* ── Finance ─────────────────────────── */
.finance-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--gap); }
.total-row td { border-top: 1px solid var(--border-strong); }
.card .section-head { margin-bottom: 12px; }
.watchlist-items li > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
@media (max-width: 1280px) { .finance-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) { .finance-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 360px) { .finance-tiles { grid-template-columns: minmax(0, 1fr); } }
