:root {
    color-scheme: light;
    --paper: #f6f1e7;
    --ink: #2a2118;
    --muted: #6b5c4e;
    --line: #e4d8c8;
    --rust: #9a3412;
    --rust-dark: #7c2d12;
    --card: #fffdf8;
    --ok: #166534;
    --ok-bg: #ecfdf3;
    --bad: #991b1b;
    --bad-bg: #fef2f2;
    --warn-bg: #fff7ed;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 16px/1.45 "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
    color: var(--ink);
    background: var(--paper);
}

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

aside {
    background: #2a2118;
    color: #f6f1e7;
    padding: 1.25rem 1rem 2rem;
}

aside a {
    display: block;
    color: #f6f1e7;
    text-decoration: none;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
}

aside a:hover { background: rgba(246, 241, 231, 0.08); }

.brand {
    font-weight: 700;
    letter-spacing: 0.01em;
    margin-bottom: 1rem;
}

.brand span { color: #fdba74; }

.group {
    margin: 1rem 0.5rem 0.25rem;
    font: 0.72rem/1.2 system-ui, sans-serif;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #d6c4b0;
}

.main { min-width: 0; }

header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--line);
    background: var(--card);
    font: 0.9rem/1.3 system-ui, sans-serif;
}

header form { display: flex; gap: 0.75rem; align-items: center; }

main { padding: 1.5rem; max-width: 1100px; }

h1 { font-size: 1.8rem; margin: 0 0 0.4rem; }

h2 { font-size: 1.15rem; margin: 1.4rem 0 0.5rem; }

h3 { margin: 0 0 0.35rem; font-size: 1rem; }

a { color: var(--rust-dark); }

.note, .crumb { color: var(--muted); margin-top: 0; }

.page-head, .actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.banner {
    background: var(--warn-bg);
    border: 1px solid #fdba74;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    margin: 0 1.5rem;
}

main .banner { margin: 0 0 1rem; }

.banner.ok { background: var(--ok-bg); border-color: #86efac; color: var(--ok); }

.banner.bad { background: var(--bad-bg); border-color: #fca5a5; color: var(--bad); }

.banner:empty, .banner.bad:empty, .validation-summary-valid { display: none; }

.filters, .stack, .action-grid form, .facts {
    display: grid;
    gap: 0.75rem;
}

.filters {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    align-items: end;
    margin: 1rem 0;
    font: 0.92rem/1.3 system-ui, sans-serif;
}

label { display: grid; gap: 0.3rem; font: 0.92rem/1.3 system-ui, sans-serif; }

input, select, textarea, button, .button {
    font: 1rem/1.3 system-ui, sans-serif;
    color: var(--ink);
}

input, select, textarea {
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 1px solid #c8b8a4;
    border-radius: 6px;
    background: white;
}

button, .button {
    display: inline-block;
    border: 0;
    background: var(--rust);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
}

.button.ghost, button.ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid #c8b8a4;
}

button.danger, .button.danger { background: var(--bad); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }

table { width: 100%; border-collapse: collapse; font: 0.95rem/1.35 system-ui, sans-serif; }

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

th a { text-decoration: none; }

.matrix td, .matrix th { text-align: center; }

.matrix th:first-child, .matrix td:first-child, .matrix th[scope="row"] { text-align: left; }

.matrix input { width: auto; }

.pill {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: #ffedd5;
    font-size: 0.85rem;
}

.facts {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin: 1rem 0;
}

.facts div { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.7rem 0.8rem; }

dt { color: var(--muted); font: 0.78rem/1.2 system-ui, sans-serif; text-transform: uppercase; letter-spacing: 0.04em; }

dd { margin: 0.2rem 0 0; white-space: pre-wrap; word-break: break-word; }

.tabs { display: flex; gap: 0.4rem; margin: 0.5rem 0 1rem; }

.tabs a { text-decoration: none; padding: 0.35rem 0.7rem; border-radius: 999px; background: white; border: 1px solid var(--line); }

.tabs a.on { background: var(--ink); color: var(--paper); }

.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.8rem; }

.action-grid form, dialog form {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.9rem;
}

.pager { display: flex; gap: 1rem; align-items: center; margin-top: 0.8rem; font: 0.92rem/1.3 system-ui, sans-serif; }

.bulk { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.7rem; }

.bulk select, .bulk input { width: auto; }

button.help { width: 1.4rem; height: 1.4rem; margin-left: 0.35rem; border-radius: 999px; padding: 0; line-height: 1.3rem; font-weight: 700; }
dialog { border: 0; border-radius: 12px; padding: 0; box-shadow: 0 16px 50px rgba(42, 33, 24, 0.25); }
.dialog-card { padding: 1rem 1.1rem; max-width: 36rem; }

dialog::backdrop { background: rgba(42, 33, 24, 0.45); }

.prose { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem; }

.links { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 140px;
    padding: 0.4rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.bars i {
    display: block;
    flex: 1;
    background: var(--rust);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
}

.flow {
    font-family: ui-monospace, monospace;
    white-space: pre-wrap;
}

@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    aside { padding-bottom: 1rem; }
    header, main { padding-left: 1rem; padding-right: 1rem; }
    .banner { margin-left: 1rem; margin-right: 1rem; }
}
