:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e5e9f2;
    --brand: #4f46e5;
    --brand-d: #4338ca;
    --brand-soft: #eef2ff;
    --green: #16a34a;
    --green-soft: #dcfce7;
    --red: #dc2626;
    --red-soft: #fee2e2;
    --amber: #d97706;
    --amber-soft: #fef3c7;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg); color: var(--ink);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ─── Login ─── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background: radial-gradient(1200px 500px at 50% -10%, #e0e7ff 0%, var(--bg) 55%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 24px;
    box-shadow: var(--shadow); padding: 36px 32px; }
.login-card .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-card .logo .mark { width: 40px; height: 40px; border-radius: 12px; background: var(--brand);
    color: #fff; display: grid; place-items: center; font-size: 20px; }
.login-card h1 { font-size: 20px; margin: 0; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 2px 0 24px; }

/* ─── Shell ─── */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 22px 16px;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.brand .mark { width: 36px; height: 36px; border-radius: 10px; background: var(--brand); color: #fff;
    display: grid; place-items: center; font-size: 18px; font-weight: 800; }
.brand .name { font-weight: 800; font-size: 15px; line-height: 1.1; }
.brand .name small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px;
    color: var(--muted); font-weight: 600; font-size: 14px; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand-d); }
.nav a .ic { width: 18px; text-align: center; }
.sidebar .foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.sidebar .who { font-size: 13px; font-weight: 600; }
.sidebar .who small { display: block; color: var(--muted); font-weight: 500; }
.main { padding: 30px 34px 60px; max-width: 1200px; }
.page-h { margin: 0 0 4px; font-size: 24px; font-weight: 800; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }

/* ─── Cards / grid ─── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 22px; }
.grid { display: grid; gap: 16px; }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow); }
.stat .v { font-size: 30px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 2px; }
.stat .ic { float: right; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; }

/* ─── Forms ─── */
.field { margin-bottom: 16px; }
label.lb { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.input, .select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px;
    font-size: 14px; background: #fff; color: var(--ink); outline: none; transition: border .15s, box-shadow .15s; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px;
    border: 1px solid transparent; border-radius: 11px; font-weight: 700; font-size: 14px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

/* ─── Badges ─── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.no { background: var(--red-soft); color: var(--red); }
.badge.ent { background: var(--brand-soft); color: var(--brand-d); }
.badge.gray { background: #f1f5f9; color: #475569; }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; padding: 12px 14px; color: var(--muted); font-weight: 700; font-size: 12px;
    text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); background: #fafbff; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover td { background: #fafbff; cursor: pointer; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ─── Result card ─── */
.result { margin-top: 20px; }
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 0; }
.kv > div { padding: 10px 4px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv > div:nth-child(odd) { color: var(--muted); font-weight: 600; }

/* ─── Progress ─── */
.progress { height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); transition: width .3s; }

/* ─── Modal / toast ─── */
#modal-root:empty { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center;
    padding: 24px; z-index: 100; }
.modal { background: #fff; border-radius: 18px; max-width: 640px; width: 100%; max-height: 85vh; overflow: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal .mh { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal .mh h3 { margin: 0; font-size: 17px; }
.modal .mb { padding: 20px 22px; }
pre.json { background: #0f172a; color: #e2e8f0; padding: 16px; border-radius: 12px; overflow: auto; font-size: 12.5px; line-height: 1.5; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
    background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,.3); transition: all .25s; pointer-events: none; z-index: 200; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.err { background: #b91c1c; }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; font-size: 14px; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 34px; text-align: center;
    color: var(--muted); background: #fbfcfe; transition: border .15s, background .15s; }
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }
.pagination { display: flex; align-items: center; gap: 12px; margin-top: 16px; justify-content: flex-end; font-size: 14px; }
.hide { display: none !important; }

@media (max-width: 820px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .nav { flex-direction: row; flex-wrap: wrap; margin: 0; }
    .sidebar .foot { margin: 0 0 0 auto; border: none; padding: 0; }
    .main { padding: 20px; }
    .kv { grid-template-columns: 1fr; }
    .kv > div:nth-child(odd) { padding-bottom: 0; border: none; }
}
