:root {
    color-scheme: light;
    --ink: #302020;
    --muted: #695351;
    --surface: #ffffff;
    --background: #f8f4f3;
    --line: #e9dad7;
    --red: #b42b1e;
    --logo-red: #e63524;
    --dark-red: #361b1c;
    --control-border: #baaaa6;
    --red-tint: #fdf1ef;
    --amber: #845300;
    --radius: 14px;
    font-family: "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; font-size: 15px; line-height: 1.5; }
a { color: var(--red); }
:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.65rem, 4vw, 2.55rem); line-height: 1.13; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { font-size: 1.07rem; line-height: 1.3; }
.muted, small { color: var(--muted); }
.sr-only, .skip:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.skip:focus {
    position: absolute;
    z-index: 3;
    top: .5rem;
    left: .5rem;
    padding: .5rem;
    background: white;
}

.top { background: var(--dark-red); color: #fff; border-bottom: 3px solid var(--logo-red); }
.top-inner, .wrap { max-width: 1240px; margin: auto; padding-inline: clamp(1rem, 4vw, 2.5rem); }
.top-inner { min-height: 72px; display: flex; align-items: center; gap: 2rem; }
.top a { color: inherit; text-decoration: none; }
.top a:hover { text-decoration: underline; }
.top :focus-visible { outline-color: #ffb3a7; }
.brand { display: inline-block; line-height: 0; max-width: 100%; }
.brand img { width: clamp(205px, 25vw, 280px); max-width: 100%; height: auto; }
.account { display: flex; gap: .75rem; align-items: center; margin-left: auto; text-align: right; overflow-wrap: anywhere; }
.account-actions { display: flex; align-items: stretch; gap: .5rem; max-width: 100%; }
.account-profile span { text-decoration: underline; text-underline-offset: .2em; }
.account small { display: block; color: #f0c4bc; }
.account form { display: flex; margin: 0; }
.top .quiet { background: transparent; border-color: #a77a73; color: white; min-height: 36px; }
.top .quiet:hover { background: #573133; text-decoration: none; }

.wrap { padding-block: 2.25rem 3rem; }
.page-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.page-heading p { margin-top: .5rem; color: var(--muted); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.3rem; min-width: 0; }
.login { max-width: 450px; margin: clamp(.5rem, 6vh, 4rem) auto; padding: clamp(1.15rem, 5vw, 2rem); }
.login h1 { font-size: 1.85rem; }
.account-settings { overflow-wrap: anywhere; }
.account-settings form + form { margin-top: 1.25rem; }
.login p { margin-block: .45rem 1.25rem; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.stat { position: relative; }
.stat > span { font-size: .9rem; color: var(--muted); }
.stat strong { display: block; font-size: 1.9rem; line-height: 1.15; margin-top: .38rem; }
.stat.attention { background: #fff7e3; border-color: #ecd79e; }
.stat.attention > span, .stat.attention strong, .stat-link { color: var(--amber); }
.stat-link { display: inline-block; margin-top: .4rem; font-weight: 700; font-size: .86rem; }

.filters { margin-bottom: 1rem; }
.filters-grid { margin-top: .8rem; display: grid; grid-template-columns: 1.25fr 1.05fr 1fr 1fr auto; align-items: end; gap: .7rem; }
.stack { display: grid; gap: .85rem; }
label { display: grid; align-content: start; gap: .32rem; min-width: 0; font-size: .88rem; font-weight: 650; }
label small { font-weight: 400; }
input, select, textarea, button { font: inherit; }
input:not([type="checkbox"]), select, textarea {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--control-border);
    border-radius: 8px;
    padding: .5rem .65rem;
    color: var(--ink);
    background: white;
    font-weight: 400;
    font-size: 1rem;
}
textarea { resize: vertical; }
.checkbox { display: flex; align-items: center; gap: .4rem; }
.checkbox input { width: 1rem; height: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
button, .button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: .35rem;
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: .5rem .8rem;
    font-weight: 650;
    font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.primary { color: white; background: var(--red); }
.primary:hover { background: #8f2117; }
.secondary { color: var(--ink); background: white; border-color: var(--control-border); }
.secondary:hover { background: var(--red-tint); }
button:disabled { opacity: .55; cursor: default; }

.delete-panel { margin-top: 1.25rem; }
.delete-panel summary { color: var(--red); cursor: pointer; font-weight: 650; }
.delete-panel p { margin-block: .75rem; }
.delete-panel .actions { align-items: end; }
.delete-panel label { width: 12rem; }

.table-panel { padding: 0; overflow: hidden; }
.table-heading, .table-panel > h2 { padding: 1rem 1.3rem; }
.table-heading { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
.entry-table { min-width: 740px; }
th, td { padding: .8rem .85rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
th:first-child, td:first-child { padding-left: 1.3rem; }
th:last-child, td:last-child { padding-right: 1.3rem; }
thead { background: #f6e8e5; color: #573332; font-size: .79rem; }
tbody th { font-weight: 700; }
[data-entry-row] { cursor: pointer; }
[data-entry-row]:hover, [data-entry-row]:focus-within { background: var(--red-tint); }
.open-link { font-weight: 700; white-space: nowrap; }
.pill { display: inline-block; border-radius: 6px; padding: .24rem .47rem; font-size: .8rem; font-weight: 650; white-space: nowrap; }
.pill.neutral { background: #f2eeed; color: #5e5150; }
.pill.ok { background: #e5f3ea; color: #18533a; }
.pill.soon { background: #fff1cc; color: #714500; }
.pill.overdue { background: #f9e7e3; color: #823427; }
.date-status { display: block; margin-top: .2rem; }
.empty { padding: 1.25rem 1.3rem; color: var(--muted); border-top: 1px solid var(--line); }
.pagination { display: flex; gap: .7rem; justify-content: center; align-items: center; padding: .85rem; border-top: 1px solid var(--line); }

.back { display: inline-block; margin-bottom: 1rem; font-weight: 650; }
.sections { display: grid; gap: .85rem; }
.sections h2 { margin-bottom: .85rem; }
.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0; }
.field-grid .wide { grid-column: 1 / -1; }
.field-grid dt { color: var(--muted); font-size: .84rem; font-weight: 650; }
.field-grid dd { margin: .3rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sequential-fields { grid-template-columns: minmax(0, 1fr); gap: .75rem; max-width: 56rem; }
.entry-field { grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr); align-items: start; gap: .35rem 1.15rem; }
.entry-field > span { padding-top: .65rem; }
.legacy-document-status { margin-left: 15.15rem; color: var(--muted); overflow-wrap: anywhere; }
.legacy-document-status label { margin-top: .3rem; }
.form-footer { margin-top: 1rem; justify-content: flex-start; }
.user-columns { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.user-columns section > form { margin-top: .8rem; }
.user-row-actions { display: flex; flex-wrap: wrap; gap: .35rem .75rem; }
.user-row-actions a { white-space: nowrap; }
.notice { margin-bottom: 1rem; padding: .7rem .95rem; border-radius: 8px; border: 1px solid; }
.notice.success { background: #e5f3ea; color: #18533a; }
.notice.error { background: #fbecea; color: #7d2c24; }
.notice ul { margin: 0; padding-left: 1.2rem; }

dialog { width: min(620px, calc(100% - 2rem)); max-height: calc(100% - 2rem); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); padding: 0; }
dialog::backdrop { background: rgb(42 20 18 / .54); }
.dialog-head, .dialog-foot { padding: 1.05rem 1.2rem; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: .7rem; border-bottom: 1px solid var(--line); }
.deadline-list { margin: 0; padding: 0; list-style: none; }
.deadline-list li + li, .dialog-foot { border-top: 1px solid var(--line); }
.deadline-list a { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .65rem 1.2rem; text-decoration: none; }
.deadline-list a:hover { background: var(--red-tint); text-decoration: underline; }
.deadline-list a:focus-visible { outline-offset: -3px; }
.deadline-list a > span:first-child { overflow-wrap: anywhere; }
.deadline-list small { display: block; }

@media (max-width: 920px) {
    .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
    .top-inner { gap: .6rem 1rem; flex-wrap: wrap; padding-block: .75rem; }
    .account { flex: 1 1 100%; flex-wrap: wrap; justify-content: space-between; text-align: left; }
    .account-actions .quiet { padding-inline: .55rem; white-space: normal; text-align: center; }
    .wrap { padding-top: 1.3rem; }
    .stat { padding: .65rem .6rem; }
    .stat > span { display: block; font-size: .75rem; line-height: 1.28; }
    .stat strong { font-size: 1.35rem; }
    .stats { gap: .4rem; }
    .field-grid:not(.sequential-fields) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .entry-field { grid-template-columns: 1fr; }
    .entry-field > span { padding-top: 0; }
    .legacy-document-status { margin-left: 0; }
    .user-columns { grid-template-columns: 1fr; }
}
@media (max-width: 380px) {
    .filters-grid, .field-grid { grid-template-columns: 1fr; }
}
