:root {
    color-scheme: light;
    --bg: #f3f1eb;
    --panel: #fffdf8;
    --panel-border: #d9cfbe;
    --text: #231b13;
    --muted: #6a5d50;
    --accent: #1f6b5c;
    --shadow: 0 20px 50px rgba(35, 27, 19, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(31, 107, 92, 0.12), transparent 24rem),
        linear-gradient(180deg, #faf7f2 0%, var(--bg) 100%);
    color: var(--text);
}

.auth-page {
    min-height: 100vh;
}

.shell {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 20px 40px;
    display: grid;
    gap: 20px;
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
}

.sidebar,
.workspace {
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 24px;
    padding: 20px;
    background: rgba(255, 253, 248, 0.86);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.brand {
    margin-bottom: 24px;
}

.brand h1 {
    font-size: 1.55rem;
    margin-bottom: 10px;
}

.brand-copy {
    font-size: 0.95rem;
}

.nav {
    display: grid;
    gap: 8px;
}

.admin-session-card {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid rgba(217, 207, 190, 0.75);
    display: grid;
    gap: 10px;
}

.admin-session-name {
    font-weight: 700;
    word-break: break-word;
}

.nav-link {
    display: block;
    padding: 12px 14px;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover {
    background: rgba(31, 107, 92, 0.06);
    border-color: rgba(31, 107, 92, 0.16);
    transform: translateX(2px);
}

.nav-link.is-active {
    background: linear-gradient(135deg, rgba(31, 107, 92, 0.14), rgba(31, 107, 92, 0.04));
    border-color: rgba(31, 107, 92, 0.22);
    color: var(--accent);
    font-weight: 700;
}

.workspace {
    display: grid;
    gap: 20px;
}

.topbar {
    padding: 8px 4px 0;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.content {
    display: grid;
    gap: 20px;
}

.panel,
.card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 24px;
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.hero-badge {
    flex-shrink: 0;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(31, 107, 92, 0.12);
    color: var(--accent);
    font-weight: 700;
}

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
    padding: 18px;
}

.preview-card {
    min-height: 0;
}

.stat-card {
    min-height: 170px;
}

.stat-label {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.stat-value {
    display: block;
    margin-bottom: 12px;
    font-size: 2.4rem;
    line-height: 1;
}

.preview-stat-text {
    font-size: 1.25rem;
    line-height: 1.25;
    word-break: break-word;
}

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

.section-badge {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(31, 107, 92, 0.12);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    font: inherit;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    cursor: not-allowed;
    opacity: 0.58;
}

.button.is-live {
    cursor: pointer;
    opacity: 1;
}

.button-secondary {
    background: rgba(35, 27, 19, 0.08);
    color: var(--text);
    text-decoration: none;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.tab {
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(35, 27, 19, 0.05);
    color: var(--muted);
    font-size: 0.92rem;
}

.tab.is-active {
    background: rgba(31, 107, 92, 0.12);
    color: var(--accent);
    font-weight: 700;
}

.revision-section {
    display: grid;
    gap: 18px;
    margin-bottom: 22px;
}

.notice {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    font-weight: 700;
}

.empty-state {
    padding: 24px;
    border: 1px dashed var(--panel-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.4);
}

.success-notice {
    background: rgba(31, 107, 92, 0.1);
    border-color: rgba(31, 107, 92, 0.22);
    color: var(--accent);
}

.revision-warning {
    border-style: solid;
    background: rgba(154, 45, 31, 0.05);
}

.preview-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.payload-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.payload-card {
    min-width: 0;
}

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

.preview-metrics strong {
    display: block;
    font-size: 1.6rem;
    line-height: 1;
    margin-bottom: 6px;
}

.preview-metrics span {
    color: var(--muted);
    font-size: 0.9rem;
}

.guard-check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
}

.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.toolbar-row form {
    margin: 0;
}

.preview-toolbar {
    margin-bottom: 18px;
}

.detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.detail-callout {
    margin-top: 18px;
}

.kv-list {
    display: grid;
    gap: 12px;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: start;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(217, 207, 190, 0.65);
}

.kv-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.kv-row span {
    color: var(--muted);
}

.kv-row strong {
    text-align: right;
}

.rule-form {
    margin-bottom: 22px;
    padding: 20px;
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.5);
}

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

.form-grid {
    display: grid;
    gap: 14px 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 14px;
}

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

.field-wide {
    grid-column: 1 / -1;
}

.field-label {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid rgba(31, 107, 92, 0.18);
    border-color: rgba(31, 107, 92, 0.35);
}

.field textarea {
    resize: vertical;
    min-height: 120px;
}

.field-error {
    color: #9a2d1f;
    font-size: 0.85rem;
}

.field-help {
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.simple-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
}

.simple-list li + li {
    margin-top: 8px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--text);
}

.form-actions {
    display: flex;
    justify-content: flex-start;
}

.action-stack {
    display: grid;
    gap: 8px;
    align-items: start;
}

.button-small {
    padding: 9px 12px;
    font-size: 0.92rem;
}

.button-warning {
    background: #8a5a22;
}

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

.auth-card {
    width: min(100%, 520px);
    padding: 28px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.auth-brand {
    margin-bottom: 18px;
}

.auth-heading {
    margin-bottom: 16px;
}

.auth-form {
    margin-bottom: 0;
}

.auth-actions {
    margin-top: 18px;
}

.auth-error-notice {
    background: rgba(154, 45, 31, 0.08);
    border-color: rgba(154, 45, 31, 0.18);
    color: #9a2d1f;
}

.auth-footnote {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(217, 207, 190, 0.75);
}

.auth-footnote-top {
    margin-top: 0;
    margin-bottom: 18px;
    padding-top: 0;
    border-top: 0;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.55);
}

.rules-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.rules-table th,
.rules-table td {
    padding: 14px 16px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid rgba(217, 207, 190, 0.75);
}

.rules-table thead th {
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    background: rgba(35, 27, 19, 0.03);
}

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

.table-note {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.table-note-strong {
    margin-top: 6px;
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.client-activity-gap {
    margin-top: 12px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.table-actions form {
    margin: 0;
}

.table-link {
    border: 0;
    background: transparent;
    padding: 0;
    color: var(--accent);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.table-link-danger {
    color: #9a2d1f;
}

.history-subheading {
    margin-top: 26px;
}

.history-table td {
    min-width: 0;
}

.history-meta {
    min-width: 220px;
}

.history-meta summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 700;
}

.history-meta pre {
    margin: 10px 0 0;
    padding: 12px;
    border-radius: 12px;
    background: rgba(35, 27, 19, 0.04);
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.82rem;
    line-height: 1.45;
}

.payload-block {
    margin: 0;
    padding: 14px;
    border-radius: 14px;
    background: rgba(35, 27, 19, 0.04);
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.84rem;
    line-height: 1.5;
    overflow-x: auto;
}

.cell-value {
    max-width: 320px;
    word-break: break-word;
}

.status-pill {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-pill.is-enabled {
    background: rgba(31, 107, 92, 0.12);
    color: var(--accent);
}

.status-pill.is-previewed {
    background: rgba(38, 92, 164, 0.12);
    color: #265ca4;
}

.status-pill.is-applied,
.status-pill.is-active {
    background: rgba(31, 107, 92, 0.12);
    color: var(--accent);
}

.status-pill.is-rollback {
    background: rgba(138, 90, 34, 0.12);
    color: #8a5a22;
}

.status-pill.is-simulated {
    background: rgba(38, 92, 164, 0.12);
    color: #265ca4;
}

.status-pill.is-blocked {
    background: rgba(154, 45, 31, 0.12);
    color: #9a2d1f;
}

.status-pill.is-disabled {
    background: rgba(120, 74, 37, 0.1);
    color: #784a25;
}

.status-pill.is-revoked {
    background: rgba(154, 45, 31, 0.12);
    color: #9a2d1f;
}

p {
    color: var(--muted);
    line-height: 1.6;
}

code {
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(31, 107, 92, 0.08);
    color: var(--accent);
}

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

    .sidebar {
        position: static;
    }

    .hero,
    .section-heading,
    .form-topline,
    .kv-row {
        flex-direction: column;
    }

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

    .field-wide {
        grid-column: auto;
    }

    .kv-row strong {
        text-align: left;
    }
}
