:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f9fafb;
  --text: #16191d; --muted: #667085; --line: #e3e6ea;
  --accent: #0f766e; --accent-strong: #0b5f58; --accent-soft: #e4f3f1; --on-accent: #ffffff;
  --danger: #b42318; --danger-soft: #fdecea;
  --warn: #93370d; --warn-soft: #fff4dc; --warn-line: #f3d9a4;
  --ok: #067647; --ok-soft: #e3f5ea;
  --brand-bg: #0c3b38; --brand-text: #e6f3f1; --brand-muted: #9cc7c1;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1113; --surface: #161a1d; --surface-2: #1b2024;
    --text: #e8ebee; --muted: #98a2ad; --line: #2a3036;
    --accent: #2bb3a4; --accent-strong: #52cabc; --accent-soft: #123330; --on-accent: #06211e;
    --danger: #f1867c; --danger-soft: #35201e;
    --warn: #f1c27a; --warn-soft: #33290f; --warn-line: #4d3f17;
    --ok: #6cd39a; --ok-soft: #12291d;
    --brand-bg: #0a2b29;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.3; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.hidden { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7;
        stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
a.btn { text-decoration: none; color: var(--text); }
a.btn.primary { color: var(--on-accent); }
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--line) 60%, var(--muted)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--danger); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; height: 40px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 5px; font-weight: 500; font-size: 13px; }
.field > span em { color: var(--danger); font-style: normal; margin-left: 2px; }
.field small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=tel], select {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 4px 0 16px; }
.check input { margin-top: 4px; accent-color: var(--accent); }
.form-error { color: var(--danger); background: var(--danger-soft); border-radius: 8px;
              padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 5fr) 6fr; }
.auth-brand {
  background: var(--brand-bg); color: var(--brand-text); padding: 48px 56px;
  display: flex; flex-direction: column; justify-content: space-between;
  background-image: radial-gradient(circle at 12% 0%, rgba(43,179,164,.22), transparent 46%),
                    radial-gradient(circle at 100% 100%, rgba(43,179,164,.12), transparent 40%);
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--on-accent);
             display: grid; place-items: center; }
.auth-brand h1 { font-size: 32px; line-height: 1.25; margin-bottom: 14px; letter-spacing: .3px; }
.auth-brand p.lead { color: var(--brand-muted); font-size: 15px; margin: 0 0 32px; max-width: 30em; }
.points { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.points li { display: flex; gap: 12px; align-items: flex-start; }
.points .dot { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.08);
               display: grid; place-items: center; flex: none; color: #7fe0d3; }
.points b { display: block; font-weight: 600; }
.points span { color: var(--brand-muted); font-size: 13px; }
.auth-foot { color: var(--brand-muted); font-size: 12px; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 440px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line);
        border-radius: 10px; margin-bottom: 22px; }
.tabs button { flex: 1; height: 34px; border: 0; border-radius: 7px; background: transparent; cursor: pointer;
               color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text);
                                     box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.auth-card h2 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 20px; }
.notice { display: flex; gap: 8px; background: var(--accent-soft); color: var(--accent-strong);
          border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 16px; }

/* ---------- console shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px;
        display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .logo { padding: 2px 10px 18px; }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 14px 8px 2px; }
.side-foot .who { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; margin-bottom: 8px; }
.side-foot .who b { display: block; color: var(--text); font-size: 13px; }
.main { padding: 28px 36px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.balance-pill { display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 14px; border-radius: 999px;
                border: 1px solid var(--line); background: var(--surface); }
.balance-pill b { font-size: 16px; }

.banner { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--radius); padding: 12px 14px;
          margin-bottom: 18px; border: 1px solid var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.banner.info { border-color: transparent; background: var(--accent-soft); color: var(--accent-strong); }
.banner .icon { margin-top: 2px; }
.banner a { color: inherit; font-weight: 600; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
          border-bottom: 1px solid var(--line); gap: 12px; flex-wrap: wrap; }
.card-h h2 { font-size: 15px; }
.card-b { padding: 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -.3px; }
.stat .s { color: var(--muted); font-size: 12px; }
.split { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; }
.split.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 18px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-weight: 500; color: var(--muted); font-size: 12.5px; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
td.right, th.right { text-align: right; }
.strike { text-decoration: line-through; color: var(--muted); font-size: 12px; margin-right: 6px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.tier { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--surface-2);
        border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.tier.peak { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.chip { display: inline-block; padding: 0 8px; border-radius: 6px; background: var(--surface-2);
        border: 1px solid var(--line); font-size: 12px; margin-right: 4px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 130px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px;
         border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* ---------- chart ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart g:hover .bar { opacity: 1; }
.chart .hit { fill: transparent; }
.chart g:hover .hit { fill: color-mix(in srgb, var(--accent) 8%, transparent); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart line { stroke: var(--line); }

/* ---------- code / guide ---------- */
.code { position: relative; background: #0f1417; color: #d6e2df; border-radius: 8px; padding: 14px 16px;
        font: 12.5px/1.65 var(--mono); overflow-x: auto; white-space: pre; margin: 0; }
.code-wrap { position: relative; }
.code-wrap .btn { position: absolute; top: 8px; right: 8px; height: 26px; font-size: 12px; padding: 0 9px;
                  background: rgba(255,255,255,.08); color: #d6e2df; border-color: rgba(255,255,255,.14); }
.code-wrap .btn:hover { background: rgba(255,255,255,.16); }
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px 16px; align-items: center; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--line);
               padding: 2px 8px; border-radius: 6px; word-break: break-all; }
.steps { padding-left: 20px; margin: 0 0 14px; color: var(--muted); }
.steps li { margin: 4px 0; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

/* ---------- dialog & toast ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px));
         background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0,0,0,.28); }
dialog::backdrop { background: rgba(10, 14, 16, .55); }
.dlg-h { padding: 18px 22px 0; }
.dlg-h h2 { font-size: 17px; }
.dlg-b { padding: 16px 22px 6px; }
.dlg-f { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }
.model-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; max-height: 180px; overflow: auto;
              border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.model-pick label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.model-pick input { accent-color: var(--accent); }
.secret { display: flex; gap: 8px; align-items: stretch; margin: 10px 0 8px; }
.secret .inline-code { flex: 1; padding: 9px 10px; user-select: all; }
#toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0;
         background: #16191d; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px;
         pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); }

/* ---------- loading ---------- */
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2));
            background-size: 200% 100%; animation: sh 1.3s linear infinite; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } #toast { transition: none; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split, .split.even { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 24px; }
  .auth-brand h1 { font-size: 24px; }
  .auth-brand .points, .auth-foot { display: none; }
  .auth-brand p.lead { margin-bottom: 0; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap;
          padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); gap: 6px; }
  .side .logo { padding: 0 8px 0 4px; }
  .nav { display: flex; gap: 2px; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .nav a { padding: 7px 10px; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 10px; }
  .side-foot .who { display: none; }
  .main { padding: 20px 16px 48px; }
}
@media (max-width: 560px) {
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat .v { font-size: 21px; }
  .row2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  th, td { padding: 10px 12px; }
}

.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { flex: 1; height: 34px; border: 0; border-radius: 7px; background: transparent; cursor: pointer;
              color: var(--muted); font-weight: 500; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; min-width: 0; }
.with-btn .btn { flex: none; }
form.contact .form-error { margin-bottom: 10px; }

.with-btn { align-items: center; }
.captcha-img { flex: none; width: 160px; height: 56px; padding: 0; border: 1px solid var(--line); border-radius: 8px;
               overflow: hidden; cursor: pointer; background: #eef0f3; color: #4b5563; font-size: 12px; }
.captcha-img img { display: block; width: 100%; height: 100%; }
p.alt { margin: 16px 0 0; text-align: center; font-size: 13px; }
@media (max-width: 400px) { .captcha-img { width: 128px; } .captcha-img img { object-fit: cover; } }

/* show/hide password */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px; padding: 0;
             display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent;
             color: var(--muted); cursor: pointer; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle[aria-pressed="true"] { color: var(--accent); }
/* hide Edge's own reveal/clear buttons so there is only one eye */
input::-ms-reveal, input::-ms-clear { display: none; }

/* recharge */
.banner.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
#pay-result:not(:empty) { margin-bottom: 14px; }
#pay-result .banner { margin-bottom: 0; }
.amounts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.amt { height: 40px; min-width: 88px; padding: 0 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
       cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums; }
.amt:hover { background: var(--surface-2); }
.amt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.amt-custom { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 1px solid var(--line);
              border-radius: 8px; background: var(--surface); }
.amt-custom:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.amt-custom input { border: 0; background: transparent; height: 36px; width: 120px; padding: 0; box-shadow: none; outline: none;
                    font: inherit; color: inherit; font-variant-numeric: tabular-nums; }
.pay-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pay-actions .btn { height: 42px; padding: 0 20px; font-size: 15px; }

/* ---------- key limits, savings badge, playground ---------- */
.save { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; vertical-align: middle;
        background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
           font: inherit; color: inherit; resize: vertical; transition: border-color .15s, box-shadow .15s; }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row3 label small { margin: 0 0 3px; }
.small-text { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num.over { color: var(--danger); font-weight: 600; }
.pg .pg-log { min-height: 220px; max-height: 52vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 0 12px; }
.pg .msg { max-width: 88%; padding: 10px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.pg .msg.user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.pg .msg .who { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.pg .msg .body, .pg .msg .think { white-space: pre-wrap; word-break: break-word; line-height: 1.65; }
.pg .msg .think { color: var(--muted); font-size: 13px; border-left: 3px solid var(--line); padding-left: 10px; margin-bottom: 8px; }
.pg-sys { margin-bottom: 12px; }
.pg-sys summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.pg-status { min-height: 20px; font-size: 12px; margin: 2px 0 8px; }
.pg-input { display: flex; gap: 10px; align-items: flex-end; }
.pg-actions { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 700px) { .row3 { grid-template-columns: 1fr; } .pg .msg { max-width: 100%; } .pg-input { flex-direction: column; align-items: stretch; } }
