:root {
  --bg: #F8FAFC; --card: #fff; --text: #0F172A; --muted: #475569; --faint: #94A3B8; --line: #E4E7EB; --line2: #EEF1F5;
  --navy: #1E3A5F; --pri: #2563EB; --pri-d: #1D4ED8; --soft: #EFF4FF;
  --ok: #059669; --ok-bg: #ECFDF5; --warn: #B45309; --warn-bg: #FFF7ED; --err: #DC2626; --err-bg: #FEF2F2;
  --c-buy: #2563EB; --c-sell: #059669;
  --r: 12px; --shadow: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.5; color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; display: flex; min-height: 100vh; background: var(--bg); }
a { color: var(--pri); }
:focus-visible { outline: 3px solid #93C5FD; outline-offset: 2px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }

/* ---------- sidebar ---------- */
.side { width: 240px; flex: none; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; color: var(--navy); text-decoration: none; padding: 0 8px 18px; }
.brand b { color: var(--pri); }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; background: var(--navy); color: #fff; display: grid; place-items: center; }
.company { display: block; padding: 0 4px 16px; font-size: 12px; color: var(--muted); font-weight: 500; }
.company select { width: 100%; margin-top: 6px; min-width: 0; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; margin-bottom: 2px; font-weight: 500; transition: background .15s, color .15s; }
nav a:hover { background: #F1F5F9; color: var(--text); }
nav a.on { background: var(--soft); color: var(--pri-d); }
nav a.on svg { color: var(--pri); }
.nav-h { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 16px 10px 6px; }
.side-foot { margin-top: auto; padding-top: 12px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-top: 1px solid var(--line); }
.me .av { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); color: var(--pri-d); font-weight: 700; display: grid; place-items: center; flex: none; }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who small { color: var(--muted); font-size: 12px; }
.quota { margin: 0 4px 10px; padding: 12px; border-radius: 10px; background: #F8FAFC; border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.quota b { color: var(--text); }
.quota .bar, .meter { height: 6px; background: #E8EDF4; border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.quota .bar i, .meter i { display: block; height: 100%; background: var(--pri); border-radius: 99px; }
.quota .bar i.hi, .meter i.hi { background: var(--warn); }
.quota .bar i.full, .meter i.full { background: var(--err); }
.quota a { font-weight: 600; text-decoration: none; }

/* ---------- layout ---------- */
main { flex: 1; padding: 28px 32px 40px; min-width: 0; max-width: 1400px; }
h2 { margin: 0 0 18px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.page-h { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-h h2 { margin: 0; }
.page-h p { margin: 4px 0 0; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-h h3 { margin: 0; }
.card-h a { font-size: 13px; font-weight: 500; text-decoration: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + * { margin-top: 16px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- forms ---------- */
input, select, button { font: inherit; }
input[type=text], input[type=password], input[type=date], input[type=search], select {
  height: 38px; padding: 0 11px; border: 1px solid #D5DBE3; border-radius: 8px; background: #fff; color: var(--text); min-width: 140px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--pri); cursor: pointer; }
button, a.btn, label.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 8px; border: 1px solid var(--pri); background: var(--pri); color: #fff; cursor: pointer; white-space: nowrap; font-weight: 500; text-decoration: none; transition: background .15s, border-color .15s, color .15s; }
button:hover, a.btn:hover { background: var(--pri-d); border-color: var(--pri-d); }
button.sec, a.btn.sec, label.btn.sec { background: #fff; color: var(--text); border-color: #D5DBE3; }
button.sec:hover, a.btn.sec:hover, label.btn.sec:hover { background: #F8FAFC; border-color: #B8C2CF; }
button.ghost, a.ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 0 9px; height: 32px; display: inline-flex; align-items: center; gap: 5px; border-radius: 7px; font-size: 13px; font-weight: 500; text-decoration: none; }
button.ghost:hover, a.ghost:hover { background: #F1F5F9; color: var(--text); }
button.icon { width: 34px; padding: 0; }
button.danger { background: #fff; color: var(--err); border-color: #FCA5A5; }
button.danger:hover { background: var(--err-bg); }
button:disabled { opacity: .5; cursor: default; pointer-events: none; }
.chk { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text) !important; flex-direction: row !important; height: 38px; cursor: pointer; }
details summary { cursor: pointer; }

.captcha { display: flex; align-items: center; gap: 8px; }
.captcha .img { background: #fff; border: 1px solid var(--line); border-radius: 8px; height: 42px; width: 200px; cursor: pointer; overflow: hidden; }
.captcha .img svg, .captcha .img img { display: block; }

/* ---------- KPI ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.stat.hl { background: var(--navy); border-color: var(--navy); color: #fff; }
.stat.hl .k, .stat.hl .s { color: #CBD5E1; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; background: #fff; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: middle; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: #F8FAFC; position: sticky; top: 0; border-bottom-color: var(--line); }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover td { background: #F8FAFF; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .sub { color: var(--muted); font-size: 12px; }
.tbl .acts { white-space: nowrap; text-align: right; }
.card.tbl-wrap { padding: 0; overflow: auto; }
.pill { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #F1F5F9; color: var(--muted); margin: 1px 3px 1px 0; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: #047857; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.err { background: var(--err-bg); color: #B91C1C; }
.pill.buy { background: var(--soft); color: var(--pri-d); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.err { color: var(--err); }
.card.err { background: var(--err-bg); border-color: #FECACA; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px !important; }

.progress { height: 6px; background: #E8EDF4; border-radius: 99px; overflow: hidden; margin: 12px 0; }
.progress > div { height: 100%; background: var(--pri); width: 30%; border-radius: 99px; animation: indet 1.2s infinite ease-in-out; }
@keyframes indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.log { max-height: 180px; overflow: auto; font-size: 12px; background: #F8FAFC; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }

/* ---------- dialog / toast / drop ---------- */
dialog { border: none; border-radius: 14px; padding: 0; width: min(980px, 95vw); max-height: 92vh; box-shadow: 0 24px 64px rgba(15,23,42,.28); }
dialog::backdrop { background: rgba(15,23,42,.45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px 12px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
#dlg-body { padding: 16px 20px; }
#dlg-body iframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; }

.drop { border: 2px dashed #CBD5E1; border-radius: var(--r); padding: 36px; text-align: center; color: var(--muted); background: #FBFCFE; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--pri); background: var(--soft); }
.drop .big { width: 44px; height: 44px; border-radius: 12px; background: var(--soft); color: var(--pri); display: grid; place-items: center; margin: 0 auto 12px; }

#toast { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
#toast div { background: #0F172A; color: #fff; padding: 11px 15px; border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.25); max-width: 420px; animation: tin .2s ease-out; }
#toast div.e { background: var(--err); }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- dashboard ---------- */
.chips { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.chips button { height: 32px; background: transparent; border: 0; color: var(--muted); padding: 0 12px; border-radius: 7px; }
.chips button:hover { background: #F1F5F9; color: var(--text); }
.chips button.on { background: var(--navy); color: #fff; }
.dash { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.dash > div > .card:last-child { margin-bottom: 0; }
@media (max-width: 1100px) { .dash { grid-template-columns: 1fr; } }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-family: inherit; }
.chart .grid { stroke: var(--line2); }
.chart rect.b { transition: opacity .15s; }
.chart g.m:hover rect.b { opacity: .8; }
.chart g.m:hover rect.hov { fill: #F1F5F9; }
.chart-tip { position: fixed; pointer-events: none; background: #0F172A; color: #fff; font-size: 12px; padding: 8px 10px; border-radius: 8px; box-shadow: 0 8px 24px rgba(15,23,42,.25); z-index: 50; line-height: 1.6; font-variant-numeric: tabular-nums; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.actions { display: grid; gap: 8px; }
.action { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; transition: border-color .15s, background .15s; }
.action:hover { border-color: #BFDBFE; background: #F8FAFF; }
.action .ic { width: 36px; height: 36px; border-radius: 9px; background: var(--soft); color: var(--pri); display: grid; place-items: center; flex: none; }
.action .ic.g { background: var(--ok-bg); color: var(--ok); }
.action .ic.n { background: #EEF2F7; color: var(--navy); }
.action b { display: block; font-weight: 600; }
.action small { color: var(--muted); }
.action > svg:last-child { margin-left: auto; color: var(--faint); }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 10px; background: var(--warn-bg); border: 1px solid #FED7AA; color: #7C2D12; margin-bottom: 16px; }
.notice svg { color: var(--warn); margin-top: 1px; }
.notice.ok { background: var(--ok-bg); border-color: #A7F3D0; color: #064E3B; }
.notice.ok svg { color: var(--ok); }
.notice a { font-weight: 600; color: inherit; }
.rank { display: grid; gap: 12px; }
.rank .it { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 13px; }
.rank .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.rank .vl { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.rank .tr { grid-column: 1 / -1; height: 6px; background: #F1F5F9; border-radius: 99px; overflow: hidden; }
.rank .tr i { display: block; height: 100%; border-radius: 99px; }
.onboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 900px) { .onboard { grid-template-columns: 1fr; } }
.ob { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; gap: 12px; }
.ob .n { width: 28px; height: 28px; border-radius: 50%; background: #EEF2F7; color: var(--navy); font-weight: 700; display: grid; place-items: center; flex: none; font-size: 13px; }
.ob.done .n { background: var(--ok); color: #fff; }
.ob b { display: block; }
.ob p { margin: 2px 0 6px; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  body { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav-h { display: none; }
  .side-foot { display: none; }
  main { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- license ---------- */
.tbl.kv td { padding: 10px 0; }
.tbl.kv td.n { padding-left: 16px; }
.tbl.kv .meter { max-width: 260px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.plan { border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.plan.hot { border: 2px solid var(--pri); }
.plan .pr { font-size: 22px; font-weight: 700; color: var(--navy); margin-top: 6px; font-variant-numeric: tabular-nums; }
.plan .pr small { font-size: 14px; }
.plan button { margin-top: 12px; }
.pay { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
.pay .qr img { display: block; width: 280px; height: 280px; border: 1px solid var(--line); border-radius: 12px; }
@media (max-width: 700px) { .pay { grid-template-columns: 1fr; } }

.origbox { background: #F8FAFC; border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.origbox code { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; user-select: all; }
label.btn { font-size: 14px; margin: 0; }
