:root {
  --bg: #F4F5F7; --panel: #FFFFFF; --line: #E6E8EC; --line-soft: #EFF0F3;
  --ink: #0E0F13; --ink-2: #3A3D46; --muted: #6B6F7A;
  --graphite: #16181F; --graphite-2: #23262F; --side-ink: #C9CCD4; --side-muted: #8A8E99;
  --lime: #C8F24B; --lime-soft: #F2FBD6; --lime-ink: #4B6400;
  --good: #1A7F37; --good-soft: #E6F4EA; --warn: #9A5B00; --warn-soft: #FFF3DC; --danger: #C4281C; --danger-soft: #FDECEA;
  --free: #C9CCD4; --unl: #16181F;
  --radius: 14px; --shadow: 0 1px 2px rgba(14, 15, 19, .04), 0 4px 16px rgba(14, 15, 19, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
#app { min-height: 100%; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 4px; font-weight: 750; }
h2 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 12px; } .muted { color: var(--muted); } .small { font-size: 12.5px; } .mono { font-family: var(--mono); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
a { color: var(--ink); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; background: var(--line-soft); min-height: 38px; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; transition: background .15s, border-color .15s, transform .15s; }
button:hover { background: var(--line); }
button.primary { background: var(--graphite); color: #fff; }
button.primary:hover { background: var(--graphite-2); }
button.danger { background: var(--danger); color: #fff; }
button.ghost { background: var(--panel); border-color: var(--line); }
button.ghost:hover { background: var(--bg); }
button.link { background: none; padding: 0; min-height: 0; text-decoration: underline; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--graphite); outline-offset: 2px; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 9px 12px; }
input:focus, textarea:focus { border-color: var(--graphite); outline: none; box-shadow: 0 0 0 3px rgba(22, 24, 31, .08); }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.ic { width: 18px; height: 18px; flex: none; } .ic.sm { width: 14px; height: 14px; }

/* ------------------------------------------------------------ layout */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--graphite); color: var(--side-ink); display: flex; flex-direction: column; padding: 20px 14px; gap: 22px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; }
.brand b { display: block; color: #fff; font-size: 16px; letter-spacing: -.01em; }
.brand span { display: block; font-size: 12px; color: var(--side-muted); }
.brand.login b { color: var(--ink); } .brand.login span { color: var(--muted); } .brand.login { padding: 0; margin-bottom: 4px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav { justify-content: flex-start; width: 100%; background: transparent; color: var(--side-ink); font-weight: 550; padding: 9px 12px; border-radius: 10px; }
.nav:hover { background: rgba(255, 255, 255, .06); }
.nav[aria-current="page"] { background: rgba(200, 242, 75, .12); color: var(--lime); }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.me b { display: block; color: #fff; font-size: 13px; } .me .grow span { display: block; font-size: 12px; color: var(--side-muted); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--lime); color: var(--graphite); font-weight: 800; font-size: 12px; flex: none; }
.avatar.sm { width: 30px; height: 30px; background: var(--graphite); color: var(--lime); }
.avatar.sm.anon { background: var(--line); color: var(--muted); }
.iconbtn { background: transparent; padding: 6px; min-height: 0; border-radius: 8px; color: inherit; }
.side .iconbtn:hover { background: rgba(255, 255, 255, .08); }
.content { padding: 28px 32px 64px; max-width: 1320px; width: 100%; }
.pagehead { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.pagehead p { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; } .stack.lg { gap: 20px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 0; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--graphite); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.cardhead { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; }
.cardhead p { margin: 2px 0 0; }
.big { color: var(--ink); font-size: 13px; }
.narrow { max-width: 420px; margin: 12vh auto 0; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.empty { color: var(--muted); background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; margin: 0; }

/* ------------------------------------------------------------ stats */
.stats4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow); min-height: 132px; font-weight: 400; overflow: hidden; }
.stat.click:hover { border-color: #CDD0D7; background: var(--panel); transform: translateY(-1px); }
.stat-label { display: flex; align-items: center; gap: 6px; width: 100%; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stat-label .go { margin-left: auto; opacity: 0; transition: opacity .15s; }
.stat.click:hover .go { opacity: 1; }
.stat-value { font-size: 30px; line-height: 1.1; letter-spacing: -.03em; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; max-width: 62%; }
.stats4.mini .stat { min-height: 0; padding: 14px 16px; }
.stats4.mini .stat-value { font-size: 22px; }
.stats4.mini .stat-sub { max-width: none; }
.spark { position: absolute; right: 14px; bottom: 14px; width: 38%; height: 40px; }
.spark-line { fill: none; stroke: var(--graphite); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.spark-fill { fill: var(--lime); opacity: .35; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 12px; border-radius: 999px; padding: 1px 7px 1px 5px; }
.delta.up { color: var(--good); background: var(--good-soft); }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--muted); background: var(--line-soft); padding-left: 7px; }

/* ------------------------------------------------------------ controls */
.seg { display: inline-flex; background: var(--line-soft); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: transparent; min-height: 30px; padding: 4px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(14, 15, 19, .1); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 30px; padding: 4px 12px; border-radius: 999px; background: var(--panel); border-color: var(--line); font-size: 13px; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--graphite); border-color: var(--graphite); color: #fff; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.searchbox { position: relative; flex: 1 1 280px; max-width: 420px; margin: 0; color: var(--muted); }
.searchbox .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); }
.searchbox input { padding-left: 36px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 12px; flex-wrap: wrap; }

/* ------------------------------------------------------------ charts */
.areachart { position: relative; }
.areachart svg { width: 100%; height: auto; display: block; overflow: visible; }
.areachart .grid { stroke: var(--line-soft); stroke-width: 1; }
.areachart .axis { stroke: var(--line); stroke-width: 1; }
.areachart .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.area-line { fill: none; stroke: var(--graphite); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.cross, .dot { transition: none; } .areachart:not(.hover) .cross, .areachart:not(.hover) .dot { visibility: hidden; }
.cross { stroke: var(--graphite); stroke-width: 1; stroke-dasharray: 3 3; opacity: .5; }
.dot { fill: var(--lime); stroke: var(--graphite); stroke-width: 2; }
.tip { position: absolute; transform: translate(-50%, calc(-100% - 14px)); background: var(--graphite); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 12px; pointer-events: none; white-space: nowrap; display: flex; flex-direction: column; box-shadow: 0 6px 18px rgba(14, 15, 19, .2); }
.tip[hidden] { display: none; }
.tip span { color: var(--side-muted); font-size: 11px; }
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 34%) minmax(0, 1fr) auto; gap: 10px; align-items: center; background: transparent; border: 0; border-radius: 8px; padding: 6px 4px; min-height: 0; font-weight: 400; text-align: left; width: 100%; }
button.hbar:hover { background: var(--bg); }
.hbar .lbl { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 10px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--graphite); border-radius: 999px; }
.hbar .val { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; min-width: 56px; }
.hbar .val small { color: var(--muted); font-weight: 500; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.key.free { background: var(--free); } .key.unl { background: var(--unl); }
.planbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; gap: 2px; background: var(--panel); margin: 4px 0 12px; }
.planbar span { flex: 0 0 auto; min-width: 0; } .planbar .free { background: var(--free); } .planbar .unl { background: var(--unl); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-2); margin-bottom: 16px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.kv { grid-template-columns: 1fr auto; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.kv dd { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ health */
.health { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.health li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.health li:last-child { border-bottom: 0; }
.health b { display: block; font-size: 13.5px; } .health .num { font-size: 16px; font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 8px; min-width: 62px; justify-content: center; }
.status.ok { color: var(--good); background: var(--good-soft); }
.status.warn { color: var(--warn); background: var(--warn-soft); }
.status.info { color: var(--ink-2); background: var(--line-soft); }

/* ------------------------------------------------------------ tables */
.tablewrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 650; border-bottom-color: var(--line); white-space: nowrap; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--bg); }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.who > div > span { display: block; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 650; background: var(--line-soft); color: var(--ink-2); white-space: nowrap; }
.badge.lime { background: var(--lime); color: var(--graphite); }
.badge.green { background: var(--good-soft); color: var(--good); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }

/* ------------------------------------------------------------ misc */
.error { color: var(--danger); font-weight: 600; }
.notice { background: var(--lime); border-radius: 10px; padding: 10px 14px; color: var(--graphite); }
dialog { border: 0; border-radius: var(--radius); padding: 24px; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 24px 64px rgba(14, 15, 19, .25); }
dialog::backdrop { background: rgba(14, 15, 19, .45); backdrop-filter: blur(2px); }
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; max-width: 760px; width: min(760px, 100%); border-radius: 0; padding: 0; display: flex; flex-direction: column; }
dialog.drawer:not([open]) { display: none; }
.drawer-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.drawer-body { padding: 20px 24px 40px; overflow-y: auto; flex: 1; }
.drawer-body .card { box-shadow: none; border: 0; padding: 0; }
.qr { width: 200px; height: 200px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--line-soft); border-radius: 6px; padding: 2px 6px; word-break: break-all; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dt { color: var(--muted); font-size: 13px; } dd { margin: 0; }
body > .card.narrow, #app > .card.narrow { padding: 28px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1180px) {
  .stats4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px; }
  .brand div { display: none; }
  .side nav { flex-direction: row; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  .nav { width: auto; white-space: nowrap; padding: 8px 10px; }
  .nav .ic { display: none; }
  .me { border-top: 0; padding: 0; }
  .me .grow, .me .avatar { display: none; }
  .content { padding: 20px 16px 48px; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .stats4 { grid-template-columns: minmax(0, 1fr); }
  .stat-sub { max-width: 60%; }
  h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
