:root {
    --red: #990000;
    --red-2: #b42318;
    --bg: #151617;
    --panel: #222426;
    --panel-2: #2b2d30;
    --line: #393d42;
    --text: #f5f5f5;
    --muted: #aeb4bd;
    --green: #57a773;
    --amber: #e0a13a;
    --blue: #82afff;
    --violet: #cba6f7;
    --shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 18px;
    background: #080808;
    border-right: 1px solid #232323;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    margin-bottom: 22px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    background: var(--red);
    border-radius: 8px;
    color: white;
    font-weight: 900;
}

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

.brand strong {
    font-size: 18px;
    font-weight: 900;
}

.brand small {
    color: var(--muted);
    font-size: 12px;
}

.nav-list {
    display: grid;
    gap: 7px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 800;
}

.nav-item:hover,
.nav-item.is-active {
    background: #2a2a2c;
    color: var(--text);
}

.material-symbol {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid #3b3b3d;
    border-radius: 8px;
    background: #151515;
    font-size: 13px;
    font-weight: 900;
    line-height: 1;
}

.main {
    min-width: 0;
    padding: 28px clamp(18px, 4vw, 42px) 46px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(30px, 4vw, 44px);
    letter-spacing: 0;
}

h2 {
    margin-bottom: 14px;
    font-size: 22px;
}

h3 {
    margin-bottom: 7px;
    font-size: 18px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.primary-action,
.secondary-action,
.danger-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    color: white;
    font-weight: 900;
}

.primary-action {
    background: var(--red);
}

.secondary-action {
    background: var(--panel-2);
    border: 1px solid var(--line);
}

.danger-action {
    background: var(--red-2);
}

.system-pill,
.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.status-ok {
    color: #d9ffe5;
    background: rgba(87, 167, 115, 0.15);
    border: 1px solid rgba(87, 167, 115, 0.45);
}

.status-warning {
    color: #ffe5b4;
    background: rgba(224, 161, 58, 0.15);
    border: 1px solid rgba(224, 161, 58, 0.45);
}

.status-critical {
    color: #ffd7d7;
    background: rgba(180, 35, 24, 0.15);
    border: 1px solid rgba(180, 35, 24, 0.45);
}

.status-muted {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
}

.grid {
    display: grid;
    gap: 16px;
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.panel,
.stat-card,
.alarm-card,
.rule-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
}

.stat-card {
    padding: 18px;
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.stat-card strong {
    display: block;
    margin-top: 12px;
    font-size: 30px;
    font-weight: 900;
}

.section {
    margin-top: 22px;
}

.alarm-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    padding: 16px;
}

.alarm-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 8px;
    font-size: 30px;
}

.priority-main {
    color: #ffd7d7;
    background: rgba(180, 35, 24, 0.18);
    border: 1px solid rgba(180, 35, 24, 0.55);
}

.priority-prealarm {
    color: #ffe5b4;
    background: rgba(224, 161, 58, 0.18);
    border: 1px solid rgba(224, 161, 58, 0.55);
}

.priority-technical {
    color: #eddcff;
    background: rgba(203, 166, 247, 0.14);
    border: 1px solid rgba(203, 166, 247, 0.45);
}

.priority-info {
    color: #d8e7ff;
    background: rgba(130, 175, 255, 0.14);
    border: 1px solid rgba(130, 175, 255, 0.45);
}

.alarm-card h3 {
    margin: 0 0 4px;
}

.alarm-card p,
.muted {
    color: var(--muted);
}

.alarm-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.data-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
}

.timeline {
    display: grid;
    gap: 10px;
}

.timeline-row {
    display: grid;
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.timeline-row time {
    color: var(--muted);
    font-weight: 900;
}

.response-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.response-box {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-2);
}

.response-box strong {
    display: block;
    font-size: 28px;
    font-weight: 900;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 7px;
}

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

.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #171819;
    color: var(--text);
}

.rule-card {
    padding: 16px;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

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

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid #232323;
    }

    .nav-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .grid-4,
    .grid-3,
    .grid-2,
    .split {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 20px 14px 32px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-inline {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
    }

    .primary-action,
    .secondary-action,
    .danger-action {
        flex: 1;
    }

    .nav-list {
        grid-template-columns: 1fr 1fr;
    }

    .alarm-card {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .alarm-card .primary-action {
        grid-column: 1 / -1;
    }

    .response-grid {
        grid-template-columns: 1fr;
    }
}
