:root {
    color-scheme: dark;
    --bg: #070b10;
    --surface: #0d141c;
    --panel: #101923;
    --panel-soft: #152230;
    --line: #263545;
    --line-strong: #385064;
    --text: #eef5f8;
    --muted: #91a3b5;
    --faint: #607386;
    --accent: #2dd4bf;
    --accent-soft: rgba(45, 212, 191, 0.16);
    --info: #60a5fa;
    --low: #34d399;
    --medium: #fbbf24;
    --high: #fb923c;
    --critical: #ef4444;
    --danger: #fb7185;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

a, button, input, select { font: inherit; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

code {
    color: #d7e4ee;
    font-family: "Courier New", monospace;
    font-size: 13px;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 22px 16px;
    background: #091018;
    border-right: 1px solid var(--line);
}

.sidebar-brand,
.sidebar-nav a,
.sidebar-group a,
.link-button {
    color: var(--muted);
    text-decoration: none;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
    color: var(--text);
}

.sidebar-brand strong,
.sidebar-brand small { display: block; }

.sidebar-brand small,
.sidebar-group span {
    color: var(--faint);
    font-size: 12px;
    text-transform: uppercase;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: #06100f;
    background: var(--accent);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
}

.brand-mark.large {
    width: 52px;
    height: 52px;
    margin-bottom: 16px;
}

.sidebar-nav,
.sidebar-group {
    display: grid;
    gap: 6px;
}

.sidebar-group { margin-top: 28px; }

.sidebar-nav a,
.sidebar-group a,
.link-button {
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 6px;
}

.sidebar-nav a:hover,
.sidebar-group a:hover,
.link-button:hover {
    color: var(--text);
    background: var(--panel-soft);
}

.sidebar-logout { margin-top: auto; }

.link-button {
    width: 100%;
    background: transparent;
    border: 1px solid var(--line);
    cursor: pointer;
    text-align: left;
}

.content-shell { min-width: 0; }

.content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 28px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.content-header h1 {
    margin: 0;
    font-size: 30px;
    letter-spacing: 0;
}

.content-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.header-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
}

.status-pill,
.version-pill,
.protected-access,
.control-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-pill.healthy,
.protected-access,
.control-pill {
    color: #ccfbf1;
    background: var(--accent-soft);
    border-color: rgba(45, 212, 191, 0.35);
}

.content-main {
    display: grid;
    gap: 18px;
    padding: 24px 32px 34px;
}

.app-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px 32px 28px;
    color: var(--faint);
    font-size: 13px;
}

.kpi-grid,
.dashboard-grid {
    display: grid;
    gap: 16px;
}

.kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.8fr); }

.panel,
.kpi-card,
.auth-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.kpi-card {
    display: grid;
    gap: 14px;
    min-height: 176px;
    padding: 16px;
}

.kpi-card h2,
.panel-header h2 {
    margin: 0;
    font-size: 15px;
    letter-spacing: 0;
}

.kpi-card strong {
    display: block;
    margin-top: 10px;
    font-size: 34px;
    line-height: 1;
}

.kpi-card p,
.panel-header p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.kpi-icon {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 30px;
    color: #ccfbf1;
    background: var(--accent-soft);
    border: 1px solid rgba(45, 212, 191, 0.35);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
}

.kpi-icon.info { color: #dbeafe; background: rgba(96, 165, 250, 0.16); border-color: rgba(96, 165, 250, 0.34); }
.kpi-icon.warning { color: #fef3c7; background: rgba(251, 191, 36, 0.16); border-color: rgba(251, 191, 36, 0.34); }
.kpi-icon.orange { color: #ffedd5; background: rgba(251, 146, 60, 0.16); border-color: rgba(251, 146, 60, 0.34); }
.kpi-icon.danger,
.kpi-icon.critical { color: #fee2e2; background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.34); }

.panel {
    min-width: 0;
    padding: 18px;
}

.panel-wide { min-height: 360px; }

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.panel-header > span {
    color: var(--muted);
    font-size: 13px;
}

.chart-area {
    min-height: 274px;
    overflow: hidden;
    background: #0a1119;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.chart-area svg {
    display: block;
    width: 100%;
    height: 274px;
}

.chart-grid { stroke: rgba(145, 163, 181, 0.18); }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 3; }
.chart-area-fill { fill: rgba(45, 212, 191, 0.12); }
.chart-label { fill: var(--muted); font-size: 11px; }

.severity-list,
.ranking-list,
.ip-list,
.status-list {
    display: grid;
    gap: 12px;
}

.severity-row,
.ranking-row,
.ip-row,
.status-list div {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr) 44px;
    align-items: center;
    gap: 12px;
    min-height: 34px;
}

.ranking-row,
.status-list div {
    grid-template-columns: minmax(0, 1fr) auto;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(38, 53, 69, 0.7);
}

.ranking-row:last-child,
.status-list div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.ip-row { grid-template-columns: 150px minmax(0, 1fr) 44px; }

.bar-progress {
    width: 100%;
    height: 10px;
    overflow: hidden;
    appearance: none;
    background: #0a1119;
    border: 0;
    border-radius: 999px;
}

.bar-progress::-webkit-progress-bar { background: #0a1119; }
.bar-progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.bar-progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.severity-progress-info::-webkit-progress-value { background: var(--info); }
.severity-progress-low::-webkit-progress-value { background: var(--low); }
.severity-progress-medium::-webkit-progress-value { background: var(--medium); }
.severity-progress-high::-webkit-progress-value { background: var(--high); }
.severity-progress-critical::-webkit-progress-value { background: var(--critical); }
.severity-progress-info::-moz-progress-bar { background: var(--info); }
.severity-progress-low::-moz-progress-bar { background: var(--low); }
.severity-progress-medium::-moz-progress-bar { background: var(--medium); }
.severity-progress-high::-moz-progress-bar { background: var(--high); }
.severity-progress-critical::-moz-progress-bar { background: var(--critical); }

.severity-badge {
    display: inline-flex;
    justify-content: center;
    min-width: 78px;
    padding: 4px 8px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
}

.severity-info { color: #bfdbfe; background: rgba(96, 165, 250, 0.12); }
.severity-low { color: #bbf7d0; background: rgba(52, 211, 153, 0.12); }
.severity-medium { color: #fde68a; background: rgba(251, 191, 36, 0.12); }
.severity-high { color: #fed7aa; background: rgba(251, 146, 60, 0.14); }
.severity-critical { color: #fecaca; background: rgba(239, 68, 68, 0.16); }

.status-list { margin: 0; }
.status-list dt { color: var(--muted); }
.status-list dd { margin: 0; font-weight: 700; }

.control-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-wrapper {
    overflow-x: auto;
    background: #0a1119;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 820px;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

th {
    color: var(--muted);
    background: var(--panel-soft);
    font-size: 12px;
    letter-spacing: 0;
    text-transform: uppercase;
}

tbody tr:last-child td { border-bottom: 0; }

.console-table td {
    font-family: "Courier New", monospace;
    font-size: 13px;
}

.truncate {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state {
    color: var(--muted);
    text-align: center;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 190px 230px auto auto;
    align-items: end;
    gap: 14px;
}

.filter-field {
    display: grid;
    gap: 8px;
}

.filter-field label {
    color: var(--muted);
    font-size: 13px;
}

.filter-field input,
.filter-field select,
.form-field input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--text);
    background: #0a1119;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.filter-field input:focus,
.filter-field select:focus,
.form-field input:focus {
    border-color: var(--accent);
}

.primary-button,
.secondary-button {
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 800;
}

.primary-button {
    color: #04110f;
    background: var(--accent);
    border: 1px solid var(--accent);
}

.secondary-button {
    color: var(--text);
    background: var(--panel-soft);
    border: 1px solid var(--line);
}

.secondary-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    color: var(--muted);
    text-decoration: none;
}

.secondary-link:hover { color: var(--text); }

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 18px;
    color: var(--muted);
}

.pagination-disabled {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    color: var(--faint);
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at top, rgba(45, 212, 191, 0.12), transparent 34%), var(--bg);
}

.auth-panel {
    width: min(430px, 100%);
    padding: 32px;
}

.brand-block h1 {
    margin: 0;
    font-size: 34px;
    letter-spacing: 0;
}

.brand-block p {
    margin: 6px 0 14px;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 18px;
    margin-top: 28px;
}

.form-field {
    display: grid;
    gap: 8px;
}

.form-field label {
    color: var(--muted);
    font-size: 14px;
}

.flash-list {
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
}

.flash-message {
    padding: 10px 12px;
    color: #fecdd3;
    background: rgba(251, 113, 133, 0.12);
    border: 1px solid rgba(251, 113, 133, 0.4);
    border-radius: 6px;
}

.field-error {
    color: #fecdd3;
    font-size: 13px;
}

@media (max-width: 1240px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }

    .sidebar {
        position: static;
        min-height: 0;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar-nav,
    .sidebar-group {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid,
    .dashboard-grid-main {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .content-header,
    .content-main,
    .app-footer {
        padding-right: 16px;
        padding-left: 16px;
    }

    .content-header { flex-direction: column; }
    .content-header h1 { font-size: 24px; }

    .kpi-grid,
    .filter-bar,
    .sidebar-nav,
    .sidebar-group {
        grid-template-columns: 1fr;
    }

    .severity-row,
    .ip-row {
        grid-template-columns: 1fr;
    }

    .truncate { white-space: normal; }
}
