:root { --bg:#f4f7fb; --ink:#17202a; --muted:#667085; --line:#e2e8f0; --brand:#1f6feb; --card:#fff; --ok:#146c43; --warn:#8a5a00; --bad:#b42318; }
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif; line-height:1.6; }
[hidden] { display:none !important; }
.muted { color:var(--muted); font-size:13px; }
.error { color:var(--bad); font-size:14px; margin:8px 0; }
.grow { flex:1; }
.center { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:16px; }
.card { background:var(--card); border:1px solid var(--line); border-radius:14px; padding:22px; margin-bottom:16px; box-shadow:0 4px 14px rgba(15,23,42,.05); }
.card.narrow { width:100%; max-width:380px; }
.card h1 { margin:0 0 4px; font-size:22px; }
.card h2 { margin:0 0 14px; font-size:18px; }
label { display:block; margin-top:14px; font-weight:600; font-size:14px; }
input { display:block; width:100%; margin-top:6px; padding:10px 12px; border:1px solid #cbd5e1; border-radius:8px; font:inherit; background:#fff; }
input:focus { outline:2px solid var(--brand); outline-offset:1px; }
.btn { border:1px solid #cbd5e1; background:#fff; color:var(--ink); padding:8px 14px; border-radius:8px; cursor:pointer; font:inherit; }
.btn:hover { background:#f1f5f9; }
.btn.primary { background:var(--brand); border-color:var(--brand); color:#fff; width:100%; margin-top:16px; padding:11px; }
.btn.primary:hover { filter:brightness(.95); }
.btn.sm { padding:5px 10px; font-size:13px; width:auto; margin:0; }
.btn.ok { background:var(--ok); border-color:var(--ok); color:#fff; }
.btn.danger { color:var(--bad); }
.topbar { display:flex; align-items:center; gap:12px; background:#fff; border-bottom:1px solid var(--line); padding:12px 20px; position:sticky; top:0; z-index:5; }
.container { max-width:1100px; margin:20px auto; padding:0 16px; }
table { width:100%; border-collapse:collapse; }
table.kv td { padding:9px 6px; border-bottom:1px solid #eef1f5; vertical-align:top; }
table.kv td:first-child { width:38%; font-weight:600; }
table.kv td:last-child { direction:ltr; text-align:right; word-break:break-all; }
.table-wrap { overflow-x:auto; }
table.grid th { text-align:right; font-size:13px; color:var(--muted); padding:8px 6px; border-bottom:2px solid var(--line); white-space:nowrap; }
table.grid td { padding:10px 6px; border-bottom:1px solid #eef1f5; vertical-align:middle; }
.mail { direction:ltr; text-align:right; color:var(--muted); font-size:12px; }
.stats { display:flex; flex-wrap:wrap; gap:12px; }
.stats > div { flex:1 1 130px; background:#f6f8fb; border-radius:10px; padding:14px; text-align:center; }
.stats strong { display:block; font-size:24px; }
.stats span { color:var(--muted); font-size:13px; }
.search { max-width:340px; margin:0 0 12px; }
.meter { min-width:110px; font-size:12px; }
.meter > div:first-child { text-align:right; }
code { background:#eef2f7; padding:1px 6px; border-radius:6px; }
.meter .bar { height:6px; background:#e8edf3; border-radius:3px; overflow:hidden; margin-top:4px; }
.meter .bar i { display:block; height:100%; background:var(--brand); }
.meter.hot .bar i { background:var(--bad); }
.pill { display:inline-block; padding:2px 10px; border-radius:999px; font-size:12px; background:#eef2f7; }
.pill.APPROVED { background:#e6f7ee; color:var(--ok); }
.pill.PENDING { background:#fff4e0; color:var(--warn); }
.pill.REJECTED { background:#fde8e6; color:var(--bad); }
.row-actions { display:flex; gap:6px; flex-wrap:wrap; }
dialog { border:none; border-radius:14px; padding:22px; width:440px; max-width:94vw; box-shadow:0 20px 50px rgba(15,23,42,.3); }
dialog::backdrop { background:rgba(15,23,42,.45); }
dialog h3 { margin:0 0 4px; }
.actions { display:flex; gap:8px; justify-content:flex-end; margin-top:18px; }
.actions .btn.primary { width:auto; margin:0; }
.toast { position:fixed; bottom:18px; inset-inline-start:18px; background:#17202a; color:#fff; padding:10px 16px; border-radius:10px; z-index:50; max-width:90vw; }
.toast.bad { background:var(--bad); }

/* ---------- tabs ---------- */
.tabs { display:flex; gap:4px; overflow-x:auto; background:#fff; border-bottom:1px solid var(--line); padding:0 16px; position:sticky; top:57px; z-index:4; }
.tab { border:0; background:none; font:inherit; font-size:14px; color:var(--muted); padding:12px 14px; cursor:pointer; border-bottom:3px solid transparent; white-space:nowrap; }
.tab:hover { color:var(--ink); }
.tab.active { color:var(--brand); border-bottom-color:var(--brand); font-weight:600; }
.badge { display:inline-block; min-width:20px; padding:0 6px; margin-inline-start:4px; border-radius:999px; background:var(--bad); color:#fff; font-size:12px; line-height:20px; text-align:center; }

/* ---------- billing ---------- */
.toolbar { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-bottom:12px; }
.toolbar .search { margin:0; }
select { padding:9px 12px; border:1px solid #cbd5e1; border-radius:8px; font:inherit; background:#fff; }
textarea { display:block; width:100%; margin-top:6px; padding:10px 12px; border:1px solid #cbd5e1; border-radius:8px; font:inherit; resize:vertical; }
.stats.small { margin-bottom:14px; }
.stats.small > div { padding:10px; }
.stats.small strong { font-size:18px; direction:ltr; }
.pill.ACTIVE { background:#e6f7ee; color:var(--ok); }
.pill.GRACE { background:#fff4e0; color:var(--warn); }
.pill.SUSPENDED { background:#fde8e6; color:var(--bad); }
.pill.NONE { background:#eef2f7; color:var(--muted); }
.pill.auto { background:#e8f0fe; color:var(--brand); margin-top:4px; }
.neg { color:var(--bad); }
.pos { color:var(--ok); }
.note { font-size:12px; max-width:260px; white-space:pre-wrap; word-break:break-word; }
.btn.danger-fill { background:var(--bad); border-color:var(--bad); }
.settings-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.settings-grid .example, .settings-grid .error, .settings-grid .actions { grid-column:1 / -1; }
fieldset { border:1px solid var(--line); border-radius:10px; padding:4px 16px 16px; margin:0; }
legend { font-weight:700; padding:0 6px; }
fieldset.inline { display:grid; grid-template-columns:1fr 2fr; gap:12px; margin-top:12px; }
.example { background:#f6f8fb; border-radius:10px; padding:12px 14px; font-size:14px; }
.example:empty { display:none; }
dialog.wide { width:760px; }
dialog h4 { margin:22px 0 8px; }
.balance { font-size:16px; margin:6px 0 0; }
.tx-wrap { max-height:320px; overflow-y:auto; }

@media (max-width: 640px) {
  .topbar { flex-wrap:wrap; }
  .tabs { top:0; position:static; }
  fieldset.inline, .settings-grid { grid-template-columns:1fr; }
}

/* ---------- archive ---------- */
.steps { margin:0 0 16px; padding-inline-start:20px; color:var(--muted); font-size:13px; line-height:1.9; }
.steps b { color:var(--ink); }
.timeline { list-style:none; display:flex; flex-wrap:wrap; gap:6px; padding:0; margin:12px 0; }
.timeline li { display:flex; flex-direction:column; align-items:center; gap:2px; min-width:96px; padding:8px 10px; border-radius:10px; background:#f3f5f8; color:var(--muted); font-size:12px; }
.timeline li b { font-size:13px; }
.timeline li.done { background:#e6f7ee; color:var(--ok); }
.danger-text { background:#fde8e6; color:var(--bad); border-radius:10px; padding:10px 12px; line-height:1.8; }
.btn.sm.danger { border-color:#f3c1bb; }
.btn:disabled { opacity:.55; cursor:not-allowed; }

/* ---------- promos & grants ---------- */
.card-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:6px; }
.card-head h2 { margin:0; }
.btn.primary.inline { width:auto; margin:0; padding:8px 16px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:0 14px; }
.form-grid.three { grid-template-columns:repeat(3, 1fr); }
label.check { display:flex; align-items:center; gap:8px; font-weight:600; }
label.check input { width:auto; margin:0; }
#promo-dialog select { display:block; width:100%; margin-top:6px; }
@media (max-width: 640px) { .form-grid, .form-grid.three { grid-template-columns:1fr; } }

/* ---------- live streaming ---------- */
.cdn-box { border-radius:10px; padding:12px 14px; margin:12px 0 16px; line-height:1.9; font-size:14px; }
.cdn-box.ok { background:#e6f7ee; color:var(--ok); }
.cdn-box.warn { background:#fff4e0; color:var(--warn); }
.cdn-box code { margin-inline-start:6px; }
.stats .bucket { display:flex; flex-direction:column; align-items:center; gap:4px; }
.stats .bucket strong { font-size:32px; }
.stats .bucket .meter { width:100%; max-width:260px; }
.stats .bucket.hot { background:#fde8e6; }
.form-grid.four { grid-template-columns:repeat(4, 1fr); }
@media (max-width: 900px) { .form-grid.four { grid-template-columns:1fr 1fr; } }
@media (max-width: 640px) { .form-grid.four { grid-template-columns:1fr; } }

/* ---------- CDN billing ---------- */
.inline-form { display:flex; align-items:flex-end; gap:10px; flex-wrap:wrap; margin-top:12px; }
.inline-form label { margin:0; }
.inline-form input { width:120px; }

/* ---------- exchange rate ---------- */
.fx-box { margin-top:10px; padding:10px 12px; background:#f6f8fb; border-radius:10px; display:flex; flex-direction:column; gap:8px; }
.fx-box label.check { margin:0; }
.fx-pending { display:flex; align-items:center; gap:10px; flex-wrap:wrap; background:#fff4e0; color:var(--warn); border-radius:8px; padding:8px 10px; }
input:disabled { background:#f1f3f6; color:var(--muted); }

/* ---------- teacher code ---------- */
.code-tag { display:inline-block; font:600 11px/1.6 ui-monospace, Consolas, monospace; background:#eef2f7; color:var(--muted); border-radius:6px; padding:0 6px; vertical-align:middle; }
.code-tag:empty { display:none; }
a.btn { text-decoration:none; display:inline-block; }

/* ---------- site themes ---------- */
.theme-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:16px; margin-top:12px; }
.theme-card { border:1px solid var(--line); border-radius:12px; overflow:hidden; background:#fff; display:flex; flex-direction:column; }
.theme-card.off { opacity:.75; }
.theme-shot { aspect-ratio:16/10; background:#f1f3f6; border-bottom:1px solid var(--line); }
.theme-shot img { width:100%; height:100%; object-fit:cover; object-position:top; display:block; }
.theme-body { padding:12px 14px 14px; display:flex; flex-direction:column; gap:8px; flex:1; }
.theme-body p { margin:0; font-size:13.5px; }
.theme-title { display:flex; justify-content:space-between; align-items:baseline; gap:8px; flex-wrap:wrap; }
.theme-title strong { font-size:16px; }
.theme-title .muted { font-size:12px; }
.theme-badges { display:flex; gap:6px; flex-wrap:wrap; }
.theme-swatches { display:flex; gap:6px; flex-wrap:wrap; }
.theme-swatches span { display:flex; border-radius:999px; overflow:hidden; outline:1px solid var(--line); }
.theme-swatches i { width:11px; height:18px; display:block; }
.theme-stats { display:flex; gap:12px; flex-wrap:wrap; font-size:13px; color:var(--muted); }
.theme-controls { display:flex; gap:12px; flex-wrap:wrap; align-items:center; font-size:13.5px; }
.theme-controls label { display:flex; align-items:center; gap:6px; margin:0; }
.theme-controls select { width:auto; }
.theme-price { width:84px; }
.theme-price:disabled { background:#f1f3f6; color:var(--muted); }
.btn.danger { color:var(--bad); border-color:#f3c3bd; }
.theme-error { white-space:pre-line; max-height:220px; overflow:auto; }

/* ---------- agents ---------- */
#agent-detail h4 { margin:18px 0 6px; font-size:15px; }
#agent-detail .stats { margin-top:10px; }

/* ---------- agent portal ---------- */
.notice { border-radius:10px; padding:10px 14px; margin-bottom:16px; font-weight:600; }
.notice.bad { background:#fde8e6; color:var(--bad); }
.share { display:flex; flex-direction:column; gap:10px; }
.share-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.share-row .label { width:110px; color:var(--muted); font-size:14px; }
.share-row code { font-size:15px; padding:6px 10px; word-break:break-all; flex:1 1 220px; min-width:0; }
.form-grid .wide { grid-column:1 / -1; }
.form-grid select { display:block; width:100%; margin-top:6px; }
td.neg { color:var(--bad); }
td.pos { color:var(--ok); }
.tabs { position:static; margin-bottom:16px; border-radius:12px; border:1px solid var(--line); }
@media (max-width:640px) { .share-row .label { width:auto; } }
