* {
    box-sizing: border-box;
}

body,
ul,
ol,
input,
button,
textarea,
select,
section,
main,
html,
form,
h1,
h2,
h3,
p,
dl,
dd {
    margin: 0;
    padding: 0;
}

:root {
    color-scheme: light;
    --ink: #1b1b1f;
    --muted: #62656f;
    --line: #d8dbe3;
    --paper: #ffffff;
    --wash: #f4f5f7;
    --accent: #0f766e;
    --accent-dark: #0b514c;
    --danger: #9f1239;
    --ok: #166534;
}

html {
    max-width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--wash);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

body {
    min-height: 100vh;
}

a:any-link {
    color: inherit;
    text-decoration: none;
}

a:hover,
button:hover,
input[type="submit"]:hover {
    opacity: 0.72;
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
}

input,
option,
button,
textarea,
select {
    border: 0;
    color: inherit;
    font: inherit;
}

button,
input[type="file"],
select {
    cursor: pointer;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
    padding: 14px clamp(16px, 4vw, 42px);
}

.brand {
    font-weight: 700;
}

.site-header nav {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: 0.95rem;
}

main {
    min-height: calc(100vh - 106px);
    padding: 28px clamp(16px, 4vw, 42px) 44px;
}

.hero,
.admin-shell,
.document-view,
.empty {
    margin: 0 auto;
    max-width: 1080px;
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 0 24px;
}

.hero h1,
.document-head h1,
.admin-shell h1,
.empty h1 {
    max-width: 760px;
    font-size: clamp(2rem, 4vw, 4rem);
    line-height: 1.03;
}

.hero p,
.document-head p,
.admin-shell > div > p {
    max-width: 720px;
    color: var(--muted);
    margin-top: 10px;
}

.eyebrow {
    color: var(--accent-dark);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.button {
    align-items: center;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    min-height: 42px;
    padding: 9px 14px;
    white-space: nowrap;
}

.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

.filters,
.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 14px;
    margin: 0 auto 22px;
    max-width: 1080px;
    padding: 16px;
}

.filters {
    align-items: end;
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto auto;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    min-height: 42px;
    padding: 9px 10px;
}

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

.archive-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    margin: 0 auto;
    max-width: 1080px;
}

.item-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    min-height: 240px;
    padding: 16px;
}

.item-card h2 {
    font-size: 1.2rem;
    line-height: 1.22;
}

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

.item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.item-meta span {
    background: var(--wash);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.78rem;
    padding: 3px 8px;
}

.item-actions,
.document-actions,
.admin-topline {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

.document-head {
    display: flex;
    justify-content: space-between;
    gap: 22px;
    padding: 16px 0 22px;
}

.facts {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 0;
    grid-template-columns: repeat(4, 1fr);
    margin-bottom: 18px;
    overflow: hidden;
}

.facts div {
    border-right: 1px solid var(--line);
    padding: 12px;
}

.facts div:last-child {
    border-right: 0;
}

.facts dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.facts dd {
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.preview {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.preview h2,
.admin-list h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.preview-image,
.preview-pdf {
    display: block;
    max-height: 78vh;
    min-height: 420px;
    object-fit: contain;
    width: 100%;
}

.preview-text {
    background: #111318;
    border-radius: 6px;
    color: #f3f4f6;
    max-height: 72vh;
    overflow: auto;
    padding: 14px;
    white-space: pre-wrap;
}

.download-only,
.empty {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.download-only p,
.empty p,
.empty-line {
    color: var(--muted);
    margin-bottom: 14px;
}

.notice {
    border-radius: 6px;
    font-weight: 700;
    margin: 16px 0;
    padding: 10px 12px;
}

.notice.ok {
    background: #dcfce7;
    color: var(--ok);
}

.notice.error {
    background: #ffe4e6;
    color: var(--danger);
}

.upload-form {
    grid-template-columns: 1fr 1fr;
}

.upload-form label:first-of-type,
.upload-form label:nth-of-type(4),
.checks,
.upload-form button {
    grid-column: 1 / -1;
}

.checks {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.checks label {
    align-items: center;
    display: flex;
    grid-template-columns: auto 1fr;
}

.checks input {
    min-height: auto;
}

.admin-topline {
    justify-content: space-between;
    margin: 18px auto;
    max-width: 1080px;
}

.admin-list {
    margin: 0 auto;
    max-width: 1080px;
}

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

table {
    border-collapse: collapse;
    min-width: 780px;
    width: 100%;
}

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

th {
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

footer {
    background: #111318;
    color: #fff;
    padding: 14px 16px;
    text-align: center;
}

@media (max-width: 760px) {
    .site-header,
    .hero,
    .document-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .filters,
    .upload-form {
        grid-template-columns: 1fr;
    }

    .facts {
        grid-template-columns: 1fr;
    }

    .facts div {
        border-bottom: 1px solid var(--line);
        border-right: 0;
    }

    .facts div:last-child {
        border-bottom: 0;
    }

    .preview-image,
    .preview-pdf {
        min-height: 300px;
    }
}

@media print {
    html,
    body {
        background: #fff;
        color: #000;
        font-size: 12pt;
    }

    .site-header,
    footer,
    .document-actions {
        display: none;
    }

    main {
        padding: 0;
    }

    .document-view,
    .preview,
    .facts {
        border: 0;
        border-radius: 0;
        max-width: none;
        padding: 0;
    }

    .facts {
        border-top: 1px solid #000;
        border-bottom: 1px solid #000;
        margin: 14px 0;
    }

    .preview-pdf {
        min-height: 70vh;
    }
}
