:root {
    --bg: #0b0f1a;
    --bg2: #131a2b;
    --bg3: #1c2440;
    --fg: #e7ecff;
    --muted: #8d97b8;
    --accent: #00d2ff;
    --accent2: #5b8cff;
    --good: #4ade80;
    --bad: #f87171;
    --warn: #fbbf24;
    --border: #2a3457;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-size: 14px; }
.app { max-width: 1200px; margin: 0 auto; padding: 20px 24px 40px; }

header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
h1 { margin: 0; font-size: 22px; color: #fff; }
.tag { background: var(--accent); color: #0b0f1a; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.server-status { font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--bad); margin: 0 4px; vertical-align: middle; }
.dot-on { background: var(--good); box-shadow: 0 0 6px var(--good); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { background: transparent; color: var(--muted); border: none; padding: 10px 18px; cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s; }
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.panel { display: none; }
.panel.active { display: block; }

label { display: block; font-weight: 600; color: var(--fg); margin: 8px 0 4px; font-size: 13px; }
textarea, input[type=text], input[type=password] {
    width: 100%; padding: 10px 12px; background: var(--bg2); color: var(--fg);
    border: 1px solid var(--border); border-radius: 6px; font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 13px;
}
textarea { resize: vertical; min-height: 80px; }
textarea:focus, input:focus { outline: none; border-color: var(--accent); }

.row { display: flex; gap: 16px; }
.col { flex: 1; }
.col-narrow { flex: 0 0 280px; }
.opts { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.chk { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; padding: 4px 0; font-size: 13px; }

.source-toggles { margin: 16px 0; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 12px 16px; }
.source-toggles summary { cursor: pointer; font-weight: 600; color: var(--fg); }
.src-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; margin-top: 10px; }
.src-item { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 6px; border-radius: 4px; }
.src-item:hover { background: var(--bg3); }
.src-item .badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; margin-left: auto; }
.src-item .b-key { background: var(--warn); color: #1a1a2e; }
.src-item .b-no-key { background: var(--bad); color: #fff; }
.src-item .b-free { background: var(--good); color: #0b0f1a; }
.src-item .b-bin { background: var(--accent2); color: #fff; }
.src-item.disabled { opacity: 0.5; }

.actions { display: flex; gap: 8px; align-items: center; margin: 16px 0; flex-wrap: wrap; }
.spacer { flex: 1; }
button.primary, button.secondary {
    border: none; border-radius: 6px; padding: 10px 18px; cursor: pointer; font-size: 14px; font-weight: 600;
    transition: background 0.15s, transform 0.05s;
}
button.primary { background: var(--accent); color: #0b0f1a; }
button.primary:hover { background: #5be8ff; }
button.primary:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }
button.secondary { background: var(--bg3); color: var(--fg); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border); }
button.secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.status-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg2); border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.counter { margin-left: auto; color: var(--accent); font-weight: 700; }
.loader { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; display: none; }
.loader.active { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; margin-bottom: 14px; }
.pg-item { padding: 6px 10px; background: var(--bg2); border-radius: 4px; border: 1px solid var(--border); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.pg-item .name { font-weight: 600; }
.pg-item.ok { border-left: 3px solid var(--good); }
.pg-item.err { border-left: 3px solid var(--bad); }
.pg-item.pending { border-left: 3px solid var(--warn); }
.pg-item .num { color: var(--accent); font-weight: 700; }

.results { margin-top: 12px; }
.results h3 { color: var(--fg); margin: 8px 0; }
.muted { color: var(--muted); font-weight: normal; font-size: 13px; }
pre#output { background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 14px; color: #b8e4ff; max-height: 480px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; font-size: 12.5px; }

table.data { width: 100%; border-collapse: collapse; margin-top: 10px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
table.data th, table.data td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
table.data th { background: var(--bg3); color: var(--fg); font-weight: 600; position: sticky; top: 0; }
table.data tr.avail-yes { background: rgba(74, 222, 128, 0.08); }
table.data tr.avail-no { color: var(--muted); }
table.data tr.avail-err { background: rgba(248, 113, 113, 0.08); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }

.hint { color: var(--muted); font-size: 13px; line-height: 1.5; background: var(--bg2); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 4px; margin-bottom: 14px; }
.hint code { background: var(--bg3); padding: 2px 6px; border-radius: 3px; color: var(--accent); }

footer { margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--border); text-align: center; color: var(--muted); font-size: 12px; }
footer code { color: var(--accent); }

.namecheap-box { margin: 12px 0; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px; }
.namecheap-box summary { cursor: pointer; font-weight: 600; }

/* ---- SEO Edition additions (smart input + TLD presets + buy link) ---- */
.tld-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 6px 0 4px; }
.tld-card { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.tld-card:hover { border-color: var(--accent2); }
.tld-card input[type="radio"] { accent-color: var(--accent); }
.tld-card:has(input:checked) { background: rgba(0, 210, 255, 0.07); border-color: var(--accent); }
.tld-card small { color: var(--muted); font-size: 11px; }

/* ---- Mode tabs: 3 separate hunting methods ---- */
.mode-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.mode-tab { flex: 1; min-width: 150px; background: var(--bg2); color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 13px 16px; cursor: pointer; font-size: 14px; font-weight: 600; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.mode-tab:hover { color: var(--fg); border-color: var(--accent2); }
.mode-tab.active { background: rgba(0, 210, 255, 0.08); color: var(--accent); border-color: var(--accent); }
.mode-panel { display: none; }
.mode-panel.active { display: block; }
.big-btn { font-size: 16px; padding: 14px 28px; margin-top: 16px; }

.parent-warn { color: var(--warn); font-size: 12.5px; line-height: 1.5; margin-top: 8px; padding: 9px 13px; background: rgba(251, 191, 36, 0.08); border: 1px solid rgba(251, 191, 36, 0.25); border-radius: 6px; }
.parent-warn code { background: var(--bg3); padding: 1px 5px; border-radius: 3px; color: var(--warn); }

/* ---- Master scan switch + status lamp ---- */
.master-switch { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 4px; }
.scan-status { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin-left: auto; }
.lamp { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 8px transparent; transition: background 0.2s, box-shadow 0.2s; }
.lamp.on { background: var(--good); box-shadow: 0 0 12px var(--good); }
.lamp.off { background: var(--bad); }

/* ---- Pagination ---- */
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 14px 0; }

/* ---- Role-based visibility (user vs admin) ---- */
body[data-role="user"] .admin-only { display: none !important; }
body[data-role="admin"] .user-only { display: none !important; }
/* default before /auth/me resolves: hide both to avoid flash */
body:not([data-role]) .admin-only, body:not([data-role]) .user-only { visibility: hidden; }

/* ---- Star/hide tag buttons ---- */
.tag-btn { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 2px 6px; border-radius: 4px; cursor: pointer; font-size: 12px; margin-left: 4px; }
.tag-btn:hover { background: var(--bg3); color: var(--fg); }

/* ---- L3 seeder ---- */
details.l3-seed { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
details.l3-seed summary { cursor: pointer; font-weight: 600; color: var(--warn); }
details.l3-seed[open] summary { margin-bottom: 8px; }

/* ---- Kho sub-tabs (Cấp 2 / Cấp 3 / Sắp drop) ---- */
.kho-tabs { display: flex; gap: 6px; margin: 18px 0 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.kho-tab { background: transparent; color: var(--muted); border: none; border-bottom: 2px solid transparent; padding: 9px 16px; cursor: pointer; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.kho-tab:hover { color: var(--fg); }
.kho-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.kho-tab .tab-count {
    background: var(--bg3);
    color: var(--muted);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    min-width: 28px;
    text-align: center;
}
.kho-tab.active .tab-count { background: rgba(0, 210, 255, 0.15); color: var(--accent); }
.kho-tab.has-fresh .tab-count::after { content: " 🟢"; font-size: 8px; }
.kho-panel { display: none; }
.kho-panel.active { display: block; }

/* Sticky tabs khi scroll trong panel — nằm dưới sticky header */
.kho-tabs-sticky {
    position: sticky;
    top: 56px;  /* dưới sticky header */
    background: var(--bg);
    z-index: 90;
    padding-top: 4px;
    margin-top: 14px;
}

/* ---- Sticky header trong Kho panel ---- */
.kho-sticky-header {
    position: sticky;
    top: -1px;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
    margin: -10px 0 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.kho-sticky-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.kho-sticky-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.kho-quick-stats {
    font-size: 12px;
    background: var(--bg2);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.kho-quick-stats .stat-on { color: var(--good); font-weight: 700; }
.kho-quick-stats .stat-off { color: var(--bad); font-weight: 700; }

/* Icon button (compact, square, like scroll-to-top) */
.icon-btn {
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--fg);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s, transform 0.05s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover { background: var(--accent); color: var(--bg); }
.icon-btn:active { transform: scale(0.92); }

/* ---- Kho domain (DB) store ---- */
.store-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; font-size: 13px; }
.store-stats .stat { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px; min-width: 110px; }
.store-stats .stat b { display: block; font-size: 20px; color: var(--accent); }
.store-stats .stat.on b { color: var(--good); }
.store-stats .muted-row { width: 100%; color: var(--muted); font-size: 12px; }

.buy-link { color: var(--good); text-decoration: none; font-weight: 600; padding: 4px 10px; background: rgba(74, 222, 128, 0.1); border-radius: 4px; border: 1px solid rgba(74, 222, 128, 0.3); font-size: 12px; }
.buy-link:hover { background: rgba(74, 222, 128, 0.2); }

@media (max-width: 720px) {
    .tld-presets { grid-template-columns: 1fr 1fr; }
}

/* Shared-registry warning: cn.com / us.com / co.uk etc. usually = aftermarket */
.badge-premium { background: rgba(251, 191, 36, 0.15); color: var(--warn); padding: 2px 6px; border-radius: 3px; font-size: 11px; border: 1px solid rgba(251, 191, 36, 0.3); margin-left: 6px; }
.buy-risky { background: rgba(251, 191, 36, 0.1); color: var(--warn); border-color: rgba(251, 191, 36, 0.3); }
.buy-risky:hover { background: rgba(251, 191, 36, 0.2); }

.modal { position:fixed; inset:0; background:rgba(0,0,0,0.6); z-index:1000; display:flex; align-items:center; justify-content:center; }
.modal-card { background:var(--bg); border:1px solid var(--border); border-radius:8px; padding:24px; max-width:600px; width:90%; max-height:80vh; overflow:auto; position:relative; }
.modal-close { position:absolute; top:8px; right:12px; background:transparent; border:none; color:var(--fg); cursor:pointer; font-size:18px; }
.domain-link { color:var(--fg); text-decoration:none; }
.domain-link:hover { color:var(--accent); text-decoration:underline; }

/* ---- Help tip icon (ⓘ) — inline next to confusing labels ---- */
.help-tip {
    display: inline-block;
    cursor: help;
    color: var(--accent2);
    font-size: 12px;
    margin-left: 2px;
    user-select: none;
    transition: color 0.15s, transform 0.15s;
    vertical-align: baseline;
}
.help-tip:hover {
    color: var(--accent);
    transform: scale(1.15);
}

/* ---- Glossary box at top of Kho domain section ---- */
details.glossary {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 8px;
}
details.glossary summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--fg);
    padding: 2px 0;
}
details.glossary summary:hover { color: var(--accent); }
details.glossary[open] summary { margin-bottom: 10px; color: var(--accent); }
.glossary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px 16px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.6;
}
.glossary-grid b { color: var(--accent); font-weight: 700; }

/* ---- Hover hint on buttons: visual cue (subtle outline on hover for tooltip-enabled buttons) ---- */
button[title]:hover, label[title]:hover, input[title]:hover, select[title]:hover {
    /* native browser tooltip handles the text — just add subtle visual cue */
}

/* Cursor:help on labels with title for clarity that they're informational */
label[title], span[title]:not([class]) { cursor: help; }

/* ---- Live log terminal (admin) ---- */
.logs-terminal {
    background: #050810;
    color: #cfd8e8;
    font-family: 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
    font-size: 11.5px;
    line-height: 1.45;
    padding: 10px 12px;
    height: 320px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-top: 6px;
    white-space: pre-wrap;
    word-break: break-word;
}
.logs-terminal .log-line {
    padding: 1px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.logs-terminal .log-line:hover { background: rgba(0, 210, 255, 0.05); }
.logs-terminal .log-time { color: #5b8cff; margin-right: 8px; }
.logs-terminal .log-level { font-weight: 700; margin-right: 4px; }
.logs-terminal .log-info  { color: #cfd8e8; }
.logs-terminal .log-warn  { color: #fbbf24; }
.logs-terminal .log-warn .log-level  { color: #fbbf24; }
.logs-terminal .log-error { color: #f87171; }
.logs-terminal .log-error .log-level { color: #f87171; }
.logs-terminal::-webkit-scrollbar { width: 8px; height: 8px; }
.logs-terminal::-webkit-scrollbar-track { background: #0a0f1c; }
.logs-terminal::-webkit-scrollbar-thumb { background: #2a3457; border-radius: 4px; }
.logs-terminal::-webkit-scrollbar-thumb:hover { background: #3a4567; }

#logsStatus.connected { color: var(--good); font-weight: 700; }
#logsStatus.disconnected { color: var(--muted); }
#logsStatus.error { color: var(--bad); font-weight: 700; }

/* ═══════════════════════════════════════════════════════════ */
/* UI Redesign v2: Stats hero + Admin drawer + Toast            */
/* ═══════════════════════════════════════════════════════════ */

/* ---- Stats hero (4-tile overview ở top kho) ---- */
.kho-stats-hero {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 14px 0;
}
.hero-tile {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--muted);
    border-radius: 10px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: help;
    transition: border-color 0.2s, transform 0.05s;
}
.hero-tile:hover { transform: translateY(-1px); border-color: var(--accent2); }
.hero-tile.good { border-left-color: var(--good); }
.hero-tile.accent { border-left-color: var(--accent); }
.hero-tile.warn { border-left-color: var(--warn); }
.hero-num {
    font-size: 26px;
    font-weight: 700;
    color: var(--fg);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.hero-tile.good .hero-num { color: var(--good); }
.hero-tile.accent .hero-num { color: var(--accent); }
.hero-tile.warn .hero-num { color: var(--warn); }
.hero-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}
@media (max-width: 720px) {
    .kho-stats-hero { grid-template-columns: 1fr 1fr; }
    .hero-num { font-size: 22px; }
}

/* ---- Admin compact toolbar (1 dòng — replace inline admin master switch) ---- */
.kho-admin-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin: 10px 0;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.kho-admin-bar .spacer { flex: 1; }
.scan-status-compact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 4px 10px;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--border);
}
.admin-drawer-trigger {
    padding: 8px 16px !important;
    font-size: 13px !important;
}

/* ---- Admin drawer (slide from right) ---- */
.admin-drawer {
    position: fixed;
    top: 0;
    right: -480px;     /* hidden by default */
    width: 460px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
    z-index: 1100;
    transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.admin-drawer.open { right: 0; }

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg2);
    flex-shrink: 0;
}
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px 32px;
}
.drawer-section {
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px dashed var(--border);
}
.drawer-section:last-child { border-bottom: none; }
.drawer-section h4 {
    margin: 0 0 8px;
    font-size: 13px;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.drawer-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 6px;
}
.drawer-actions button { padding: 7px 14px; font-size: 13px; }
.drawer-actions input[type="text"] { padding: 7px 10px; font-size: 13px; }
.drawer-section textarea { font-size: 12px; padding: 8px 10px; }
.scan-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
}
.small { font-size: 11px !important; }

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1099;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s;
}
.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* ---- Toast notifications (replace alert + flash) ---- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    pointer-events: none;
}
.toast {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 6px;
    padding: 12px 18px;
    color: var(--fg);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    min-width: 240px;
    max-width: 380px;
    pointer-events: auto;
    animation: toastIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.success { border-left-color: var(--good); }
.toast.error { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }
.toast.fading {
    animation: toastOut 0.25s forwards;
}
@keyframes toastIn {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(20px); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════ */
/* UI Redesign v3 — App Shell (sidebar + topbar + routes)       */
/* ═══════════════════════════════════════════════════════════ */

/* ───────── LOGIN GATE ───────── */
.login-gate {
    position: fixed; inset: 0; z-index: 3000;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at 50% 30%, #131a2b 0%, #0b0f1a 70%);
}
.login-card {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: 14px; padding: 36px 32px; width: 90%; max-width: 380px;
    text-align: center; box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.login-brand { margin: 0 0 4px; font-size: 26px; color: #fff; }
.login-tagline { margin: 0 0 4px; font-size: 15px; color: var(--accent); font-weight: 600; }
.login-sub { margin: 0 0 20px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.login-card input { text-align: center; font-size: 15px; padding: 12px; }
.login-error { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 10px; }
.login-hint { font-size: 11.5px; margin: 14px 0 0; }

/* ───────── SHELL GRID ───────── */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

/* ───────── SIDEBAR ───────── */
.sidebar {
    background: var(--bg2); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { font-size: 17px; font-weight: 700; color: #fff; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: transparent; border: none; color: var(--muted);
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    font-size: 14px; font-weight: 500; text-align: left;
    border-left: 3px solid transparent; transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg3); color: var(--fg); }
.nav-item.active { background: rgba(0,210,255,0.1); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.nav-ico { font-size: 16px; width: 20px; text-align: center; }
.nav-divider { font-size: 10px; color: var(--muted); letter-spacing: 1px; padding: 14px 12px 6px; font-weight: 700; opacity: 0.6; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.role-badge { font-size: 13px; font-weight: 700; color: var(--good); }

/* ───────── TOPBAR ───────── */
.shell-main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 80;
    display: flex; align-items: center; gap: 14px;
    padding: 10px 20px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar-search { flex: 1; max-width: 520px; }
.topbar-search input { width: 100%; padding: 9px 14px; font-family: inherit; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.scan-status-badge {
    display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted);
    padding: 6px 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; cursor: pointer;
}
.scan-status-badge:hover { border-color: var(--accent2); }
.sidebar-toggle { display: none; }

/* ───────── CONTENT / ROUTES ───────── */
.content { padding: 22px 24px 60px; max-width: 1280px; }
.route-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.route-head h2 { margin: 0; font-size: 20px; color: #fff; }
.route-head .muted { font-size: 12px; }

/* ───────── DASHBOARD ───────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.dash-card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.dash-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dash-card-head h3 { margin: 0; font-size: 15px; color: var(--fg); }
.link-btn { background: transparent; border: none; color: var(--accent); cursor: pointer; font-size: 12.5px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.dash-list { display: flex; flex-direction: column; gap: 2px; }
.dash-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 6px; font-size: 13px; }
.dash-row:hover { background: var(--bg3); }
.dash-rank { color: var(--muted); width: 18px; font-variant-numeric: tabular-nums; font-size: 12px; }
.dash-row .domain-link { flex: 0 0 auto; }
.dash-meta { color: var(--muted); font-size: 11.5px; margin-left: 4px; }
.dash-score { margin-left: auto; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.dash-empty { color: var(--muted); font-size: 13px; padding: 18px 6px; line-height: 1.6; }

/* ───────── FILTER BAR (kho/logs) ───────── */
.filter-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 0 12px; margin-bottom: 4px;
}

/* ───────── MOBILE ───────── */
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: -240px; width: 220px; z-index: 1200;
        transition: left 0.25s; box-shadow: 4px 0 24px rgba(0,0,0,0.4);
    }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: inline-flex; }
    .dash-grid { grid-template-columns: 1fr; }
    .content { padding: 16px; }
}
