:root {
  --bg: #111111;
  --card: #1c1c1e;
  --text: #f4f1ea;
  --ok: #3ef5a0;
  --bad: #e07a6e;
  --muted: #8e8e93;
  --line: #2c2c2e;
  --inset: #18181a;
  --rail: #0c0c0c;
  --chip: #2c2c2e;
  --primary: #f4f1ea;
  --on-primary: #111111;
}
html[data-theme="light"] {
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1a2438;
  --ok: #1f8f5f;
  --bad: #d4534a;
  --muted: #5a6578;
  --line: #e8ecf3;
  --inset: #f7f9fc;
  --rail: #ffffff;
  --chip: #e8ecf3;
  --primary: #2f6bff;
  --on-primary: #ffffff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
.sidebar {
  flex: none;
  display: flex;
  align-items: stretch;
  min-height: 100%;
  background: var(--rail);
  border-right: 1px solid var(--line);
}
#rail {
  width: 76px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 8px;
  background: var(--rail);
}
#rail button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: 12px;
  min-height: 58px;
  padding: 8px 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}
#rail button svg { width: 22px; height: 22px; }
#rail button.on { background: var(--card); color: var(--text); }
.nav-drawer {
  width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--card);
}
.sidebar.drawer-open .nav-drawer {
  width: min(220px, 28vw);
  border-right: 1px solid var(--line);
}
.drawer-panel { display: none; padding: 8px 0 16px; overflow: auto; }
.drawer-panel.open { display: block; }
.drawer-title {
  padding: 14px 16px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
}
.nav-drawer button {
  display: flex;
  align-items: center;
  width: calc(100% - 16px);
  min-height: 40px;
  margin: 0 8px 8px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.nav-drawer button.on { background: var(--chip); color: var(--text); }
.page { flex: 1; min-width: 0; }
.bill-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.bill-row .bills { margin: 0; }
#password-view .settings { width: 100%; }
.login-page {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}
.brand-side {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  overflow: hidden;
  color: var(--text);
  background: var(--rail);
}
.brand-inner {
  position: relative;
  z-index: 1;
  width: 78%;
  margin: auto;
  padding: 8% 6%;
}
.brand-logo { display: flex; align-items: center; gap: 12px; font-size: 21px; font-weight: 700; }
.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(8, 20, 48, 0.28);
}
.form-logo { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 14px; }
.rail-logo { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 12px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { width: 22px; height: 22px; border-radius: 6px; }
.brand-hero { margin-top: 36px; }
.eyebrow { display: block; margin-bottom: 16px; font-size: 12px; letter-spacing: 0.22em; color: var(--muted); }
.brand-hero h1 { margin: 0 0 14px; font-size: 40px; line-height: 1.25; font-weight: 750; }
.brand-hero p { width: 86%; margin: 0 0 22px; color: var(--muted); font-size: 15px; line-height: 1.7; }
.login-chips { display: flex; gap: 10px; }
.login-chips span {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
}
.form-side {
  flex: 0 1 32%;
  width: auto;
  max-width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.form-card {
  width: min(400px, 100%);
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
.form-head { margin-bottom: 26px; }
.form-logo { display: block; width: 48px; height: 48px; border-radius: 14px; margin-bottom: 14px; }
.form-head h2 { margin: 0 0 8px; font-size: 27px; font-weight: 700; color: var(--text); }
.form-head p { margin: 0; color: var(--muted); font-size: 14px; }
.form-card label, .bind-card label { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; color: var(--muted); font-size: 13px; }
.form-card input, .bind-card input {
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--inset);
  color: var(--text);
  box-shadow: none;
}
.form-card input:focus, .bind-card input:focus { border-color: #2f6bff; outline: 3px solid rgba(47, 107, 255, 0.16); }
.form-card .primary, .bind-card .primary {
  width: 100%;
  height: 48px;
  margin-top: 22px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.08em;
}
.form-card .primary:hover, .bind-card .primary:hover { transform: translateY(-1px); }
#msg { color: #e07a6e; min-height: 1.2em; margin: 12px 0 0; }
.bind-card {
  width: min(24rem, calc(100% - 32px));
  padding: 28px 26px 22px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18);
}
.bind-card h2 { margin: 0 0 8px; font-size: 20px; color: var(--text); }
.bind-card img { display: block; margin: 8px auto 8px; padding: 8px; border-radius: 12px; background: #fff; }
#ops, #users-view, #password-view, #channel-view, #data-page {
  width: 100%;
  min-height: 0;
  padding: 24px 28px 40px;
  background: var(--bg);
  color: var(--text);
}
#ops .settings, #users-view .settings, #channel-view .settings, #data-page .settings, #password-view .settings {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}
#ops h2, #users-view h2, #password-view h2, #channel-view h2, #data-page h2 { margin: 0; color: var(--text); font-size: 26px; font-weight: 700; }
#ops input, #ops select, #users-view input, #password-view input, #channel-view input, #channel-view select, #data-page input, #add-sheet input, #add-sheet select {
  height: 46px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--inset);
  color: var(--text);
}
#ops button, #users-view button, #password-view button, #channel-view button, #data-page button, #add-sheet button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--chip);
  color: var(--text);
}
#ops .primary, #users-view .primary, #channel-view .primary, #password-view .primary, #add-sheet .primary, .list-head .primary {
  width: auto;
  height: 40px;
  margin-top: 0;
  border: 0;
  color: var(--on-primary);
  font-weight: 650;
  background: var(--primary);
}
#ops .hint, #users-view .hint, #password-view .hint, #channel-view .hint, #data-page .hint, #password-msg { color: var(--muted); }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.pager-bar { display: flex; justify-content: flex-end; margin-top: 20px; }
.pager { display: flex; align-items: center; gap: 12px; margin: 0; }
.pager span { min-width: 96px; text-align: center; color: var(--muted); }
.row-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
}
.row-item .row-main {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.row-item .row-main > span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 2px 10px;
  border-radius: 8px;
  background: var(--inset);
}
.proxy-row .row-main { justify-content: space-between; flex-wrap: nowrap; }
.proxy-row .row-main strong { min-width: 0; font-size: 16px; font-weight: 650; }
.proxy-row .row-status {
  flex: none;
  padding: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
}
.row-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}
.row-actions button,
.add-row button,
.row-item > button {
  width: auto;
  flex: none;
  margin-top: 0;
}
.add-row .primary,
.row-actions .primary {
  width: auto;
  height: 40px;
  margin-top: 0;
  border: 0;
  color: #fff;
  font-weight: 650;
  letter-spacing: 0;
  background: linear-gradient(135deg, #6b97ff, #2f6bff);
}
.row-actions .toggle { margin-left: 4px; }
.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
  margin: 0;
}
.toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 26px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.toggle > span {
  display: block;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--chip);
  transition: background 0.15s ease;
}
.toggle > span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
#ops .toggle,
#users-view .toggle {
  width: 44px;
  height: 26px;
}
#ops .toggle input,
#users-view .toggle input {
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
}
.toggle input:checked + span::after { transform: translateX(18px); }
.row-error {
  flex: 1 0 100%;
  margin: 0;
  color: #d4534a;
  font-size: 13px;
}
#data-page { padding: 16px 24px 24px; }
#data-view .row-item button,
#data-view button.pager,
#data-view .pager button { width: auto; flex: none; }
.merchant-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--inset);
  color: var(--text);
}
.merchant-line span { flex: 1; color: var(--text); }
@media (max-width: 860px) {
  .brand-side { display: none; }
  .form-side { flex: 1 1 auto; width: 100%; }
  .form-card { width: 88%; }
  #password-view .settings, .who-side { width: 100%; }
  .layout { display: block; }
}
#bind-msg { color: #e07a6e; min-height: 1.2em; }
.bind-mask {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
}
#msg, #password-msg { color: var(--bad); min-height: 1.2em; }
.merchant-line button { flex: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: 2px;
}
.page > header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 20px 12px;
}
.brand { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h1 { margin: 2px 0 0; font-size: 22px; font-weight: 650; letter-spacing: 0; }
#count { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.head-side { display: flex; align-items: center; gap: 8px; }
#theme-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 40px;
  padding: 0 14px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
}
.pager button {
  border: 0;
  border-radius: 10px;
  min-height: 36px;
  padding: 0 12px;
  background: var(--card);
}
.pager button:disabled { opacity: 0.4; }
.chips {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 0 16px 8px;
}
.chips button {
  border: 0;
  border-radius: 999px;
  min-height: 32px;
  padding: 0 12px;
  background: var(--card);
  white-space: nowrap;
}
.chips button.on { background: var(--text); color: var(--bg); }
.merchant-line { display: flex; gap: 8px; }
.merchant-line button:first-child { flex: 1; text-align: left; }
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(280px, 46vw);
  padding: 3px;
  background: var(--card);
  border-radius: 12px;
}
.tabs button {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  min-height: 36px;
  padding: 0 12px;
}
.tabs button.on { background: var(--chip); color: var(--text); }
.layout { display: block; }
.list { padding: 8px 16px 32px; }
article.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 8px;
}
article.row.picked { border-color: #3a3a3c; box-shadow: inset 3px 0 0 var(--ok); }
.row-main { min-width: 0; }
article h2 { margin: 0; font-size: 17px; font-weight: 640; letter-spacing: 0.01em; }
.meta, .bills, .payout, .notice { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.money { font-size: 16px; font-weight: 650; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--inset);
  color: var(--muted);
  font-size: 12px;
}
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--bad); }
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bad);
  display: inline-block;
}
.add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  border: 1px dashed #3a3a3c;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
}
.add span { color: var(--ok); font-size: 22px; line-height: 1; }
.empty { padding: 28px 8px 12px; }
.empty h2 { margin: 0 0 6px; font-size: 18px; }
.empty p { margin: 0; color: var(--muted); max-width: 28em; }
.detail[hidden], .sheet[hidden], .list[hidden] { display: none; }
.detail { padding: 4px 16px 40px; }
.detail article {
  max-width: none;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 8px 4px 0;
  margin: 0;
}
.who { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.who-side {
  width: 38%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.who-side .balance { margin: 0; text-align: right; }
.who-side .balance strong { display: block; font-size: 28px; line-height: 1.1; }
.proxy-side {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 8px 10px;
  margin: 0;
}
.proxy-side select { width: 100%; height: 36px; border-radius: 10px; }
.proxy-side small { grid-column: 2; color: var(--muted); font-size: 12px; }
.state { margin: 0 0 4px; font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.state.ok { color: var(--ok); }
.state.bad { color: var(--bad); }
.detail h2 { font-size: 28px; }
.balance { margin: 0; text-align: right; font-size: 32px; font-weight: 650; line-height: 1; }
.balance span { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 500; letter-spacing: 0.08em; color: var(--muted); }
.hold {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: #241716;
  border: 1px solid #5c3330;
}
.hold h3 { margin: 0 0 4px; font-size: 16px; }
.hold p { margin: 0; color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions .logs { margin-left: auto; }
.log-box {
  max-height: 360px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 12px;
  background: var(--inset);
  color: var(--text);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}
article button, .sheet-card button, #back {
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text);
}
button.primary { background: var(--primary); color: var(--on-primary); font-weight: 650; }
button.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1px #6a3d38; }
button.ghost { background: transparent; color: var(--muted); }
#back { margin: 0 0 8px; }
#toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(28rem, calc(100% - 24px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 12px 14px;
  border-radius: 14px;
  background: #1c2530;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.toast b { display: block; font-size: 15px; }
.toast span { color: var(--muted); font-size: 14px; }
#alarm[hidden] { display: none; }
#alarm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
}
#alarm article {
  width: min(460px, 100%);
  margin: 0;
  padding: 18px 16px 16px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid #5c3330;
}
#alarm h2 { font-size: 22px; }
#alarm .hint { margin-top: 8px; }
.group { margin-top: 22px; }
.ledger-tabs { display: flex; gap: 8px; margin-top: 10px; }
.ledger-tabs button {
  border: 0;
  border-radius: 10px;
  padding: 6px 12px;
  background: #243040;
  color: var(--muted);
}
.ledger-tabs button.on { background: #1f8f5f; color: #fff; }
.ledger {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.ledger li {
  display: grid;
  grid-template-columns: 92px 72px 42px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid #2a2a2e;
  font-size: 14px;
}
.ledger span, .ledger small { color: var(--muted); }
.ledger small { grid-column: 1 / -1; }
.group h3 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.fields { display: grid; grid-template-columns: 1fr; gap: 10px; }
label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
label small { color: var(--muted); font-size: 12px; line-height: 1.45; }
label.switch {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
input, select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--ok); }
.settings { margin-top: 8px; }
.settings .primary { width: 100%; margin-top: 18px; }
.settings .add-row .primary,
.settings .row-actions button,
.settings .row-item > button {
  width: auto;
  margin-top: 0;
  flex: none;
}
.settings-menu { display: flex; flex-direction: column; gap: 8px; }
.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--inset);
  color: var(--text);
  font-size: 16px;
}
.menu-row em { color: var(--muted); font-style: normal; font-size: 20px; }
.placeholder { max-width: 360px; padding: 48px 12px; color: var(--muted); }
.placeholder strong { display: block; margin-bottom: 6px; color: var(--text); font-size: 18px; font-weight: 640; }
.sheet {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  padding: 24px;
}
.sheet-card {
  width: min(420px, calc(100% - 32px));
  min-width: 0;
  padding: 22px 20px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.sheet-card h2 { margin: 0; font-size: 20px; }
.hint { margin: 8px 0 14px; color: var(--muted); font-size: 14px; }
#sheet-msg { min-height: 1.2em; margin: 8px 0 0; color: var(--bad); }
#drawer {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.45);
}
#drawer[hidden] { display: none; }
.drawer-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
}
.drawer-card {
  position: relative;
  width: min(28rem, 92%);
  height: 100%;
  overflow: auto;
  padding: 0 0 28px;
  background: var(--card);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.35);
}
.drawer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
  margin-bottom: 8px;
  padding: 18px 16px 12px;
  background: var(--card);
}
#drawer-body { padding: 0 16px; }
#drawer input, #drawer select { background: var(--inset); }
#drawer label.switch { background: var(--inset); }
.drawer-bar h2 { margin: 0; font-size: 20px; }
.drawer-bar button {
  border: 0;
  border-radius: 10px;
  min-height: 36px;
  padding: 0 12px;
  background: var(--chip);
}
.drawer-bar button[hidden] { display: none; }
.sheet-card .actions { margin-top: 16px; }
.sheet-card .primary {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  border-radius: 14px;
  font-weight: 650;
}
.sheet-card .ghost { width: 100%; margin-top: 10px; }
.proxies {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px 8px;
}
.proxies article {
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
  cursor: default;
}
.proxies article.on { box-shadow: inset 3px 0 0 var(--ok); }
.proxies article.on em { color: var(--ok); }
.proxies b { display: block; font-size: 13px; }
.proxies span, .proxies em { display: block; color: var(--muted); font-size: 12px; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proxies span:empty { display: none; }
@media (max-width: 720px) {
  .page > header { flex-direction: column; align-items: stretch; padding: 16px 16px 8px; }
  .tabs { width: 100%; }
  .proxies { gap: 6px; padding: 0 12px 8px; }
  .proxies article { padding: 8px; }
  .proxies b, .proxies span, .proxies em { font-size: 11px; }
  .who { align-items: flex-start; }
  .balance { font-size: 28px; }
}
@media (min-width: 900px) {
  .page { display: flex; flex-direction: column; overflow: hidden; height: 100%; }
  .page > header { padding: 22px 24px 14px; flex: none; }
  .proxies { padding: 0 24px 12px; flex: none; }
  .layout {
    display: grid;
    grid-template-columns: 28% minmax(0, 1fr);
    flex: 1;
    min-height: 0;
  }
  .list, .detail { overflow: auto; min-height: 0; }
  .list { border-right: 1px solid var(--line); padding: 8px 16px 24px; }
  .detail { padding: 8px 28px 40px; }
  .detail .fields { grid-template-columns: 1fr 1fr; }
  .detail label.switch, .detail .settings .primary, .detail .notice { grid-column: 1 / -1; }
  .sheet { align-items: center; }
  .sheet-card { border-radius: 18px; }
}
.setting-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
}
.setting-card h3 { margin: 0; font-size: 16px; font-weight: 650; }
.setting-card .fields { display: grid; gap: 12px; }
.setting-card label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
#data-page .source-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 128px;
  height: auto;
  margin: 0;
  padding: 18px;
  border-radius: 16px;
  background: var(--card);
  text-align: left;
}
#data-page .source-card strong { font-size: 18px; font-weight: 700; }
#data-page .source-card span { color: var(--muted); font-size: 14px; line-height: 1.55; }
#data-page .source-card.on { box-shadow: inset 0 0 0 2px var(--ok); }
@media (min-width: 720px) {
  .setting-card[data-id="socket"] .fields { grid-template-columns: minmax(0, 1fr) 140px; }
}
@media (max-width: 899px) {
  body { display: block; padding-bottom: 84px; }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    min-height: 0;
    flex-direction: column;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .rail-logo { display: none; }
  #rail {
    width: 100%;
    flex-direction: row;
    gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  #rail button { flex: 1; min-height: 56px; }
  .nav-drawer {
    display: none;
    width: auto;
    min-height: 0;
    border-right: 0;
  }
  .sidebar.drawer-open .nav-drawer {
    display: flex;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 84px;
    width: auto;
    max-height: min(52vh, 420px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  }
  .page { width: 100%; }
  .page > header { gap: 12px; }
  .head-side, .tabs { width: 100%; }
  .proxies { grid-template-columns: 1fr; gap: 10px; }
  .proxies b, .proxies span, .proxies em { font-size: 13px; white-space: normal; }
  article.row { flex-direction: column; align-items: stretch; gap: 10px; }
  .row-side { flex-direction: row; align-items: center; justify-content: space-between; width: 100%; }
  .who { flex-direction: column; gap: 16px; }
  .who-side { width: 100%; }
  .who-side .balance { text-align: left; }
  .actions button { flex: 1 1 calc(50% - 8px); }
  .pager { width: 100%; justify-content: space-between; }
  #ops, #users-view, #password-view, #channel-view, #data-page { padding: 16px 14px 28px; }
  #theme-toggle { bottom: 96px; }
  .sidebar.drawer-open ~ #theme-toggle { visibility: hidden; }
}
.data-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th,
.data-table td {
  height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.data-table th { color: var(--muted); font-weight: 500; background: var(--inset); }
.data-table tr.row-item { display: table-row; margin: 0; padding: 0; gap: 0; border: 0; background: transparent; }
.data-table td[data-actions] { overflow: visible; text-align: right; }
.data-actions { display: inline-flex; gap: 8px; justify-content: flex-end; border: 0; padding: 0; margin: 0; }
.data-table .data-actions button { min-height: 32px; height: 32px; padding: 0 10px; }
.cell-label { display: none; }
.cell-value { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#data-page .data-table input[type="checkbox"] { width: 18px; height: 18px; margin: 0; padding: 0; }
.data-table th:last-child,
.data-table td[data-actions] { width: 280px; }
.switch-table th:last-child,
.switch-table td[data-actions] { width: 96px; }
.data-empty { padding: 28px 8px; color: var(--muted); }
.subhead { margin: 22px 0 10px; font-size: 14px; font-weight: 650; }
.issue-card { gap: 0; }
.issue-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.issue-id { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.issue-id strong { font-size: 16px; font-weight: 650; }
.issue-site, .issue-desc { margin: 8px 0 0; word-break: break-word; }
.issue-meta { margin: 6px 0 0; color: var(--muted); font-size: 13px; word-break: break-all; }
.issue-id .issue-meta { margin: 0; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--inset);
  font-size: 12px;
}
.pill.bad { color: var(--bad); }
.pill.ok { color: var(--ok); }
.fold { margin-top: 8px; color: var(--muted); font-size: 13px; }
.fold p { margin: 6px 0 0; color: var(--text); word-break: break-all; }
@media (min-width: 900px) {
  .data-more { display: none; }
}
@media (max-width: 899px) {
  .data-scroll { overflow: visible; border: 0; background: transparent; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: auto; }
  .data-table tr.row-item {
    display: block;
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--card);
  }
  .data-table td {
    height: auto;
    max-width: none;
    padding: 2px 0;
    border: 0;
    white-space: normal;
    overflow: visible;
    line-height: 1.4;
  }
  .data-table td[data-extra] { display: none; }
  .data-table tr.open td[data-extra] {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 6px;
  }
  .data-table tr.open td[data-extra] .cell-label { display: inline; color: var(--muted); flex: none; }
  .data-table tr.open td[data-extra] .cell-value {
    min-width: 0;
    text-align: right;
    word-break: break-all;
  }
  .data-table td[data-lead="1"] { font-size: 16px; font-weight: 650; }
  .data-table td[data-lead="2"] { color: var(--muted); font-size: 13px; }
  .data-table td[data-flag-cell] { display: inline-flex; width: auto; margin-right: 12px; align-items: center; gap: 4px; }
  .data-table td[data-flag-cell] .cell-label { display: inline; color: var(--muted); }
  .data-table td[data-actions] {
    display: flex;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  .data-actions { display: flex; flex-wrap: wrap; }
}
