:root {
    color-scheme: light;
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-muted: #edf1f4;
    --text: #18212f;
    --muted: #62707f;
    --line: #d8dee7;
    --primary: #1f5f6b;
    --primary-dark: #184b55;
    --accent: #b46b45;
    --danger-bg: #fff2f0;
    --danger-text: #a33a2b;
    --shadow: 0 24px 60px rgba(12, 20, 32, 0.2);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

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

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0 16px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.button-primary {
    color: #fff;
    background: var(--primary);
}

.button-primary:hover {
    background: var(--primary-dark);
}

.button-secondary {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line);
}

.button-secondary:hover {
    background: var(--surface-muted);
}

.auth-page {
    background:
        linear-gradient(120deg, rgba(24, 33, 47, 0.9), rgba(31, 95, 107, 0.78)),
        linear-gradient(90deg, rgba(180, 107, 69, 0.18), rgba(255, 255, 255, 0));
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 32px 16px;
}

.auth-panel {
    width: min(100%, 430px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: var(--shadow);
}

.auth-header {
    border-bottom: 1px solid var(--line);
    padding: 28px 30px 22px;
}

.auth-kicker,
.app-eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.auth-title {
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
}

.auth-subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 15px;
    line-height: 1.45;
}

.auth-form {
    display: grid;
    gap: 18px;
    padding: 26px 30px 30px;
}

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

.form-field label {
    font-size: 14px;
    font-weight: 700;
}

.form-field input:not([type="checkbox"]):not([type="radio"]),
.form-field select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 13px;
    color: var(--text);
    font-size: 16px;
    background: #fff;
}

.form-field input:not([type="checkbox"]):not([type="radio"]):focus,
.form-field select:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(31, 95, 107, 0.18);
}

.form-field .form-error {
    margin: 0;
    color: var(--danger-text);
    font-size: 13px;
}

.radio-inline > div {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.radio-inline label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 14px;
}

.filter-bar label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-bar input,
.filter-bar select {
    min-width: 180px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}

.auth-alert {
    border: 1px solid rgba(163, 58, 43, 0.28);
    border-radius: 6px;
    padding: 11px 13px;
    color: var(--danger-text);
    background: var(--danger-bg);
    font-size: 14px;
}

.auth-submit {
    width: 100%;
}

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

.app-sidebar {
    display: flex;
    flex-direction: column;
    gap: 28px;
    border-right: 1px solid var(--line);
    padding: 24px 18px;
    background: #202832;
    color: #fff;
}

.app-brand {
    display: grid;
    gap: 8px;
}

.app-brand-mark {
    width: 48px;
    height: 48px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    font-weight: 800;
}

.app-brand-text {
    color: #dbe2ea;
    font-size: 14px;
}

.app-nav {
    display: grid;
    gap: 6px;
}

.app-nav a {
    border-radius: 6px;
    padding: 11px 12px;
    color: #edf1f4;
    font-weight: 700;
}

.app-nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.app-main {
    min-width: 0;
}

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

.app-topbar h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.2;
}

.app-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 14px;
}

.app-content {
    padding: 32px;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.content-grid + .content-grid {
    margin-top: 18px;
}

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

.panel {
    min-height: 150px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    background: var(--surface);
}

.panel h2 {
    margin: 0 0 10px;
    font-size: 18px;
}

.panel p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.panel-empty {
    font-style: italic;
}

.panel-cta .button {
    margin-top: 14px;
}

.flash {
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-bottom: 18px;
    padding: 12px 14px;
    background: var(--surface);
    font-size: 14px;
}

.flash-success {
    border-color: rgba(31, 95, 107, 0.35);
    color: var(--primary-dark);
    background: #eef6f5;
}

.flash-error,
.flash-danger {
    border-color: rgba(163, 58, 43, 0.28);
    color: var(--danger-text);
    background: var(--danger-bg);
}

.alert-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.alert {
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 700;
}

.alert-warning {
    border-color: rgba(180, 107, 69, 0.4);
    color: #7c4a2d;
    background: #fdf3ec;
}

.alert-danger {
    border-color: rgba(163, 58, 43, 0.35);
    color: var(--danger-text);
    background: var(--danger-bg);
}

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

.stat-tile {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px 20px;
    background: var(--surface);
}

.stat-label {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.stat-value {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    line-height: 1.1;
}

.stat-hint {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

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

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
}

.badge-low {
    color: #365a43;
    background: #e7f2ea;
}

.badge-medium {
    color: #7c4a2d;
    background: #fdf3ec;
}

.badge-high {
    color: var(--danger-text);
    background: var(--danger-bg);
}

.badge-critical {
    color: #fff;
    background: #a33a2b;
}

.badge-neutral {
    color: var(--muted);
    background: var(--surface-muted);
}

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

.page-head h1 {
    margin: 6px 0 8px;
    font-size: 24px;
}

.page-head p {
    margin: 0;
    max-width: 60ch;
    color: var(--muted);
}

.button-row {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.panel-side {
    display: grid;
    gap: 10px;
    align-content: start;
}

.panel-side-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.panel-side-row strong {
    font-size: 16px;
}

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

.detail-grid div {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.detail-grid div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.detail-grid dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.detail-grid dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
}

.progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--surface-muted);
    overflow: hidden;
}

.progress-track span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
}

.progress-track.is-warning span {
    background: var(--accent);
}

.progress-track.is-danger span {
    background: #a33a2b;
}

.activity-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.activity-item {
    display: flex;
    align-items: baseline;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
    font-size: 14px;
}

.activity-item:last-child {
    border-bottom: 0;
}

.activity-time {
    min-width: 48px;
    color: var(--primary);
    font-weight: 800;
}

.activity-label {
    font-weight: 700;
}

.activity-meta {
    color: var(--muted);
    font-size: 13px;
}

.tablet-search label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 700;
}

.tablet-search-row {
    display: flex;
    gap: 10px;
}

.tablet-search-row input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 13px;
    font-size: 16px;
}

.tablet-search-row input:focus {
    border-color: var(--primary);
    outline: 3px solid rgba(31, 95, 107, 0.18);
}

.tablet-result {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
}

.tablet-result div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}

.tablet-result dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.tablet-result dd {
    margin: 0;
    font-weight: 700;
    text-align: right;
}

.tablet-not-found {
    margin-top: 18px;
    border: 1px solid rgba(163, 58, 43, 0.28);
    border-radius: 6px;
    padding: 11px 13px;
    color: var(--danger-text);
    background: var(--danger-bg);
    font-size: 14px;
}

.tablet-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.tablet-actions .button[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
}

.panel h2 + .panel-empty,
.panel p + h2 {
    margin-top: 16px;
}

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

    .content-grid-2 {
        grid-template-columns: 1fr;
    }
}

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

    .app-sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .app-topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 22px 20px;
    }

    .app-content {
        padding: 20px;
    }

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

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

    .tablet-search-row {
        flex-direction: column;
    }

    .tablet-actions {
        grid-template-columns: 1fr;
    }
}
