@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');
:root {
    --bg: #F5F4F1;
    --surface: #FFFFFF;
    --surface-2: #FAFAF8;
    --border: #E8E6E1;
    --border-2: #D4D1CB;
    --text: #1A1916;
    --muted: #7A7670;
    --muted-2: #B0ADA7;
    --accent: #1B4FD8;
    --accent-bg: #EEF2FF;
    --green: #16A34A;
    --green-bg: #DCFCE7;
    --amber: #B45309;
    --amber-bg: #FEF3C7;
    --red: #DC2626;
    --red-bg: #FEE2E2;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow: 0 4px 16px rgba(0, 0, 0, .07), 0 1px 4px rgba(0, 0, 0, .05);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100vh;
    font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 56px;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 28px;
}

.nav-brand,
.nav-right,
.nav-links {
    display: flex;
    align-items: center;
}

.nav-brand {
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
}

.nav-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--text);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
}

.nav-links {
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-link {
    padding: 7px 13px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 7px;
    color: var(--muted);
    transition: background 140ms, color 140ms;
}

.nav-link:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-link.active {
    background: var(--text);
    color: #fff;
}

.nav-right {
    gap: 8px;
}

.nav-clock {
    min-width: 72px;
    padding: 5px 10px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    text-align: center;
}

.page {
    width: min(1560px, calc(100% - 48px));
    margin: 0 auto;
    padding: 28px 0 64px;
    display: grid;
    gap: 18px;
}

.panel,
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.hero {
    padding: clamp(24px, 3vw, 42px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: center;
    gap: 24px;
    box-shadow: var(--shadow);
}

.hero__meta,
.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hero__meta {
    margin-bottom: 14px;
}

.hero h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 4.5rem);
    font-weight: 400;
    letter-spacing: 0;
    line-height: .98;
}

.hero p {
    margin: 16px 0 0;
    max-width: 720px;
    color: var(--muted);
    line-height: 1.55;
}

/* System Animations */
.hero-anim {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    border: 1px solid var(--border);
    overflow: hidden;
}

.anim-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}
.anim-placeholder .pulse-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border-2);
    animation: default-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.anim-placeholder .pulse-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--muted-2);
}
@keyframes default-pulse {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

.anim-monarch, .anim-trident {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.anim-monarch .core {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #7C3AED, #4F46E5);
    border-radius: 18px;
    transform: rotate(45deg);
    animation: monarch-pulse 3s infinite cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.4);
    z-index: 2;
}
.anim-monarch .core::after {
    content: "M";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    transform: rotate(-45deg);
    color: white;
    font-size: 28px;
    font-weight: 800;
}
@keyframes monarch-pulse {
    0%, 100% { transform: rotate(45deg) scale(1); box-shadow: 0 0 30px rgba(124, 58, 237, 0.4); }
    50% { transform: rotate(45deg) scale(1.08); box-shadow: 0 0 45px rgba(124, 58, 237, 0.6); }
}
.anim-monarch .ring {
    position: absolute;
    width: 140px;
    height: 140px;
    border: 2px dashed rgba(124, 58, 237, 0.4);
    border-radius: 50%;
    animation: monarch-spin 15s linear infinite;
}
@keyframes monarch-spin {
    to { transform: rotate(360deg); }
}

.anim-trident .core {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #0369A1, #0284C7);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 30px rgba(3, 105, 161, 0.4);
    display: grid;
    place-items: center;
    animation: trident-float 4s ease-in-out infinite;
    z-index: 2;
}
.anim-trident .core::after {
    content: "T";
    color: white;
    font-size: 32px;
    font-weight: 800;
}
.anim-trident .bar {
    position: absolute;
    bottom: 0;
    width: 4px;
    height: 100px;
    background: linear-gradient(to top, transparent, #0ea5e9);
    animation: trident-scan 2s ease-in-out infinite alternate;
}
@keyframes trident-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}
@keyframes trident-scan {
    0% { height: 50px; opacity: 0.3; }
    100% { height: 120px; opacity: 1; }
}

.chip,
.count-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.chip.info {
    color: var(--accent);
    border-color: #C7D2FE;
    background: var(--accent-bg);
}

.chip.ok {
    color: var(--green);
    border-color: #BBF7D0;
    background: var(--green-bg);
}

.chip.warn {
    color: var(--amber);
    border-color: #FDE68A;
    background: var(--amber-bg);
}

.chip.down {
    color: var(--red);
    border-color: #FECACA;
    background: var(--red-bg);
}

.primary-button,
.secondary-button,
.ghost-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    transition: background 140ms, border-color 140ms;
}

.primary-button {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-btn:hover {
    opacity: .82;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stat {
    padding: 20px;
}

.stat__label {
    display: block;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.stat__value {
    display: block;
    margin-top: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 2.4rem;
    font-weight: 500;
    line-height: 1;
}

.stat__value--small {
    font-size: 1.35rem;
    line-height: 1.2;
}

.stat__meta {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
}

.filters-panel {
    padding: 18px;
    overflow: visible;
}

.filters {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 1.2fr;
    gap: 12px;
}

.filters label {
    display: grid;
    gap: 7px;
}

.filters span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.filters select,
.filters input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 9px 11px;
}

/* Custom Multiselect */
.custom-select-wrapper {
    display: grid;
    gap: 7px;
    position: relative;
}
.custom-select-wrapper span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.custom-multiselect {
    position: relative;
    user-select: none;
}
.multiselect-header {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    padding: 9px 30px 9px 11px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.multiselect-header::after {
    content: "▼";
    position: absolute;
    right: 12px;
    top: 14px;
    font-size: 10px;
    color: var(--muted);
}
.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 50;
    display: none;
    flex-direction: column;
}
.custom-multiselect.open .multiselect-dropdown {
    display: flex;
}
.multiselect-dropdown input {
    margin: 8px;
    width: calc(100% - 16px);
    min-height: 36px;
}
.multiselect-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 0 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.multiselect-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
}
.multiselect-option:hover {
    background: var(--surface-2);
}
.multiselect-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: auto;
    margin: 0;
    cursor: pointer;
}
.multiselect-option span {
    color: var(--text);
    font-weight: 500;
    font-size: 13px;
    text-transform: none;
    letter-spacing: normal;
}

.filters select:focus,
.filters input:focus {
    outline: 2px solid #C7D2FE;
    border-color: var(--accent);
}

.panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--border);
}

.panel__head h2 {
    margin: 0;
    font-size: 1rem;
}

.panel__head p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.tab {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 800;
}

.tab.active {
    color: var(--accent);
    border-color: #C7D2FE;
    background: var(--accent-bg);
}

.chart-wrap {
    position: relative;
    min-height: 380px;
    padding: 18px;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 340px !important;
}

.empty-overlay {
    position: absolute;
    inset: 18px;
    display: none;
    place-items: center;
    border: 1px dashed var(--border-2);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .86);
    color: var(--muted);
    font-weight: 700;
    text-align: center;
    padding: 24px;
}

.empty-overlay.visible {
    display: grid;
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
    gap: 18px;
}

.table-wrap {
    max-height: 520px;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th,
td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
}

td:last-child {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 700;
}

.timeline {
    display: grid;
    gap: 10px;
    padding: 18px;
}

.event {
    display: grid;
    gap: 5px;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.event strong {
    font-size: 13px;
}

.event span,
.event time {
    color: var(--muted);
    font-size: 12px;
}

.event.empty {
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

@media (max-width: 1100px) {
    .hero,
    .grid,
    .filters {
        grid-template-columns: 1fr;
    }

    .hero__actions,
    .tabs {
        justify-content: flex-start;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .topnav {
        align-items: flex-start;
        flex-direction: column;
        padding: 12px 16px;
    }

    .page {
        width: min(100% - 24px, 1560px);
        padding-top: 16px;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .panel__head {
        flex-direction: column;
    }

    .chart-wrap canvas {
        height: 280px !important;
    }
}
