:root {
    --ink: #26323f;
    --muted: #65717d;
    --line: #d7e2dd;
    --surface: #ffffff;
    --soft: #f2f8f4;
    --brand: #008442;
    --brand-strong: #006f62;
    --brand-bright: #26a737;
    --accent: #b58b22;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    color: var(--ink);
    background: var(--surface);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

main {
    flex: 1;
}

.home-main {
    display: flex;
    flex-direction: column;
}

.category-main {
    display: flex;
    flex-direction: column;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.narrow {
    max-width: 860px;
}

.topbar {
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.topbar__inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #465564;
    font-weight: 700;
}

.brand:hover {
    color: #465564;
    text-decoration: none;
}

.brand__mark {
    width: 42px;
    height: 56px;
    object-fit: contain;
}

.brand__text {
    max-width: 520px;
    font-size: 1.28rem;
    line-height: 1.15;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    font-size: .95rem;
}

.logout-form {
    margin: 0;
}

.logout-form button {
    min-height: auto;
    padding: 0;
    border: 0;
    color: var(--brand);
    background: transparent;
    font-weight: 400;
}

.hero {
    background: linear-gradient(90deg, #008774 0%, #008b6a 28%, #009657 55%, #12a346 78%, #26a737 100%);
    color: #fff;
}

.hero__inner {
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
}

.hero h1,
.page-title h1 {
    margin: 0;
    font-size: clamp(1.7rem, 2.8vw, 2.45rem);
    line-height: 1.05;
    letter-spacing: 0;
}

.hero p {
    max-width: 680px;
    color: rgba(255, 255, 255, .88);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    font-size: .78rem;
}

.search {
    display: grid;
    gap: 8px;
}

.search--hero {
    width: min(980px, 100%);
}

.search label,
.filters label {
    font-weight: 700;
}

.search__row {
    display: flex;
    gap: 8px;
}

.search--hero .search__row {
    gap: 10px;
}

.search--hero input {
    min-height: 52px;
    border-color: rgba(255, 255, 255, .8);
    font-size: 1rem;
}

.search--hero button {
    min-height: 52px;
    padding: 0 24px;
    background: #008442;
}

.search--hero input {
    flex: 1 1 420px;
}

.site-action {
    flex: 0 0 auto;
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border: 1px solid rgba(255, 255, 255, .9);
    border-radius: 6px;
    color: #fff;
    background: rgba(255, 255, 255, .08);
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.site-action:hover {
    color: #fff;
    background: rgba(255, 255, 255, .16);
    text-decoration: none;
}

.site-action--back {
    border-color: rgba(255, 255, 255, .9);
    color: #fff;
    background: rgba(255, 255, 255, .08);
}

.site-action--home {
    min-width: 52px;
    padding: 0;
}

.site-action--home svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

input,
select,
button,
.button-secondary,
.button-primary {
    min-height: 44px;
    border-radius: 6px;
    border: 1px solid var(--line);
    font: inherit;
}

input,
select {
    width: 100%;
    padding: 0 12px;
    color: var(--ink);
    background: #fff;
}

input[type="file"] {
    display: flex;
    align-items: center;
    padding: 7px;
    color: var(--muted);
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    min-height: 30px;
    margin-right: 12px;
    padding: 0 12px;
    border: 1px solid var(--brand);
    border-radius: 5px;
    color: var(--brand);
    background: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
    color: #fff;
    background: var(--brand);
}

button,
.button-secondary,
.button-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border-color: var(--brand);
    color: #fff;
    background: var(--brand);
    font-weight: 700;
    cursor: pointer;
}

.button-secondary {
    color: var(--brand);
    background: #fff;
}

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

.button-secondary:hover,
.button-primary:hover,
.document-link:hover {
    text-decoration: none;
}

.section {
    padding: 40px 0;
}

.section--featured-cards {
    flex: 1;
    padding: 34px 0 48px;
    background: #f5f5f5;
}

.section--category-cards {
    flex: 1;
    padding: 34px 0 48px;
    background: #f5f5f5;
}

.section--muted {
    background: var(--soft);
}

.page-title {
    padding: 24px 0;
    border-bottom: 0;
    background: linear-gradient(90deg, #008774 0%, #008b6a 28%, #009657 55%, #12a346 78%, #26a737 100%);
    color: #fff;
}

.page-title__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.page-title__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.page-title__actions .site-action {
    min-height: 44px;
    padding: 0 16px;
}

.page-title__actions .site-action--home {
    min-width: 44px;
    padding: 0;
}

.page-title__actions .site-action--home svg {
    width: 21px;
    height: 21px;
}

.page-title h1 {
    font-size: clamp(1.55rem, 2.2vw, 2rem);
}

.page-title p:not(.eyebrow) {
    max-width: 760px;
    color: rgba(255, 255, 255, .86);
}

.page-title .eyebrow {
    color: #fff2c1;
}

.section__header,
.results__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.section__header h2 {
    margin: 0;
    font-size: 1.45rem;
}

.section__header--featured h2 {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.section__header--featured h2::before {
    content: "";
    width: 24px;
    height: 24px;
    border: 3px solid var(--brand);
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 31%, var(--brand) 0 3px, transparent 4px),
        radial-gradient(circle at 38% 62%, var(--brand) 0 3px, transparent 4px),
        radial-gradient(circle at 62% 62%, var(--brand) 0 3px, transparent 4px);
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.category-grid--featured {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
}

.category-card {
    min-height: 108px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
}

.category-card--featured {
    min-height: 196px;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px 18px;
    border-color: #d2d2d2;
    border-radius: 16px;
    text-align: center;
}

.category-card--featured:hover {
    border-color: var(--brand-bright);
    box-shadow: 0 10px 24px rgba(0, 132, 66, .14);
    text-decoration: none;
}

.category-card--featured strong {
    max-width: 170px;
    font-size: 1rem;
    line-height: 1.35;
}

.category-card--featured span:not(.category-card__icon) {
    font-size: .88rem;
}

.category-card__count {
    color: #7b8791;
}

.category-card--compact {
    min-height: 150px;
    gap: 10px;
    padding: 20px 16px;
}

.category-card__icon {
    width: 56px;
    height: 56px;
    margin-bottom: 2px;
    background: no-repeat center / contain url("data:image/svg+xml,%3Csvg width='64' height='64' viewBox='0 0 64 64' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M18 8h21l9 9v39H18V8Z' stroke='%23008442' stroke-width='3' stroke-linejoin='round'/%3E%3Cpath d='M38 8v11h10M24 29h18M24 38h18M24 47h12' stroke='%23008442' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.category-card--compact .category-card__icon {
    width: 42px;
    height: 42px;
}

.category-card span,
.publication p,
.publication__meta,
.empty {
    color: var(--muted);
}

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.filters {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
}

.filters form {
    display: grid;
    gap: 10px;
}

.publication-list {
    display: grid;
    gap: 10px;
}

.publication {
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
}

.publication:first-child {
    border-top: 1px solid var(--line);
}

.publication h3 {
    margin: 4px 0 6px;
    font-size: 1.05rem;
}

.publication h3 a {
    color: var(--brand);
}

.publication p {
    margin: 0;
}

.publication__note,
.document-missing {
    margin-top: 8px;
    color: #8a5f00;
    font-weight: 700;
}

.publication__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .84rem;
}

.publication__meta span {
    padding-right: 8px;
    border-right: 1px solid var(--line);
}

.publication__meta span:last-child {
    border-right: 0;
}

.publication__status {
    color: #8a5f00;
    font-weight: 700;
}

.publication__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    font-size: .9rem;
}

.document-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 6px;
    color: #fff;
    background: var(--brand);
    font-weight: 700;
}

.detail__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0;
}

.messages,
.form-errors {
    margin-bottom: 18px;
    padding: 12px 14px;
    border: 1px solid #d7e2dd;
    border-radius: 8px;
    background: #e9f6eb;
}

.messages p {
    margin: 0;
}

.messages--dismissible {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-right: 10px;
}

.messages__dismiss {
    flex: 0 0 auto;
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    border-color: transparent;
    border-radius: 50%;
    color: var(--brand);
    background: transparent;
    font-size: 1.35rem;
    line-height: 1;
}

.messages__dismiss:hover {
    color: #fff;
    background: var(--brand);
}

.form-errors {
    border-color: #e3b7b7;
    background: #fff1f1;
}

.management {
    display: grid;
    gap: 18px;
}

.management__bar,
.management-search,
.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.management__bar {
    justify-content: space-between;
}

.management__actions,
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.management-search {
    flex: 1;
}

.management-search input {
    max-width: 420px;
}

.management-search select {
    max-width: 220px;
}

.management-table {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    background: var(--soft);
    font-size: .86rem;
}

td span {
    display: block;
    color: var(--muted);
    font-size: .88rem;
}

.table-note {
    max-width: 520px;
    margin: 8px 0 0;
    color: var(--ink);
}

.table-actions {
    margin-top: 8px;
    font-size: .9rem;
}

.badge {
    display: inline-flex;
    width: fit-content;
    margin: 0 4px 4px 0;
    padding: 3px 8px;
    border-radius: 999px;
    color: var(--muted);
    background: var(--soft);
    font-size: .78rem;
    font-weight: 700;
}

.badge--ok {
    color: var(--brand-strong);
    background: #e7ffeb;
}

.badge--warn {
    color: #8a5f00;
    background: #fff5d8;
}

.badge--danger {
    color: #9d2f2f;
    background: #fff1f1;
}

.form-panel {
    display: grid;
    gap: 18px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
}

.login-panel {
    width: min(460px, 100%);
    max-width: 460px;
}

.login-layout {
    display: flex;
    justify-content: center;
}

.form-help,
.form-link {
    margin: 0;
}

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

.form-link {
    text-align: center;
    font-size: .95rem;
}

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

.form-grid:has(.field:nth-child(3)) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
    display: grid;
    gap: 6px;
}

.field label,
.checks label {
    font-weight: 700;
}

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

.field ul {
    margin: 0;
    padding-left: 18px;
    color: #9d2f2f;
}

textarea {
    width: 100%;
    min-height: 132px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    resize: vertical;
}

.checks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
}

.toggle-field {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.toggle-field:hover {
    border-color: #b8cbc4;
    background: #fbfdfc;
}

.toggle-field input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.toggle-field__switch {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 24px;
    border: 1px solid #b7c7c0;
    border-radius: 999px;
    background: #e9efec;
    transition: background .16s ease, border-color .16s ease;
}

.toggle-field__switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .22);
    transition: transform .16s ease;
}

.toggle-field input[type="checkbox"]:checked + .toggle-field__switch {
    border-color: var(--brand);
    background: var(--brand);
}

.toggle-field input[type="checkbox"]:checked + .toggle-field__switch::after {
    transform: translateX(20px);
}

.toggle-field input[type="checkbox"]:focus-visible + .toggle-field__switch {
    outline: 3px solid rgba(0, 132, 66, .22);
    outline-offset: 2px;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 28px;
}

.pagination a,
.pagination strong,
.pagination span {
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.pagination strong {
    color: #fff;
    border-color: var(--brand);
    background: var(--brand);
}

.detail dl {
    display: grid;
    gap: 10px;
}

.detail dl div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.detail dt {
    font-weight: 700;
}

.detail dd {
    margin: 0;
}

.footer {
    margin-top: auto;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    background: #26323f;
    color: #fff;
    font-size: .86rem;
}

.footer__grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
}

.footer p,
.footer a {
    margin: 4px 0 0;
    color: rgba(255, 255, 255, .78);
}

@media (max-width: 800px) {
    .topbar__inner,
    .layout,
    .footer__grid {
        grid-template-columns: 1fr;
    }

    .topbar__inner {
        align-items: flex-start;
        padding: 14px 0;
    }

    .brand {
        align-items: flex-start;
    }

    .brand__mark {
        width: 34px;
        height: 46px;
    }

    .brand__text {
        max-width: 280px;
        font-size: 1rem;
    }

    .hero__inner {
        min-height: auto;
        padding: 22px 0;
    }

    .page-title__inner {
        align-items: flex-start;
        flex-direction: column;
        gap: 16px;
    }

    .page-title__actions {
        width: 100%;
        justify-content: flex-start;
    }

    .page-title__actions .site-action {
        flex: 1 1 150px;
    }

    .search__row {
        flex-direction: column;
    }

    .search__row .site-action {
        width: 100%;
    }

    .footer__grid {
        display: grid;
    }

    .management__bar,
    .management-search,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .management-search input,
    .management-search select {
        max-width: none;
    }

    .form-grid,
    .form-grid:has(.field:nth-child(3)) {
        grid-template-columns: 1fr;
    }
}
