:root {
    --bg: #f5f4ee;
    --surface: #fffdf5;
    --surface-strong: #f0ecd9;
    --surface-ink: #232219;
    --text: #20201b;
    --muted: #5a584b;
    --brand: #c25b2b;
    --brand-soft: #f6dfcf;
    --ok: #2f7d4a;
    --bad: #ab2d2d;
    --border: #dfd8c3;
    --focus: #1f6feb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text);
    background:
        radial-gradient(1300px 700px at 2% -10%, #f2d4bc 0%, transparent 55%),
        radial-gradient(1000px 600px at 110% 15%, #e5dfcb 0%, transparent 50%),
        linear-gradient(175deg, #f9f4ea 0%, #f3f0e5 52%, #ece8dc 100%);
}

.container-fluid {
    width: min(1260px, 94vw);
    margin: 2rem auto 3rem;
    display: grid;
    gap: 1rem;
}

.hero {
    border-left: 6px solid var(--brand);
    padding-left: 0.75rem;
}

.hero h1 {
    margin: 0;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.eyebrow {
    margin: 0 0 0.25rem;
    color: var(--brand);
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 0.82rem;
}

.subtitle {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 8px 30px rgba(41, 37, 29, 0.08);
}

h2 {
    margin: 0;
}

.grid-2,
.grid-3,
.grid-4,
.compact-grid {
    display: grid;
    gap: 0.8rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
}

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.grid-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

label {
    display: grid;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.93rem;
}

input,
select,
button,
textarea {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.58rem 0.65rem;
    background: white;
    color: var(--text);
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.btn-wrap {
    display: flex;
    justify-content: flex-start;
    align-items: flex-end;
}

.btn {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.58rem 0.95rem;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--brand);
    border-color: #a8481f;
    color: white;
}

.btn-primary:hover {
    background: #aa4d22;
}

.btn-secondary {
    background: var(--surface-strong);
    border-color: #dbcfab;
    color: var(--surface-ink);
}

.btn-secondary:hover {
    background: #e8e0c8;
}

.btn-danger {
    background: #f2d8d8;
    border-color: #d8a3a3;
    color: #7c2222;
}

.btn-danger:hover {
    background: #e9c8c8;
}

.actions-row {
    margin-top: 0.65rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.actions-bottom {
    align-self: end;
}

.status-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--muted);
}

.status-badge.ok {
    background: #eaf6ee;
    color: var(--ok);
    border-color: #c8ebd2;
}

.status-badge.bad {
    background: #fff0f0;
    color: var(--bad);
    border-color: #f2c9c9;
}

.table-wrapper {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 920px;
}

th,
td {
    border-bottom: 1px solid var(--border);
    text-align: left;
    padding: 0.55rem 0.4rem;
    font-size: 0.9rem;
    vertical-align: top;
}

tr.selected {
    background: var(--brand-soft);
}

.stack-form {
    display: grid;
    gap: 0.7rem;
}

.details-box {
    margin: 0;
    border: 1px solid #32302a;
    border-radius: 12px;
    background: #1e1e1e;
    color: #f6f6f6;
    padding: 0.8rem;
    overflow: auto;
    min-height: 150px;
}

.cell-muted {
    color: var(--muted);
    font-size: 0.82rem;
}

.pill {
    display: inline-block;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.16rem 0.5rem;
    font-size: 0.78rem;
    background: #fff;
    color: var(--muted);
}

.pill-core {
    border-color: #e0b995;
    background: #fff3e8;
    color: #8b4f28;
}

.pill-on {
    border-color: #b9e2c6;
    background: #eaf6ee;
    color: var(--ok);
}

.pill-off {
    border-color: #f1c7c7;
    background: #fff0f0;
    color: var(--bad);
}

.link-btn {
    color: #1a5a99;
    text-decoration: none;
    font-size: 0.85rem;
}

.link-btn:hover {
    text-decoration: underline;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tab-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    background: #efe9d7;
    border: 1px solid #ddd0ac;
    border-radius: 14px;
    padding: 0.45rem;
    position: sticky;
    top: 0.5rem;
    z-index: 10;
}

.tab-btn {
    border: 1px solid transparent;
    background: transparent;
    color: #4f4837;
    padding: 0.5rem 0.8rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
}

.tab-btn:hover {
    background: #e4dac0;
}

.tab-btn.is-active {
    background: #2f2b21;
    color: #f5efde;
}

.tab-panel {
    display: grid;
    gap: 1rem;
}

.hidden {
    display: none;
}

.compact-grid > p.subtitle {
    margin: 0;
    font-weight: 600;
    color: #544f41;
}

.full-row {
    grid-column: 1 / -1;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
}

.module-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    padding: 0.45rem 0.55rem;
}

.module-check span {
    display: grid;
}

.module-check small {
    color: var(--muted);
    font-size: 0.78rem;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.58rem 0.65rem;
    color: #49453a;
    background: #fbfaf5;
}

.switch-label input {
    width: auto;
}

.split-header {
    display: flex;
    gap: 0.65rem;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.8rem;
}

@media (max-width: 900px) {
    .container-fluid {
        width: min(1260px, 96vw);
        margin-top: 1rem;
    }

    .grid-panels {
        grid-template-columns: 1fr;
    }

    table {
        min-width: 760px;
    }

    .tab-nav {
        top: 0;
    }
}

@media (max-width: 640px) {
    .card {
        padding: 0.8rem;
        border-radius: 12px;
    }

    .tab-btn {
        flex: 1 1 calc(50% - 0.5rem);
        text-align: center;
    }

    .module-grid {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
    }

    .actions-row {
        align-items: stretch;
    }

    .row-actions .btn {
        width: auto;
    }
}
