:root {
    --bg: #f5f7f9;
    --panel: #ffffff;
    --ink: #1c2730;
    --muted: #66727f;
    --line: #dfe6ec;
    --accent: #156c7a;
    --accent-strong: #0f515c;
    --danger: #b42318;
    --success-bg: #e8f6ee;
    --error-bg: #fff0ed;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 232px;
    background: #14212b;
    color: #f7fbfc;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand-mark {
    font-size: 22px;
    font-weight: 800;
}

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

.sidebar a,
.logout-form button {
    width: 100%;
    border: 0;
    border-radius: 6px;
    padding: 10px 12px;
    background: transparent;
    color: #dce8ec;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.sidebar a.active,
.sidebar a:hover,
.logout-form button:hover {
    background: rgba(255, 255, 255, .11);
    color: #ffffff;
}

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

.main {
    margin-left: 232px;
    padding: 28px;
}

.main > section + section,
.main > form + section,
.main > section + form {
    margin-top: 22px;
}

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

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin: 0 0 4px;
}

h1, h2 { margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 18px; }

.form-panel h2 + label,
.form-panel h2 + input,
.form-panel h2 + .inline-fields {
    margin-top: 2px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

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

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.metric strong {
    font-size: 30px;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.metric small {
    display: block;
    color: var(--muted);
    font-weight: 800;
    margin-top: 6px;
}

.state-panel {
    border-left: 5px solid var(--line);
}

.state-panel.good { border-left-color: #23865a; }
.state-panel.bad { border-left-color: var(--danger); }
.state-panel.unknown { border-left-color: #8a6d2f; }

.state-message {
    color: var(--muted);
    margin: 10px 0 0;
}

.grid-two {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 0;
}

.grid-three {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
    margin-bottom: 18px;
}

.dashboard-stack {
    display: grid;
    gap: 22px;
}

.dashboard-stack > .metrics,
.dashboard-stack > .panel,
.dashboard-stack > .grid-three {
    margin-bottom: 0;
}

.dashboard-stack .panel {
    overflow: hidden;
}

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

.dashboard-discovery .panel-head,
.dashboard-discovery .metrics {
    margin-bottom: 0;
}

.compact-metrics {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.compact-metrics .metric,
.dashboard-kpis .metric {
    min-height: 120px;
}

.dashboard-kpis {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    margin-bottom: 0;
}

.dashboard-kpis .metric {
    display: grid;
    align-content: space-between;
    gap: 8px;
}

.dashboard-brand-grid {
    margin-bottom: 0;
}

.dashboard-brand-grid .panel,
.dashboard-action-grid .panel {
    min-width: 0;
}

.dashboard-action-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    gap: 22px;
    align-items: start;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.panel {
    padding: 18px;
    overflow-x: auto;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

form {
    margin: 0;
}

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

.filter-form {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.panel hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 18px 0;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid #cdd7df;
    border-radius: 6px;
    background: #ffffff;
    color: var(--ink);
    padding: 8px 10px;
    font: inherit;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

button {
    min-height: 40px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    padding: 8px 14px;
    font-weight: 800;
    cursor: pointer;
}

button:hover { background: var(--accent-strong); }

.link-danger {
    background: transparent;
    color: var(--danger);
    padding: 0;
    min-height: auto;
}

.link-danger:hover {
    background: transparent;
    text-decoration: underline;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
    line-height: 1.45;
}

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

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

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    background: #e7f1f3;
    color: #164f58;
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 800;
}

.inline-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
    align-items: end;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
}

.memory-timeline {
    display: grid;
    gap: 14px;
}

.timeline-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdfe;
}

.timeline-item h2 {
    font-size: 15px;
    margin-bottom: 6px;
}

.timeline-item p {
    margin: 0 0 6px;
}

.timeline-item p:last-child {
    margin-bottom: 0;
}

.mini-form {
    display: grid;
    grid-template-columns: minmax(84px, 1fr) minmax(84px, 1fr) minmax(120px, 1.4fr) auto;
    gap: 6px;
    min-width: 420px;
}

.mini-form.compact-status {
    grid-template-columns: minmax(120px, 1fr) auto;
    min-width: 220px;
}

.mini-form input,
.mini-form select,
.mini-form button {
    min-height: 32px;
    font-size: 12px;
}

.table-link {
    color: var(--accent);
    font-weight: 800;
}

.table-link:hover {
    text-decoration: underline;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.tasks-table {
    min-width: 1180px;
    table-layout: fixed;
}

.tasks-table th,
.tasks-table td {
    padding: 9px 7px;
}

.tasks-table th {
    white-space: nowrap;
    line-height: 1.2;
}

.tasks-table th:nth-child(1),
.tasks-table td:nth-child(1) { width: 170px; }
.tasks-table th:nth-child(2),
.tasks-table td:nth-child(2) { width: 130px; }
.tasks-table th:nth-child(3),
.tasks-table td:nth-child(3) { width: 210px; }
.tasks-table th:nth-child(4),
.tasks-table td:nth-child(4) { width: 150px; }
.tasks-table th:nth-child(5),
.tasks-table td:nth-child(5),
.tasks-table th:nth-child(6),
.tasks-table td:nth-child(6),
.tasks-table th:nth-child(8),
.tasks-table td:nth-child(8),
.tasks-table th:nth-child(11),
.tasks-table td:nth-child(11) { width: 86px; }
.tasks-table th:nth-child(7),
.tasks-table td:nth-child(7) { width: 100px; }
.tasks-table th:nth-child(9),
.tasks-table td:nth-child(9),
.tasks-table th:nth-child(10),
.tasks-table td:nth-child(10) { width: 64px; }
.tasks-table th:nth-child(12),
.tasks-table td:nth-child(12) { width: 430px; }
.tasks-table th:nth-child(13),
.tasks-table td:nth-child(13) { width: 54px; }

.task-context {
    font-size: 12px;
    color: var(--muted);
}

.task-context span {
    display: block;
}

.alert {
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 14px;
}

.alert.success { background: var(--success-bg); color: #17613a; }
.alert.error { background: var(--error-bg); color: #9f1d12; }
.muted { color: var(--muted); }

.manifesto-text {
    margin: 0;
    color: var(--text);
    font-size: 18px;
    line-height: 1.8;
    font-weight: 700;
}

.guest {
    display: grid;
    place-items: center;
    background: #eef3f5;
}

.login-shell {
    width: min(420px, calc(100vw - 32px));
}

.login-card {
    padding: 28px;
}

.login-card h1 {
    font-size: 36px;
    margin-bottom: 4px;
}

.login-card p {
    color: var(--muted);
    margin: 0 0 22px;
}

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

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: auto;
        min-height: auto;
    }

    .main {
        margin-left: 0;
        padding: 18px;
    }

    .metrics,
    .grid-two,
    .grid-three,
    .dashboard-action-grid,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-stack {
        gap: 16px;
    }

    .compact-metrics,
    .dashboard-kpis {
        grid-template-columns: 1fr;
    }
}
