/* ─────────────────────────────────────────────────────────────────
   LS3 Solutions MQTT Admin Panel
   Clean light theme matching VAH DNS Panel aesthetic
   ───────────────────────────────────────────────────────────────── */

:root {
    --bg-body: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-topbar: #ffffff;
    --bg-soft: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --accent: #2563eb;
    --accent-light: #eff6ff;
    --accent-hover: #1d4ed8;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #ea580c;
    --warning-light: #ffedd5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --sidebar-width: 250px;
    --topbar-height: 56px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow:    0 2px 8px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
    --shadow-md: 0 6px 16px rgba(0,0,0,.06), 0 3px 8px rgba(0,0,0,.04);
    --radius: 10px;
    --mono: 'IBM Plex Mono', SFMono-Regular, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    background: var(--bg-body);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    margin: 0;
    font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code, pre { font-family: var(--mono); }

/* ── login screen ───────────────────────────────────────────────── */
body.login {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background:
        radial-gradient(1200px 600px at 50% -200px, rgba(37,99,235,.08), transparent 60%),
        var(--bg-body);
}
.auth-wrap { width: 420px; max-width: calc(100% - 32px); }
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 36px 32px 28px;
    text-align: center;
}
.auth-logo { width: 64px; height: auto; margin: 6px auto 18px; display: block; }
.auth-h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 4px;
    letter-spacing: -.01em;
}
.auth-sub {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 22px;
}
.auth-form { text-align: left; }
.auth-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.auth-input {
    display: block;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.auth-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.auth-btn {
    width: 100%;
    margin-top: 18px;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 11px 18px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}
.auth-btn:hover { background: var(--accent-hover); }
.auth-err {
    margin-top: 14px;
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
}
.auth-foot {
    margin-top: 22px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ── app shell ──────────────────────────────────────────────────── */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ── sidebar ────────────────────────────────────────────────────── */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}
.sidebar-brand .brand-icon { height: 28px; width: auto; flex-shrink: 0; }
.sidebar-brand .brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.01em;
    line-height: 1;
}
.sidebar-brand .brand-tag {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
    padding: 3px 7px;
    border-radius: 4px;
    letter-spacing: .08em;
    margin-left: auto;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 10px;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}
.sidebar-nav li { margin: 1px 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    transition: color .15s, background .15s;
}
.sidebar-nav a:hover {
    color: var(--accent);
    background: var(--accent-light);
}
.sidebar-nav li.is-active a {
    color: var(--accent);
    background: var(--accent-light);
    font-weight: 600;
}
.sidebar-nav i { font-size: 16px; width: 20px; text-align: center; opacity: .75; }
.sidebar-nav a:hover i,
.sidebar-nav li.is-active i { opacity: 1; }

.sidebar-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}
.sidebar-foot .health {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.sidebar-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.sidebar-foot .health.is-ok .dot   { background: var(--success); box-shadow: 0 0 6px rgba(22,163,74,.5); }
.sidebar-foot .health.is-down .dot { background: var(--danger); }

/* ── main + topbar ──────────────────────────────────────────────── */
.main { min-width: 0; }

.topbar {
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    height: var(--topbar-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-title i { color: var(--accent); font-size: 18px; }
.topbar-meta { display: flex; align-items: center; gap: 18px; font-size: 13px; color: var(--text-secondary); }
.topbar-meta .meta-cell { display: flex; align-items: center; gap: 6px; }
.topbar-meta .meta-cell label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
}
.topbar-meta .meta-cell b {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--text);
}
.topbar-meta a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}
.topbar-meta a:hover { background: var(--bg-soft); color: var(--accent); }

.page { padding: 24px 28px; }
.page-head { margin-bottom: 18px; }
.page-head h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 4px;
    letter-spacing: -.01em;
}
.page-head .lead { color: var(--text-secondary); font-size: 14px; margin: 0; }

/* ── grid + cards ───────────────────────────────────────────────── */
.row { display: grid; gap: 16px; }
.row.cols-stats { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row.cols-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.row + .row { margin-top: 16px; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
}
.card-hd h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-hd h2 i { color: var(--accent); font-size: 16px; }
.card-hd .card-id { font-size: 12px; color: var(--text-muted); font-family: var(--mono); }
.card-hd .card-act { display: flex; gap: 8px; }
.card-body { padding: 16px 18px; }
.card-body--tight { padding: 0; }
.card-foot {
    padding: 12px 18px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-muted);
}

/* ── stat card ──────────────────────────────────────────────────── */
.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: border-color .25s, box-shadow .25s;
}
.stat-lbl {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.stat-lbl i { color: var(--accent); font-size: 14px; }
.stat-val {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
    line-height: 1.15;
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.stat-val small {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    letter-spacing: 0;
}
.stat-val.stat-val--small { font-size: 16px; }
.stat-sub {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.stat-sub b { color: var(--text-secondary); font-weight: 600; }
.stat--accent {
    border-left: 3px solid var(--accent);
}
.stat.is-pulse { animation: pulseShadow .6s ease-out; }
@keyframes pulseShadow {
    0%   { box-shadow: 0 0 0 4px rgba(37,99,235,.15), var(--shadow-sm); }
    100% { box-shadow: 0 0 0 0  rgba(37,99,235,0),    var(--shadow-sm); }
}

/* ── kv list ────────────────────────────────────────────────────── */
.kv { padding: 0; }
.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 11px 18px;
    border-bottom: 1px solid var(--border-light);
}
.kv-row:last-child { border-bottom: 0; }
.kv-k {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}
.kv-v { font-family: var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }

/* ── tables ─────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.tbl th, .tbl td {
    padding: 11px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
.tbl th {
    background: var(--bg-soft);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
}
.tbl tbody tr:hover { background: var(--bg-soft); }
.tbl td.b { color: var(--text); font-weight: 500; }
.tbl td.dim { color: var(--text-muted); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.center, .tbl th.center { text-align: center; }
.tbl td.mono, .tbl th.mono { font-family: var(--mono); }

/* ── pills / badges ─────────────────────────────────────────────── */
.pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    letter-spacing: .02em;
}
.pill--ok   { background: var(--success-light); color: var(--success); }
.pill--err  { background: var(--danger-light);  color: var(--danger); }
.pill--warn { background: var(--warning-light); color: var(--warning); }
.pill--dim  { background: #f1f5f9; color: var(--text-muted); }

/* ── role page (ACL groups) ─────────────────────────────────────── */
.role { border-top: 1px solid var(--border-light); }
.role:first-of-type { border-top: 0; }
.role-hd {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 18px 8px;
}
.role-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    font-family: var(--mono);
}
.role-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

/* ── feed/log preformatted blocks ───────────────────────────────── */
.feed, .log {
    background: #0f172a;
    color: #cbd5e1;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.55;
    padding: 14px 18px;
    margin: 0;
    border-radius: 0 0 var(--radius) var(--radius);
    height: 360px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.log span { display: block; }
.log--err  { color: #fca5a5; }
.log--warn { color: #fcd34d; }
.log--ok   { color: #86efac; }

/* ── small inputs / buttons ─────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color .12s, background .12s, border-color .12s;
    font-family: inherit;
}
.btn:hover { color: var(--accent); background: var(--accent-light); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-hover); color: #fff; border-color: var(--accent-hover); }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text);
    outline: none;
    font-family: inherit;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* ── ip rules legend ────────────────────────────────────────────── */
.legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-soft);
}
.legend-cell { display: flex; align-items: center; gap: 12px; }
.legend-sw { width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.legend-sw--ok    { background: var(--success); box-shadow: 0 0 6px rgba(22,163,74,.5); }
.legend-sw--accent { background: var(--accent); box-shadow: 0 0 6px rgba(37,99,235,.5); }
.legend-cell b { font-family: var(--mono); font-size: 13px; color: var(--text); display: block; font-weight: 600; }
.legend-cell span { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── helpers ────────────────────────────────────────────────────── */
.dim { color: var(--text-muted); }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.r { text-align: right; }
code.inline { background: var(--bg-soft); color: var(--accent); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── responsive ─────────────────────────────────────────────────── */
@media (max-width: 880px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
}
