:root {
  --bg: #0b1220;
  --bg-elev: #121a2b;
  --bg-soft: #172033;
  --line: #243049;
  --line-soft: #1c2740;
  --text: #e8eef8;
  --muted: #8b9bb8;
  --accent: #3b82f6;
  --accent-2: #22c55e;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #34d399;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --radius: 14px;
  --font: "DM Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(59, 130, 246, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 197, 94, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-card .brand {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.login-card .hint { color: var(--muted); margin: 0 0 20px; font-size: 0.92rem; line-height: 1.5; }
.login-card label { display: block; font-size: 0.82rem; color: var(--muted); margin: 10px 0 6px; }
.login-card input { width: 100%; margin: 0 0 8px; }
.login-card .primary { width: 100%; margin-top: 12px; }

/* Shell */
.layout {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  background: rgba(12, 18, 32, 0.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
}
.side .brand-wrap { padding: 4px 10px 18px; }
.side h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.side .sub { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
.bj-clock {
  margin-top: 10px;
  font-family: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.bj-clock .t {
  display: block;
  margin-top: 2px;
  color: #d7e2f0;
  font-variant-numeric: tabular-nums;
}
.ledger-range {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.ledger-range label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.ledger-range input[type="date"] { min-width: 150px; }
.receipt-list { display: grid; gap: 8px; max-width: 720px; margin: 8px 0 12px; }
.receipt-list button { text-align: left; }
.receipt-list .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.receipt-frame { width: 360px; background: #111; border-radius: 28px; padding: 12px; }
.receipt-frame canvas { width: 100%; height: auto; display: block; border-radius: 18px; background: #F8F8F8; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  margin: 0;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #c9d4e8;
  cursor: pointer;
  font: inherit;
  transition: 0.15s ease;
}
.nav button .ico {
  width: 1.4rem;
  text-align: center;
  opacity: 0.85;
  font-size: 0.95rem;
}
.nav button.active,
.nav button:hover {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.35);
  color: #fff;
}
.nav-badge {
  margin-left: auto;
  min-width: 1.35rem;
  height: 1.25rem;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--warn);
  color: #1a1400;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-parent .nav-caret {
  margin-left: auto;
  font-size: 0.72rem;
  opacity: 0.55;
  transition: transform 0.15s ease;
}
.nav-group:not(.open) .nav-caret {
  transform: rotate(-90deg);
}
.nav-parent.in-section {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
}
.nav-sub {
  display: none;
  flex-direction: column;
  gap: 2px;
  margin: 0 0 4px 10px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.nav-group.open .nav-sub {
  display: flex;
}
.nav-sub button {
  padding: 8px 12px;
  font-size: 0.92rem;
}
.order-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.order-chips button {
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}
.order-chips button.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(59, 130, 246, 0.45);
  color: #fff;
}
.pool-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}
.pool-summary .pill {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
}
.pool-summary .pill.active {
  border-color: rgba(59, 130, 246, 0.45);
  color: #fff;
}

.nav .spacer { flex: 1; }
.nav #logoutBtn {
  color: #f0a8a8;
  border-color: transparent;
}
.nav #logoutBtn:hover {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
}

.main {
  padding: 22px 26px 40px;
  min-width: 0;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.page-head .desc {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
  max-width: 720px;
}
.pull-rate {
  margin: 6px 0 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 650;
}
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.live-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.15);
  animation: pulse 1.6s ease infinite;
}
@keyframes pulse {
  50% { opacity: 0.45; }
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 14px;
  box-shadow: var(--shadow);
}
.panel.flat { box-shadow: none; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

input, button, select, textarea {
  margin: 0;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid #334561;
  background: #0e1626;
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.7);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
button { cursor: pointer; }
button.primary {
  background: linear-gradient(180deg, #4b8dff, #2f6fed);
  border-color: #2f6fed;
  color: #fff;
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.06); }
button.ghost {
  background: transparent;
  border-color: #3a4f6d;
  color: #d7e2f0;
}
button.ghost:hover { background: rgba(255,255,255,0.04); }
button.sm { padding: 6px 10px; font-size: 0.82rem; border-radius: 8px; }
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}
.device-batch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0 8px;
}
.device-grid {
  display: grid;
  grid-template-columns: repeat(var(--device-cols, 4), minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.device-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 6px;
  display: grid;
  gap: 4px;
  min-width: 0;
}
.device-card.busy { border-color: #8a6420; }
.device-card-head,
.device-card-meta,
.device-card-nums,
.device-card-ops {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}
.device-card-head { flex-wrap: nowrap; }
.device-remark {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.2rem;
  font-weight: 700;
}
.device-card-nums,
.device-card-ops { color: var(--muted); font-size: 0.78rem; }
.device-card button.sm { padding: 2px 6px; font-size: 0.75rem; }
.device-card input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: #2f6fed;
  cursor: pointer;
  border: none;
  background: transparent;
  box-shadow: none;
  flex: 0 0 auto;
}
th.col-check, td.col-check {
  width: 36px;
  padding-left: 10px;
  padding-right: 8px;
  text-align: center;
  vertical-align: middle;
}
.col-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: #2f6fed;
  cursor: pointer;
  border: none;
  background: transparent;
  box-shadow: none;
}
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.form-grid {
  display: grid;
  gap: 14px;
  max-width: 640px;
}
.form-grid label {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-grid input, .form-grid select { width: 100%; }

.msg { color: var(--danger); }
.hint { color: var(--muted); font-size: 13px; }
.ok { color: var(--ok); }
.meta { color: var(--muted); font-size: 0.9rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
}
.card .n {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.card .l { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.card .sub { color: var(--muted); font-size: 0.75rem; margin-top: 6px; }

/* Table */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-elev);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}
table.data th,
table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
table.data th {
  position: sticky;
  top: 0;
  background: #151e31;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}
table.data tr:hover td { background: rgba(59, 130, 246, 0.05); }
table.data tr.stuck-alert td {
  background: rgba(239, 68, 68, 0.08);
  box-shadow: inset 3px 0 0 #ef4444;
}
table.data tr.stuck-alert:hover td {
  background: rgba(239, 68, 68, 0.14);
}
table.data tr.stuck-alert-yellow td {
  background: rgba(234, 179, 8, 0.10);
  box-shadow: inset 3px 0 0 #eab308;
}
table.data tr.stuck-alert-yellow:hover td {
  background: rgba(234, 179, 8, 0.16);
}
table.data tr.stuck-alert-quiet td {
  background: rgba(139, 155, 184, 0.06);
  box-shadow: inset 3px 0 0 #8b9bb8;
}
table.data tr:last-child td { border-bottom: none; }
.mono { font-family: var(--mono); font-size: 0.84rem; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 0.8rem; margin-top: 3px; line-height: 1.4; }
.cell-fail { color: #ffb4b4; font-size: 0.8rem; margin-top: 4px; max-width: 360px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; white-space: nowrap; }
.empty {
  padding: 36px 16px;
  text-align: center;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: #243140;
  color: #d7e2ea;
  white-space: nowrap;
}
.badge.on, .badge.success { background: rgba(34, 197, 94, 0.15); color: #86efac; }
.badge.off, .badge.fail { background: rgba(248, 113, 113, 0.15); color: #fca5a5; }
.badge.stuck { background: rgba(239, 68, 68, 0.22); color: #fecaca; font-size: 0.68rem; padding: 1px 6px; margin-left: 6px; vertical-align: middle; }
.badge.stuck.yellow { background: rgba(234, 179, 8, 0.22); color: #fde68a; }
.badge.stuck.quiet { background: rgba(139, 155, 184, 0.2); color: #cbd5e1; }
.badge.wait { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.badge.warn { background: rgba(251, 191, 36, 0.15); color: #fde68a; }
.badge.reason { font-weight: 700; }
.stuck-deadline { color: #f87171; font-weight: 600; }
.stuck-deadline.yellow { color: #facc15; }
.stuck-deadline.quiet { color: var(--muted); }
.cd {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 128px;
  padding: 6px 8px 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid #64748b;
}
.cd-pay { border-left-color: #60a5fa; }
.cd-confirm { border-left-color: #fbbf24; }
.cd-top { display: flex; align-items: baseline; gap: 8px; }
.cd-num {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #e8eef4;
}
.cd-pay .cd-num { color: #93c5fd; }
.cd-confirm .cd-num { color: #fde68a; }
.cd-low { border-left-color: #f87171; }
.cd-low .cd-num { color: #fca5a5; }
.cd-done .cd-num { color: #94a3b8; }
.cd-label { font-size: 0.72rem; color: var(--muted); }
.cd-sub { color: var(--muted); font-size: 0.75rem; line-height: 1.35; }
.page-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.page-size input { width: 4.6rem; padding: 6px 8px; }
.point-input { width: 4.6rem; padding: 4px 6px; }
.point-now { display: inline-block; min-width: 5.4rem; margin-right: 6px; font-weight: 700; }
.point-now.own { color: #fde68a; }
#orders table.data th,
#orders table.data td {
  padding: 6px 10px;
  vertical-align: middle;
}
#orders .cell-line {
  line-height: 1.35;
  font-weight: 600;
}
#orders .cell-line .mono { font-weight: 600; }
#orders .cell-amt { font-weight: 600; }
#orders .cell-geo {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}
#orders .cd-line {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  white-space: nowrap;
}
#orders .cd-line .cd-num { font-size: 0.95rem; }
#orders .cd-line .cd-sub { margin: 0; white-space: nowrap; }
.cd-block { margin-bottom: 12px; max-width: 220px; }
.stuck-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}
.stuck-banner.hidden { display: none; }
.stuck-chip {
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.stuck-chip.muted { opacity: 0.55; }
.stuck-chip.yellow {
  border-color: rgba(234, 179, 8, 0.55);
  background: rgba(234, 179, 8, 0.14);
  color: #fde68a;
}
.stuck-chip:hover { background: rgba(239, 68, 68, 0.2); }
.stuck-chip.yellow:hover { background: rgba(234, 179, 8, 0.24); }

.presence {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 12px;
}

/* Modal */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.65);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
  backdrop-filter: blur(4px);
}
.modal {
  width: min(720px, 100%);
  max-height: min(82vh, 900px);
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg-elev);
}
.modal-head h3 { margin: 0; font-size: 1rem; }
.modal-body { padding: 16px; }
.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
  font-size: 0.9rem;
  margin-bottom: 14px;
}
.kv .k { color: var(--muted); }
.kv .v { word-break: break-all; font-family: var(--mono); font-size: 0.84rem; }
.event-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
.pager button[disabled] { opacity: 0.4; cursor: default; }

.region-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.region-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px 10px;
  box-shadow: var(--shadow);
}
.region-card h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.region-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 0.92rem;
  color: var(--text);
  cursor: pointer;
  position: relative;
}
.region-switch input {
  position: absolute;
  opacity: 0;
  width: 46px;
  height: 26px;
  right: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.region-switch .track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: #3a4a63;
  border: 1px solid #4a5d7a;
  position: relative;
  flex: 0 0 auto;
  transition: 0.15s ease;
}
.region-switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e8eef8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  transition: 0.15s ease;
}
.region-switch input:checked + .track {
  background: #22c55e;
  border-color: #16a34a;
}
.region-switch input:checked + .track::after {
  left: 22px;
}
.region-switch input:disabled + .track { opacity: 0.55; }

.ov-board {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px 8px;
  margin-bottom: 14px;
}
.ov-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.ov-top h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}
.ov-when {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.ov-total {
  margin: 18px 0 0;
  font-size: 56px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}
.ov-track {
  display: flex;
  height: 10px;
  margin-top: 22px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-soft);
}
.ov-track .house { background: var(--accent); }
.ov-track .agent { background: #5d6d86; }
.ov-track .empty { flex: 1 1 auto; background: var(--line); }
.ov-money {
  display: flex;
  gap: 16px;
  margin-top: 14px;
}
.ov-money > div { min-width: 0; flex: 1 1 0%; }
.ov-money.split > div:first-child { flex: var(--ov-house) 1 0%; }
.ov-money.split > div:last-child { flex: var(--ov-agent) 1 0%; min-width: 8.5rem; }
.ov-money.house-only > div:first-child { flex: 3 1 0%; }
.ov-money.house-only > div:last-child { flex: 1 1 0%; min-width: 8.5rem; }
.ov-money.agent-only > div:first-child { flex: 1 1 0%; min-width: 8.5rem; }
.ov-money.agent-only > div:last-child { flex: 3 1 0%; }
.ov-board .k { color: var(--muted); font-size: 13px; }
.ov-money .v {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.ov-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 99px;
  margin-right: 6px;
  vertical-align: 1px;
}
.ov-dot.house { background: var(--accent); }
.ov-dot.agent { background: #5d6d86; }
.ov-ops {
  display: grid;
  margin-top: 22px;
  border-top: 1px solid var(--line);
}
.ov-ops.n5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ov-ops.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ov-ops.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ov-ops article {
  min-width: 0;
  padding: 16px 16px 16px 0;
}
.ov-ops article + article {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}
.ov-ops .v {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.ov-board .sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.ov-sums {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
}
.ov-sums article {
  min-width: 0;
  padding: 18px 18px 18px 0;
}
.ov-sums article + article {
  padding-left: 22px;
  border-left: 1px solid var(--line);
}
.ov-sums .v {
  margin-top: 8px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav button { width: auto; }
  .nav .spacer { display: none; }
  .ov-ops.n5 { grid-template-columns: 1fr 1fr; }
  .ov-ops.n5 article { padding: 14px 0; border-left: 0; }
  .ov-ops.n5 article + article { padding-left: 0; border-left: 0; }
  .ov-ops.n5 article:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .ov-total { font-size: 44px; }
}
@media (max-width: 520px) {
  .ov-board { padding: 18px 16px 4px; }
  .ov-money,
  .ov-money.split,
  .ov-money.house-only,
  .ov-money.agent-only { flex-direction: column; }
  .ov-money > div,
  .ov-money.split > div,
  .ov-money.house-only > div,
  .ov-money.agent-only > div { flex: none; width: 100%; min-width: 0; }
  .ov-ops.n5,
  .ov-ops.n3,
  .ov-ops.n2,
  .ov-sums { grid-template-columns: 1fr; }
  .ov-ops article,
  .ov-ops article + article,
  .ov-sums article + article { padding-left: 0; border-left: 0; }
  .ov-ops article + article,
  .ov-sums article + article { border-top: 1px solid var(--line); }
  .ov-total { font-size: 36px; }
}
tr.ledger-sub td:first-child { padding-left: 28px; }
.city-find { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 0.82rem; max-width: 200px; margin: 0 0 12px; }
.city-find input { width: 100%; }
.city-board { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.city-card { border-radius: 8px; padding: 8px 10px; min-width: 0; }
.city-card.on { background: #15243a; border: 1px solid var(--accent); }
.city-card.off { background: #10182a; border: 1px solid var(--line); color: var(--muted); }
.city-card .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.city-card .name { font-weight: 500; overflow-wrap: anywhere; }
.city-card .total { font-variant-numeric: tabular-nums; white-space: nowrap; }
.city-card.on .total { color: var(--text); }
.city-card .sub { margin: 4px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.35; overflow-wrap: anywhere; }
.city-card .who { margin-top: 8px; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.city-card .names { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.city-card .names span { background: var(--bg-elev); color: var(--text); border-radius: 4px; padding: 1px 6px; }
.city-card .names span.empty { color: var(--muted); }
.city-card .names button.chip {
  background: var(--bg-elev); color: var(--text); border: 1px solid transparent;
  border-radius: 4px; padding: 1px 6px; font: inherit; cursor: pointer;
}
.city-card .names button.chip.stop,
.city-card .names span.stop { color: var(--muted); }
.city-card .names button.chip.on {
  background: #1d4ed8;
  color: #fff;
  border-color: #93c5fd;
  box-shadow: 0 0 0 2px #93c5fd;
}
.ask-mask {
  position: fixed; inset: 0; z-index: 80; background: transparent;
}
.city-ask { position: fixed; z-index: 81; width: 240px; padding: 12px; margin: 0; }
.city-ask .who { margin: 6px 0 14px; color: var(--muted); font-size: 0.85rem; }
.city-ask .row { display: flex; justify-content: flex-end; gap: 8px; margin: 0; }
.hq-notes {
  position: fixed; right: 24px; bottom: 24px; z-index: 40;
  width: 280px; display: flex; flex-direction: column; gap: 8px;
}
.hq-note {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 12px 12px 16px; margin: 0;
  background:
    linear-gradient(90deg, rgba(59, 130, 246, 0.22), rgba(59, 130, 246, 0) 46%),
    #141c2e;
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 12px 28px rgba(0, 0, 0, 0.35);
}
.hq-note::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: #60a5fa;
}
.hq-note span { font-size: 0.92rem; color: #b7c6dc; }
.hq-note b { color: #fff; font-weight: 700; }
