:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --hover: rgba(0, 0, 0, .04);
  --border: rgba(0, 0, 0, .08);
  --border-strong: rgba(0, 0, 0, .15);
  --card-border: rgba(0, 0, 0, .04);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --subtle: #86868b;
  --primary: #007aff;
  --primary-text: #ffffff;
  --focus: rgba(0, 122, 255, .28);
  --green: #34c759;
  --amber: #ff9500;
  --red: #ff3b30;
  --red-soft: rgba(255, 59, 48, .08);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 24px rgba(0, 0, 0, .04);
  --shadow-pop: 0 24px 64px rgba(0, 0, 0, .18), 0 2px 8px rgba(0, 0, 0, .06);
  --overlay: rgba(0, 0, 0, .22);
  --glass: rgba(255, 255, 255, .72);
  --nav-active: rgba(0, 0, 0, .06);
  --seg: rgba(118, 118, 128, .12);
  --seg-on: #ffffff;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 18px;
  --accent: #007aff;
  --accent-2: #30b0c7;
  --accent-soft: rgba(0, 122, 255, .10);
  --map-land: #e8e8ed;
  --map-line: #ffffff;
  --map-1: #bcd7ff;
  --map-2: #7fb3ff;
  --map-3: #2f86ff;
  --chip: rgba(118, 118, 128, .10);
  --tip: rgba(29, 29, 31, .88);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --hover: rgba(255, 255, 255, .06);
    --border: rgba(255, 255, 255, .10); --border-strong: rgba(255, 255, 255, .18); --card-border: rgba(255, 255, 255, .06);
    --text: #f5f5f7; --muted: #98989d; --subtle: #6e6e73; --primary: #0a84ff; --primary-text: #ffffff; --focus: rgba(10, 132, 255, .4);
    --green: #30d158; --amber: #ff9f0a; --red: #ff453a; --red-soft: rgba(255, 69, 58, .14);
    --shadow: none; --shadow-pop: 0 24px 64px rgba(0, 0, 0, .6); --overlay: rgba(0, 0, 0, .45);
    --glass: rgba(28, 28, 30, .72); --nav-active: rgba(255, 255, 255, .08); --seg: rgba(118, 118, 128, .24); --seg-on: #636366;
    --accent: #0a84ff; --accent-2: #40c8e0; --accent-soft: rgba(10, 132, 255, .18);
    --map-land: #2c2c2e; --map-line: #1c1c1e; --map-1: #173a6b; --map-2: #1f5bb3; --map-3: #0a84ff; --chip: rgba(118, 118, 128, .24); --tip: rgba(58, 58, 60, .92);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1c1c1e; --surface-2: #2c2c2e; --hover: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .10); --border-strong: rgba(255, 255, 255, .18); --card-border: rgba(255, 255, 255, .06);
  --text: #f5f5f7; --muted: #98989d; --subtle: #6e6e73; --primary: #0a84ff; --primary-text: #ffffff; --focus: rgba(10, 132, 255, .4);
  --green: #30d158; --amber: #ff9f0a; --red: #ff453a; --red-soft: rgba(255, 69, 58, .14);
  --shadow: none; --shadow-pop: 0 24px 64px rgba(0, 0, 0, .6); --overlay: rgba(0, 0, 0, .45);
  --glass: rgba(28, 28, 30, .72); --nav-active: rgba(255, 255, 255, .08); --seg: rgba(118, 118, 128, .24); --seg-on: #636366;
  --accent: #0a84ff; --accent-2: #40c8e0; --accent-soft: rgba(10, 132, 255, .18);
  --map-land: #2c2c2e; --map-line: #1c1c1e; --map-1: #173a6b; --map-2: #1f5bb3; --map-3: #0a84ff; --chip: rgba(118, 118, 128, .24); --tip: rgba(58, 58, 60, .92);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.47 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
svg { display: block; flex: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.subtle { color: var(--subtle); }
.hidden { display: none !important; }

/* Layout */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 22px 14px; border-right: 1px solid var(--border); background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 26px; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.brand small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 .5px 1px rgba(0, 0, 0, .25)); }
.brand-mark svg { width: 100%; height: 100%; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14.5px;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a.active { background: var(--nav-active); color: var(--text); font-weight: 600; }
.nav a.active svg { color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.side-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--muted); cursor: pointer; text-align: left;
}
.side-btn:hover { background: var(--hover); color: var(--text); }
.side-btn .val { margin-left: auto; color: var(--subtle); font-size: 13px; }

.main { min-width: 0; padding: 32px 40px 56px; max-width: 2200px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; min-height: 40px; }
.page-head h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.025em; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.page-head .spacer { flex: 1; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 14px; }
.card-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.card-head .meta { color: var(--muted); font-size: 13px; }
.card-head.ruled { border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 4px 22px 22px; }
.grid { display: grid; gap: 20px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.stat { padding: 20px 22px 16px; display: flex; flex-direction: column; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat .label { color: var(--muted); font-size: 14px; font-weight: 500; }
.stat .chip { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat .value { font-size: 32px; font-weight: 700; margin-top: 10px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .value small { font-size: 16px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.stat .note { color: var(--muted); font-size: 13px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .spark { margin-top: 12px; height: 40px; }
.stat .spark svg { width: 100%; height: 40px; overflow: visible; }
.two-col { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.dash { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: stretch; margin-bottom: 20px; }
.dash .col { display: grid; gap: 20px; align-content: start; }

/* Lists: every row is at most two lines */
.list { display: flex; flex-direction: column; }
.list-head, .row {
  display: grid; align-items: center; gap: 18px; padding: 0 22px;
}
.list-head {
  min-height: 44px; color: var(--muted); font-size: 12.5px; font-weight: 500;
  border-bottom: 1px solid var(--border); background: transparent;
}
.card > .list-head:first-child { border-radius: var(--r-lg) var(--r-lg) 0 0; }
.row { min-height: 68px; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.row:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }
.row:last-child { border-bottom: 0; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--hover); }
.cell { min-width: 0; }
.l1, .l2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.l1 { font-weight: 500; }
.l2 { color: var(--muted); font-size: 13px; margin-top: 2px; }
.cell.num { font-variant-numeric: tabular-nums; }
.cell.end { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.m-only { display: none; }
.cols-accounts { grid-template-columns: minmax(140px, 1.1fr) minmax(160px, 1.3fr) 180px 190px 72px 60px 36px; }
.cols-exits { grid-template-columns: minmax(170px, 1.3fr) 130px minmax(150px, 1.1fr) 170px 120px 72px 60px 36px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }

/* Status */
.status { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--subtle); flex: none; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 500; margin-right: 4px;
}
.meter { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--text); opacity: .7; }
.meter.warn > span { background: var(--amber); opacity: 1; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 18px;
  border-radius: 980px; border: 0; background: var(--chip); color: var(--text);
  cursor: pointer; font-weight: 500; white-space: nowrap; transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--seg); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.primary:hover { opacity: .9; background: var(--primary); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { opacity: .9; }
.btn.ghost { background: none; color: var(--accent); }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 28px; padding: 0 12px; font-size: 13px; }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); outline: none; transition: box-shadow .15s, border-color .15s, background .15s;
}
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.textarea { height: auto; min-height: 76px; padding: 8px 12px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--focus); }
.search { position: relative; width: 280px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--subtle); }
.search .input { padding-left: 32px; }

.switch { position: relative; display: inline-flex; width: 42px; height: 26px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 26px; background: var(--seg); transition: background .2s; }
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); transition: transform .2s cubic-bezier(.3, .7, .4, 1);
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:disabled + span { opacity: .45; }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Forms in dialogs */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 13px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); }
.error { font-size: 12.5px; color: var(--red); }
.dialog-body > .error { margin: -4px 0 12px; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.field-row .text { min-width: 0; }
.field-row .text .l2 { white-space: normal; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: 9px; background: var(--seg); }
.segmented button { border: 0; background: none; padding: 5px 13px; border-radius: 7px; cursor: pointer; color: var(--text); font-weight: 500; font-size: 13px; }
.segmented button.on { background: var(--seg-on); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .04); }
.notice { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.notice.warn { background: var(--red-soft); color: var(--red); }

/* Dialog */
.dialog-backdrop {
  position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; padding: 16px; z-index: 50;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .15s ease-out;
}
.dialog {
  width: 100%; max-width: 460px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 22px; box-shadow: var(--shadow-pop);
  animation: pop .18s cubic-bezier(.3, .7, .4, 1);
}
.dialog.wide { max-width: 560px; }
.dialog-head { display: flex; align-items: flex-start; gap: 12px; padding: 22px 24px 4px; }
.dialog-head h3 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.015em; }
.dialog-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.dialog-head .icon-btn { margin: -4px -6px 0 auto; }
.dialog-body { padding: 16px 24px 4px; overflow-y: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 24px 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }

.kv { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 16px; }
.kv-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { width: 64px; color: var(--muted); font-size: 13px; flex: none; }
.kv-row .v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code {
  position: relative; padding: 12px 44px 12px 12px; border-radius: var(--r); background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.6;
  white-space: pre-wrap; word-break: break-all; margin-bottom: 16px;
}
.code .icon-btn { position: absolute; top: 6px; right: 6px; }
.pair-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 32px; font-weight: 600; letter-spacing: .18em; text-align: center; padding: 18px 0 6px; }
.pair-exp { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.steps { margin: 0 0 16px; padding-left: 18px; color: var(--muted); font-size: 13px; }
.steps li { margin-bottom: 4px; }

/* Menu */
.menu {
  position: fixed; z-index: 60; min-width: 180px; padding: 5px; background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-pop); animation: fade .1s;
}
.menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px;
  background: none; cursor: pointer; text-align: left; white-space: nowrap;
}
.menu button:hover { background: var(--accent); color: #fff; }
.menu button.danger:hover { background: var(--red); color: #fff; }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* Issues and simple lists */
.issue { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-top: 1px solid var(--border); min-height: 62px; }

.issue .grow { flex: 1; min-width: 0; }
.all-good { display: flex; align-items: center; gap: 10px; padding: 18px 22px 22px; color: var(--muted); }
.simple-row { display: flex; align-items: center; gap: 12px; padding: 11px 22px; border-top: 1px solid var(--border); }
.rank { width: 22px; height: 22px; border-radius: 6px; background: var(--chip); color: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; }
.rank.top { background: var(--accent-soft); color: var(--accent); }
.barline { height: 4px; border-radius: 4px; background: var(--chip); margin-top: 6px; overflow: hidden; }
.barline > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.simple-row .grow { flex: 1; min-width: 0; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding: 8px 0; }
.bars .bar { flex: 1; min-width: 3px; border-radius: 3px 3px 0 0; background: var(--text); opacity: .75; }
.bars .bar.zero { background: var(--border); opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; color: var(--subtle); font-size: 11px; margin-bottom: 16px; }

/* Toasts */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 10px 16px; border-radius: 980px; background: var(--tip); color: #fff;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: var(--shadow-pop); font-size: 13px; animation: pop .14s ease-out; max-width: 90vw;
}
.toast.error { background: var(--red); color: #fff; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 28px; text-align: center; }
.login-brand .brand-mark { width: 64px; height: 64px; border-radius: 16px; }
.login-brand h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -.025em; }
.login-brand p { margin: 4px 0 0; color: var(--muted); }
.login .card { padding: 26px; border-radius: 22px; }
.pw { position: relative; }
.pw .input { padding-right: 40px; }
.pw .icon-btn { position: absolute; right: 3px; top: 3px; }
.login .btn.primary { width: 100%; height: 42px; margin-top: 6px; font-size: 15px; }
.login-foot { margin-top: 18px; display: flex; justify-content: center; gap: 4px; }
.login-foot .btn { color: var(--muted); }

.loading { padding: 40px; text-align: center; color: var(--subtle); }

/* Narrow screens */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .dash { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 4px;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto;
  }
  .brand { padding: 0 6px 0 0; }
  .brand span { display: none; }
  .nav { flex-direction: row; }
  .nav a { padding: 7px 10px; white-space: nowrap; }
  .nav a svg { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; }
  .side-btn { width: auto; padding: 7px; }
  .side-btn .label, .side-btn .val { display: none; }
  .main { padding: 18px 16px 40px; }
  .page-head { flex-wrap: wrap; }
  .search { width: 100%; order: 3; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 24px; }
  .stat { padding: 16px; }
  .donut-wrap { padding: 4px 16px 18px; }
  .card-head { padding: 16px 16px 12px; }
  .chart { padding: 0 12px 14px; }
  .map-wrap { padding: 0 6px 6px; }
  .chart .axis { font-size: 22px; }
  .map-svg text { font-size: 30px; }
  .simple-row, .issue { padding-left: 16px; padding-right: 16px; }
  .list-head { display: none; }
  .row { grid-template-columns: minmax(0, 1fr) auto auto !important; gap: 10px; padding: 10px 14px; }
  .row .d-only { display: none; }
  .m-only { display: block; }
  .fields-2 { grid-template-columns: 1fr; }
  .dialog-backdrop { align-items: end; padding: 0; }
  .dialog { max-width: none !important; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
}

/* Overview visuals */
.map-card { display: flex; flex-direction: column; }
.map-wrap { position: relative; padding: 0 16px 8px; flex: 1; display: flex; align-items: center; }
.map-svg { width: 100%; height: auto; display: block; }
.map-svg .prov { fill: var(--map-land); stroke: var(--map-line); stroke-width: .8; transition: fill .15s; }
.map-svg .prov.l1 { fill: var(--map-1); }
.map-svg .prov.l2 { fill: var(--map-2); }
.map-svg .prov.l3 { fill: var(--map-3); }
.map-svg .prov:hover { fill: var(--accent); opacity: .85; }
.map-svg .dash-line { fill: var(--muted); stroke: var(--muted); stroke-width: 1.2; }
.map-svg .inset-frame { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1; }
.map-svg .dot { stroke: var(--surface); stroke-width: 3; }
.map-svg .dot.green { fill: var(--green); }
.map-svg .dot.amber { fill: var(--amber); }
.map-svg .dot.red { fill: var(--red); }
.map-svg .halo { fill: var(--green); opacity: .25; transform-box: fill-box; transform-origin: center; animation: halo 2.4s ease-out infinite; }
@keyframes halo { from { transform: scale(1); opacity: .35; } to { transform: scale(2.6); opacity: 0; } }
.map-svg text { font-size: 19px; fill: var(--text); font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; pointer-events: none; }
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12.5px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 22px 20px; }
.chip-note { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 8px; background: var(--chip); color: var(--muted); font-size: 12.5px; }
.tooltip {
  position: fixed; z-index: 80; pointer-events: none; padding: 8px 11px; border-radius: 10px; background: var(--tip); color: #fff;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow-pop); white-space: nowrap;
}
.tooltip b { font-weight: 600; }
.chart { position: relative; padding: 0 22px 18px; }
.chart svg { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--subtle); font-size: 11px; }
.chart .area-down { fill: var(--accent); opacity: .12; }
.chart .line-down { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .area-up { fill: var(--accent-2); opacity: .10; }
.chart .line-up { fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-linejoin: round; }
.chart .bar-down { fill: var(--accent); }
.chart .bar-up { fill: var(--accent-2); }
.chart .cursor { stroke: var(--border-strong); stroke-width: 1; }
.chart-empty { padding: 36px 22px 44px; text-align: center; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.legend-dot.down { background: var(--accent); }
.legend-dot.up { background: var(--accent-2); }
.donut-wrap { display: flex; align-items: center; gap: 22px; padding: 6px 22px 22px; }
.donut { width: 132px; height: 132px; flex: none; position: relative; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.donut .center b { display: block; font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.donut .center span { color: var(--muted); font-size: 12px; }
.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.donut-legend div { display: flex; align-items: center; gap: 8px; }
.donut-legend .n { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Exit detail */
.page-head .grow { min-width: 0; }
.back { margin: -6px 0 6px -10px; color: var(--muted); }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; background: var(--chip); font-size: 13px; font-weight: 500; color: var(--muted); }
.pill.green { color: var(--green); }
.pill.red { color: var(--red); }
.inline-switch { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 500; margin-right: 6px; }
.stats6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stats6 .value { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats6 .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.section-head .meta { color: var(--muted); font-size: 13px; }
.charts2 { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 20px; }
.strip-wrap { display: flex; align-items: center; gap: 12px; padding: 0 22px 18px 22px; }
.strip-wrap svg { flex: 1; }
.strip-label { color: var(--muted); font-size: 12.5px; flex: none; width: 56px; }
.strip { flex: 1; min-width: 0; width: 100%; height: 14px; display: block; border-radius: 4px; overflow: hidden; }
.strip-none { fill: var(--chip); }
.strip-on { fill: var(--green); }
.strip-off { fill: var(--red); }
.strip-part { fill: var(--amber); }
.chart .bar-ok { fill: var(--green); }
.chart .bar-fail { fill: var(--red); }
.chart .bar-dns { fill: var(--amber); }
.chart circle.line-down { fill: var(--accent); stroke: none; }
.chart circle.line-up { fill: var(--accent-2); stroke: none; }
.legend-dot.ok { background: var(--green); }
.legend-dot.fail { background: var(--red); }
.legend-dot.dns { background: var(--amber); }
.simple-row.clickable { cursor: pointer; }
.simple-row.clickable:hover { background: var(--hover); }
.nowrap { white-space: nowrap; font-size: 12.5px; }
@media (max-width: 1680px) { .stats6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1180px) { .charts2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .stats6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-head { flex-wrap: wrap; }
  .strip-wrap { padding: 0 12px 14px; }
  .inline-switch { margin-right: 0; }
}

/* Monitoring period controls */
#mon-charts { transition: opacity .15s; }
#mon-charts.is-loading { opacity: .5; pointer-events: none; }
.period-chip { height: 32px; gap: 8px; padding: 0 6px 0 12px; color: var(--text); background: var(--accent-soft); }
.chip-x { width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.chip-x:hover { background: var(--hover); color: var(--text); }
.quick-periods { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chart svg.brushable { cursor: crosshair; }
.chart .brush { fill: var(--accent); opacity: .12; stroke: var(--accent); stroke-opacity: .4; }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--border-strong); }

/* Charts: continuous curves */
.chart .gap-line { stroke-dasharray: 3 4; opacity: .45; }
.chart .line-down, .chart .line-up { stroke-width: 2.2; stroke-linecap: round; }
.row.clickable:hover, .simple-row.clickable:hover { background: var(--hover); }
.code.pre { white-space: pre; word-break: normal; overflow-x: auto; }
.segmented.small button { padding: 3px 10px; font-size: 12.5px; }
.map-svg.world .country { stroke-width: .5; }
.map-svg.world .country.cn { stroke: none; }
.map-svg.world text { font-size: 13px; stroke-width: 3px; }
.usage-card { margin-bottom: 20px; }
.usage-card .kv { margin-bottom: 14px; }
.kv-row .v.wrap { white-space: normal; }
.kv-row .btn.sm { flex: none; }
.api-guide { margin-top: 20px; }
.api-guide p { margin: 0 0 16px; font-size: 13.5px; }
.simple-row .l2.nowrap { flex: none; margin-top: 0; }
.chart .line-client { fill: none; stroke: #af52de; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.chart circle.line-client { fill: #af52de; stroke: none; }
.legend-dot.client { background: #af52de; }
.span2 { grid-column: 1 / -1; }
.span2 > .card { height: 100%; }
.chart .area-client { fill: #af52de; opacity: .1; }
/* Account users: pick one source for monitoring. */
.simple-row.selected, .simple-row.selected:hover { background: var(--accent-soft); }
.simple-row .num.nowrap { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; line-height: 1.3; }
.usage-row { margin-bottom: 20px; align-items: start; }
.usage-row .usage-card { margin-bottom: 0; }
.users-card .simple-row { padding-top: 9px; padding-bottom: 9px; }
.users-card .l1.mono, .users-all .l1.mono { font-size: 13.5px; }
.search.users-search { width: 100%; margin-bottom: 10px; }
.users-search .input { width: 100%; }
.users-all { max-height: 56vh; overflow-y: auto; margin: 0 -24px; }
.users-all .simple-row { padding-left: 24px; padding-right: 24px; }
.btn.picker { gap: 6px; font-variant-numeric: tabular-nums; }
.btn.picker.on { background: var(--accent-soft); color: var(--accent); }
.simple-row .num .subtle { font-size: 11.5px; }
.section-note { margin: -6px 0 14px; color: var(--muted); font-size: 12.5px; }
/* Settings */
.settings-grid { align-items: start; }
.kv-row .k.wide { width: 120px; }
.muted.small { font-size: 12.5px; margin: 4px 0 8px; }
.allow-mine { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); }
.allow-mine .l1 { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.allow-row .ip { width: 190px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.allow-row .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot { padding: 12px 22px 16px; border-top: 1px solid var(--border); }
@media (max-width: 760px) { .allow-row .ip { width: 140px; } .card-foot { padding: 12px 16px; } }
/* Speed test */
.speed-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; transition: opacity .2s; }
.speed-grid.is-loading { opacity: .45; }
.speed-tile { padding: 12px 14px; border-radius: var(--r); background: var(--chip); }
.speed-tile .v { margin-top: 4px; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.speed-tile .v small { font-size: 13px; font-weight: 500; color: var(--muted); }
.speed-status { margin: 10px 0 4px; font-size: 12.5px; }
.speed-history { margin: 6px 0 4px; }
.speed-history-head { margin: 10px 0 4px; }
.speed-row { display: flex; gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); font-size: 13px; font-variant-numeric: tabular-nums; }
.red-text { color: var(--red); }
.speed-sub { display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.page-head .btn svg { margin-right: 4px; }
/* Path quality */
.path-card { margin-bottom: 20px; }
.path-row { display: flex; align-items: flex-start; gap: 0; }
.path-node { flex: none; width: 76px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.path-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--chip); color: var(--text); }
.path-seg { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 18px; }
.path-line { width: 100%; height: 4px; border-radius: 2px; background: var(--border); }
.path-seg.green .path-line { background: var(--green); }
.path-seg.amber .path-line { background: var(--amber); }
.path-seg.red .path-line { background: var(--red); }
.path-text { text-align: center; padding: 0 8px; max-width: 100%; }
.path-text .l1 { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.path-text .l2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.speed-note { grid-column: 1 / -1; font-size: 12.5px; }
.chip-note.sm { height: 20px; padding: 0 6px; font-size: 11.5px; flex: none; }
@media (max-width: 760px) {
  .path-row { flex-direction: column; align-items: stretch; }
  .path-node { flex-direction: row; width: auto; gap: 10px; }
  .path-seg { flex-direction: row; padding: 6px 0 6px 18px; align-items: center; }
  .path-line { width: 4px; height: 44px; flex: none; }
  .path-text { text-align: left; }
}
.ft-section { border-top: 1px solid var(--border); }
.ft-section h2.sm { font-size: 14px; }
.ft-row { gap: 10px; }
.ft-row .mono.grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-hint { margin: 10px 22px 6px; padding: 10px 12px; border-radius: var(--r); background: var(--red-soft, rgba(255, 59, 48, .10)); color: var(--text); font-size: 13px; line-height: 1.5; }
