/* ============================================================
 * MARCUS Operations Console — v3 design system
 * Dark, minimal, monospace-for-data. No external CSS framework.
 * ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* Without this, `display: grid` on .shell / .modal / .login-shell
 * overrides the user-agent default for the [hidden] attribute, so
 * elements we mean to keep collapsed (the modal, the shell before
 * login, etc.) become visible the moment the page loads. */
[hidden] { display: none !important; }

:root {
    --bg-0:      #07090d;        /* deepest */
    --bg-1:      #0d1117;        /* panel  */
    --bg-2:      #131922;        /* card   */
    --bg-3:      #1b2330;        /* hover  */
    --line:      #1f2733;
    --line-2:    #2a3445;
    --text:      #e6edf3;
    --text-dim:  #8b95a6;
    --text-mute: #5d6678;
    --brand:     #6e7bff;        /* MARCUS indigo */
    --brand-2:   #9aa4ff;
    --ok:        #2ecf85;
    --warn:      #f5b400;
    --danger:    #ff5470;
    --info:      #5cb8ff;
    --shadow:    0 8px 24px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.25);
    --radius:    10px;
    --radius-sm: 6px;
}

html, body {
    margin: 0; padding: 0;
    background: var(--bg-0);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.mono, code, .hwid, .kpi-value {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-feature-settings: 'tnum';
}

a { color: inherit; text-decoration: none; }
.link { color: var(--brand-2); }
.link:hover { text-decoration: underline; }

.muted    { color: var(--text-mute); }
.dim      { color: var(--text-dim); }
.grow     { flex: 1; }
.err      { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ============== LOGIN ============== */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(1200px 600px at 50% -10%, rgba(110,123,255,.12), transparent),
        radial-gradient(800px 500px at 90% 110%, rgba(110,123,255,.08), transparent),
        var(--bg-0);
}
.login-card {
    width: 420px; max-width: 95vw;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 32px 32px 28px;
    box-shadow: var(--shadow);
}
.brand {
    display: flex; align-items: center; gap: 14px;
    margin-bottom: 28px;
}
.brand-mark {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-radius: 10px;
    display: grid; place-items: center;
    font-weight: 800; font-size: 22px;
    color: #fff;
}
.brand-title { font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.brand-sub   { color: var(--text-mute); font-size: 12px; }

.lbl { display:block; font-size: 12px; color: var(--text-dim); margin: 14px 0 6px; }
.inp {
    width: 100%;
    background: var(--bg-1);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    transition: border-color .15s, background .15s;
    font-family: inherit;
}
.inp:focus {
    outline: none;
    border-color: var(--brand);
    background: var(--bg-2);
}
.inp::placeholder { color: var(--text-mute); }

/* ============== BUTTONS ============== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--bg-3);
    color: var(--text);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
    font-family: inherit;
}
.btn:hover { background: #232b3a; border-color: #3b475c; }
.btn:active { transform: scale(.98); }
.btn-primary {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
    border: none; color: #fff; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.1); background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-3); }
.btn-danger { background: var(--danger); border: none; color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-warn { background: var(--warn); border: none; color: #1a1a1a; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; margin-top: 18px; }

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

.side {
    background: var(--bg-1);
    border-right: 1px solid var(--line);
    padding: 20px 14px;
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.side .brand { padding: 0 8px 16px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }

.nav { flex: 1; overflow-y: auto; }
.nav-group {
    color: var(--text-mute);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    padding: 18px 12px 6px;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-dim);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 1px;
    transition: background .12s, color .12s;
    cursor: pointer;
    position: relative;
}
.nav-link:hover { background: var(--bg-3); color: var(--text); }
.nav-link.active {
    background: rgba(110,123,255,.12);
    color: var(--text);
}
.nav-link.active::before {
    content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
    width: 3px; background: var(--brand);
    border-radius: 2px;
}
.nav-link .ico {
    width: 22px; text-align: center;
    color: var(--text-mute); font-size: 14px;
}
.nav-link.active .ico { color: var(--brand-2); }
.badge-dot {
    margin-left: auto;
    width: 6px; height: 6px; border-radius: 50%;
    background: transparent;
}
.badge-dot.on {
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(46,207,133,.15);
    animation: dot-pulse 1.6s infinite;
}
@keyframes dot-pulse {
    0%,100% { opacity: 1; }
    50%     { opacity: .35; }
}

.side-footer {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    display: flex; align-items: center; gap: 10px;
}
.me { display: flex; align-items: center; gap: 10px; flex: 1; padding-left: 4px; }
.me-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(46,207,133,.18); }
.me-text { font-size: 13px; }
.me-role { color: var(--text-mute); font-size: 11px; }

/* ============== MAIN ============== */
.main { padding: 24px 28px 60px; }
.topbar {
    display: flex; align-items: end; justify-content: space-between;
    margin-bottom: 22px;
}
.crumb { color: var(--text-mute); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.page-title { font-size: 22px; font-weight: 700; margin: 4px 0 0; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.pulse {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--text-dim); font-size: 12px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg-2);
}
.pulse .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(46,207,133,.15);
}
.pulse.off .dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(255,84,112,.15); }

/* ============== PAGES ============== */
.page { display: none; }
.page.active { display: block; animation: page-in .18s ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ============== KPIs ============== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.kpi {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content:''; position:absolute; top:0; left:0; right:0; height: 3px;
    background: linear-gradient(90deg, var(--brand), var(--brand-2));
    opacity: .6;
}
.kpi.danger::before { background: var(--danger); opacity:.8; }
.kpi.warn::before   { background: var(--warn);   opacity:.8; }
.kpi-label { color: var(--text-mute); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.kpi-value { font-size: 32px; font-weight: 700; margin: 8px 0 6px; }
.kpi-trend { color: var(--text-mute); font-size: 11px; }
.kpi-trend.ok { color: var(--ok); }

/* ============== CARDS ============== */
.row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}
.row.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.card.span-2 { grid-column: span 1; }
@media (max-width: 1100px) {
    .row, .row.row-3 { grid-template-columns: 1fr; }
}

.card {
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.card-sub { color: var(--text-mute); font-size: 11px; }
.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); color: var(--text-mute); font-size: 12px; }

/* ============== TABLES ============== */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table thead th {
    text-align: left;
    color: var(--text-mute);
    font-weight: 500;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-1);
    position: sticky; top: 0;
}
.table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table tbody tr:hover { background: var(--bg-3); }
.table tbody tr:last-child td { border-bottom: 0; }

.table-stream tbody tr { animation: row-in .25s ease-out; }
@keyframes row-in {
    from { background: rgba(110,123,255,.15); }
    to   { background: transparent; }
}

.hwid {
    color: var(--text-dim);
    font-size: 11px;
    max-width: 180px;
    display: inline-block;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    vertical-align: middle;
    cursor: copy;
}
.hwid:hover { color: var(--text); }

/* Severity & action chips */
.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    line-height: 18px;
}
.chip-critical { background: rgba(255,84,112,.15); color: var(--danger); }
.chip-high     { background: rgba(245,180,0,.15); color: var(--warn); }
.chip-medium   { background: rgba(92,184,255,.12); color: var(--info); }
.chip-info     { background: rgba(139,149,166,.15); color: var(--text-dim); }

.chip-kick { background: rgba(255,84,112,.15); color: var(--danger); }
.chip-warn { background: rgba(245,180,0,.15); color: var(--warn); }
.chip-ok   { background: rgba(46,207,133,.15); color: var(--ok); }

.chip-sig-ok  { background: rgba(46,207,133,.12); color: var(--ok); font-size:10px; }
.chip-sig-bad { background: rgba(255,84,112,.18); color: var(--danger); font-size:10px; }

/* online dot */
.dot-on  { display:inline-block; width: 8px; height: 8px; border-radius:50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(46,207,133,.18); margin-right: 6px; vertical-align: middle; }
.dot-off { display:inline-block; width: 8px; height: 8px; border-radius:50%; background: var(--text-mute); margin-right: 6px; vertical-align: middle; }

/* ============== TOOLBAR ============== */
.toolbar {
    display: flex; gap: 10px; align-items: center;
    margin-bottom: 16px;
}
.toolbar .inp { width: auto; flex: 1; max-width: 360px; padding: 8px 12px; font-size: 13px; }

/* ============== SPARKLINE ============== */
.sparkline { width: 100%; height: 90px; display: block; }

/* ============== MODAL ============== */
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    display: grid; place-items: center;
    z-index: 1000;
    animation: fade .15s ease-out;
}
@keyframes fade { from { opacity:0 } to { opacity:1 } }
.modal-card {
    width: 540px; max-width: 95vw;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-height: 86vh;
    overflow: hidden;
    display: flex; flex-direction: column;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal .x {
    background: transparent; border: 0; color: var(--text-mute);
    font-size: 22px; line-height: 1; cursor: pointer;
}
.modal .x:hover { color: var(--text); }

/* ============== TOASTS ============== */
.toast-wrap {
    position: fixed; right: 18px; bottom: 18px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 2000;
}
.toast {
    padding: 12px 16px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius-sm);
    color: var(--text);
    box-shadow: var(--shadow);
    min-width: 240px;
    animation: toast-in .2s ease-out;
}
.toast.ok      { border-left-color: var(--ok); }
.toast.error   { border-left-color: var(--danger); }
.toast.warn    { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity:0; transform: translateX(10px); } to { opacity:1; transform:none; } }

/* ============== KV LIST ============== */
.kv { margin: 0; }
.kv dt { color: var(--text-mute); font-size: 12px; margin-top: 14px; }
.kv dt:first-child { margin-top: 0; }
.kv dd { margin: 4px 0 0; font-size: 13px; }
.kv code { background: var(--bg-1); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); font-size: 12px; }

/* ============== HWID DETAIL ============== */
.hwid-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.hwid-detail .row-label { color: var(--text-mute); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.hwid-detail .row-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; word-break: break-all; }

/* responsive small */
@media (max-width: 900px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: relative; height: auto; flex-direction: row; padding: 12px; overflow-x: auto; }
    .nav { display: flex; }
    .nav-group { display: none; }
    .side-footer { border-top: 0; border-left: 1px solid var(--line); padding-left: 12px; padding-top: 0; }
    .main { padding: 16px; }
}
