:root {
  --ink: #191c2b;
  --ink-soft: #343a52;
  --muted: #7b8197;
  --faint: #a2a8b9;
  --line: #e4e7f0;
  --line-strong: #d5d9e6;
  --paper: #f4f5f9;
  --card: #ffffff;
  --indigo: #4f5fe7;
  --indigo-deep: #3d4bd0;
  --indigo-soft: #eef0ff;
  --navy: #121528;
  --navy-soft: #1a1e35;
  --green: #2d956d;
  --green-soft: #e8f6f0;
  --orange: #bb763b;
  --orange-soft: #fcf2e8;
  --red: #b95757;
  --red-soft: #faeded;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(25, 28, 43, .03), 0 10px 30px rgba(25, 28, 43, .035);
  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Code", "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--indigo-deep); text-decoration: none; }
code, .mono { font-family: var(--mono); }
h1, h2, h3, h4, p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 18px; height: 18px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Brand & buttons ---------- */
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; font-size: 21px; font-weight: 650; letter-spacing: -.03em; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px;
  color: #fff; font: 700 18px/1 var(--font);
  background: linear-gradient(145deg, #7683ef, #4352d4 62%, #2d378f);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.32), 0 6px 16px rgba(57,70,193,.24);
}
.brand-light { font-weight: 320; opacity: .92; }
.brand sup { font-size: 9px; margin-left: 2px; opacity: .55; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink-soft);
  font-weight: 550; font-size: 13px; white-space: nowrap;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
}
.button:hover { border-color: #bfc5d8; background: #fbfbfe; }
.button:active { transform: translateY(1px); }
.button:disabled { opacity: .55; cursor: wait; }
.button.primary {
  border-color: var(--indigo); color: #fff;
  background: linear-gradient(180deg, #5c6aeb, #4b59dc);
  box-shadow: 0 3px 10px rgba(79,95,231,.22), inset 0 1px 0 rgba(255,255,255,.2);
}
.button.primary:hover { background: linear-gradient(180deg, #6673ee, #4250d5); border-color: #4250d5; }
.button.subtle { background: transparent; }
.button.small { min-height: 31px; padding: 0 10px; font-size: 12px; }
.button .icon { width: 15px; height: 15px; }
.icon-button {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  color: var(--muted); font-size: 20px; line-height: 1;
}
.icon-button:hover { color: var(--ink); border-color: var(--line-strong); }
.text-button {
  border: 0; background: none; padding: 1px 0; color: var(--indigo-deep);
  font-size: 12px; font-weight: 550; border-bottom: 1px solid transparent;
}
.text-button:hover { border-bottom-color: currentColor; }
.text-button:disabled { color: var(--faint); cursor: wait; }

.eyebrow {
  font-size: 10px; font-weight: 650; letter-spacing: .15em; line-height: 1.4;
  color: #8b91ab; text-transform: uppercase;
}
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px;
  background: #f8f9fc; color: var(--muted);
  font-size: 10.5px; font-weight: 550; line-height: 1.6; white-space: nowrap;
}
.badge.green { color: #247c5b; background: var(--green-soft); border-color: #cdeadd; }
.badge.orange { color: #a56630; background: var(--orange-soft); border-color: #f0ddc8; }
.badge.red { color: #a74b4b; background: var(--red-soft); border-color: #f0d3d3; }
.badge.blue { color: var(--indigo-deep); background: var(--indigo-soft); border-color: #dce0fd; }
.tiny-dot { width: 5px; height: 5px; border-radius: 50%; background: #43a47d; display: inline-block; flex: 0 0 auto; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(390px, .92fr);
  background: #fff;
}
.login-story {
  position: relative; overflow: hidden; min-height: 100vh;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 54px 30px;
  background:
    radial-gradient(ellipse 52% 44% at 72% 33%, rgba(92, 106, 235, .28), transparent 68%),
    radial-gradient(ellipse 40% 44% at 10% 88%, rgba(80, 155, 204, .14), transparent 65%),
    linear-gradient(150deg, #171b34 0%, #111426 52%, #0d1020 100%);
  color: #f2f3fa;
}
.login-story::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 58px 58px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.65), transparent 78%);
}
.login-story > * { position: relative; z-index: 1; }
.login-story .brand { color: #fff; }
.login-copy { max-width: 560px; margin: auto 0; padding: 42px 0; }
.login-copy .eyebrow { color: #99a2c7; margin-bottom: 20px; }
.login-copy h1 {
  font-size: clamp(42px, 5vw, 68px); font-weight: 560; line-height: 1.11;
  letter-spacing: -.055em; margin-bottom: 24px;
}
.login-copy p { color: #aeb6d0; font-size: 15px; line-height: 1.85; }
.endpoint-stack { margin-top: 38px; display: grid; gap: 7px; max-width: 390px; }
.endpoint-chip {
  display: flex; align-items: center; gap: 11px;
  height: 38px; padding: 0 12px;
  border: 1px solid rgba(255,255,255,.09); border-radius: 7px;
  background: rgba(255,255,255,.035); backdrop-filter: blur(6px);
  color: #c6ccdf; font-size: 12px;
  animation: rise .6s both;
}
.endpoint-chip:nth-child(2) { animation-delay: .06s; }
.endpoint-chip:nth-child(3) { animation-delay: .12s; }
.endpoint-chip:nth-child(4) { animation-delay: .18s; }
.endpoint-chip code { font-size: 11.5px; letter-spacing: -.01em; }
.endpoint-chip .method { color: #8f9ad4; font: 600 9px/1 var(--mono); letter-spacing: .08em; }
.signal { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: #65bd97; box-shadow: 0 0 0 3px rgba(101,189,151,.12); }
.login-foot { display: flex; gap: 22px; color: #7e87a8; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.login-panel {
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  position: relative; padding: 48px 42px;
  background: linear-gradient(180deg, #fff, #fbfbfd);
}
.login-panel form { width: 100%; max-width: 348px; }
.login-badge {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%;
  background: var(--indigo-soft); color: var(--indigo); margin-bottom: 24px;
}
.login-badge .icon { width: 20px; height: 20px; }
.login-panel h2 { font-size: 28px; letter-spacing: -.035em; font-weight: 600; margin: 9px 0 4px; }
.login-panel form > p.muted { font-size: 13px; margin-bottom: 28px; }
.login-panel label { display: block; font-size: 12px; font-weight: 600; margin: 0 0 7px; color: var(--ink-soft); }
.login-submit { width: 100%; margin-top: 4px; min-height: 43px; }
.login-note { margin-top: 17px !important; color: var(--faint); font-size: 10.5px !important; text-align: center; }
.login-powered { position: absolute; bottom: 26px; color: #b4b9c9; font: 600 8.5px/1 var(--font); letter-spacing: .13em; }
.form-error { color: var(--red); font-size: 12px; min-height: 19px; margin-top: 8px; }

/* ---------- Shell ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: 238px;
  display: flex; flex-direction: column; padding: 26px 16px 18px;
  background:
    radial-gradient(ellipse 90% 42% at 22% 0%, rgba(88,101,224,.13), transparent 70%),
    #111424;
  color: #d9dcea; border-right: 1px solid rgba(255,255,255,.055);
}
.sidebar .brand { padding: 0 10px; margin-bottom: 26px; }
.workspace {
  display: flex; align-items: center; gap: 9px; margin: 0 3px 26px;
  padding: 9px 10px; border: 1px solid rgba(255,255,255,.07); border-radius: 9px;
  background: rgba(255,255,255,.035);
}
.workspace-avatar { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 7px; background: #272c4c; color: #aeb7ff; font-size: 12px; font-weight: 650; }
.workspace div { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.workspace strong { font-size: 11.5px; font-weight: 560; color: #eceefa; white-space: nowrap; }
.workspace small { font-size: 9.5px; color: #737b9d; }
.workspace .tiny-dot { margin-left: auto; width: 4px; height: 4px; }
.nav-label { padding: 0 13px; margin: 0 0 7px; color: #626a8c; font-size: 8.5px; font-weight: 650; letter-spacing: .16em; }
.second-label { margin-top: 22px; }
.sidebar nav { display: grid; gap: 2px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 12px;
  border-radius: 7px; color: #8f96b3; font-size: 12px; font-weight: 480;
  transition: color .15s, background .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.045); color: #d7dbeb; }
.sidebar nav a.active { background: rgba(105,118,236,.16); color: #eef0ff; box-shadow: inset 2px 0 0 #7180ea; }
.sidebar nav a .icon { width: 16px; height: 16px; opacity: .82; }
.nav-hint { margin-left: auto; color: #5b6382; font: 500 9px/1 var(--mono); letter-spacing: .02em; }
.count { margin-left: auto; min-width: 19px; padding: 1px 5px; border-radius: 4px; background: rgba(255,255,255,.07); color: #aab0ca; font: 550 9px/1.6 var(--mono); text-align: center; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 9px; }
.edge-card {
  display: flex; align-items: center; gap: 8px; padding: 10px;
  border: 1px solid rgba(255,255,255,.06); border-radius: 8px; background: rgba(255,255,255,.022);
}
.edge-icon { color: #8994e5; font-size: 13px; }
.edge-card div { display: flex; flex-direction: column; line-height: 1.35; }
.edge-card strong { color: #cbd0e2; font-size: 10px; font-weight: 560; }
.edge-card small { color: #687092; font-size: 9px; }
.edge-card .tiny-dot { margin-left: auto; width: 4px; height: 4px; }
.account {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px;
  border: 0; border-radius: 7px; background: transparent; color: #9da4c0; text-align: left;
}
.account:hover { background: rgba(255,255,255,.04); }
.account > span:nth-child(2) { display: flex; flex-direction: column; line-height: 1.35; }
.account strong { font-size: 10.5px; font-weight: 560; color: #d5d9e9; }
.account small { font-size: 9px; color: #69718f; }
.account .icon { margin-left: auto; width: 14px; height: 14px; opacity: .55; }
.avatar { width: 27px; height: 27px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: #303657; color: #c5cbff; font-size: 10px; font-weight: 650; }
.avatar.small { width: 25px; height: 25px; }

.main-shell { margin-left: 238px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 57px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 0 38px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.78); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 25;
}
.topbar > div { display: flex; align-items: center; gap: 9px; font-size: 11px; color: var(--faint); }
.topbar .slash { color: #ccd0db; }
#breadcrumb-current { color: var(--ink-soft); font-weight: 550; }
.topbar-right { gap: 13px !important; }
.connection { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; color: var(--muted); }
.topbar-divider { width: 1px; height: 16px; background: var(--line); }
main { width: 100%; max-width: 1440px; margin: 0 auto; padding: 32px 38px 20px; flex: 1; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 27px; }
.page-heading .eyebrow { margin-bottom: 9px; }
.page-heading h1 { font-size: 30px; font-weight: 570; letter-spacing: -.045em; line-height: 1.2; }
.heading-dot { color: var(--indigo); }
.page-heading p { color: var(--muted); font-size: 12.5px; margin-top: 7px; }
.heading-actions { display: flex; align-items: center; gap: 8px; padding-bottom: 2px; }
#view-content { min-height: 300px; }
.main-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  padding: 26px 0 6px; color: var(--faint); font-size: 10px;
}
.footer-dot { padding: 0 4px; color: #c8ccd8; }
.loading { padding: 70px 0; color: var(--muted); text-align: center; font-size: 12px; }

/* ---------- Common panels ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 19px 20px;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-head h3, .form-panel h3 { font-size: 13.5px; font-weight: 620; letter-spacing: -.012em; }
.panel-head p, .form-panel > p { color: var(--muted); font-size: 11px; margin-top: 3px; }
.panel-head .badge { flex: 0 0 auto; }
.panel-head + .panel-head { margin-top: -4px; margin-bottom: 9px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .8fr); gap: 14px; margin-bottom: 14px; }
.notice {
  display: block; padding: 11px 13px; margin-bottom: 14px;
  border: 1px solid #dfe3f5; border-radius: var(--radius-sm);
  background: #f7f8ff; color: #646b88; font-size: 11px; line-height: 1.65;
}
.notice strong { color: var(--ink-soft); }
.notice.danger { background: var(--red-soft); border-color: #f0d6d6; color: #955252; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 26px; height: 26px; color: #b2b8ca; margin-bottom: 10px; }
.empty div { font-size: 12.5px; color: var(--ink-soft); font-weight: 550; }
.empty p { font-size: 11px; margin-top: 4px; }

/* ---------- Overview ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; margin-bottom: 14px; }
.stat-card {
  position: relative; overflow: hidden; min-height: 118px; padding: 16px 17px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.stat-card::after {
  content: ""; position: absolute; width: 110px; height: 110px; right: -51px; top: -53px;
  border-radius: 50%; background: radial-gradient(circle, rgba(98,112,232,.08), transparent 68%);
}
.stat-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10.5px; }
.stat-label .icon { width: 14px; height: 14px; color: #a7adc1; }
.stat-value { font-size: 30px; font-weight: 555; letter-spacing: -.04em; line-height: 1.25; margin-top: 7px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 450; color: var(--faint); letter-spacing: 0; margin-left: 4px; }
.stat-note { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; margin-top: 6px; font-size: 9.5px; color: var(--faint); min-height: 15px; }
.stat-note .highlight { color: #4c8f73; }
.stat-progress { width: 100%; margin: 6px 0 0; }
.stat-progress .quota-track { height: 4px; }

.legend { display: flex; align-items: center; flex-wrap: wrap; gap: 13px; color: var(--muted); font-size: 9.5px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i, .tip-key { width: 6px; height: 6px; border-radius: 2px; display: inline-block; }
.text-color { background: #4f6df5 !important; }
.image-color { background: #e0663d !important; }
.voice-color { background: #18a37a !important; }
.modules-color { background: #d0a020 !important; }
.period-pill { padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--faint); font-size: 9.5px; }
.chart-wrap { position: relative; min-height: 186px; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font: 9.5px var(--font); fill: #989fb3; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: #eef0f5; stroke-width: 1; }
.chart .baseline { stroke: #dfe3ec; stroke-width: 1; }
.chart .chart-total { font-size: 9px; font-weight: 600; fill: #7a8199; }
.chart-hit { fill: transparent; cursor: crosshair; outline: none; }
.chart-hit:hover, .chart-hit:focus { fill: rgba(79,95,231,.045); }
.chart-note { color: var(--faint); font-size: 9.5px; border-top: 1px dashed var(--line); padding-top: 9px; margin-top: 7px; }
.chart-tooltip {
  position: absolute; top: 5px; right: 8px; z-index: 5; width: 166px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.97);
  box-shadow: 0 8px 24px rgba(25,28,43,.09); pointer-events: none;
}
.tip-date { font: 600 9px/1.4 var(--mono); color: var(--muted); margin-bottom: 6px; }
.tip-row { display: flex; align-items: center; gap: 6px; font-size: 9.5px; padding: 1.5px 0; }
.tip-name { color: var(--muted); }
.tip-value { margin-left: auto; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.tip-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px; }
.tip-total .tip-name { color: var(--ink-soft); font-weight: 550; }
.chart-data { margin-top: 8px; }
.chart-data summary { cursor: pointer; color: var(--faint); font-size: 9.5px; }
.chart-data[open] summary { margin-bottom: 7px; }
.chart-data table { font-size: 10px; }
.chart-data th, .chart-data td { padding: 5px 7px; }

.routing { display: grid; gap: 2px; }
.route-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid #f0f2f7; }
.route-row:last-child { border-bottom: 0; }
.route-row > div { min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.route-row strong { font-size: 11px; font-weight: 550; }
.route-row small { color: var(--faint); font: 9px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-row .badge { margin-left: auto; flex: 0 0 auto; }
.service-icon {
  width: 25px; height: 25px; flex: 0 0 auto; display: grid; place-items: center;
  border-radius: 7px; font: 600 11px/1 var(--font);
}
.service-icon.text { color: #4f6df5; background: #eef1ff; }
.service-icon.image { color: #d5673e; background: #fdf0e9; }
.service-icon.voice { color: #168867; background: #e9f7f2; }
.service-icon.modules { color: #b58917; background: #fbf5e3; }
.upstream-note {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 13px; padding-top: 11px;
  border-top: 1px dashed var(--line); color: var(--faint); font-size: 8.5px;
}
.upstream-note .icon { width: 12px; height: 12px; }
.upstream-note .mono { color: #858ca4; font-size: 8.5px; }
.connection-banner {
  display: flex; align-items: center; gap: 14px; margin-top: 14px; padding: 15px 18px;
  border: 1px solid #dde1f7; border-radius: var(--radius);
  background:
    radial-gradient(ellipse 28% 140% at 87% 50%, rgba(111,124,238,.11), transparent 70%),
    linear-gradient(100deg, #f8f9ff, #f2f4ff);
}
.connection-banner > .icon { width: 20px; height: 20px; color: #7380d9; flex: 0 0 auto; }
.connection-banner div { min-width: 0; }
.connection-banner strong { font-size: 12px; font-weight: 580; }
.connection-banner p { color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.connection-banner .button { margin-left: auto; background: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; }
table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
th {
  padding: 8px 10px; text-align: left; white-space: nowrap;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: #fafbfd; color: #8b91a6;
  font-size: 8.5px; font-weight: 650; letter-spacing: .045em; text-transform: uppercase;
}
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
td { padding: 11px 10px; border-bottom: 1px solid #eff1f6; vertical-align: middle; color: var(--ink-soft); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfcfe; }
.name-cell { display: flex; align-items: center; gap: 8px; min-width: 132px; }
.name-cell > div { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.name-cell strong { font-size: 11px; font-weight: 560; color: var(--ink); white-space: nowrap; }
.name-cell small { font-size: 8.5px; color: var(--faint); white-space: nowrap; }
.key-avatar { width: 26px; height: 26px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; background: #f0f2f9; color: #8790ad; }
.key-avatar .icon { width: 13px; height: 13px; }
.cell-sub { margin-top: 4px; }
.region-pill { font: 8.5px var(--mono); color: var(--faint); }
.table-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.table-foot { display: flex; justify-content: space-between; gap: 14px; padding-top: 12px; color: var(--faint); font-size: 9px; }
.quota-cell { min-width: 144px; display: grid; gap: 4px; }
.quota-line { display: flex; align-items: center; gap: 6px; }
.quota-line .label { width: 24px; flex: 0 0 auto; color: var(--faint); font: 7.5px var(--mono); letter-spacing: .04em; }
.quota-line .pct { min-width: 25px; text-align: right; color: #7c8399; font: 8px var(--mono); }
.quota-track { width: 100%; height: 4px; max-width: 80px; }
.quota-empty { color: var(--faint); font-size: 9px; }
.quota-sync { color: var(--faint); font-size: 8.5px; line-height: 1.5; }
.quota-sync .text-button { font-size: 8.5px; margin-left: 2px; }
.quota-error { color: #b26e6e; font-size: 8.5px; margin-top: 3px; }
.scopes { display: flex; flex-wrap: wrap; gap: 3px; min-width: 95px; }
.scope { padding: 1px 5px; border-radius: 4px; background: #f1f3f9; color: #6f7791; font-size: 8.5px; }
.path-text { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 8.5px; }
.filters { display: flex; gap: 7px; margin-bottom: 3px; }
.filters input { flex: 1; min-width: 0; }
.filters select { width: 138px; flex: 0 0 auto; }

/* ---------- Forms & settings ---------- */
input, select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px;
  border: 1px solid var(--line-strong); border-radius: 7px;
  background: #fff; color: var(--ink); font-size: 12px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: #98a2ea; box-shadow: 0 0 0 3px rgba(79,95,231,.1); }
input[readonly] { background: #f7f8fb; color: var(--muted); }
label { display: block; margin-bottom: 6px; color: var(--ink-soft); font-size: 11px; font-weight: 560; }
input + label, select + label, textarea + label, .two-cols + label, .checkboxes + label { margin-top: 14px; }
.form-help { color: var(--faint); font-size: 9.5px; line-height: 1.6; margin-top: 4px; }
.form-help code { color: #6d7490; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.two-cols label { margin-top: 0; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 19px; padding-top: 15px; border-top: 1px solid var(--line); }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.form-panel h3 { margin-bottom: 2px; }
.form-panel > p { margin-bottom: 17px; }
.form-panel > label:first-of-type { margin-top: 0; }
.form-panel input + .form-help { margin-bottom: 13px; }
.form-panel textarea + .form-help { margin-bottom: 13px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 4px 0 15px; margin-bottom: 14px; border-bottom: 1px solid #f0f2f7; }
.setting-row label { margin: 0; font-size: 11.5px; }
.setting-row p { color: var(--faint); font-size: 9.5px; margin-top: 2px; }
.setting-row + label { margin-top: 0; }
.switch { position: relative; width: 36px; height: 20px; flex: 0 0 auto; margin: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 20px; background: #d9dde8; transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform .2s; }
.switch input:checked + span { background: var(--indigo); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(79,95,231,.2); }
.switch input:disabled + span { opacity: .55; }
.checkboxes { display: flex; flex-wrap: wrap; gap: 6px; margin: 1px 0 0; }
.checkboxes label {
  display: inline-flex; align-items: center; gap: 5px; margin: 0; padding: 6px 9px;
  border: 1px solid var(--line); border-radius: 6px; background: #fbfbfd;
  color: var(--muted); font-size: 10.5px; font-weight: 480; cursor: pointer;
}
.checkboxes label:has(input:checked) { border-color: #c9cef6; background: var(--indigo-soft); color: var(--indigo-deep); }
.checkboxes input { width: 13px; height: 13px; min-height: 0; margin: 0; padding: 0; accent-color: var(--indigo); }
.upstream-list { display: grid; gap: 5px; margin-top: 2px; }
.upstream-list div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 9px; border-radius: 6px; background: #f8f9fc; }
.upstream-list span { color: var(--muted); font-size: 9.5px; }
.upstream-list code { color: #626b8a; font-size: 9px; word-break: break-all; text-align: right; }

/* ---------- Docs ---------- */
.docs-grid { display: grid; grid-template-columns: minmax(0, 1.42fr) minmax(310px, .88fr); gap: 14px; align-items: start; }
.docs-content h3 { font-size: 13.5px; font-weight: 620; letter-spacing: -.012em; margin: 3px 0 8px; display: flex; align-items: center; gap: 8px; }
.docs-content h3:not(:first-child) { margin-top: 27px; }
.docs-content p { color: var(--muted); font-size: 11px; line-height: 1.75; margin-bottom: 10px; }
.docs-content p code, .docs-content .notice code { padding: 1px 4px; border-radius: 3px; background: #f1f3f9; color: #5d6580; font-size: 9.5px; }
.step-number {
  width: 19px; height: 19px; display: inline-grid; place-items: center; flex: 0 0 auto;
  border-radius: 50%; background: var(--indigo-soft); color: var(--indigo-deep);
  font: 600 9px/1 var(--mono);
}
.sdk-heading { margin-top: 25px !important; }
.sdk-card { padding: 13px; margin: 11px 0 0; border: 1px solid var(--line); border-radius: 9px; background: #fcfcfe; }
.sdk-card h4 { font-size: 11px; font-weight: 600; margin-bottom: 4px; }
.sdk-card p { font-size: 10px; margin-bottom: 8px; }
.sdk-card p code { font-size: 9px; }
.code-block {
  margin: 0 0 9px; padding: 12px 13px; border-radius: 7px;
  background: #171a2a; color: #c7cde3; border: 1px solid #232741;
  font: 9.5px/1.75 var(--mono); white-space: pre-wrap; word-break: break-word; overflow-x: auto;
}
.code-block.small { padding: 9px 11px; font-size: 9px; margin-bottom: 8px; }
.endpoint-group { margin-bottom: 13px; padding-bottom: 11px; border-bottom: 1px solid #f0f2f7; }
.endpoint-group:last-of-type { border-bottom: 0; }
.endpoint-group-title { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; font-size: 10px; font-weight: 620; color: var(--ink-soft); }
.endpoint-group-title .service-icon { width: 20px; height: 20px; border-radius: 5px; font-size: 9px; }
.endpoint { display: flex; align-items: center; gap: 7px; min-height: 27px; border-bottom: 1px dashed #f1f2f7; }
.endpoint:last-child { border-bottom: 0; }
.endpoint code { font-size: 9px; color: #545c77; }
.method { flex: 0 0 auto; min-width: 36px; padding: 1px 4px; border-radius: 3px; font: 550 7.5px/1.7 var(--mono); text-align: center; }
.method.get { background: #eaf4f9; color: #3d809d; }
.method.post { background: #ecf4ee; color: #438160; }
.method.delete { background: #faeeee; color: #a35555; }
.endpoint-label { margin-left: auto; color: var(--faint); font-size: 8.5px; text-align: right; padding-left: 6px; }
.status-list { display: grid; gap: 4px; margin-top: 10px; }
.status-list span { color: var(--muted); font-size: 9.5px; padding: 5px 8px; border-radius: 5px; background: #f8f9fc; }
.status-list b { display: inline-block; min-width: 58px; color: var(--ink-soft); font: 600 9px var(--mono); }

/* ---------- Modal & toast ---------- */
dialog {
  width: min(560px, calc(100vw - 30px)); max-height: calc(100vh - 36px);
  padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; color: var(--ink); box-shadow: 0 25px 70px rgba(15,19,40,.24);
  overflow: auto;
}
dialog::backdrop { background: rgba(16,20,38,.47); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .17s ease-out; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 21px 15px; border-bottom: 1px solid var(--line); }
.modal-heading h2 { font-size: 17px; font-weight: 600; letter-spacing: -.025em; margin-top: 4px; }
#modal-content { padding: 18px 21px 21px; }
#modal-content > label:first-child { margin-top: 0; }
#modal-content > .form-footer { margin-top: 18px; }
.modal-note { color: var(--muted); font-size: 10px; line-height: 1.65; margin-bottom: 13px; }
.modal-note code { background: #f1f3f9; border-radius: 3px; padding: 1px 4px; }
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.account-card { display: flex; flex-direction: column; gap: 2px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfbfd; }
.account-card span { color: var(--faint); font-size: 9px; }
.account-card strong { font-size: 13px; font-weight: 570; letter-spacing: -.01em; }
.account-card small { color: var(--muted); font-size: 8.5px; }
.quota-item { margin-top: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 6px; }
.quota-item span { color: var(--muted); font-size: 9.5px; }
.quota-item .quota-track { height: 5px; max-width: none; }
.account-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 0 15px; margin-top: 7px; }
.account-detail div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 8px 1px; border-bottom: 1px solid #f0f2f7; }
.account-detail span { color: var(--muted); font-size: 9px; white-space: nowrap; }
.account-detail strong { color: var(--ink-soft); font-size: 9.5px; font-weight: 550; text-align: right; }
.token-reveal { margin: 12px 0; padding: 12px; border: 1px dashed #b9c1f0; border-radius: 8px; background: #f7f8ff; color: #3f4ab5; font-size: 11px; line-height: 1.65; word-break: break-all; user-select: all; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100;
  max-width: min(460px, calc(100vw - 30px)); padding: 9px 16px;
  border: 1px solid #2f354d; border-radius: 8px; background: #1b1f33; color: #f1f3fb;
  box-shadow: 0 10px 35px rgba(15,19,40,.25); font-size: 11px;
  animation: toastIn .22s ease-out;
}
.toast.error { background: #7c3030; border-color: #964141; }

@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(5px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 5px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content-grid { grid-template-columns: minmax(0, 1.3fr) minmax(280px, .85fr); }
  main { padding-left: 26px; padding-right: 26px; }
  .topbar { padding: 0 26px; }
}
@media (max-width: 980px) {
  .sidebar {
    position: sticky; inset: auto; top: 0; width: 100%; height: auto;
    flex-direction: row; align-items: center; gap: 12px; padding: 10px 18px;
    border-right: 0; border-bottom: 1px solid rgba(255,255,255,.07);
  }
  .sidebar .brand { padding: 0; margin: 0; font-size: 17px; flex: 0 0 auto; }
  .brand-mark { width: 29px; height: 29px; font-size: 15px; border-radius: 8px; }
  .workspace, .nav-label, .sidebar-bottom, .nav-hint { display: none; }
  .sidebar nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a { min-height: 31px; padding: 0 9px; white-space: nowrap; font-size: 11px; }
  .sidebar nav a .icon { width: 14px; height: 14px; }
  .main-shell { margin-left: 0; }
  .topbar { position: static; }
  .docs-grid { grid-template-columns: 1fr; }
  .login-screen { grid-template-columns: 1fr; }
  .login-story { min-height: 48vh; padding: 28px 32px 26px; }
  .login-copy { padding: 38px 0 24px; }
  .login-copy h1 { font-size: 43px; }
  .login-foot { display: none; }
  .login-panel { padding: 40px 28px 70px; }
}
@media (max-width: 720px) {
  main { padding: 22px 16px 16px; }
  .topbar { padding: 0 16px; height: 51px; }
  .topbar .connection { display: none; }
  .topbar-divider { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; margin-bottom: 20px; }
  .page-heading h1 { font-size: 25px; }
  .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { min-height: 105px; padding: 13px; }
  .stat-value { font-size: 25px; }
  .content-grid, .settings-grid { grid-template-columns: 1fr; }
  .panel { padding: 15px 14px; }
  .table-wrap { margin: 0 -14px; }
  th:first-child, td:first-child { padding-left: 14px; }
  th:last-child, td:last-child { padding-right: 14px; }
  .connection-banner { align-items: flex-start; flex-wrap: wrap; }
  .connection-banner .button { margin-left: 34px; }
  .form-panel { padding: 16px 14px; }
  .table-foot { flex-direction: column; gap: 4px; }
  .account-grid, .account-detail { grid-template-columns: 1fr; }
  .docs-content { padding: 16px 15px; }
  .login-story { padding: 22px 22px 20px; min-height: 42vh; }
  .login-copy { padding: 28px 0 8px; }
  .login-copy h1 { font-size: 36px; }
  .login-copy p { font-size: 12.5px; }
  .endpoint-stack { display: none; }
  .login-panel { padding: 32px 22px 62px; }
  .login-panel h2 { font-size: 24px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .two-cols, .account-grid, .account-detail { grid-template-columns: 1fr; }
  .two-cols { gap: 0; }
  .two-cols > div + div { margin-top: 12px; }
  .sidebar { gap: 8px; padding: 9px 12px; }
  .sidebar .brand > span:last-child { display: none; }
  .sidebar nav a { padding: 0 7px; font-size: 10px; }
  .sidebar nav a .icon { display: none; }
  .filters { flex-direction: column; }
  .filters select { width: 100%; }
  .chart-tooltip { top: 0; right: 0; width: 148px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---- accounts & billing ---- */
.auth-tabs { display: flex; gap: 4px; padding: 4px; margin: 6px 0 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 8px 0; border-radius: 7px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.auth-tabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(25, 28, 43, .08); }
.login-note a { color: var(--indigo); }
.price-list { display: grid; gap: 2px; }
.price-list div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.price-list div:last-child { border-bottom: 0; }
.price-list span { color: var(--muted); }
.balance-big { font-size: 38px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 18px; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
.inline-check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 8px 0; }
.inline-check input { width: auto; }
.positive { color: var(--green); font-weight: 600; }
.negative { color: var(--red); font-weight: 600; }
.logs-table td { vertical-align: top; }
.users-table .table-actions { flex-wrap: wrap; max-width: 260px; }
pre.token-reveal { white-space: pre-wrap; max-height: 280px; overflow: auto; }
.recharge-form { display: grid; gap: 8px; margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px dashed var(--line); }
.preset-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line-strong); background: var(--card); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink-soft); }
.chip:hover { border-color: var(--indigo); color: var(--indigo); }
.pay-types { display: flex; gap: 8px; flex-wrap: wrap; }
.pay-type { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.pay-type input { width: auto; margin: 0; }
.pay-type:has(input:checked) { border-color: var(--indigo); background: var(--indigo-soft); color: var(--indigo-deep); }
.price-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.price-grid label { font-size: 12px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 18px; }
.plan-card { display: flex; flex-direction: column; gap: 6px; }
.plan-card h3 { margin: 0; font-size: 20px; }
.plan-card ul { margin: 6px 0 12px; padding-left: 18px; color: var(--ink-soft); font-size: 13px; line-height: 1.9; flex: 1; }
.plan-card p { color: var(--muted); font-size: 13px; margin: 0; }
.plan-seats { align-self: flex-start; font-size: 12px; font-weight: 700; color: var(--indigo-deep); background: var(--indigo-soft); padding: 3px 10px; border-radius: 999px; }
.plan-price { font-size: 30px; font-weight: 750; letter-spacing: -.02em; }
.plan-price small { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan-edit h3 { display: flex; justify-content: space-between; align-items: center; }
