/* ── Theme Variables ─────────────────────────────────────────────────────── */
:root {
    --bg:         #f0f4ff;
    --surface:    #ffffff;
    --surface2:   #f8faff;
    --surface3:   #eef2fb;
    --border:     #e1e8f5;
    --border2:    #c7d4ed;
    --text:       #0f172a;
    --text2:      #334155;
    --text3:      #64748b;
    --text4:      #94a3b8;
    --primary:    #4f46e5;
    --primary2:   #6366f1;
    --primary-l:  #e0e7ff;
    --primary-t:  rgba(79,70,229,.12);
    --green:      #10b981;
    --green-l:    #d1fae5;
    --red:        #ef4444;
    --red-l:      #fee2e2;
    --yellow:     #f59e0b;
    --yellow-l:   #fef3c7;
    --blue:       #3b82f6;
    --blue-l:     #dbeafe;
    --purple:     #8b5cf6;
    --purple-l:   #ede9fe;
    --shadow:     0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(79,70,229,.06);
    --shadow2:    0 4px 24px rgba(79,70,229,.12);
    --radius:     12px;
    --radius2:    8px;
}

[data-theme="dark"] {
    --bg:         #0c0e1a;
    --surface:    #141928;
    --surface2:   #1c2236;
    --surface3:   #232b42;
    --border:     #2a3550;
    --border2:    #3a4a6a;
    --text:       #f1f5f9;
    --text2:      #cbd5e1;
    --text3:      #94a3b8;
    --text4:      #4a5568;
    --primary:    #6366f1;
    --primary2:   #818cf8;
    --primary-l:  #1e1b4b;
    --primary-t:  rgba(99,102,241,.15);
    --green:      #34d399;
    --green-l:    #064e3b;
    --red:        #f87171;
    --red-l:      #450a0a;
    --yellow:     #fbbf24;
    --yellow-l:   #451a03;
    --blue:       #60a5fa;
    --blue-l:     #1e3a5f;
    --purple:     #a78bfa;
    --purple-l:   #2e1065;
    --shadow:     0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
    --shadow2:    0 4px 24px rgba(0,0,0,.4);
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body {
    margin: 0; padding: 0;
    background: var(--bg) !important;
    color: var(--text) !important;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    transition: background .2s, color .2s;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: .85rem;
    box-shadow: var(--shadow);
    transition: background .2s, border-color .2s;
}
.card-hover:hover { border-color: var(--primary); box-shadow: var(--shadow2); }
.ch {
    font-size: .68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.2px; color: var(--text3);
    border-bottom: 1px solid var(--border);
    padding-bottom: .5rem; margin-bottom: .85rem;
    display: flex; align-items: center; gap: .4rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .4rem .85rem; border-radius: var(--radius2);
    font-size: .82rem; font-weight: 500;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text2); cursor: pointer; text-decoration: none;
    transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface3); color: var(--primary); border-color: var(--primary); }
.btn-p { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-p:hover { background: var(--primary2); color: #fff; border-color: var(--primary2); }
.btn-s { background: var(--green-l); color: var(--green); border-color: var(--green); }
.btn-s:hover { opacity: .85; color: var(--green); }
.btn-d { background: var(--red-l); color: var(--red); border-color: var(--red); }
.btn-d:hover { opacity: .85; color: var(--red); }
.btn-w { background: var(--yellow-l); color: var(--yellow); border-color: var(--yellow); }
.btn-sm { padding: .25rem .55rem; font-size: .76rem; }
.btn-icon { padding: .3rem .45rem; font-size: .82rem; }

/* ── Form Fields ─────────────────────────────────────────────────────────── */
.fi {
    background: var(--surface2) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: var(--radius2);
    padding: .45rem .8rem;
    font-size: .86rem;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
.fi:focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-t) !important;
    background: var(--surface) !important;
}
.fi::placeholder { color: var(--text4) !important; }
select.fi option { background: var(--surface2); color: var(--text); }
.fl { font-size: .76rem; color: var(--text3); margin-bottom: .3rem; font-weight: 600; display: block; letter-spacing: .3px; }
.mb { margin-bottom: .75rem; }
.fg { display: grid; gap: .6rem; }
.fg-2 { grid-template-columns: 1fr 1fr; }
.fg-3 { grid-template-columns: 1fr 1fr 1fr; }
@media(max-width:600px) { .fg-2, .fg-3 { grid-template-columns: 1fr; } }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.al {
    display: flex; align-items: center; gap: .5rem;
    border-radius: var(--radius2); padding: .7rem 1rem;
    margin-bottom: .75rem; font-size: .86rem; font-weight: 500;
}
.al-s { background: var(--green-l); border: 1px solid var(--green); color: var(--green); }
.al-d { background: var(--red-l); border: 1px solid var(--red); color: var(--red); }
.al-i { background: var(--blue-l); border: 1px solid var(--blue); color: var(--blue); }
.al-w { background: var(--yellow-l); border: 1px solid var(--yellow); color: var(--yellow); }

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.sc {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow);
    position: relative; overflow: hidden;
}
.sc::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--sc-color, var(--primary));
}
.sv { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }
.sl { font-size: .72rem; color: var(--text3); text-transform: uppercase; letter-spacing: .8px; margin-top: .3rem; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
table th {
    color: var(--text3); font-size: .68rem; text-transform: uppercase;
    letter-spacing: .8px; padding: .65rem .85rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700; background: var(--surface2); text-align: left;
    white-space: nowrap;
}
table td {
    padding: .6rem .85rem; border-bottom: .5px solid var(--border);
    vertical-align: middle; color: var(--text2);
}
table tbody tr:hover td { background: var(--surface2); }
table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.bs {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .2em .55em; border-radius: 6px;
    font-size: .71rem; font-weight: 700; line-height: 1.4;
}

/* ── Status Pills ────────────────────────────────────────────────────────── */
.pill {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .25em .7em; border-radius: 20px;
    font-size: .73rem; font-weight: 600;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.page-wrap { padding: 1.25rem; max-width: 1200px; margin: 0 auto; }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.page-title { margin: 0; font-weight: 800; color: var(--text); font-size: 1.2rem; letter-spacing: -.3px; }
.page-sub { font-size: .8rem; color: var(--text3); margin-top: .1rem; }

/* ── Autofill Fix ────────────────────────────────────────────────────────── */
input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--surface2) inset !important;
    -webkit-text-fill-color: var(--text) !important;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text4); }

/* ── Dropdown ────────────────────────────────────────────────────────────── */
.dropdown {
    position: absolute; z-index: 100;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: .35rem 0;
    box-shadow: var(--shadow2); min-width: 160px;
}
.dropdown-item {
    display: flex; align-items: center; gap: .5rem;
    padding: .4rem .85rem; font-size: .82rem; cursor: pointer;
    color: var(--text2); transition: background .1s;
}
.dropdown-item:hover { background: var(--surface2); color: var(--primary); }
.dropdown-sep { height: 1px; background: var(--border); margin: .25rem 0; }

/* ── Toggle Switch ───────────────────────────────────────────────────────── */
.toggle {
    width: 40px; height: 22px; border-radius: 11px;
    background: var(--border2); cursor: pointer;
    position: relative; transition: background .2s; flex-shrink: 0;
}
.toggle.on { background: var(--primary); }
.toggle::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on::after { left: 21px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media(max-width: 768px) {
    .page-wrap { padding: .85rem; }
    .hide-mobile { display: none !important; }
}
