/**
 * WafX Dashboard — Global Stylesheet
 * Design system adapted from the Kinby layout language:
 * soft light surface, 22px card radius, shadowless borders, blue accent,
 * Manrope typography. Dark theme via `html.dark`.
 */

/* ===== TOKENS — LIGHT ===== */
:root {
    /* Typography */
    --font: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    /* Surfaces */
    --bg: #eef2f6;
    --glow-a: #dce7f7;
    --glow-b: #fbe7dc;
    --surface: #fcfdfe;
    --surface-2: #f5f8fb;
    --raised: #fefeff;
    --well: #1226420e;
    --line: #1226421a;
    --line-2: #1226422e;

    /* Shadows */
    --shadow: 0 1px 2px #1226420d, 0 14px 30px -20px #12264247;
    --shadow-pop: 0 26px 60px -18px #12264257, 0 2px 6px #12264214;

    /* Text */
    --text: #13202f;
    --muted: #4c5a6a;
    --faint: #66727f;

    /* Accent */
    --primary: #2160e0;
    --primary-dark: #1a4fbf;
    --on-primary: #f8fbff;
    --accent-text: #1a4fbf;
    --focus: #2160e0;

    /* Status */
    --success: #2fa37a;
    --warning: #d9a21b;
    --danger: #e0516b;
    --info: #1f5a9e;
    --good: #16694a;
    --warn: #855400;
    --warn-strong: #a8531f;
    --bad: #a8213a;

    /* Category hues */
    --blue: #2f6fe6;
    --peach: #f28a5c;
    --mint: #2fa37a;
    --sky: #5ba3e6;
    --gold: #d9a21b;
    --rose: #e0516b;
    --moss: #7c9a2e;
    --teal: #13a39a;
    --slate: #84909c;
    --purple: #8b5cf6;
    --ink: #1d2a3a;

    /* Geometry */
    --r-card: 22px;
    --r-tile: 14px;
    --gap: 16px;
    --side-w: 252px;
    --edge: 12px;
    --gutter: clamp(16px, 1.7vw, 28px);

    /* Legacy aliases — kept so existing page styles keep working */
    --light-bg: var(--bg);
    --light-card: var(--surface);
    --light-border: var(--line);
    --light-text: var(--text);
    --light-text-secondary: var(--muted);
    --card-bg: var(--surface);
    --card-bg2: var(--surface-2);
    --border: var(--line-2);
    --border-color: var(--line);
    --text-secondary: var(--muted);
    --text-muted: var(--faint);
    --text-primary: var(--text);
    --bg-secondary: var(--surface-2);
    --input-bg: var(--raised);
    --hover-bg: var(--well);
    --code-bg: var(--surface-2);
    --stat-bg: var(--surface-2);
    --accent: var(--primary);

    /* Sidebar */
    --sidebar-bg: var(--surface);
    --sidebar-border: var(--line);
    --sidebar-hover: var(--well);
    --sidebar-active-bg: var(--primary);
    --sidebar-active-border: var(--primary);
    --sidebar-text: var(--muted);
    --sidebar-text-active: var(--on-primary);

    --ease: cubic-bezier(.2, .8, .2, 1);
    color-scheme: light;
}

/* ===== TOKENS — DARK ===== */
html.dark {
    --bg: #080b12;
    --glow-a: #16233c;
    --glow-b: #2a1d18;
    --surface: #111925;
    --surface-2: #161f2d;
    --raised: #1a2331;
    --well: #ffffff0a;
    --line: #ffffff17;
    --line-2: #ffffff2b;

    --shadow: 0 1px 2px #0000004d, 0 18px 40px -24px #000000b3;
    --shadow-pop: 0 26px 60px -18px #000000b3, 0 2px 6px #00000059;

    --text: #e8eef7;
    --muted: #9aa8ba;
    --faint: #7c8a9c;

    --primary: #4f83f1;
    --primary-dark: #3f74e4;
    --on-primary: #07101f;
    --accent-text: #93b5f8;
    --focus: #4f83f1;

    --success: #4bbd8a;
    --warning: #e0aa3a;
    --danger: #e8697f;
    --info: #6aa5e8;
    --good: #5cc79a;
    --warn: #e0aa3a;
    --warn-strong: #f0906a;
    --bad: #e8697f;

    --blue: #4f83f1;
    --peach: #f0906a;
    --mint: #4bbd8a;
    --sky: #6aa5e8;
    --gold: #e0aa3a;
    --rose: #e8697f;
    --moss: #9cbb45;
    --teal: #2fbdb2;
    --slate: #93a1b3;
    --purple: #a78bfa;
    --ink: #cdd8e6;

    color-scheme: dark;
}

/* Suppress all transitions during initial theme application to prevent FOUC */
html.no-transition *,
html.no-transition *::before,
html.no-transition *::after {
    transition: none !important;
    animation-duration: 0.001ms !important;
}

/* ===== THEME SWITCH ANIMATION =====
   Preferred path: the View Transition API (see theme.js) cross-fades the whole
   page in one composited pass — cheap even with thousands of nodes.
   The rules below are the fallback for browsers without that API: they
   cross-fade the main surfaces instead of every single node. */
html.theme-anim body,
html.theme-anim .sidebar,
html.theme-anim .topbar,
html.theme-anim .card,
html.theme-anim .content-card,
html.theme-anim .stat-card,
html.theme-anim .stat-mini,
html.theme-anim .info-row,
html.theme-anim .modal-content,
html.theme-anim .log-box,
html.theme-anim .report-domain-card,
html.theme-anim .sys-card,
html.theme-anim .overall-bar,
html.theme-anim .score-pill,
html.theme-anim .progress-bar-bg,
html.theme-anim .nav-item,
html.theme-anim .nav-sub-item,
html.theme-anim .nav-group-label,
html.theme-anim .page-title,
html.theme-anim .page-subtitle,
html.theme-anim .card-title,
html.theme-anim .card-subtitle,
html.theme-anim .badge,
html.theme-anim .btn,
html.theme-anim .btn-primary,
html.theme-anim .btn-secondary,
html.theme-anim .btn-sm,
html.theme-anim .btn-edit-sm,
html.theme-anim .btn-danger-sm,
html.theme-anim .btn-login,
html.theme-anim .nav-icon-wrap,
html.theme-anim th,
html.theme-anim td,
html.theme-anim input,
html.theme-anim select,
html.theme-anim textarea {
    transition:
        background-color .32s var(--ease),
        border-color .32s var(--ease),
        color .32s var(--ease),
        box-shadow .32s var(--ease);
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: .32s;
    animation-timing-function: cubic-bezier(.2, .8, .2, 1);
    mix-blend-mode: normal;
}
::view-transition-old(root) { animation-name: wafx-fade-out; }
::view-transition-new(root) { animation-name: wafx-fade-in; }
@keyframes wafx-fade-out { to { opacity: 0; } }
@keyframes wafx-fade-in { from { opacity: 0; } }

/* ===== RESET ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background:
        radial-gradient(1020px 600px at 0% -20%, rgba(124, 161, 230, 0.18), transparent 55%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg) 100%);
    color: var(--text);
    display: flex;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Soft background glow, as in the reference layout */
.main-wrap {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0 18px 20px 0;
}
.main-wrap::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(1100px 520px at 12% -12%, var(--glow-a) 0%, transparent 62%),
        radial-gradient(900px 460px at 96% -6%, var(--glow-b) 0%, transparent 58%);
    opacity: .85;
    z-index: 0;
}
html.dark .main-wrap::before { opacity: .5; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c3cedb; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #9aa8ba; background-clip: content-box; }
html.dark ::-webkit-scrollbar-thumb { background: #2b3746; background-clip: content-box; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #3a4859; background-clip: content-box; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 250px;
    min-width: 250px;
    height: calc(100vh - 36px);
    margin: 18px 0 18px 18px;
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: width .25s var(--ease), min-width .25s var(--ease), background .25s;
    border: 1px solid var(--line);
    border-radius: 30px;
    position: relative;
    z-index: 2;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 18px 38px -30px rgba(18, 38, 66, 0.46);
}
html.no-transition .sidebar { transition: none !important; }

.sidebar-logo {
    padding: 18px 18px 14px;
    display: flex;
    align-items: center;
    gap: 11px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.logo-icon-box {
    width: 40px;
    height: 40px;
    background: linear-gradient(140deg, #1e2c47, #0d1626);
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 4px;
    box-shadow: 0 8px 18px -10px #0d1626a6;
}
.logo-icon-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.logo-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    letter-spacing: -.02em;
}
.logo-badge {
    font-size: 9px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: .1em;
    margin-top: 3px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    padding: 10px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 8px 12px;
    border-radius: 14px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: -.005em;
    text-decoration: none;
    transition: background .16s, color .16s, box-shadow .16s, transform .12s;
    cursor: pointer;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--text);
    text-decoration: none;
}
.nav-item.active,
.nav-item.sidebar-active {
    background: linear-gradient(135deg, #2d6ae8 0%, #1e5fe0 100%);
    color: var(--sidebar-text-active);
    box-shadow: 0 12px 24px -18px rgba(33, 96, 224, 0.8);
}
.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── Icon wrapper ── */
.nav-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--ic, #94a3b8) 12%, transparent);
    color: var(--ic, #94a3b8);
    flex-shrink: 0;
    transition: background .16s, color .16s;
}
.nav-item:hover .nav-icon-wrap {
    background: color-mix(in srgb, var(--ic, #94a3b8) 20%, transparent);
}
.nav-item.active .nav-icon-wrap,
.nav-item.sidebar-active .nav-icon-wrap {
    background: #ffffff26;
    color: #fff;
}
.nav-sub-item:hover .nav-icon-wrap {
    background: color-mix(in srgb, var(--ic, #94a3b8) 20%, transparent);
}
.nav-sub-item.active .nav-icon-wrap,
.nav-sub-item.sidebar-active .nav-icon-wrap {
    background: color-mix(in srgb, var(--ic, #94a3b8) 22%, transparent);
    color: var(--ic, #94a3b8);
}
.nav-icon-wrap svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ── Nav section label ── */
.nav-section {
    padding: 16px 12px 5px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: var(--faint);
    opacity: .8;
    pointer-events: none;
    user-select: none;
}

/* ── Plugin nav group ── */
.nav-group-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 6px 10px;
    border-radius: 12px;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .16s, color .16s;
    user-select: none;
}
.nav-group-label:hover { background: var(--sidebar-hover); color: var(--text); }
.nav-group-label.open  { color: var(--text); }

.nav-group-label .nav-group-arrow {
    margin-left: auto;
    transition: transform .2s;
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}
.nav-group-label.open .nav-group-arrow { transform: rotate(90deg); }

.nav-group-children {
    display: none;
    flex-direction: column;
    gap: 2px;
    padding-left: 10px;
    margin-left: 14px;
    border-left: 1px solid var(--line);
}
.nav-group-children.open { display: flex; }

.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 36px;
    padding: 4px 8px;
    border-radius: 10px;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background .16s, color .16s;
}
.nav-sub-item .nav-icon-wrap { width: 26px; height: 26px; border-radius: 9px; }
.nav-sub-item:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
.nav-sub-item.active,
.nav-sub-item.sidebar-active {
    background: var(--sidebar-hover);
    color: var(--text);
    font-weight: 700;
}
.nav-sub-item > svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Locked (unlicensed) nav items ── */
.nav-locked { opacity: .55; }
.nav-lock-ic { font-size: 11px; margin-left: 4px; }

.sidebar-footer {
    padding: 12px 12px 14px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    background: var(--sidebar-bg);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding: 8px 10px;
    background: var(--well);
    border-radius: 12px;
    gap: 8px;
}
.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}
.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f83f1, #7c5cf0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}
.sidebar-user-meta { min-width: 0; }
.sidebar-user-name {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 10.5px;
    color: var(--faint);
    text-transform: capitalize;
    margin-top: 1px;
}
.sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    color: var(--faint);
    transition: background .15s, color .15s;
    flex-shrink: 0;
    text-decoration: none;
}
.sidebar-logout:hover {
    background: #e0516b1f;
    color: var(--danger);
}
.sidebar-logout svg { width: 15px; height: 15px; }

.system-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding: 0 2px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px #2fa37a26;
    animation: pulse-dot 2.4s infinite;
    flex-shrink: 0;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}

.status-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--good);
}

.status-version {
    font-size: 10.5px;
    color: var(--faint);
    margin-left: 16px;
}

/* ===== SIDEBAR COLLAPSED (rail) STATE ===== */
.sidebar.collapsed {
    width: 76px;
    min-width: 76px;
}
.sidebar.collapsed .sidebar-logo {
    justify-content: center;
    padding: 16px 8px;
    gap: 0;
    border-bottom-color: var(--line);
}
.sidebar.collapsed .logo-text { display: none; }
.sidebar.collapsed .nav-section { display: none; }
.sidebar.collapsed .nav-group-arrow { display: none; }
.sidebar.collapsed .nav-group-children { display: none !important; }
.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-group-label {
    font-size: 0;
    justify-content: center;
    min-height: 0;
    padding: 5px 0;
    gap: 0;
}
.sidebar.collapsed .nav-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: color-mix(in srgb, var(--ic, #94a3b8) 14%, transparent);
    color: var(--ic, #94a3b8);
}
.sidebar.collapsed .nav-item:hover .nav-icon-wrap,
.sidebar.collapsed .nav-group-label:hover .nav-icon-wrap {
    background: color-mix(in srgb, var(--ic, #94a3b8) 24%, transparent);
}
.sidebar.collapsed .nav-item.active .nav-icon-wrap,
.sidebar.collapsed .nav-item.sidebar-active .nav-icon-wrap {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 8px 18px -10px #2160e0cc;
}
.sidebar.collapsed .sidebar-footer { padding: 10px 8px 12px; }
.sidebar.collapsed .system-status { justify-content: center; }
.sidebar.collapsed .status-label,
.sidebar.collapsed .status-version { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 5px 4px; }
.sidebar.collapsed .sidebar-user-meta,
.sidebar.collapsed .sidebar-logout { display: none; }

/* Tooltip for rail items */
.sidebar.collapsed .nav-item::after,
.sidebar.collapsed .nav-group-label::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(-4px);
    background: var(--ink);
    color: var(--bg);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .16s, transform .16s;
    z-index: 40;
    box-shadow: var(--shadow-pop);
}
html.dark .sidebar.collapsed .nav-item::after,
html.dark .sidebar.collapsed .nav-group-label::after {
    background: #e8eef7;
    color: #101722;
}
.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .nav-group-label:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}
.sidebar.collapsed .nav-item,
.sidebar.collapsed .nav-group-label { position: relative; }

/* ===== TOPBAR ===== */
.topbar {
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--line);
    border-radius: 26px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    justify-content: space-between;
    position: relative;
    z-index: 3;
    margin: 18px 18px 0;
    transition: background .25s, border-color .25s, box-shadow .25s;
    box-shadow: 0 10px 24px -22px rgba(18, 38, 66, .55);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.breadcrumb-item {
    font-size: 13px;
    font-weight: 600;
    color: var(--faint);
}

.breadcrumb-sep {
    color: var(--line-2);
    font-size: 13px;
}

.breadcrumb-current {
    font-size: 14px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -.01em;
}

/* Nav finder — filters the sidebar menu */
.topbar-search {
    position: relative;
    flex: 1;
    max-width: 620px;
    margin-left: 8px;
}
.topbar-search input {
    width: 100%;
    height: 46px;
    padding: 0 18px 0 42px;
    border-radius: 9999px;
    border: 1px solid var(--line);
    background: rgba(245,248,251,0.9);
    color: var(--text);
    font-size: 14px;
    transition: border-color .16s, background .16s, box-shadow .16s;
}
.topbar-search input::placeholder { color: var(--faint); }
.topbar-search input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}
.topbar-search .ibtn-search {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--faint);
    pointer-events: none;
}
.topbar-search .ibtn-search svg { width: 15px; height: 15px; }
.nav-hidden { display: none !important; }

.topbar-spacer { flex: 1; }

.topbar-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== PAGE CONTENT ===== */
.page-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    padding: 26px var(--gutter) 48px;
    position: relative;
    z-index: 1;
    max-width: 1500px;
    width: 100%;
    margin: 0 auto;
}

.page-title {
    font-size: clamp(2.2rem, 2.8vw, 4rem);
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.06;
    letter-spacing: -.045em;
}

.page-subtitle {
    font-size: 15px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 22px;
    max-width: 720px;
}

/* ===== CARDS ===== */
.card {
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    border-radius: 26px;
    border: 1px solid var(--line);
    box-shadow: 0 16px 30px -28px rgba(18, 38, 66, 0.38);
    padding: 22px;
    transition: box-shadow .2s, transform .2s;
}
.card:hover {
    box-shadow: 0 20px 32px -28px rgba(18, 38, 66, 0.48);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.card-title {
    font-size: 15.5px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -.01em;
    display: flex;
    align-items: center;
    gap: 9px;
}

/* Tinted rounded-square icon in a card header */
.card-ico {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--ic, var(--primary)) 13%, transparent);
    color: var(--ic, var(--primary));
    flex-shrink: 0;
}
.card-ico svg { width: 16px; height: 16px; }

.card-subtitle {
    font-size: 12.5px;
    color: var(--muted);
    margin-bottom: 16px;
    margin-top: 3px;
}

.card-header .card-subtitle {
    font-size: 11.5px;
    margin-bottom: 0;
    margin-top: 3px;
}

/* content-card alias */
.content-card {
    background: var(--surface);
    border-radius: var(--r-card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 22px;
}

/* ===== STAT CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--gap);
    margin-bottom: 22px;
}

@media (max-width: 1400px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
    background: color-mix(in srgb, var(--surface) 75%, transparent);
    border-radius: 22px;
    padding: 18px 18px 16px;
    border: 1px solid var(--line);
    box-shadow: 0 16px 30px -26px rgba(18, 38, 66, 0.42);
    transition: box-shadow .2s, transform .2s, border-color .2s;
    min-height: 150px;
}
.stat-card:hover {
    box-shadow: 0 20px 34px -26px rgba(18, 38, 66, 0.5);
    transform: translateY(-2px);
    border-color: rgba(33, 96, 224, 0.18);
}

.stat-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

/* Icon boxes — soft tinted squares, as in the reference layout */
.stat-icon-box {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--ic, var(--primary)) 14%, transparent);
    color: var(--ic, var(--primary));
}
.stat-icon-box svg { width: 19px; height: 19px; }

.icon-green  { --ic: var(--mint);  background: color-mix(in srgb, var(--mint) 14%, transparent);  color: var(--mint); }
.icon-red    { --ic: var(--rose);  background: color-mix(in srgb, var(--rose) 14%, transparent);  color: var(--rose); }
.icon-teal   { --ic: var(--teal);  background: color-mix(in srgb, var(--teal) 14%, transparent);  color: var(--teal); }
.icon-purple { --ic: var(--purple); background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--purple); }
.icon-orange { --ic: var(--peach); background: color-mix(in srgb, var(--peach) 14%, transparent); color: var(--peach); }
.icon-blue   { --ic: var(--blue);  background: color-mix(in srgb, var(--blue) 14%, transparent);  color: var(--blue); }

.stat-change {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--good);
    display: flex;
    align-items: center;
    gap: 2px;
}
.stat-change.down { color: var(--bad); }
.stat-change svg { width: 12px; height: 12px; }

.stat-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    margin-bottom: 5px;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ===== CHART ROW ===== */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--gap);
    margin-bottom: 22px;
}

@media (max-width: 1100px) { .charts-row { grid-template-columns: 1fr; } }

.chart-legend {
    display: flex;
    gap: 14px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

.legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.donut-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.donut-canvas-wrap {
    position: relative;
    width: 130px;
    height: 130px;
    flex-shrink: 0;
}

.donut-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.donut-legend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
}

.donut-legend-left {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
}

.donut-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.donut-count {
    font-weight: 700;
    color: var(--text);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* ===== RECENT THREATS ===== */
.threats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.threat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}
.threat-row:last-child { border-bottom: none; }

.threat-left { display: flex; flex-direction: column; gap: 3px; }

.threat-ip {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.threat-type {
    font-size: 12px;
    color: var(--bad);
    font-weight: 500;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.threat-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.threat-time {
    font-size: 11px;
    color: var(--faint);
    display: flex;
    align-items: center;
    gap: 4px;
}
.threat-time svg { width: 11px; height: 11px; }

.empty-state {
    text-align: center;
    padding: 28px;
    color: var(--faint);
    font-size: 13px;
}

/* ===== BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.55;
    letter-spacing: .01em;
    border: 1px solid transparent;
}

.badge-success  { background: #2fa37a1f; color: var(--good);   border-color: #2fa37a2e; }
.badge-warning  { background: #d9a21b1f; color: var(--warn);   border-color: #d9a21b2e; }
.badge-danger   { background: #e0516b1f; color: var(--bad);    border-color: #e0516b2e; }
.badge-info     { background: #2160e01f; color: var(--info);   border-color: #2160e02e; }
.badge-critical { background: #e0516b1f; color: var(--bad);    border-color: #e0516b2e; }
.badge-high     { background: #f28a5c1f; color: #a8531f;       border-color: #f28a5c2e; }
.badge-medium   { background: #d9a21b1f; color: var(--warn);   border-color: #d9a21b2e; }
.badge-blocked  { background: #e0516b1f; color: var(--bad);    border-color: #e0516b2e; }
.badge-rate-limited { background: #f28a5c1f; color: #a8531f;  border-color: #f28a5c2e; }

/* pill variant (rounded) */
.badge-pill { border-radius: 9999px; }

/* ===== TABLE ===== */
table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    padding: 11px 13px;
    font-size: 11.5px;
    font-weight: 800;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

td {
    padding: 13px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--line);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--well); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .16s, transform .12s, box-shadow .16s, color .16s;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 8px 18px -12px #2160e0b3;
}
.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--line);
}
.btn-secondary:hover { background: var(--well); border-color: var(--line-2); }

.btn-danger-sm {
    background: #e0516b14;
    color: var(--bad);
    border: 1px solid #e0516b2e;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.btn-edit-sm {
    background: #2160e014;
    color: var(--accent-text);
    border: 1px solid #2160e02e;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.btn-sm {
    background: #2160e014;
    color: var(--accent-text);
    border: 1px solid #2160e02e;
    padding: 5px 14px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}
.btn-sm:hover { background: #2160e01f; }

/* ===== FORMS ===== */
input, select, textarea {
    font-family: inherit;
    padding: 9px 13px;
    border: 1px solid var(--line-2);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text);
    background: var(--input-bg);
    outline: none;
    transition: border-color .16s, box-shadow .16s;
}
select { cursor: pointer; }

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.form-group input, .form-group select { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== MODAL ===== */
.modal {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--ink) 85%, transparent);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal.open { display: flex; }
.modal.hidden { display: none; }

.modal-content {
    background: var(--surface);
    border-radius: var(--r-card);
    padding: 26px;
    width: 480px;
    max-width: 95vw;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow-pop);
    border: 1px solid var(--line);
    animation: slideUp .25s var(--ease);
}

.modal-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    letter-spacing: -.015em;
}
.modal-title button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--faint);
    font-size: 20px;
    line-height: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

@keyframes slideUp {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}


/* ── Modal layout ── */
#host-modal .modal-content {
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--r-card);
    background: var(--surface);
}
#host-modal .modal-title {
    flex-shrink: 0;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: var(--r-card) var(--r-card) 0 0;
    margin: -20px -20px 0 -20px;
}
#host-modal .tab-nav {
    flex-shrink: 0;
    margin: 0 -20px 0 -20px;
    padding: 0 4px;
    background: var(--surface-2);
    border-radius: var(--r-tile) var(--r-tile) 0 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 2;
}
#host-modal form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
.modal-tab-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 24px 24px;
    margin: 0 -24px;
    background: var(--surface);
    border-radius: 0 0 var(--r-card) var(--r-card);
    /* custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.modal-tab-body::-webkit-scrollbar { width: 5px; }
.modal-tab-body::-webkit-scrollbar-track { background: transparent; }
.modal-tab-body::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 3px; }
.modal-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 8px;
    background: var(--surface-2);
}

/* ── Tabs ── */
.tab-nav { 
    display: flex; 
    gap: 4px; 
    border-bottom: 1px solid var(--border,var(--border)); 
    margin-bottom: 0; 
    overflow-x: auto; 
    padding: 0 4px;
    background: var(--surface-2);
    border-radius: var(--r-tile) var(--r-tile) 0 0;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn { 
    background: transparent; 
    border: none; 
    padding: 10px 16px; 
    font-size: 12.5px; 
    font-weight: 500;
    color: var(--text-secondary); 
    cursor: pointer; 
    border-radius: var(--r-tile) var(--r-tile) 0 0;
    transition: background .15s, color .15s, box-shadow .15s;
    white-space: nowrap; 
    flex-shrink: 0; 
    position: relative;
}
.tab-btn:hover { 
    background: var(--well); 
    color: var(--text); 
}
.tab-btn.active { 
    color: var(--text); 
    background: var(--surface); 
    box-shadow: 0 -2px 8px -2px var(--shadow);
    z-index: 1;
}
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 1px 1px 0 0;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Toggle rows ── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0;
    border-bottom: 1px solid var(--line); gap: 12px; }
.toggle-row:last-child { border-bottom: none; }
.toggle-row > div { flex: 1; min-width: 0; }
.toggle-row-label { font-size: 13px; color:var(--text,#f1f5f9); font-weight: 500; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.toggle-row-sub { font-size: 11px; color:var(--text-secondary,#94a3b8); margin-top: 3px; line-height: 1.4; }
.toggle-section-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color:var(--text-secondary,#64748b); margin: 14px 0 2px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border,var(--border)); }

/* ── Badges ── */
.feat-badge { display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 3px;
    background: rgba(59,130,246,.15); color: var(--info); margin: 1px; white-space: nowrap; }
.feat-badge.green { background: rgba(34,197,94,.15); color: var(--good); }
.feat-badge.orange { background: rgba(249,115,22,.15); color: var(--warn); }
.feat-badge.purple { background: rgba(168,85,247,.15); color: var(--purple); }

/* ── Misc inputs ── */
.ssl-method-fields { margin-top: 12px; }
.ssl-method-fields .form-group { margin-bottom: 10px; }
.input-addon-group { display: flex; }
.input-addon-group select { border-radius: 6px 0 0 6px; border-right: none; width: 82px; flex-shrink: 0; padding-left: 6px; padding-right: 2px; }
.input-addon-group input { border-radius: 0 6px 6px 0; flex: 1; min-width: 0; }
.lb-server-row { display: grid;grid-template-columns: 22px 1fr 80px 28px;align-items: center;gap: 8px; }
.lb-server-row .lb-addr { min-width: 0;font-family: monospace;font-size: 12.5px; }
.lb-server-row .lb-weight { text-align: center;padding: 6px 4px; }
.lb-server-row .lb-remove { background: none;border: none;color: var(--text-muted);cursor: pointer;font-size: 14px;padding: 0;line-height: 1;width: 28px;height: 28px;border-radius: 6px;transition: color .15s,background .15s; }
.lb-server-row .lb-remove:hover { color: var(--bad);background: rgba(248,113,113,.12); }
.lb-server-row .lb-num { font-size: 11px;color: var(--text-muted);text-align: center; }
.lb-head { display: grid;grid-template-columns: 22px 1fr 80px 28px;gap: 8px;font-size: 10px;font-weight: 700;text-transform: uppercase;letter-spacing: .06em;color: var(--text-muted);margin-bottom: 6px; }
.upstream-card { background: var(--surface);border: 1px solid var(--border,var(--border));border-radius: 10px;overflow: hidden; }
.upstream-card-head { display: flex;align-items: center;justify-content: space-between;gap: 10px;padding: 10px 14px;border-bottom: 1px solid var(--border,var(--border));background: var(--surface-2); }
.upstream-card-body { padding: 14px; }
.upstream-row { display: grid;grid-template-columns: 110px 1fr;gap: 10px;align-items: center;margin-bottom: 12px; }
.upstream-row > label { font-size: 11px;font-weight: 600;text-transform: uppercase;letter-spacing: .05em;color:var(--text-secondary,#94a3b8);margin: 0; }
.upstream-preview { margin: 12px 0 0;padding: 10px 12px;background: var(--surface-2);border: 1px solid var(--border);border-radius: 10px;font: 11.5px/1.55 var(--mono);color: var(--text);white-space: pre;overflow-x: auto; }
.expand-field { background: var(--surface-2); border: 1px solid var(--border,var(--border)); border-radius: 6px; padding: 10px 12px; margin-top: 6px; }

/* ── Path Route cards ── */
.path-route-card {
    background: var(--surface-2);
    border: 1px solid var(--border,var(--border));
    border-radius: 10px;
    overflow: hidden;
    transition: border-color .15s;
}
.path-route-card:hover { border-color: rgba(59,130,246,.4); }
.pr-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border,var(--border));
}
.pr-card-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    background: rgba(59,130,246,.18); color: var(--info);
    font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.pr-card-head-title { flex: 1; font-size: 12px; font-weight: 600; color: var(--text,#f1f5f9); }
.pr-card-head-desc  { font-size: 11px; color: var(--text-secondary,#94a3b8); }
.pr-remove {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 15px; padding: 0 2px; line-height: 1; flex-shrink: 0;
    border-radius: 4px; transition: color .15s, background .15s;
    width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
}
.pr-remove:hover { color: var(--bad); background: rgba(248,113,113,.12); }
.pr-card-body {
    padding: 12px 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
}
.pr-field { display: flex; flex-direction: column; gap: 4px; }
.pr-field.full { grid-column: 1 / -1; }
.pr-field label { font-size: 11px; font-weight: 600; color: var(--text-secondary,#94a3b8); text-transform: uppercase; letter-spacing: .05em; }
.pr-field input { font-size: 12px; }
.pr-field input[data-mono] { font-family: monospace; }
.pr-card-foot {
    padding: 8px 14px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    gap: 10px;
}
.pr-card-foot .toggle-row-label { font-size: 12px; }
.pr-card-foot .toggle-row-sub   { font-size: 11px; color: var(--text-secondary,#94a3b8); margin-top: 1px; }
.pr-empty {
    text-align: center; padding: 28px 0 20px;
    color: var(--text-secondary,#94a3b8);
}
.pr-empty svg { margin: 0 auto 10px; display: block; opacity: .45; }
.pr-empty p { font-size: 12.5px; margin: 0 0 4px; }
.pr-empty small { font-size: 11px; opacity: .7; }


/* ===== TOGGLE SWITCH ===== */
.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 25px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--line-2);
    border-radius: 9999px;
    transition: .3s;
}
html.dark .toggle .slider { background: var(--line-2); }

.toggle .slider::before {
    position: absolute;
    content: "";
    height: 19px;
    width: 19px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .22);
}

.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(19px); }

/* Alias for older .toggle-switch class */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 25px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-switch .slider { position: absolute; inset: 0; background: #c3cedb; border-radius: 9999px; transition: .3s; }
html.dark .toggle-switch .slider { background: var(--line-2); }
.toggle-switch .slider::before { position: absolute; content: ""; height: 19px; width: 19px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .3s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle-switch input:checked + .slider { background: var(--primary); }
.toggle-switch input:checked + .slider::before { transform: translateX(19px); }

/* ===== STAT MINI (rules page) ===== */
.stat-mini {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-tile);
    padding: 16px;
}
.stat-mini-label { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.stat-mini-value { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* ===== GRID HELPERS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ===== CHECK LIST ===== */
.check-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.check-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.check-list li::before { content: '✓'; color: var(--good); font-weight: 800; }

/* ===== SETTING ROW ===== */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: none; padding-bottom: 0; }
.setting-label { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.setting-desc { font-size: 12px; color: var(--faint); }

/* ===== LOG VIEWER ===== */
.log-box {
    background: var(--surface-2);
    border-radius: var(--r-tile);
    padding: 20px;
    min-height: 380px;
    max-height: 500px;
    overflow-y: auto;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.7;
    border: 1px solid var(--line);
    color: var(--text-secondary);
}

.log-line { color: var(--text-secondary); }
.log-line .ts { color: var(--text-muted); }
.log-line .ok { color: var(--good); }
.log-line .err { color: var(--bad); }
.log-line .warn { color: var(--warn); }
.log-line .info { color: var(--info); }

/* ===== RISK BAR (IP Reputations) ===== */
.risk-bar {
    width: 60px;
    height: 6px;
    background: var(--line);
    border-radius: 9999px;
    overflow: hidden;
}
.risk-fill { height: 100%; border-radius: 9999px; }

/* ===== CERT ICON BOX ===== */
.cert-icon {
    width: 36px;
    height: 36px;
    background: color-mix(in srgb, var(--purple) 14%, transparent);
    color: var(--purple);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cert-icon svg { width: 18px; height: 18px; }

/* ===== FILTERS ROW ===== */
.filters-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* ===== CODE ===== */
code {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--text);
    border: 1px solid var(--line);
}

/* ===== LOADING / ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.animate-fade-in { animation: fadeIn .3s ease-out; }

/* ===== UTILITY ===== */
.text-muted { color: var(--muted); }
.text-success { color: var(--good); }
.text-danger  { color: var(--bad); }
.text-warning { color: var(--warn); }
.text-info    { color: var(--info); }
.mb-0 { margin-bottom: 0 !important; }
.mt-4 { margin-top: 16px; }
.actions { display: flex; gap: 8px; align-items: center; }
.add-row { display: flex; gap: 10px; align-items: center; }

/* ===== INFO ROW (key-value pair inside a card) ===== */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
    background: var(--surface-2);
    border-radius: 12px;
    transition: background .25s;
}
.info-row-label {
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 600;
}
.info-row-value {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text);
}

/* ===== TOPBAR CONTROLS ===== */
.topbar-sidebar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 50%;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s, border-color .15s, transform .15s;
    padding: 0;
}
.topbar-sidebar-btn:hover {
    background: var(--surface-2);
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
    transform: translateY(-1px);
}
.topbar-sidebar-btn svg { width: 17px; height: 17px; }

/* ===== DARK MODE TOGGLE BUTTON ===== */
.dark-toggle {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: background .15s, color .15s, border-color .15s, transform .15s;
    flex-shrink: 0;
}
.dark-toggle:hover {
    background: var(--surface-2);
    color: var(--primary);
    border-color: color-mix(in srgb, var(--primary) 40%, transparent);
    transform: translateY(-1px);
}
.dark-toggle svg { width: 17px; height: 17px; }

/* Show sun in dark mode, moon in light mode */
.dark-toggle .icon-sun  { display: none; }
.dark-toggle .icon-moon { display: block; }
html.dark .dark-toggle .icon-sun  { display: block; }
html.dark .dark-toggle .icon-moon { display: none; }

/* ===== HOST DRAWER (right side panel) ===== */
#host-modal {
    z-index: 1000;
    background: rgba(8, 14, 24, .55);
    align-items: stretch;
    justify-content: flex-end;
    backdrop-filter: blur(2px);
}
#host-modal .modal-content {
    width: 720px;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    padding: 0;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--line);
    animation: drawerIn .28s var(--ease);
}
#host-modal .modal-title {
    margin: 0;
    padding: 18px 24px;
    border-radius: 0;
}
#host-modal .tab-nav {
    margin: 0;
    padding: 0 16px;
    border-radius: 0;
    position: static;
}
#host-modal form { min-height: 0; flex: 1; }
#host-modal .modal-tab-body {
    margin: 0;
    padding: 20px 24px 24px;
    border-radius: 0;
}
#host-modal .modal-footer {
    margin: 0;
    padding: 14px 24px;
    border-radius: 0;
}
@keyframes drawerIn {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
@media (max-width: 720px) {
    #host-modal .modal-content { width: 100vw; }
}
