:root {
    color-scheme: light;
    --ink: #1d2b27;
    --muted: #596963;
    --border: #d2ddd7;
    --surface: #ffffff;
    --page: #f3f7f4;
    --green: #17634d;
    --green-dark: #104b3a;
    --green-soft: #e8f3ed;
    --red: #8c2929;
    --red-soft: #fff0ed;
    --amber: #714e09;
    --amber-soft: #fff7df;
    --focus: #1a70b5;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-size: 1rem;
    line-height: 1.55;
}

a { color: var(--green-dark); text-underline-offset: 0.16em; }
a:hover { color: var(--green); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    z-index: 5;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.55rem 0.8rem;
    transform: translateY(-160%);
    border-radius: 0.4rem;
    background: var(--surface);
}
.skip-link:focus { transform: translateY(0); }

.site-shell { width: min(100% - 2rem, 72rem); margin: 0 auto; }
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.brand { color: var(--green-dark); font-size: 1.35rem; font-weight: 800; letter-spacing: 0.03em; text-decoration: none; }
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem 1rem; }
.main-nav > a { font-weight: 650; }
.logout-form { margin: 0; }
.page-content { min-height: calc(100vh - 9rem); padding: clamp(1.1rem, 3vw, 2.25rem) 0; }
.page-content > main { width: min(100%, 66rem); margin: 0 auto; }
.site-footer { padding: 1rem 0 1.5rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.875rem; }

h1, h2, h3 { line-height: 1.2; }
h1 { margin: 0 0 1.25rem; font-size: clamp(1.65rem, 4vw, 2.25rem); }
h2 { margin-top: 2rem; font-size: clamp(1.25rem, 3vw, 1.55rem); }
h3 { font-size: 1.1rem; }
p { max-width: 82ch; }
small { display: block; margin-top: 0.25rem; color: var(--muted); }

section, article, fieldset {
    margin: 1.1rem 0;
    padding: clamp(0.9rem, 2vw, 1.3rem);
    border: 1px solid var(--border);
    border-radius: 0.8rem;
    background: var(--surface);
}
section > :first-child, article > :first-child { margin-top: 0; }
section > :last-child, article > :last-child { margin-bottom: 0; }
fieldset { min-width: 0; }
legend { padding: 0 0.35rem; font-weight: 700; }

form:not(.logout-form) {
    max-width: 58rem;
    margin: 1rem 0;
}
form p { display: grid; gap: 0.3rem; margin: 0 0 0.9rem; }
label { display: block; font-weight: 650; }
input:not([type=hidden]), select, textarea {
    width: 100%;
    min-height: 2.7rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid #9eafa6;
    border-radius: 0.45rem;
    background: #fff;
    color: var(--ink);
    font: inherit;
}
input[type=checkbox], input[type=radio] { width: auto; min-height: auto; accent-color: var(--green); }
input[type=file] { padding: 0.45rem; }
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.65rem;
    padding: 0.55rem 0.95rem;
    border: 1px solid var(--green);
    border-radius: 0.5rem;
    background: var(--green);
    color: #fff;
    font: inherit;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}
button:hover, .button:hover { background: var(--green-dark); color: #fff; }
.button-secondary { border-color: var(--border); background: var(--surface); color: var(--ink); }
.button-secondary:hover { border-color: #9eafa6; background: var(--green-soft); color: var(--ink); }
button:disabled { cursor: not-allowed; opacity: 0.6; }
form > a, form > button + a { margin-left: 0.7rem; }

ul, ol { padding-left: 1.35rem; }
li + li { margin-top: 0.5rem; }
dl { display: grid; grid-template-columns: minmax(11rem, 0.35fr) minmax(0, 1fr); gap: 0.35rem 1rem; }
dt { color: var(--muted); font-weight: 650; }
dd { margin: 0; overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
caption { padding: 0.65rem; text-align: left; font-weight: 700; }
th, td { padding: 0.65rem; border: 1px solid var(--border); text-align: left; vertical-align: top; }
thead { background: var(--green-soft); }
table form { margin: 0; }

[role=alert], .message-error { padding: 0.75rem 0.9rem; border-left: 4px solid var(--red); border-radius: 0.3rem; background: var(--red-soft); color: var(--red); }
[role=status], .message-success { padding: 0.75rem 0.9rem; border-left: 4px solid var(--green); border-radius: 0.3rem; background: var(--green-soft); color: var(--green-dark); }

#upload-status:empty {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}
.message-warning { padding: 0.75rem 0.9rem; border-left: 4px solid #c18c19; border-radius: 0.3rem; background: var(--amber-soft); color: var(--amber); }

@media (max-width: 44rem) {
    .site-shell { width: min(100% - 1.1rem, 72rem); }
    .site-header { align-items: flex-start; flex-direction: column; gap: 0.65rem; }
    .main-nav { width: 100%; gap: 0.65rem 0.9rem; }
    .main-nav .logout-form { margin-left: auto; }
    .page-content { padding-top: 1.2rem; }
    dl { grid-template-columns: 1fr; gap: 0.15rem; }
    dd { margin-bottom: 0.6rem; }
    table { display: block; overflow-x: auto; white-space: normal; }
}

@media print {
    :root { color-scheme: light; }
    body { background: #fff; color: #000; font-size: 10.5pt; }
    .site-shell { width: 100%; }
    .site-header, .site-footer, .skip-link, button, form, noscript { display: none !important; }
    .page-content { min-height: 0; padding: 0; }
    section, article, fieldset { break-inside: avoid; border-color: #999; box-shadow: none; }
    a { color: #000; }
}
