:root {
    color-scheme: light;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --line: #e5e9f2;
    --ink: #0f172a;
    --ink-2: #475569;
    --ink-3: #94a3b8;
    --brand: #4f46e5;
    --brand-2: #7c3aed;
    --brand-soft: #eef0ff;
    --ok: #059669;
    --ok-soft: #e6f7f0;
    --bad: #dc2626;
    --bad-soft: #fdecec;
    --warn: #d97706;
    --warn-soft: #fff4e0;
    --gold: #b8860b;
    --gold-1: #f5d06f;
    --gold-2: #e0a526;
    --gold-soft: #fff8e1;
    --hdr-1: #0f172a;
    --hdr-2: #1e1b4b;
    --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
    --shadow-2: 0 8px 24px rgba(15, 23, 42, .08);
    --shadow-3: 0 24px 60px rgba(15, 23, 42, .18);
    --r: 16px;
    --r-sm: 11px;
    --nav-h: 66px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.5;
}
.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.sm { width: 15px; height: 15px; }
.hidden { display: none !important; }

/* ---------- Buttons & fields ---------- */
button { font-family: inherit; cursor: pointer; border: none; }
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: var(--r-sm);
    font-size: 14px; font-weight: 600; color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: 0 4px 14px rgba(79, 70, 229, .28);
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, background .15s;
    white-space: nowrap; text-decoration: none;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 13px; font-size: 13px; border-radius: 9px; }
.btn.ok { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 4px 14px rgba(5, 150, 105, .25); }
.btn.bad { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 4px 14px rgba(220, 38, 38, .22); }
.btn.warn { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 4px 14px rgba(217, 119, 6, .25); }
.btn.gold { background: linear-gradient(135deg, var(--gold-1), var(--gold-2)); color: #3b2a00; box-shadow: 0 4px 14px rgba(224, 165, 38, .35); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); filter: none; }
.btn.soft-bad { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.btn.soft-warn { background: var(--warn-soft); color: var(--warn); box-shadow: none; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, .09); color: #e8ecf8; border: 1px solid rgba(255, 255, 255, .12);
    transition: background .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .18); }

.field { margin-bottom: 16px; }
.field > label, .lbl {
    display: block; margin-bottom: 7px; font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .2px;
}
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
    width: 100%; min-height: 46px; padding: 11px 14px; font-size: 16px; /* 16px stops iOS zoom */
    font-family: inherit; color: var(--ink); background: var(--surface);
    border: 1.5px solid var(--line); border-radius: var(--r-sm);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(79, 70, 229, .14); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { min-height: 150px; resize: vertical; font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.6; }
.input-wrap { position: relative; }
.input-wrap .eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; background: transparent; color: var(--ink-3); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.input-wrap input { padding-right: 46px; }
.msg-err { color: var(--bad); font-size: 13px; font-weight: 500; min-height: 18px; margin-top: 6px; }
.msg-ok { color: var(--ok); font-size: 13px; font-weight: 500; margin-top: 6px; }
.help { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

/* ---------- Login ---------- */
body.center { display: flex; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(900px 520px at 8% -10%, #dfe5ff 0%, transparent 60%), radial-gradient(800px 500px at 100% 110%, #fbe3f1 0%, transparent 55%), #f4f6fb; }
body.center #loginCard { display: block; }
body.center #app, body.center #bottomNavHost { display: none !important; }
body:not(.center) #loginCard { display: none; }
.login-card {
    width: 100%; max-width: 420px; background: var(--surface); border-radius: 22px; padding: 36px 30px 28px;
    box-shadow: 0 24px 60px rgba(60, 70, 140, .16), 0 2px 6px rgba(15, 23, 42, .05); border: 1px solid var(--line); animation: rise .5s cubic-bezier(.16, 1, .3, 1);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.brand-mark {
    width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 24px rgba(79, 70, 229, .4);
}
.brand-mark .ic { width: 26px; height: 26px; }
.login-card h1 { font-size: 22px; font-weight: 800; text-align: center; letter-spacing: -.3px; }
.login-card .sub { text-align: center; color: var(--ink-2); font-size: 13.5px; margin: 6px 0 26px; }
.login-foot { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 18px; }


/* ---------- App shell: sidebar + main (light theme) ---------- */
.app { display: none; }
.app.active { display: grid; grid-template-columns: 276px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side {
    position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 80;
    display: flex; flex-direction: column; padding: 18px 14px 14px; overflow-y: auto;
    background: linear-gradient(180deg, #ffffff 0%, #f5f6ff 100%);
    color: var(--ink-2); border-right: 1px solid var(--line);
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 14px; }
.side-brand .mark { width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(99, 102, 241, .35); flex: none; color: #fff; }
.side-brand .mark .ic { width: 22px; height: 22px; }
.side-brand .t { font-weight: 800; font-size: 15.5px; color: var(--ink); line-height: 1.2; letter-spacing: -.2px; }
.side-brand .s { font-size: 10.5px; color: var(--ink-3); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }
.side-sec { font-size: 10.5px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase; color: var(--ink-3); padding: 16px 12px 8px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 43px; padding: 0 12px; margin-bottom: 2px;
    border-radius: 12px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 14px; text-align: left;
    position: relative; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--brand-soft); color: var(--brand); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); box-shadow: inset 0 0 0 1px rgba(79, 70, 229, .12); }
.nav-item.active::before { content: ''; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: linear-gradient(180deg, var(--brand), var(--brand-2)); }
.nav-item .count { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--line); color: var(--ink-2); padding: 1px 9px; border-radius: 999px; }
.nav-item.active .count { background: var(--brand); color: #fff; }
.nav-item.danger:hover { background: var(--bad-soft); color: var(--bad); }
.side-user { margin-top: auto; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); display: flex; align-items: center; gap: 11px; }
.side-user .avatar { width: 40px; height: 40px; }
.side-user .who { min-width: 0; flex: 1; }
.side-user .nm { color: var(--ink); font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .rl { font-size: 11.5px; color: var(--ink-3); text-transform: capitalize; }
.side-user .chip { font-size: 10.5px; padding: 2px 8px; }
.scrim { position: fixed; inset: 0; background: rgba(30, 41, 80, .35); backdrop-filter: blur(3px); z-index: 70; display: none; }
.scrim.active { display: block; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 14px;
    padding: 14px 28px; padding-top: calc(14px + env(safe-area-inset-top));
    background: var(--bg); background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.burger { display: none; width: 42px; height: 42px; border-radius: 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); align-items: center; justify-content: center; flex: none; }
.tb-title { min-width: 0; }
.tb-title h1 { font-size: 20px; font-weight: 800; letter-spacing: -.4px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title .crumb { font-size: 12px; color: var(--ink-3); }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tb-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 13px; white-space: nowrap; box-shadow: var(--shadow-1); }
.tb-chip .ic { width: 15px; height: 15px; }
.tb-chip.unl { background: linear-gradient(135deg, var(--gold-1), var(--gold-2)); color: #3b2a00; border-color: transparent; }

.content { width: 100%; max-width: 1160px; margin: 0 auto; padding: 24px 28px 48px; }
.page { display: none; }
.page.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.impersonate { display: none; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 16px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn); border: 1px solid rgba(217, 119, 6, .35); font-weight: 600; }
.impersonate.active { display: flex; }

/* hero + stats */
.hero {
    position: relative; overflow: hidden; border-radius: 20px; padding: 26px 28px; color: var(--ink); margin-bottom: 18px;
    background: radial-gradient(520px 220px at 95% -30%, rgba(167, 139, 250, .30), transparent 60%), radial-gradient(380px 200px at 0% 120%, rgba(56, 189, 248, .20), transparent 60%), linear-gradient(120deg, #eef2ff, #e6ebff 55%, #f3e8ff);
    border: 1px solid #dfe3fb; box-shadow: var(--shadow-1); display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.hero h2 { font-size: 23px; font-weight: 800; letter-spacing: -.5px; }
.hero p { color: var(--ink-2); margin-top: 5px; font-size: 13.5px; max-width: 520px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow-1); min-width: 0; }
.stat .si { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.stat .si .ic { width: 17px; height: 17px; }
.stat .k { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); }
.stat .v { font-size: 24px; font-weight: 800; letter-spacing: -.6px; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 30px; }
.stat .n { font-size: 12px; color: var(--ink-2); margin-top: 1px; }
.stat.unl { background: linear-gradient(135deg, #fff8e1, #ffeab0); border-color: rgba(224, 165, 38, .55); }
.stat.unl .si { background: rgba(224, 165, 38, .22); color: #a16207; }
.stat.unl .k { color: #a16207; } .stat.unl .v { color: #7a4f00; } .stat.unl .n { color: #8a6d1f; }
.stat.unl-bal { opacity: .6; }
.dash-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; align-items: start; }
.panel-h .more { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--brand); background: transparent; padding: 6px 10px; border-radius: 8px; }
.panel-h .more:hover { background: var(--brand-soft); }
.mini { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.mini:last-child { border-bottom: none; }
.mini .mi { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; flex: none; }
.mini .mm { flex: 1; min-width: 0; }
.mini .mm b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .mm span { font-size: 12px; color: var(--ink-3); }
.acct { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.acct .avatar { width: 58px; height: 58px; border-radius: 16px; font-size: 22px; }
.acct h3 { font-size: 18px; font-weight: 800; }
.bnav { display: none; }
/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow-1); }
.panel-h { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.panel-h .num { width: 30px; height: 30px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex: none; }
.panel-h .num.ok { background: var(--ok-soft); color: var(--ok); }
.panel-h h2 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.panel-h p { font-size: 12.5px; color: var(--ink-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

.drop { border: 2px dashed var(--line); border-radius: var(--r); padding: 28px 18px; text-align: center; cursor: pointer; background: var(--surface-2); transition: all .15s; }
.drop:hover, .drop.dragover { border-color: var(--brand); background: var(--brand-soft); }
.drop .ic { width: 30px; height: 30px; color: var(--brand); margin-bottom: 8px; }
.drop b { color: var(--brand); }
.drop .sm { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }
.or { display: flex; align-items: center; gap: 14px; color: var(--ink-3); font-size: 12px; font-weight: 600; margin: 16px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.tbl-wrap { margin-top: 14px; max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.tbl .x { width: 28px; height: 28px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); display: inline-flex; align-items: center; justify-content: center; }

.cost-line { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); margin: 4px 0 16px; font-size: 13.5px; color: var(--ink-2); }
.cost-line strong { color: var(--ink); font-size: 15px; }
.cost-line.unl { background: var(--gold-soft); border-color: rgba(224, 165, 38, .5); color: var(--gold); }
.cost-line.unl strong { color: var(--gold); }

.success-card { display: flex; gap: 12px; padding: 14px; border-radius: var(--r-sm); background: var(--ok-soft); border: 1px solid rgba(5, 150, 105, .3); margin-bottom: 16px; color: var(--ok); }
.success-card .tt { font-weight: 700; font-size: 14px; } .success-card .dd { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.token-row { display: flex; gap: 8px; }
.token-row input { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.code-box { background: #0b1020; border: 1px solid #232d52; border-radius: var(--r-sm); padding: 16px; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #cbd5e1; max-height: 420px; overflow: auto; white-space: pre; margin-top: 14px; line-height: 1.6; }

/* ---------- List items (batches / users / logs) ---------- */
.item { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 16px; margin-bottom: 12px; transition: box-shadow .15s, border-color .15s; }
.item:hover { box-shadow: var(--shadow-2); border-color: #c9d0e6; }
.item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.item .nm { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.chip.gold { background: linear-gradient(135deg, var(--gold-1), var(--gold-2)); color: #3b2a00; border-color: transparent; }
.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.meta-grid > div { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.meta-grid .k { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.meta-grid .v { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.item-act { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-act .sp { flex: 1; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; min-height: 0; }
.switch .tr { width: 42px; height: 24px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .2s; flex: none; }
.switch .tr::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.switch input:checked + .tr { background: #10b981; }
.switch input:checked + .tr::after { transform: translateX(18px); }
.switch input:focus-visible + .tr { box-shadow: 0 0 0 4px rgba(16, 185, 129, .25); }

.user-head { display: flex; align-items: center; gap: 12px; }
.avatar { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; text-transform: uppercase; flex: none; }
.item.unl-user { border-color: rgba(224, 165, 38, .55); background: linear-gradient(180deg, var(--gold-soft), var(--surface) 70%); }
.ctl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 4px; }
.ctl { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; }
.ctl .lbl { margin-bottom: 8px; }
.ctl .inline { display: flex; gap: 8px; }
.ctl .inline input, .ctl .inline select { min-height: 38px; padding: 6px 10px; font-size: 14px; min-width: 0; }
.ctl .inline .btn { flex: none; }
.ctl .quick { display: flex; gap: 6px; margin-top: 8px; }
.ctl.gold-ctl { border-color: rgba(224, 165, 38, .5); background: var(--gold-soft); }
.search { position: relative; margin-bottom: 14px; }
.search .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search input { padding-left: 40px; }

.log { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.log:last-child { border-bottom: none; }
.log .who { font-weight: 600; } .log .sub { font-size: 12px; color: var(--ink-3); }
.log .amt { font-weight: 700; white-space: nowrap; }
.log .amt.free { color: var(--gold); }
.empty { text-align: center; padding: 34px 10px; color: var(--ink-3); }
.empty .ic { width: 34px; height: 34px; margin-bottom: 8px; opacity: .6; }

/* compact user rows */
.item.u-item { padding: 0; overflow: hidden; margin-bottom: 8px; }
.u-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; }
.u-row:hover { background: var(--surface-2); }
.u-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.u-main { flex: 1; min-width: 0; }
.u-main .help { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-row .avatar { width: 36px; height: 36px; border-radius: 10px; font-size: 14px; }
.chev { color: var(--ink-3); transition: transform .2s; }
.u-item.open .chev { transform: rotate(180deg); }
.u-body { padding: 4px 14px 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 12.5px; color: var(--ink-2); text-align: center; }

/* ---------- Modal, toast ---------- */
.modal-ov { position: fixed; inset: 0; background: rgba(8, 12, 28, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: none; align-items: center; justify-content: center; z-index: 10000; padding: 16px; }
.modal-ov.active { display: flex; }
.modal { background: var(--surface); border-radius: 20px; padding: 26px; width: 100%; max-width: 440px; box-shadow: var(--shadow-3); animation: rise .3s cubic-bezier(.16, 1, .3, 1); }
.modal h3 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.modal .mp { color: var(--ink-2); font-size: 13.5px; margin-bottom: 18px; }
.modal-act { display: flex; gap: 10px; margin-top: 18px; }
.modal-act .btn { flex: 1; }
#toasts { position: fixed; top: 16px; right: 16px; z-index: 20000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { padding: 13px 18px; background: #065f46; color: #fff; border-radius: 12px; font-weight: 600; font-size: 13.5px; box-shadow: 0 12px 30px rgba(0, 0, 0, .3); animation: slideIn .3s; max-width: 340px; }
.toast.error { background: #991b1b; } .toast.warn { background: #92400e; }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { height: 84px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: sh 1.3s infinite; margin-bottom: 12px; }
@keyframes sh { to { background-position: -200% 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .ctl-grid { grid-template-columns: 1fr; }
    .meta-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
    .app.active { display: block; }
    .side { position: fixed; left: 0; top: 0; bottom: 0; width: 288px; max-width: 86vw; transform: translateX(-104%); transition: transform .28s cubic-bezier(.16, 1, .3, 1); box-shadow: none; padding-top: calc(18px + env(safe-area-inset-top)); }
    .side.open { transform: none; box-shadow: 0 0 50px rgba(30, 41, 80, .25); }
    .burger { display: inline-flex; }
    .topbar { padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); gap: 10px; }
    .tb-title h1 { font-size: 17px; }
    .tb-chip.plan-chip { display: none; }
    .content { padding: 14px 14px calc(var(--nav-h) + 26px + env(safe-area-inset-bottom)); }
    .bnav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; gap: 2px;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--surface);
        border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: 0 -8px 24px rgba(15, 23, 42, .12);
    }
    .bn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; padding: 6px 4px; border-radius: 12px; background: transparent; color: var(--ink-2); font-size: 11px; font-weight: 600; }
    .bn .ic { width: 21px; height: 21px; }
    .bn.active { background: var(--brand-soft); color: var(--brand); }
}
@media (max-width: 720px) {
    body { font-size: 14px; }
    .hero { padding: 20px; border-radius: 18px; }
    .hero h2 { font-size: 19px; }
    .stats { gap: 10px; }
    .stat { padding: 13px; border-radius: 14px; }
    .stat .v { font-size: 19px; padding-right: 0; }
    .stat .si { display: none; }
    .stat .k { font-size: 10px; }
    .stat .n { font-size: 11px; line-height: 1.3; }
    .panel { padding: 16px; border-radius: 14px; }
    .grid-2 { grid-template-columns: 1fr; gap: 0; }
    .item { padding: 14px; }
    .item.u-item { padding: 0; }
    .item-act .btn { flex: 1; }
    .item-act .switch { width: 100%; justify-content: space-between; padding: 6px 2px; }
    .item-act .sp { display: none; }
    .token-row { flex-direction: column; }
    .row .btn { flex: 1 1 calc(50% - 5px); }
    .modal { padding: 22px; }
    #toasts { left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top)); align-items: stretch; }
    .toast { max-width: none; }
    .tbl th, .tbl td { padding: 9px 10px; }
}
@media (max-width: 380px) {
    .meta-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
}
@media (max-width: 720px) { .hidden-sm { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* multi-page: links styled like buttons */
a.nav-item, a.bn, a.more, a.btn { text-decoration: none; }
a.more { display: inline-block; }
.hero a.btn { color: #3b2a00; }

/* batch toolbar */
.toolbar { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 260px; margin-bottom: 0; }
.seg { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; }
.seg button { min-height: 38px; padding: 0 16px; border-radius: 9px; background: transparent; color: var(--ink-2); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-1); }
@media (max-width: 720px) { .seg { width: 100%; } .seg button { flex: 1; } }

/* spreadsheet grid */
.sheet-wrap { max-height: 440px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
table.sheet { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.sheet th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.sheet th.rn, .sheet td.rn { width: 44px; text-align: center; padding: 0; color: var(--ink-3); background: var(--surface-2); font-size: 12px; font-weight: 600; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sheet th.c2 { width: 190px; }
.sheet td { padding: 0; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.sheet td:last-child, .sheet th:last-child { border-right: none; }
.sheet td input { width: 100%; min-height: 40px; padding: 0 12px; border: none; border-radius: 0; background: transparent; box-shadow: none; font-size: 14px; }
.sheet td input:focus { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.sheet tr.bad td:not(.rn) { background: var(--warn-soft); }
@media (max-width: 720px) {
    .sheet td input { font-size: 16px; padding: 0 9px; }
    .sheet th.c2 { width: 130px; } .sheet th.rn, .sheet td.rn { width: 34px; }
}
