:root {
    color-scheme: light;
    --bg: #f7f6f2;
    --panel: #ffffff;
    --ink: #202124;
    --muted: #61656f;
    --line: #dedbd3;
    --accent: #1d6f64;
    --accent-dark: #124d46;
    --warn: #9a5a00;
    --danger: #9f3030;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

code,
pre {
    font-family: Consolas, "Liberation Mono", monospace;
}

pre {
    background: #202124;
    border-radius: 6px;
    color: #ffffff;
    overflow-x: auto;
    padding: 14px;
}

.app-header {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 24px;
    justify-content: space-between;
    padding: 20px clamp(16px, 4vw, 48px);
}

.brand {
    color: var(--ink);
    display: inline-block;
    font-size: 22px;
    font-weight: 750;
    text-decoration: none;
}

.app-header p {
    color: var(--muted);
    margin: 2px 0 0;
}

nav,
.actions,
.badge-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

nav a,
.button,
button {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 650;
    min-height: 40px;
    padding: 8px 13px;
    text-decoration: none;
}

nav a.active,
.button,
button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.button.secondary {
    background: #ffffff;
    color: var(--ink);
}

main {
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px clamp(16px, 4vw, 48px) 64px;
}

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

h1,
h2,
h3 {
    line-height: 1.2;
    margin: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 42px);
}

h2 {
    font-size: 22px;
}

h3 {
    font-size: 18px;
    margin-top: 20px;
}

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

.grid {
    display: grid;
    gap: 16px;
}

.stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 24px;
}

.two-col {
    grid-template-columns: minmax(0, 1fr) minmax(300px, .72fr);
    margin-bottom: 16px;
}

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

.panel,
.stat,
.story-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 18px;
}

.story-card {
    display: grid;
    gap: 8px;
    margin-bottom: 0;
}

.story-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
    text-transform: uppercase;
}

.story-card strong {
    display: block;
    font-size: 18px;
    line-height: 1.25;
}

.story-card p {
    margin: 0;
}

.stat span {
    color: var(--muted);
    display: block;
    font-size: 14px;
}

.stat strong {
    display: block;
    font-size: 30px;
    margin-top: 8px;
}

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

table {
    border-collapse: collapse;
    width: 100%;
}

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

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
    text-transform: uppercase;
}

.badge {
    background: #eef3f1;
    border: 1px solid #d1dfdb;
    border-radius: 999px;
    color: var(--accent-dark);
    display: inline-flex;
    font-size: 13px;
    font-weight: 750;
    padding: 3px 9px;
}

.pending,
.needs-review,
.needs-changes,
.medium,
.unknown {
    background: #f6f0e6;
    border-color: #e2d1b5;
    color: var(--warn);
}

.failed,
.rejected,
.high {
    background: #f8eaea;
    border-color: #e1bcbc;
    color: var(--danger);
}

.approved,
.completed,
.low,
.not-required {
    background: #eaf4ef;
    border-color: #c8dfd4;
    color: var(--accent-dark);
}

form {
    display: grid;
    gap: 14px;
}

.inline-form {
    display: inline;
}

.inline-form button {
    min-height: 36px;
}

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

.filters-grid {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
}

label {
    color: var(--muted);
    display: grid;
    font-size: 14px;
    font-weight: 650;
    gap: 6px;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    min-height: 42px;
    padding: 9px 11px;
    width: 100%;
}

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

.markdown-preview {
    min-height: 360px;
}

.auth-wrap {
    display: grid;
    min-height: 60vh;
    place-items: center;
}

.auth-panel {
    max-width: 420px;
    width: 100%;
}

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

.detail-list div {
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

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

.detail-list dd {
    margin: 3px 0 0;
}

.timeline {
    border-left: 2px solid var(--line);
    list-style: none;
    margin: 16px 0 0;
    padding: 0 0 0 18px;
}

.timeline li {
    display: grid;
    gap: 12px;
    grid-template-columns: 54px minmax(0, 1fr);
    margin-bottom: 18px;
    position: relative;
}

.timeline li::before {
    background: var(--accent);
    border: 3px solid var(--panel);
    border-radius: 50%;
    content: "";
    height: 10px;
    left: -24px;
    position: absolute;
    top: 6px;
    width: 10px;
}

.timeline time {
    color: var(--muted);
    font-weight: 700;
}

.timeline p,
.note {
    margin: 4px 0 0;
}

.flash,
.callout {
    border-radius: 8px;
}

.flash {
    margin-bottom: 18px;
    padding: 12px 14px;
}

.flash.success {
    background: #eaf4ef;
    border: 1px solid #c8dfd4;
}

.flash.error {
    background: #f8eaea;
    border: 1px solid #e1bcbc;
}

.callout {
    background: #f3f8f6;
    border-color: #c8dfd4;
}

@media (max-width: 850px) {
    .app-header,
    .page-title,
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .stats,
    .two-col,
    .story-grid,
    .form-grid,
    .filters-grid {
        grid-template-columns: 1fr;
    }
}
