:root {
    color-scheme: dark;
    --bg: #071017;
    --panel: #0e1821;
    --panel-strong: #121f2a;
    --line: #223240;
    --line-strong: #365064;
    --text: #edf4f8;
    --muted: #94a6b4;
    --soft: #152432;
    --accent: #4fb0c6;
    --accent-strong: #7fd9ea;
    --warning: #d69b45;
    --danger: #e56b6f;
    --good: #68c18d;
    --focus: 0 0 0 3px rgba(79, 176, 198, 0.32);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

a {
    color: var(--accent-strong);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

button,
.panel-action {
    min-height: 40px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: rgba(79, 176, 198, 0.16);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    font-weight: 700;
}

button:hover,
.panel-action:hover {
    background: rgba(79, 176, 198, 0.26);
    text-decoration: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: var(--focus);
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: #09131b;
    color: var(--text);
    padding: 0 12px;
}

textarea {
    min-height: 110px;
    padding: 10px 12px;
    resize: vertical;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

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

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

th {
    color: #c7d5df;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

td {
    color: #dce8ee;
}

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

.control-sidebar {
    border-right: 1px solid var(--line);
    background: #09131c;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

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

.brand-mark {
    width: 42px;
    height: 42px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    display: grid;
    place-items: center;
    color: var(--accent-strong);
    font-weight: 900;
}

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

.control-brand small {
    color: var(--accent-strong);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
}

.control-sidebar nav {
    display: grid;
    gap: 5px;
}

.control-sidebar nav a {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-radius: 6px;
    color: #d6e2e8;
    padding: 10px 12px;
    font-weight: 700;
}

.control-sidebar nav a small {
    color: var(--muted);
    font-size: 0.73rem;
}

.control-sidebar nav a.is-active,
.control-sidebar nav a:hover {
    background: var(--soft);
    color: var(--text);
    text-decoration: none;
}

.control-main {
    min-width: 0;
    padding: 24px;
}

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

.control-kicker {
    margin: 0 0 5px;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(1.7rem, 3vw, 2.6rem);
    line-height: 1.05;
}

h2 {
    margin-bottom: 12px;
    font-size: 1.18rem;
}

.control-session-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    color: var(--muted);
    font-size: 0.88rem;
}

.control-session-summary > span,
.env-badge {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0a151e;
    padding: 0 10px;
}

.env-badge {
    border-color: var(--warning);
    color: #ffe0a7;
    font-weight: 900;
}

.link-button {
    min-height: 34px;
    background: transparent;
}

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

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

.metric-card {
    min-height: 108px;
    padding: 16px;
    display: grid;
    align-content: space-between;
}

.metric-card span,
.muted {
    color: var(--muted);
}

.metric-card strong {
    font-size: 1.9rem;
    line-height: 1;
}

.control-grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}

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

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

.control-panel {
    padding: 18px;
    margin-bottom: 18px;
}

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

.inline-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 14px;
}

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

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

.detail-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.detail-list div {
    display: grid;
    grid-template-columns: minmax(130px, 0.45fr) minmax(0, 1fr);
    gap: 12px;
}

.detail-list dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
}

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

.entity-header h2 {
    margin-bottom: 6px;
    font-size: 2rem;
}

.entity-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.status-badge {
    min-height: 30px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    color: #d5e3ea;
    background: #0b151e;
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: capitalize;
}

.status-good {
    border-color: rgba(104, 193, 141, 0.65);
    color: #baf0ce;
}

.status-danger {
    border-color: rgba(229, 107, 111, 0.7);
    color: #ffc7c9;
}

.status-info {
    border-color: rgba(79, 176, 198, 0.72);
    color: #c9f3fb;
}

.status-warning {
    border-color: rgba(214, 155, 69, 0.72);
    color: #f3d6a6;
}

.timeline {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.timeline li {
    border-left: 2px solid var(--accent);
    padding-left: 12px;
}

.timeline span {
    color: var(--muted);
    display: block;
    font-size: 0.85rem;
}

.timeline strong {
    display: block;
    margin-top: 2px;
}

.timeline p {
    color: #cfdae1;
    margin-bottom: 0;
}

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

.compact-form {
    border-top: 1px solid var(--line);
    margin-top: 14px;
    padding-top: 14px;
}

.compact-form:first-of-type {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}

.case-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.action-form {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0a151e;
    padding: 14px;
}

.action-form h3 {
    margin: 0;
    font-size: 1rem;
}

.note-list {
    margin-top: 16px;
}

.evidence-block {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #09131b;
    margin-bottom: 10px;
    overflow: hidden;
}

.evidence-block summary {
    cursor: pointer;
    padding: 12px 14px;
    color: #c7d5df;
    font-weight: 800;
}

.evidence-block pre {
    border-top: 1px solid var(--line);
    margin: 0;
    max-height: 360px;
    overflow: auto;
    padding: 14px;
    color: #dce8ee;
    font-size: 0.82rem;
    white-space: pre-wrap;
}

.staff-grant-form {
    grid-template-columns: minmax(180px, 1fr) 180px minmax(260px, 2fr) auto;
    align-items: end;
}

.table-action-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) auto;
    gap: 8px;
}

.control-alert {
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--soft);
    color: var(--text);
}

.control-alert-error {
    border-color: rgba(229, 107, 111, 0.7);
}

.control-alert-success {
    border-color: rgba(104, 193, 141, 0.7);
}

.control-auth-main {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.control-login-panel {
    width: min(100%, 920px);
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: clamp(20px, 4vw, 34px);
}

.login-copy h1 {
    max-width: 10ch;
    margin-bottom: 18px;
    font-size: clamp(2.2rem, 6vw, 4.5rem);
}

.login-copy p {
    max-width: 48ch;
    color: var(--muted);
}

.login-rules {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 26px;
}

.login-rules span {
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 7px 10px;
    color: #c9d7df;
    font-size: 0.86rem;
    font-weight: 800;
}

.login-form {
    align-content: center;
}

.login-form button {
    width: 100%;
}

@media (max-width: 1100px) {
    .metrics-grid,
    .three-col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .control-shell {
        display: block;
    }

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

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

    .control-main {
        padding: 16px;
    }

    .control-topbar,
    .entity-header {
        display: grid;
    }

    .control-session-summary,
    .entity-badges {
        justify-content: flex-start;
    }

    .metrics-grid,
    .three-col,
    .staff-grant-form,
    .control-login-panel {
        grid-template-columns: 1fr;
    }

    .inline-search,
    .filter-bar,
    .table-action-form {
        grid-template-columns: 1fr;
    }

    .case-action-grid {
        grid-template-columns: 1fr;
    }
}
