/* =====================================================
   CertID Enterprise UI — Design System
   Themes: dark (default) | light | green
   Colors: Soft Black #1A1A1A | Charcoal #36454F
           Slate Gray #708090 | Copper #B87333
   Semantic: green=healthy | amber=warning | red=critical
   ===================================================== */

/* ── CSS Reset & Base ─────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
}

input,
button,
select {
    font-family: inherit;
    font-size: inherit;
}

img,
svg {
    display: block;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ── Theme: Dark (Default) ────────────────────────── */
[data-theme="dark"] {
    --bg-base: #1a1a1a;
    --bg-surface: #1a1a1a;
    --bg-elevated: #262626;
    --bg-hover: #303030;
    --bg-sidebar: #1A1A1A;
    --bg-sidebar-hover: #262626;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-inverse: #0d1117;
    --border: #30363d;
    --border-subtle: #21262d;
    --accent: #B87333;
    --accent-hover: #ca8a45;
    --accent-muted: rgba(184, 115, 51, 0.15);
    --primary-h: 205;
    --primary-s: 19%;
    --primary-l: 26%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-hover: hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) + 10%));
    --status-green: #3fb950;
    --status-amber: #d29922;
    --status-red: #f85149;
    --status-blue: #388bfd;
    --status-green-bg: rgba(63, 185, 80, 0.1);
    --status-amber-bg: rgba(210, 153, 34, 0.1);
    --status-red-bg: rgba(248, 81, 73, 0.1);
    --status-blue-bg: rgba(56, 139, 253, 0.1);
    --scrollbar-thumb: #30363d;
}

[data-theme="dark"],
[data-theme="green"] {
    color-scheme: dark;
}

/* ── Theme: Light ─────────────────────────────────── */
[data-theme="light"] {
    color-scheme: light;
    --bg-base: #f6f8fa;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-hover: #e8ebef;
    --bg-sidebar: #1A1A1A;
    --bg-sidebar-hover: #262626;
    --text-primary: #1A1A1A;
    --text-secondary: #57606a;
    --text-muted: #8c959f;
    --text-inverse: #ffffff;
    --border: #d0d7de;
    --border-subtle: #eaeef2;
    --accent: #B87333;
    --accent-hover: #9a601f;
    --accent-muted: rgba(184, 115, 51, 0.1);
    --primary-h: 205;
    --primary-s: 19%;
    --primary-l: 26%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-hover: hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) - 6%));
    --status-green: #1a7f37;
    --status-amber: #9a6700;
    --status-red: #cf222e;
    --status-blue: #0969da;
    --status-green-bg: rgba(26, 127, 55, 0.08);
    --status-amber-bg: rgba(154, 103, 0, 0.08);
    --status-red-bg: rgba(207, 34, 46, 0.08);
    --status-blue-bg: rgba(9, 105, 218, 0.08);
    --scrollbar-thumb: #d0d7de;
}

/* ── Theme: Green (Matrix / Security) ────────────── */
[data-theme="green"] {
    --bg-base: #020c02;
    --bg-surface: #041204;
    --bg-elevated: #071707;
    --bg-hover: #0a200a;
    --bg-sidebar: #011001;
    --bg-sidebar-hover: #031503;

    --text-primary: #39ff14;
    --text-secondary: #22c55e;
    --text-muted: #15803d;
    --text-inverse: #011001;

    --border: #14532d;
    --border-subtle: #0a2e10;

    --accent: #B87333;
    --accent-hover: #ca8a45;
    --accent-muted: rgba(184, 115, 51, 0.15);

    --primary-h: 143;
    --primary-s: 64%;
    --primary-l: 24%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-hover: hsl(var(--primary-h), var(--primary-s), calc(var(--primary-l) + 5%));

    --status-green: #39ff14;
    --status-amber: #fbbf24;
    --status-red: #f85149;
    --status-blue: #34d399;

    --status-green-bg: rgba(57, 255, 20, 0.08);
    --status-amber-bg: rgba(251, 191, 36, 0.08);
    --status-red-bg: rgba(248, 81, 73, 0.08);
    --status-blue-bg: rgba(52, 211, 153, 0.08);

    --scrollbar-thumb: #14532d;
}

/* ── Global Scrollbar ─────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

/* ── Layout Shell ─────────────────────────────────── */
body {
    display: flex;
    background: var(--bg-base);
    color: var(--text-primary);
    transition: background 0.25s, color 0.25s;
}

.main-wrapper {
    flex: 1;
    margin-left: 256px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 256px;
    background: var(--bg-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
    transition: width 0.25s ease, transform 0.25s ease;
}

.sidebar-logo {
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #e6edf3;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-icon {
    width: 32px;
    height: 32px;
    color: var(--accent);
    flex-shrink: 0;
}

.logo-text {
    color: #e6edf3;
}

/* Tenant selector */
.tenant-selector {
    margin: 12px 12px 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tenant-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #8b949e;
    font-size: 0.75rem;
    font-weight: 500;
}

.tenant-badge svg {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

.tenant-badge span {
    color: var(--text-sidebar-primary);
    font-weight: 600;
}

.tenant-switch {
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.15s;
    display: flex;
    align-items: center;
}

.tenant-switch:hover {
    color: var(--accent);
}

.tenant-switch svg {
    width: 14px;
    height: 14px;
}

/* Nav sections */
.nav-section-label {
    padding: 12px 16px 4px;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 4px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.875rem;
    font-weight: 450;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    margin-bottom: 1px;
    position: relative;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item span:not(.nav-badge):not(.nav-tag) {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: rgba(255, 255, 255, 0.85);
}

.nav-item.active {
    background: rgba(184, 115, 51, 0.15);
    color: var(--accent);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.nav-badge {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    line-height: 1.4;
}

.nav-badge.accent {
    background: var(--accent-muted);
    color: var(--accent);
}

.nav-badge.danger {
    background: var(--status-red-bg);
    color: var(--status-red);
}

.nav-tag {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.4);
}

.nav-logout {
    color: rgba(248, 81, 73, 0.5);
}

.nav-logout:hover {
    background: var(--status-red-bg);
    color: var(--status-red);
}

.sidebar-footer {
    padding: 8px 8px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    margin-top: auto;
}

/* ── Top Bar ──────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    height: 66px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

.topbar-breadcrumb {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Theme switcher */
.theme-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
}

.theme-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}

.theme-btn svg {
    width: 14px;
    height: 14px;
}

.theme-btn:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.theme-btn.active {
    background: var(--accent);
    color: #fff;
}

/* Notification button */
.topbar-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
}

.topbar-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.topbar-icon-btn svg {
    width: 18px;
    height: 18px;
}

.notif-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1.5px solid var(--bg-surface);
}

.notif-dot.danger {
    background: var(--status-red);
}

/* Avatar */
.avatar-menu {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.15s;
}

.avatar-btn:hover {
    opacity: 0.85;
}

.avatar-initials {
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}

.avatar-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── Page Content ─────────────────────────────────── */
.page-content {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1400px;
    width: 100%;
}

.page-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ── Status Bar ──────────────────────────────────── */
.status-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 4px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background 0.15s;
}

.status-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.status-healthy {
    color: var(--status-green);
}

.status-healthy:hover {
    background: var(--status-green-bg);
}

.status-warning {
    color: var(--status-amber);
}

.status-warning:hover {
    background: var(--status-amber-bg);
}

.status-critical {
    color: var(--status-red);
}

.status-critical:hover {
    background: var(--status-red-bg);
}

.status-divider {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.status-bar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.status-bar-right strong {
    color: var(--text-primary);
}

.status-sync {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--status-green);
}

/* Status dots */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.green {
    background: var(--status-green);
}

.status-dot.amber {
    background: var(--status-amber);
}

.status-dot.red {
    background: var(--status-red);
}

.status-dot.blue {
    background: var(--status-blue);
}

.status-dot.pulse {
    animation: pulse-ring 1.5s ease-in-out infinite;
}

@keyframes pulse-ring {

    0%,
    100% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 1;
    }

    50% {
        box-shadow: 0 0 0 5px transparent;
        opacity: 0.7;
    }
}

/* ── Dashboard Sections ──────────────────────────── */
.dashboard-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.section-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-title svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

.section-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* ── Action Cards ─────────────────────────────────── */
.action-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.action-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.action-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.severity-critical::before {
    background: var(--status-red);
}

.severity-warning::before {
    background: var(--status-amber);
}

.severity-info::before {
    background: var(--status-blue);
}

.action-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.severity-critical:hover {
    border-color: var(--status-red);
}

.severity-warning:hover {
    border-color: var(--status-amber);
}

.severity-info:hover {
    border-color: var(--status-blue);
}

.action-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.severity-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.severity-badge svg {
    width: 12px;
    height: 12px;
}

.severity-badge.critical {
    background: var(--status-red-bg);
    color: var(--status-red);
}

.severity-badge.warning {
    background: var(--status-amber-bg);
    color: var(--status-amber);
}

.severity-badge.info {
    background: var(--status-blue-bg);
    color: var(--status-blue);
}

.action-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.action-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}

.action-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.55;
    flex: 1;
}

.action-desc strong {
    color: var(--text-primary);
    font-weight: 600;
}

.action-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 500;
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.meta-tag svg {
    width: 10px;
    height: 10px;
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 7px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    align-self: flex-start;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-danger {
    background: var(--status-red);
    color: #fff;
    border: 1px solid var(--status-red);
}

.btn-danger:hover {
    opacity: 0.85;
}

.btn-warning {
    background: var(--status-amber);
    color: #fff;
    border: 1px solid var(--status-amber);
}

.btn-warning:hover {
    opacity: 0.85;
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
}

.btn-accent:hover {
    background: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8125rem;
}

/* ── Live Feed Panel ──────────────────────────────── */
.feed-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.feed-event {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.8125rem;
    transition: background 0.15s;
    animation: feed-slide-in 0.3s ease-out;
}

.feed-event:last-child {
    border-bottom: none;
}

.feed-event:hover {
    background: var(--bg-hover);
}

@keyframes feed-slide-in {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.feed-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.feed-dot.red {
    background: var(--status-red);
    box-shadow: 0 0 6px var(--status-red);
}

.feed-dot.amber {
    background: var(--status-amber);
    box-shadow: 0 0 6px var(--status-amber);
}

.feed-dot.green {
    background: var(--status-green);
    box-shadow: 0 0 6px var(--status-green);
}

.feed-dot.blue {
    background: var(--status-blue);
    box-shadow: 0 0 6px var(--status-blue);
}

.feed-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 72px;
}

.feed-icon {
    display: flex;
    align-items: center;
    color: var(--text-muted);
}

.feed-icon svg {
    width: 13px;
    height: 13px;
}

.feed-msg {
    flex: 1;
    color: var(--text-secondary);
    line-height: 1.4;
}

.feed-msg strong {
    color: var(--text-primary);
    font-weight: 600;
}

.feed-tag {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.feed-tag.danger {
    background: var(--status-red-bg);
    color: var(--status-red);
}

.feed-tag.warning {
    background: var(--status-amber-bg);
    color: var(--status-amber);
}

.feed-tag.success {
    background: var(--status-green-bg);
    color: var(--status-green);
}

.feed-tag.info {
    background: var(--status-blue-bg);
    color: var(--status-blue);
}

.feed-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-red);
    box-shadow: 0 0 8px var(--status-red);
    animation: live-blink 1s ease-in-out infinite;
    margin-right: 4px;
}

@keyframes live-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ── KPI Grid ─────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: box-shadow 0.2s, border-color 0.2s;
    cursor: default;
}

.kpi-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border-color: var(--text-muted);
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg {
    width: 18px;
    height: 18px;
}

.kpi-icon.healthy {
    background: var(--status-green-bg);
    color: var(--status-green);
}

.kpi-icon.warning {
    background: var(--status-amber-bg);
    color: var(--status-amber);
}

.kpi-icon.critical {
    background: var(--status-red-bg);
    color: var(--status-red);
}

.kpi-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kpi-value {
    font-size: 1.375rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-unit {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-delta {
    font-size: 0.6875rem;
    font-weight: 500;
}

.kpi-delta.positive {
    color: var(--status-green);
}

.kpi-delta.negative {
    color: var(--status-red);
}

/* ── Charts ───────────────────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chart-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legend-dot.green {
    background: var(--status-green);
}

.legend-dot.red {
    background: var(--status-red);
}

.chart-area {
    position: relative;
}

.chart-area canvas {
    max-width: 100%;
}

.chart-period-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
}

.period-tab {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.period-tab:hover {
    color: var(--text-secondary);
}

.period-tab.active {
    background: var(--accent);
    color: #fff;
}

.anomaly-score {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

.score-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--status-green);
}

.score-label {
    font-size: 0.6875rem;
    color: var(--text-muted);
}

/* ── Log Table ────────────────────────────────────── */
.table-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    overflow-x: auto;
}

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.log-table th {
    text-align: left;
    padding: 11px 16px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.log-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
    color: var(--text-secondary);
}

.log-table tr:last-child td {
    border-bottom: none;
}

.log-table tbody tr:hover {
    background: var(--bg-hover);
}

.mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.event-type {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.event-type svg {
    width: 13px;
    height: 13px;
}

.event-type.critical {
    color: var(--status-red);
}

.event-type.warning {
    color: var(--status-amber);
}

.event-type.success {
    color: var(--status-green);
}

.event-type.neutral {
    color: var(--text-secondary);
}

.risk-bar {
    width: 80px;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.risk-fill {
    height: 100%;
    border-radius: 3px;
}

.risk-fill.high {
    background: var(--status-red);
}

.risk-fill.medium {
    background: var(--status-amber);
}

.risk-fill.low {
    background: var(--status-green);
}

.status-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.status-chip.resolved {
    background: var(--status-green-bg);
    color: var(--status-green);
}

.status-chip.blocked {
    background: var(--status-red-bg);
    color: var(--status-red);
}

.status-chip.success {
    background: var(--status-green-bg);
    color: var(--status-green);
}

.status-chip.internal {
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.row-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.row-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.row-action-btn svg {
    width: 16px;
    height: 16px;
}

/* ── Log Controls ─────────────────────────────────── */
.log-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 10px;
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    padding: 6px 10px 6px 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.8125rem;
    width: 200px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-muted);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 1280px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .action-cards {
        grid-template-columns: 1fr 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .main-wrapper {
        margin-left: 0;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .action-cards {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .status-bar-right {
        display: none;
    }

    .avatar-name {
        display: none;
    }

    .theme-switcher {
        display: none;
    }

    .page-content {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .search-input {
        width: 140px;
    }
}

/* ── Reduced Motion ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ── Focus Styles (a11y) ──────────────────────────── */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Sidebar Collapse Toggle (icon-only mode) ─────── */
.sidebar-collapse-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    color: var(--text-secondary);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-collapse-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.25s ease;
}

/* The collapse control is a desktop affordance only; on mobile the drawer is used instead. */
@media (min-width: 769px) {
    .sidebar-collapse-btn {
        display: inline-flex;
    }

    html.sidebar-collapsed .sidebar {
        width: 76px;
    }

    html.sidebar-collapsed .main-wrapper {
        margin-left: 76px;
    }

    html.sidebar-collapsed .sidebar-collapse-btn svg {
        transform: rotate(180deg);
    }

    /* Hide every textual element, keep icons */
    html.sidebar-collapsed .sidebar .logo-text,
    html.sidebar-collapsed .nav-item span:not(.nav-badge):not(.nav-tag),
    html.sidebar-collapsed .nav-section-label,
    html.sidebar-collapsed .nav-tag,
    html.sidebar-collapsed .nav-badge,
    html.sidebar-collapsed .tenant-badge span,
    html.sidebar-collapsed .tenant-switch,
    html.sidebar-collapsed .sidebar-org-label {
        display: none !important;
    }

    /* Center the remaining icons */
    html.sidebar-collapsed .nav-item {
        justify-content: center;
        gap: 0;
        padding-left: 0;
        padding-right: 0;
    }

    html.sidebar-collapsed .tenant-selector {
        justify-content: center;
        padding: 8px;
    }

    html.sidebar-collapsed .sidebar-logo {
        display: flex;
        justify-content: center;
    }

    html.sidebar-collapsed .sidebar-logo svg {
        width: 32px !important;
        margin: 0 auto !important;
    }

    /* Hover tooltip showing the hidden label */
    html.sidebar-collapsed .nav-item:hover::after {
        content: attr(data-label);
        position: absolute;
        left: calc(100% + 12px);
        top: 50%;
        transform: translateY(-50%);
        background: var(--bg-elevated);
        color: var(--text-primary);
        border: 1px solid var(--border);
        padding: 6px 10px;
        border-radius: 8px;
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
        z-index: 100;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
        pointer-events: none;
    }
}

/* ── Mobile Drawer Backdrop ───────────────────────── */
#sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 45;
}

@media (max-width: 768px) {
    #sidebar-backdrop.active {
        display: block;
    }

    /* Collapse has no meaning on mobile — always render the full drawer */
    html.sidebar-collapsed .sidebar {
        width: 256px;
    }
}

/* ── Global Loading Overlay (freezes the app) ─────── */
#global-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 12, 0.55);
    backdrop-filter: blur(4px);
    cursor: wait;
}

#global-loader.active {
    display: flex;
}

.global-loader-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 28px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

.global-loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: global-spin 0.8s linear infinite;
}

.global-loader-text {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

@keyframes global-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Small-screen density (tame oversized paddings) ─ */
@media (max-width: 640px) {
    .page-content {
        padding: 14px !important;
    }

    .page-content [class*="p-12"] {
        padding: 1.25rem !important;
    }

    .page-content [class*="p-10"] {
        padding: 1.15rem !important;
    }

    .page-content [class*="p-8"] {
        padding: 1rem !important;
    }

    .page-content [class*="rounded-[3rem]"] {
        border-radius: 1.5rem !important;
    }

    .page-content [class*="gap-10"] {
        gap: 1.25rem !important;
    }

    .page-content [class*="gap-8"] {
        gap: 1rem !important;
    }
}