:root {
  color-scheme: dark;
  --ink: #eef1f4;
  --muted: #8b929d;
  --quiet: #59616d;
  --line: #292e36;
  --panel: #171a1f;
  --panel-soft: #1c2026;
  --ground: #0c0e11;
  --signal: #f0b84b;
  --danger: #ee756d;
  --ok: #77c79b;
  --sans: "Avenir Next", Avenir, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --text: var(--ink);
  --dim: var(--muted);
  --border: var(--line);
  --card: var(--panel);
  --green: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --yellow: #fbbf24;
  --font-data: var(--mono);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ground); }
body { min-height: 100vh; margin: 0; color: var(--ink); font-family: var(--sans); background: radial-gradient(circle at 78% 16%, rgba(240,184,75,.055), transparent 29%), var(--ground); }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.ambient { position: fixed; inset: 0; pointer-events: none; opacity: .22; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 72px 72px; mask-image: linear-gradient(to bottom, #000, transparent 78%); }
.shell { position: relative; width: min(1160px, calc(100% - 48px)); min-height: 100vh; margin: auto; display: flex; flex-direction: column; }
.masthead { height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font-size: 13px; font-weight: 600; letter-spacing: .04em; text-decoration: none; }
.mark { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid #434a54; color: var(--signal); font-size: 12px; letter-spacing: 0; }
.site-nav { align-self: stretch; display: flex; align-items: stretch; gap: 24px; }
.site-nav a { position: relative; min-height: 44px; display: flex; align-items: center; color: var(--muted); font-size: 12px; text-decoration: none; transition: color .16s ease; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); }
.site-nav a[aria-current="page"]::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 1px; background: var(--signal); }
.site-nav a:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }

.login-view { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); align-items: center; gap: clamp(46px, 6vw, 84px); padding: 72px 0 104px; }

.account-status-panel { min-width: 0; display: grid; place-items: center; }
.account-dial { position: relative; width: min(330px, 100%); aspect-ratio: 1; display: grid; place-items: center; color: var(--quiet); }
.account-dial svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.account-dial circle { fill: none; stroke-width: 8; }
.account-dial-track { stroke: #20252c; }
.account-dial-progress { stroke: var(--quota-color, var(--quiet)); stroke-dasharray: 660; stroke-dashoffset: 660; stroke-linecap: round; transition: stroke .3s ease, stroke-dashoffset .5s ease; }
.account-dial-face { position: relative; z-index: 1; width: 71%; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; border: 1px solid rgba(255,255,255,.045); border-radius: 50%; background: radial-gradient(circle at 50% 38%, rgba(255,255,255,.055), transparent 52%), rgba(17,20,25,.92); box-shadow: inset 0 0 32px rgba(0,0,0,.24); }
.account-dial-face > span { color: var(--muted); font: 9px/1 var(--mono); letter-spacing: .13em; }
.account-dial-face strong { color: var(--ink); font: 650 clamp(42px, 4vw, 52px)/1 var(--mono); letter-spacing: -.07em; font-variant-numeric: tabular-nums; }
.account-dial-face small { max-width: 180px; min-height: 22px; color: var(--signal); font: 9px/1.45 var(--mono); text-align: center; text-wrap: pretty; }

.login-card { width: min(420px, 100%); border: 1px solid var(--line); background: rgba(23,26,31,.88); padding: 34px; box-shadow: 0 28px 80px rgba(0,0,0,.24); }
.login-card h1 { margin: 0 0 34px; font-size: 28px; letter-spacing: -.035em; font-weight: 560; }
.login-card label { display: block; margin: 18px 0 8px; color: #adb3bc; font-size: 11px; }
.login-card input { width: 100%; height: 50px; padding: 0 14px; border: 1px solid #333944; border-radius: 0; outline: none; background: #111419; color: var(--ink); transition: border-color .16s ease, box-shadow .16s ease; }
.login-card input:focus { border-color: var(--signal); box-shadow: 0 0 0 3px rgba(240,184,75,.08); }
.form-error { min-height: 34px; padding-top: 9px; color: var(--danger); font-size: 11px; }
.primary { width: 100%; min-height: 52px; display: flex; justify-content: space-between; align-items: center; padding: 0 17px; border: 1px solid var(--signal); background: var(--signal); color: #17120a; font-size: 12px; font-weight: 700; cursor: pointer; transition: background .16s ease, transform .16s ease; }
.primary:hover { background: #f6c86c; }
.primary:active { transform: translateY(1px); }
.primary:disabled { cursor: wait; opacity: .58; }
.primary b { font: 17px/1 var(--mono); }

.portal-view { flex: 1; padding: 78px 4vw 100px; }
.portal-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 55px; }
.portal-heading h1 { margin: 0; max-width: 650px; font-size: clamp(42px, 5vw, 68px); line-height: .98; letter-spacing: -.055em; font-weight: 520; text-wrap: balance; }
.balance-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: -20px 0 28px; border: 1px solid var(--line); background: rgba(23,26,31,.76); }
.balance-panel > div { min-height: 92px; display: flex; flex-direction: column; justify-content: center; gap: 10px; padding: 18px 20px; }
.balance-panel > div + div { border-left: 1px solid var(--line); }
.balance-panel span { color: var(--quiet); font: 9px/1 var(--mono); letter-spacing: .12em; }
.balance-panel strong { font: 600 24px/1 var(--mono); letter-spacing: -.04em; }
.quiet { min-height: 42px; padding: 0 16px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.quiet:hover { border-color: #454c57; color: var(--ink); }
.key-panel { border: 1px solid var(--line); background: rgba(23,26,31,.76); }
.key-panel-head { min-height: 54px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); color: var(--quiet); font: 9px/1 var(--mono); letter-spacing: .12em; }
.key-panel-head > div { display: grid; grid-template-columns: minmax(180px, 1fr) 180px; flex: 1; }
.key-panel-head b { color: var(--ink); }
.key-row { min-height: 84px; display: grid; grid-template-columns: minmax(180px, 1fr) 180px 150px 90px; align-items: center; gap: 20px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.key-row:last-child { border-bottom: 0; }
.key-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-time { color: var(--muted); font: 11px/1.4 var(--mono); }
.fast-control { display: flex; align-items: center; gap: 10px; color: var(--muted); font: 10px/1 var(--mono); letter-spacing: .08em; }
.fast-control.fixed-tier { color: var(--quiet); }
.switch { position: relative; width: 42px; height: 23px; flex: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border: 1px solid #3a414b; background: #111419; cursor: pointer; transition: .16s ease; }
.switch span::after { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #727a85; transition: .16s ease; }
.switch input:checked + span { border-color: rgba(240,184,75,.6); background: rgba(240,184,75,.1); }
.switch input:checked + span::after { transform: translateX(19px); background: var(--signal); }
.switch input:focus-visible + span { outline: 2px solid var(--signal); outline-offset: 2px; }
.delete-key { justify-self: end; border: 0; background: none; padding: 10px 0 10px 16px; color: #8e6261; font-size: 11px; cursor: pointer; }
.delete-key:hover { color: var(--danger); }
.usage-panel, .history-panel { margin-top: 54px; }
.section-heading { min-height: 78px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.section-heading p { margin: 0 0 8px; color: var(--signal); font: 9px/1 var(--mono); letter-spacing: .14em; }
.section-heading h2 { margin: 0; font-size: 22px; font-weight: 560; letter-spacing: -.025em; }
.section-heading time, .history-actions > span { color: var(--quiet); font: 10px/1.5 var(--mono); }
.portal-consumer-list { max-height: none; border-radius: 0; background: rgba(23,26,31,.76); }
.portal-consumer-list .consumer-list-head, .portal-consumer-list .consumer-row { grid-template-columns: minmax(220px,2fr) repeat(2,minmax(140px,1fr)); }
.portal-usage-state { display: block; margin-top: 3px; color: var(--danger); font: 9px/1.3 var(--mono); }
.history-heading { align-items: flex-end; }
.history-actions { display: flex; align-items: center; justify-content: flex-end; gap: 18px; }
.download-history { display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.portal-log-list-wrap { overflow: visible; border: 1px solid var(--line); border-radius: 12px; background: rgba(8,10,14,.22); }
.portal-log-list-wrap .identity-primary { max-width: 180px; }
.portal-log-list-wrap .identity-primary strong { max-width: 110px; }
dialog { width: min(430px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 0; background: var(--panel); color: var(--ink); box-shadow: 0 34px 100px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(4,5,7,.76); backdrop-filter: blur(4px); }
dialog form { padding: 30px; }
dialog h2 { margin: 0 0 10px; font-size: 22px; }
dialog p { min-height: 42px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }
.dialog-actions button { min-height: 40px; padding: 0 15px; border: 1px solid var(--line); background: transparent; cursor: pointer; }
.dialog-actions .danger { border-color: rgba(238,117,109,.45); background: rgba(238,117,109,.1); color: var(--danger); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 10px); padding: 11px 15px; border: 1px solid #3a414b; background: #20242a; color: var(--ink); font-size: 12px; opacity: 0; pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .login-view { grid-template-columns: 1fr; gap: 56px; }
  .login-card { width: min(100%, 620px); justify-self: center; }
}

@media (max-width: 780px) {
  .shell { width: min(100% - 32px, 620px); }
  .masthead { height: 74px; }
  .login-view { grid-template-columns: 1fr; gap: 52px; padding: 58px 0 80px; }
  .login-card { padding: 28px; }
  .portal-view { padding: 58px 0 80px; }
  .portal-heading { align-items: flex-start; }
  .balance-panel { margin-top: -10px; }
  .key-panel-head > div { display: none; }
  .key-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 18px; padding: 18px; }
  .key-time { grid-column: 1; grid-row: 2; }
  .fast-control { grid-column: 2; grid-row: 1; }
  .delete-key { grid-column: 2; grid-row: 2; min-height: 44px; }
  .usage-panel, .history-panel { margin-top: 44px; }
  .section-heading { align-items: flex-start; }
  .portal-consumer-list .consumer-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .portal-consumer-list .consumer-identity { grid-column: 1 / -1; }
  .history-heading { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; }
  .history-actions { width: 100%; align-items: flex-start; flex-direction: column; gap: 10px; justify-self: stretch; }
  .download-history { width: 100%; min-height: 44px; justify-content: center; }
}

@media (max-width: 470px) {
  .wordmark > span:last-child { display: none; }
  .site-nav { gap: 16px; }
  .login-view { padding-top: 46px; }
  .account-dial { width: min(280px, 100%); }
  .login-card { margin-inline: -1px; }
  .portal-heading { display: grid; }
  .balance-panel { grid-template-columns: 1fr; }
  .balance-panel > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .quiet { justify-self: start; }
  .key-row { grid-template-columns: 1fr; }
  .key-time, .fast-control, .delete-key { grid-column: 1; grid-row: auto; justify-self: start; }
  .delete-key { padding-left: 0; }
  .section-heading, .history-heading { display: grid; align-items: start; justify-content: stretch; }
  .history-actions { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
