:root {
    --bg-color: #0b0f19;
    --panel-bg: rgba(22, 28, 45, 0.6);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent-glow: rgba(57, 135, 237, 0.3);
    --accent-light: #3987ED;
    --accent-primary: #E75E26;
    --threat-color: var(--accent-primary);
}

.hidden { display: none !important; }

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.15), transparent 25%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* ═══════════════════════════════════════════════════════════════
   NAVIGATION SYSTEM — Two-Row Header
   Row 1: Logo | Primary Nav | User
   Row 2: Status (left) | Page Tools (right)
   ═══════════════════════════════════════════════════════════════ */

/* Nav color tokens */
:root {
    --nav-c-dashboard: #3987ED;
    --nav-c-visitors:  #64ffda;
    --nav-c-journeys:  #34d399;
    --nav-c-seo:       #fbbf24;
    --nav-c-social:    #5aa3e8;
    --nav-c-jobs:      #34d399;
    --nav-c-web:       #f97316;
    --nav-c-link:      #a78bfa;
    --nav-c-enrich:    #e879f9;
    --nav-c-heatmap:   #fb923c;
    --nav-c-reports:   #34d399;
}

/* Main header wrapper — stacks two rows */
.main-header {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin-bottom: 1.25rem;
    overflow: hidden; /* keeps border-radius clean */
}

/* ── Row 1: Logo + Nav + User ── */
.nav-primary {
    display: flex;
    align-items: center;
    padding: 0.55rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: 0;
}

/* Logo zone */
.nav-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    margin-right: 1.1rem;
}

/* Nav links group — fills middle, NEVER scrolls */
.nav-links {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.1rem;
    min-width: 0;
}



.nav-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    height: 28px;
    padding: 0 0.7rem;
    border-radius: 5px;
    border: 1px solid rgba(252,165,165,0.25);
    background: none;
    color: #fca5a5;
    font-size: 0.76rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.nav-logout:hover {
    background: rgba(252,165,165,0.1);
    border-color: rgba(252,165,165,0.5);
}

/* ── Row 2: Status + Page Tools + User ── */
.nav-sub {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 1.25rem;
    min-height: 30px;
}
.nav-sub-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.nav-sub-right {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.nav-user-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Nav Items (primary navigation links) ── */
.nav-item {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    height: 32px;
    padding: 0 0.82rem;
    border-radius: 6px;
    border: none;
    background: none;
    color: rgba(226,232,240,0.48);
    font-size: 0.81rem;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
}
.nav-item:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,0.07);
}

/* Active state — color + subtle tint per section */
.nav-item.ni-dashboard.active  { color: var(--nav-c-dashboard); background: rgba(57,135,237,0.12); }
.nav-item.ni-visitors.active   { color: var(--nav-c-visitors);  background: rgba(100,255,218,0.09); }
.nav-item.ni-journeys.active   { color: var(--nav-c-journeys);  background: rgba(52,211,153,0.1);  }
.nav-item.ni-journeys          { color: rgba(52,211,153,0.55); }
.nav-item.ni-journeys:hover    { color: var(--nav-c-journeys); }
.nav-item.ni-seo.active        { color: var(--nav-c-seo);       background: rgba(251,191,36,0.1);  }
.nav-item.ni-social.active     { color: var(--nav-c-social);    background: rgba(90,163,232,0.1);  }
.nav-item.ni-jobs.active       { color: var(--nav-c-jobs);      background: rgba(52,211,153,0.1);  }
.nav-item.ni-web.active        { color: var(--nav-c-web);       background: rgba(249,115,22,0.1);  }
.nav-item.ni-link.active       { color: var(--nav-c-link);      background: rgba(167,139,250,0.1); }
.nav-item.ni-enrich.active     { color: var(--nav-c-enrich);    background: rgba(232,121,249,0.1); }
.nav-item.ni-enrich            { color: rgba(232,121,249,0.55); }
.nav-item.ni-enrich:hover      { color: var(--nav-c-enrich); }
.nav-item.ni-heatmap.active    { color: var(--nav-c-heatmap);   background: rgba(251,146,60,0.1);  }
.nav-item.ni-heatmap           { color: rgba(251,146,60,0.55); }
.nav-item.ni-heatmap:hover     { color: var(--nav-c-heatmap); }
.nav-item.ni-reports.active    { color: var(--nav-c-reports);   background: rgba(52,211,153,0.1);  }
.nav-item.ni-reports           { color: rgba(52,211,153,0.55); }
.nav-item.ni-reports:hover     { color: var(--nav-c-reports); }

/* ── Page Tool Buttons (Row 2 right) ── */
.nav-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    height: 26px;
    padding: 0 0.7rem;
    border-radius: 5px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}
.nav-tool-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #e2e8f0;
}
.nav-tool-btn.primary {
    border-color: rgba(57,135,237,0.35);
    color: var(--nav-c-dashboard);
    background: rgba(57,135,237,0.08);
}
.nav-tool-btn.primary:hover {
    background: rgba(57,135,237,0.15);
    border-color: rgba(57,135,237,0.6);
}

/* Legacy aliases — keep old class names working during transition */
.header-logo  { flex-shrink: 0; display: flex; align-items: center; }
.header-nav   { flex: 1; display: flex; align-items: center; gap: 0.4rem; }
.header-actions { flex-shrink: 0; display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.nav-btn { padding: 0.3rem 0.65rem !important; font-size: 0.78rem !important; white-space: nowrap !important; border: 1px solid transparent; }

h1 {
    font-size: 2rem;
    font-weight: 700;
}

.accent {
    color: var(--accent-light);
    text-shadow: 0 0 10px rgba(129, 140, 248, 0.5);
}

.btn {
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    border: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.primary-btn {
    background: var(--accent-glow);
    color: white;
}

.primary-btn:hover {
    background: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Metrics Row */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.3s ease;
}

.metric-card:hover {
    transform: translateY(-5px);
}

.metric-card h3 {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}

.metric-value {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff, var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-top: 0.5rem;
}

/* Period context label beneath each metric — e.g. "Total · Last 30 Days · excl. bots" */
.metric-sublabel {
    font-size: 0.67rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.045em;
    margin-top: 0.4rem;
    line-height: 1.3;
    font-weight: 400;
}

/* Layout Columns */
.main-columns {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Lists */
.list-section {
    padding: 1.5rem;
}

.list-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 0.5rem;
}

.data-list {
    list-style: none;
}

.data-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.95rem;
}

.data-list li:last-child {
    border-bottom: none;
}

.count-badge {
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-light);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Threats */
.threat-section h2 {
    color: var(--threat-color);
    border-bottom-color: rgba(239, 68, 68, 0.3);
}

.threat-scroll {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.threat-scroll::-webkit-scrollbar {
    width: 6px;
}
.threat-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.threat-list li {
    flex-direction: column;
    gap: 0.25rem;
}

.threat-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.threat-status {
    color: var(--threat-color);
    font-weight: 600;
}

.threat-payload {
    font-family: monospace;
    background: rgba(0,0,0,0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    word-break: break-all;
    color: #fca5a5;
}

/* Loading & Toast */
.dashboard-grid {
    position: relative;
}

.blur-load {
    filter: blur(5px);
    pointer-events: none;
}

.loader-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

.blur-load .loader-overlay {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--accent-light);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    z-index: 100;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.toast.hidden {
    transform: translateY(100px);
    opacity: 0;
}

/* "View All" more button */
.more-btn {
    display: block;
    text-align: center;
    padding: 0.6rem 1rem;
    margin-top: 0.5rem;
    color: var(--accent-light);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px dashed rgba(57, 135, 237, 0.4);
    border-radius: 6px;
    background: rgba(57, 135, 237, 0.05);
    transition: all 0.2s ease;
    cursor: pointer;
}
.more-btn:hover {
    background: rgba(57, 135, 237, 0.15);
    border-color: var(--accent-light);
    color: #fff;
}

/* Detail page */
.detail-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1rem;
}
.detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.detail-header .back-btn {
    color: var(--accent-light);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid rgba(57, 135, 237, 0.3);
    border-radius: 6px;
    transition: all 0.2s ease;
}
.detail-header .back-btn:hover {
    background: rgba(57, 135, 237, 0.15);
}
.detail-list {
    list-style: none;
    padding: 0;
}
.detail-list li {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.detail-list li:hover {
    background: rgba(255, 255, 255, 0.03);
}
.detail-rank {
    color: var(--text-muted);
    font-size: 0.8rem;
    min-width: 2rem;
}

/* Global dark select/dropdown styling */
select, input[type="text"] {
    background-color: #1e293b;
    color: #e2e8f0;
    border: 1px solid var(--panel-border);
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
}
select option {
    background-color: #1e293b;
    color: #e2e8f0;
    padding: 4px 8px;
}
select:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-light);
    box-shadow: 0 0 0 2px rgba(57, 135, 237, 0.2);
}

/* === Drilldown Modal === */
.drill-hint {
    font-size: 0.65rem;
    color: rgba(100,255,218,0.5);
    font-weight: 400;
    font-style: italic;
    margin-left: 6px;
}
.drilldown-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(6px);
    z-index: 9000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    animation: fadeIn 0.15s ease;
}
.drilldown-overlay.hidden { display: none !important; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp { from { transform:translateY(30px); opacity:0; } to { transform:translateY(0); opacity:1; } }

.drilldown-panel {
    background: rgba(15,23,42,0.97);
    border: 1px solid rgba(100,255,218,0.15);
    border-radius: 16px;
    width: 90vw;
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0,0,0,0.5), 0 0 40px rgba(59,130,246,0.08);
    animation: slideUp 0.25s ease;
}
.drilldown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky;
    top: 0;
    background: rgba(15,23,42,0.98);
    z-index: 1;
    border-radius: 16px 16px 0 0;
}
.drilldown-header h2 {
    font-size: 1.1rem;
    color: #64ffda;
    font-weight: 600;
}
.drilldown-close {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s;
}
.drilldown-close:hover {
    background: rgba(239,68,68,0.2);
    color: #f87171;
    border-color: rgba(239,68,68,0.3);
}
.drilldown-body {
    padding: 20px 28px 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.drilldown-section {
    background: rgba(30,41,59,0.5);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 16px 20px;
}
.drilldown-section h3 {
    font-size: 0.85rem;
    color: #8b5cf6;
    margin-bottom: 12px;
    font-weight: 600;
}
.drilldown-list {
    list-style: none;
}
.drilldown-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.82rem;
}
.drilldown-list li:last-child { border-bottom: none; }
.drilldown-list .dl-label {
    color: #cbd5e1;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 12px;
}
.drilldown-list .dl-value {
    color: #64ffda;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: right;
}
.drilldown-chart-wrap {
    position: relative;
    height: 180px;
}
.drilldown-loading {
    text-align: center;
    padding: 40px;
    color: #64ffda;
    font-size: 0.9rem;
}
.drilldown-loading::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-left: 10px;
    border: 2px solid rgba(100,255,218,0.3);
    border-top-color: #64ffda;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pulse animation for health indicator */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Nav item active state — legacy selector kept for backward compat */
.nav-active {
    border-color: var(--accent-light) !important;
    background: rgba(57, 135, 237, 0.15) !important;
}

/* ═══════════════════════════════════════════════════════════════
   Page Drilldown Modal Overlay — GLOBAL
   ─────────────────────────────────────────────────────────────
   These rules MUST live in styles.css (not inline in any template)
   so that #pageDrilldownModal renders as a fixed centred overlay on
   EVERY page that includes the shared app.js drilldown system
   (visitors.html, index.html, etc.).

   Root cause of the bottom-of-page bug:
     .modal-overlay was only defined in index.html's inline <style>.
     On visitors.html the class had no positioning rules, so the
     element rendered as a normal block at the end of the document.
═══════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    box-sizing: border-box;
    opacity: 1;
    transition: opacity 0.2s ease;
}
.modal-overlay.hidden {
    display: none !important;
    opacity: 0;
}
/* Shared modal content panel */
.modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid rgba(100, 255, 218, 0.2);
    padding: 1.5rem;
    box-sizing: border-box;
    border-radius: 14px;
}
/* Page-drilldown modal: wider and flex column so tabs + scrollable body work */
#pageDrilldownModal .modal-content {
    max-width: 940px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
