:root {
  --bg: #101014;
  --card: #1a1a1f;
  --text: #e8e6e1;
  --ok: #34d399;
  --bad: #f87171;
  --muted: #7c7c84;
  --line: #27272e;
  --inset: #15151a;
  --rail: #0d0d10;
  --chip: #27272e;
  --primary: #6d9fff;
  --on-primary: #0d0d10;
  --hover: rgba(255,255,255,0.04);
  --hold-bg: #1e1412;
  --hold-border: #4a2f2c;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --ease: cubic-bezier(.4,0,.2,1);
}
html[data-theme="light"] {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a1f2e;
  --ok: #16a364;
  --bad: #dc4a4a;
  --muted: #64708a;
  --line: #e4e8f0;
  --inset: #f8f9fc;
  --rail: #ffffff;
  --chip: #e8ecf4;
  --primary: #3b74f6;
  --on-primary: #ffffff;
  --hover: rgba(0,0,0,0.04);
  --hold-bg: #fef2f2;
  --hold-border: #f3b8b4;
}
* { 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: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.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: 5px;
  border: 0;
  border-radius: var(--radius-md);
  min-height: 60px;
  padding: 8px 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: .02em;
}
#rail button svg { width: 20px; height: 20px; opacity: .7; transition: opacity .15s var(--ease); }
#rail button.on svg { opacity: 1; }
#rail button:hover { background: var(--hover); }
#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);
  transition: width .2s var(--ease);
}
.sidebar.drawer-open .nav-drawer {
  width: min(220px, 28vw);
  border-right: 1px solid var(--line);
}
.drawer-panel.open { animation: fade-up .2s var(--ease); }
.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: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.nav-drawer button {
  display: flex;
  align-items: center;
  width: calc(100% - 16px);
  min-height: 40px;
  margin: 0 8px 2px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 450;
  text-align: left;
}
.nav-drawer button { transition: background .15s var(--ease), color .15s var(--ease), transform .1s var(--ease); }
.nav-drawer button:hover { background: var(--hover); transform: translateX(2px); }
.nav-drawer button.on { background: var(--chip); color: var(--text); font-weight: 550; }
.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:
    radial-gradient(ellipse 80% 60% at 20% 80%, color-mix(in srgb, var(--primary) 12%, transparent), transparent),
    radial-gradient(ellipse 60% 50% at 90% 20%, color-mix(in srgb, var(--ok) 8%, transparent), transparent),
    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: 18px; 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: 12px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.brand-hero h1 { margin: 0 0 12px; font-size: 32px; line-height: 1.25; font-weight: 700; }
.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 38%;
  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 6px; font-size: 22px; 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: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); outline: none; }
.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 { opacity: .9; transform: translateY(-1px); box-shadow: 0 4px 12px color-mix(in srgb, var(--primary) 30%, transparent); }
#msg { color: var(--bad); 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 16px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}
#ops .settings, #users-view .settings, .data-board {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
#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: 22px; font-weight: 700; letter-spacing: -.01em; }
#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 button:hover, #users-view button:hover, #password-view button:hover, #channel-view button:hover, #data-page button:hover, #add-sheet button:hover {
  background: color-mix(in srgb, var(--chip), var(--text) 8%);
}
#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 .primary:hover, #users-view .primary:hover, #channel-view .primary:hover, #password-view .primary:hover, #add-sheet .primary:hover, .list-head .primary:hover {
  opacity: .9;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 25%, transparent);
}
#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; flex: none; margin-top: auto; padding-top: 12px; }
.list-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.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: 10px;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--text);
  transition: border-color .15s var(--ease);
}
.row-item:hover { border-color: color-mix(in srgb, var(--line), var(--text) 10%); }
.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: 36px;
  margin-top: 0;
  border: 0;
  color: var(--on-primary);
  font-weight: 600;
  letter-spacing: 0;
  background: var(--primary);
}
.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 { background: var(--ok); }
.toggle input:checked + span::after { transform: translateX(18px); }
.row-error {
  flex: 1 0 100%;
  margin: 0;
  color: var(--bad);
  font-size: 13px;
}
#data-view {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
#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: var(--bad); 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; transition: background .15s var(--ease), color .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease), opacity .15s var(--ease); }
button:active:not(:disabled) { transform: scale(.97); }
.btn-icon { display: inline-flex; align-items: center; gap: 4px; }
.btn-icon svg { flex: none; vertical-align: middle; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--ok);
  outline-offset: 2px;
}
input, select { transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.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: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
h1 { margin: 4px 0 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
#count { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.head-side { display: flex; align-items: center; gap: 8px; }
#theme-toggle {
  position: fixed;
  right: 16px;
  bottom: 56px;
  z-index: 40;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--muted);
  font-size: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
#theme-toggle:hover { color: var(--text); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
.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:hover:not(:disabled) { background: color-mix(in srgb, var(--card), var(--text) 6%); }
.pager button:disabled { opacity: 0.4; cursor: default; }
.chips {
  display: flex;
  gap: 6px;
  overflow: auto;
  padding: 0 16px 8px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  border: 0;
  border-radius: var(--radius-pill);
  min-height: 30px;
  padding: 0 12px;
  background: var(--card);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
}
.chips button:hover:not(.on) { background: color-mix(in srgb, var(--card), var(--text) 6%); }
.chips button.on { background: var(--text); color: var(--bg); font-weight: 600; }
.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(260px, 46vw);
  padding: 3px;
  background: var(--card);
  border-radius: 10px;
}
.tabs button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
}
.tabs button:hover:not(.on) { color: var(--text); }
.tabs button { transition: background .15s var(--ease), color .15s var(--ease); }
.tabs button.on { background: var(--chip); color: var(--text); font-weight: 600; }
.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: var(--radius-md);
  padding: 12px 14px;
  margin: 0 0 6px;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
article.row:hover { background: color-mix(in srgb, var(--card), var(--text) 3%); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
article.row.picked { border-color: var(--line); box-shadow: inset 3px 0 0 var(--ok); }
.row-main { min-width: 0; }
article h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.meta, .bills, .payout, .notice { color: var(--muted); margin: 3px 0 0; font-size: 12px; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.money { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--inset);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.pill.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--inset)); }
.pill.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--inset)); }
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bad);
  display: inline-block;
}
.add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.add:hover { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 4%, transparent); }
.add span { color: var(--ok); font-size: 18px; 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: 22px; font-weight: 700; letter-spacing: -.01em; }
.balance { margin: 0; text-align: right; font-size: 28px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.balance span { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 500; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.hold {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--hold-bg);
  border: 1px solid var(--hold-border);
}
.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: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--chip);
  color: var(--text);
  font-size: 13px;
}
article button:hover, .sheet-card button:hover, #back:hover { background: color-mix(in srgb, var(--chip), var(--text) 8%); }
button.primary { background: var(--primary); color: var(--on-primary); font-weight: 600; }
button.primary:hover { opacity: .9; }
button.danger { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1px var(--hold-border); }
button.danger:hover { background: color-mix(in srgb, var(--bad) 8%, transparent); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); }
#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: var(--radius-md);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  animation: toast-in .25s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
.toast b { display: block; font-size: 13px; font-weight: 600; }
.toast span { color: var(--muted); font-size: 13px; }
#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(440px, 100%);
  margin: 0;
  padding: 20px 18px 18px;
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--hold-border);
  animation: alarm-in .2s var(--ease);
}
@keyframes alarm-in { from { opacity: 0; transform: scale(.96); } }
#alarm h2 { font-size: 20px; font-weight: 700; }
#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: var(--radius-sm);
  padding: 6px 12px;
  background: var(--chip);
  color: var(--muted);
  font-size: 13px;
}
.ledger-tabs button.on { background: var(--ok); color: var(--bg); font-weight: 600; }
.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 var(--line);
  font-size: 13px;
}
.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: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  font-size: 13px;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); outline: none; }
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: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--inset);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: background .15s var(--ease), transform .15s var(--ease);
}
.menu-row:hover { background: color-mix(in srgb, var(--inset), var(--text) 4%); transform: translateX(2px); }
.menu-row em { color: var(--muted); font-style: normal; font-size: 18px; }
.menu-row svg { flex: none; color: var(--muted); }
.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(400px, calc(100% - 32px));
  min-width: 0;
  padding: 22px 20px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
  animation: sheet-in .2s var(--ease);
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade-in { from { opacity: 0; } }
.sheet-card h2 { margin: 0; font-size: 18px; font-weight: 700; }
.hint { margin: 6px 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
#sheet-msg, #add-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(26rem, 92%);
  height: 100%;
  overflow: auto;
  padding: 0 0 28px;
  background: var(--card);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
  animation: drawer-in .2s var(--ease);
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(16px); } }
.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%; }
  #ops, #users-view, #data-page, #channel-view { flex: 1; min-height: 0; overflow: hidden; }
  .page > header { padding: 22px 24px 14px; flex: none; }
  .proxies { padding: 0 24px 12px; flex: none; }
  .layout {
    display: grid;
    grid-template-columns: min(320px, 32%) 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);
  animation: fade-up .2s var(--ease);
}
.setting-card h3 { margin: 0; font-size: 16px; font-weight: 650; }
.role-tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 8px;
  flex-wrap: wrap;
}
.role-tab {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.role-tab:active { transform: scale(.96); }
.role-tab.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 600; }
.role-tab:hover:not(.on) { background: var(--hover); }
.role-tab.role-add { padding: 6px 10px; }
.role-pane { margin-top: 8px; animation: fade-in .2s var(--ease); }
.role-pane.hidden { display: none; }
.role-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.role-name { font-size: 16px; font-weight: 650; }
.role-action {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.role-action:hover { background: var(--hover); color: var(--text); }
.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  transition: background .15s var(--ease);
}
.perm-row:hover { background: color-mix(in srgb, var(--card), var(--text) 3%); }
.perm-row .row-main { flex: 1; font-size: 14px; font-weight: 550; }
.perm-child { padding-left: 32px; }
.perm-child .row-main { font-weight: 450; color: var(--muted); }
.role-select {
  width: auto;
  height: 32px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.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 { transition: box-shadow .15s var(--ease), transform .1s var(--ease); }
#data-page .source-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
#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 {
    min-height: calc(100dvh - 84px);
    padding: 16px 14px 16px;
  }
  #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; }
.issue-card .pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--inset);
  font-size: 11px;
  font-weight: 500;
}
.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; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
