:root {
    --bg: #f4f1ea;
    --panel: #fffdf8;
    --panel-strong: #f0e7d7;
    --line: #d4c8b3;
    --text: #29231b;
    --muted: #6f6455;
    --accent: #205c4c;
    --accent-soft: #dcebe5;
    --warning: #a9411d;
    --warning-soft: #f7dfd7;
    --shadow: 0 18px 50px rgba(32, 31, 26, 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, #f7e5bc 0, var(--bg) 38%), linear-gradient(135deg, #f4f1ea 0%, #efe7db 100%);
    color: var(--text);
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
code { font-family: Consolas, monospace; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    padding: 28px 22px;
    background: linear-gradient(180deg, #201f1a, #2f2b21);
    color: #f7f2ea;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.brand-copy {
    margin-top: 10px;
    color: #d7cfbf;
    line-height: 1.5;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-link {
    padding: 11px 14px;
    border-radius: 12px;
    color: #e8dfcf;
    background: rgba(255,255,255,0.03);
}

.nav-link.is-active,
.nav-link:hover {
    background: rgba(247, 229, 188, 0.16);
    color: #fff7ea;
}

.main-panel {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.topbar h1 {
    font-size: 2rem;
    margin-bottom: 6px;
}

.topbar p { color: var(--muted); }

.status-pill {
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 700;
}

.status-pill.ok {
    background: var(--accent-soft);
    color: var(--accent);
}

.status-pill.error {
    background: var(--warning-soft);
    color: var(--warning);
}

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

.banner {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.error-banner { border-color: #d9b8a9; background: #fff7f3; }

.flash-stack { display: grid; gap: 12px; }
.flash { padding: 14px 16px; }
.flash.success { border-color: #b8d0c8; background: #f5fbf8; }
.flash.error { border-color: #dfb9ad; background: #fff6f2; }

.grid-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.kpi {
    padding: 18px;
    background: linear-gradient(180deg, #fffef9 0%, #f3ecdf 100%);
}

.kpi span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.kpi strong {
    font-size: 2rem;
}

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

.card {
    padding: 20px;
}

.section-head {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 16px;
}

.section-head p { color: var(--muted); }

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

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

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--muted);
}

label.full,
.inline-check,
button.btn-primary {
    grid-column: 1 / -1;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fffdfa;
    border-radius: 12px;
    padding: 11px 12px;
    color: var(--text);
}

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

.inline-check {
    flex-direction: row;
    align-items: center;
}

.inline-check input {
    width: auto;
}

.btn-primary {
    border: 0;
    padding: 13px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, #205c4c, #173c32);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.table-wrap.narrow { max-height: 420px; }
.top-gap { margin-top: 14px; }

table {
    width: 100%;
    border-collapse: collapse;
    background: #fffdfa;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid #e5dccd;
    text-align: left;
    font-size: 0.94rem;
}

th {
    position: sticky;
    top: 0;
    background: #f8f2e7;
}

.check-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 10px;
    line-height: 1.5;
}

.check-list.compact { gap: 8px; }

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

@media (max-width: 1100px) {
    .app-shell,
    .grid-two,
    .grid-kpis,
    .inline-form,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding-bottom: 10px;
    }
}
