:root {
    --bg: #f5f2ec;
    --paper: #fffdf8;
    --surface: #ffffff;
    --ink: #1e252b;
    --muted: #6a737d;
    --line: #ddd3c3;
    --line-dark: #c5b7a4;
    --brand: #315f37;
    --brand-2: #78c9aa;
    --brand-soft: #edf7ed;
    --gold: #c29545;
    --clay: #b66b4f;
    --danger: #9d2d2d;
    --shadow: 0 18px 44px rgba(38, 44, 50, .10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        linear-gradient(180deg, rgba(245, 242, 236, .96), rgba(245, 242, 236, 1)),
        repeating-linear-gradient(90deg, rgba(15, 76, 92, .04) 0, rgba(15, 76, 92, .04) 1px, transparent 1px, transparent 72px);
    color: var(--ink);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.55;
}

a {
    color: var(--brand);
    text-underline-offset: 3px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 74px;
    padding: 0 34px;
    background: rgba(255, 253, 248, .95);
    border-bottom: 1px solid rgba(197, 183, 164, .8);
    box-shadow: 0 10px 30px rgba(28, 35, 40, .05);
    backdrop-filter: blur(14px);
}

.brand,
.admin-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    font-size: 17px;
    font-weight: 850;
    text-decoration: none;
}

.brand::before,
.admin-brand::before {
    content: "";
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background:
        linear-gradient(90deg, transparent 43%, rgba(255, 255, 255, .45) 43%, rgba(255, 255, 255, .45) 50%, transparent 50%),
        linear-gradient(135deg, var(--brand), var(--brand-2));
    box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12), 0 8px 18px rgba(15, 76, 92, .22);
}

.brand.has-logo::before,
.admin-brand.has-logo::before,
.brand:has(.brand-logo)::before,
.admin-brand:has(.brand-logo)::before {
    content: none;
}

.brand-logo {
    display: block;
    width: auto;
    height: 52px;
    max-width: 210px;
    object-fit: contain;
}

.site-header nav,
.admin-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.site-header nav a,
.admin-menu a {
    border-radius: 999px;
    color: #35424c;
    font-size: 14px;
    font-weight: 750;
    padding: 9px 13px;
    text-decoration: none;
}

.site-header nav a:hover,
.admin-menu a:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

.container {
    width: min(1320px, calc(100% - 40px));
    margin: 28px auto 54px;
}

.site-footer {
    color: var(--muted);
    padding: 30px;
    text-align: center;
}

.catalog-hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 36px;
    align-items: center;
    min-height: 330px;
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid rgba(221, 211, 195, .9);
    border-radius: 18px;
    background:
        radial-gradient(circle at 86% 18%, rgba(194, 149, 69, .26), transparent 30%),
        linear-gradient(135deg, #183f3b 0%, #315f37 48%, #78c9aa 100%);
    box-shadow: var(--shadow);
    color: #fff;
    padding: 42px;
}

.catalog-hero::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 8px;
    background: linear-gradient(90deg, var(--gold), var(--clay), var(--brand-2));
}

.catalog-hero__content {
    position: relative;
    z-index: 1;
    max-width: 840px;
}

.eyebrow {
    color: #f1cf93;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .16em;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.catalog-hero h1 {
    max-width: 780px;
    font-size: clamp(34px, 5vw, 58px);
    line-height: 1.02;
    letter-spacing: 0;
    margin-bottom: 16px;
}

.catalog-hero p {
    color: rgba(255, 255, 255, .84);
    font-size: 17px;
    max-width: 720px;
    margin-bottom: 24px;
}

.hero-search {
    display: grid;
    grid-template-columns: minmax(150px, 210px) minmax(220px, 1fr) auto;
    gap: 10px;
    max-width: 840px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 14px;
    background: rgba(255, 255, 255, .14);
    backdrop-filter: blur(10px);
}

.hero-search input,
.hero-search select {
    min-height: 54px;
    border: 0;
    border-radius: 10px;
    font-size: 16px;
    padding: 0 16px;
}

.hero-search button {
    min-height: 54px;
    border: 0;
    border-radius: 10px;
    background: var(--gold);
    color: #1e252b;
    font-weight: 850;
    padding: 0 22px;
}

.archive-visual {
    position: relative;
    height: 245px;
}

.archive-card,
.archive-lines {
    position: absolute;
    border-radius: 14px;
    background: rgba(255, 253, 248, .92);
    box-shadow: 0 24px 50px rgba(0, 0, 0, .22);
}

.archive-card::before {
    content: "";
    position: absolute;
    left: 22px;
    right: 22px;
    top: 22px;
    height: 10px;
    border-radius: 999px;
    background: rgba(15, 76, 92, .24);
}

.archive-card::after {
    content: "";
    position: absolute;
    left: 22px;
    right: 58px;
    top: 48px;
    height: 8px;
    border-radius: 999px;
    background: rgba(194, 149, 69, .50);
}

.card-b::before {
    background: rgba(47, 118, 105, .24);
}

.card-c::after {
    background: rgba(182, 107, 79, .42);
}

.card-a {
    inset: 0 26px 54px 18px;
    transform: rotate(-6deg);
}

.card-b {
    inset: 38px 0 24px 50px;
    transform: rotate(5deg);
}

.card-c {
    inset: 82px 46px 0 0;
    transform: rotate(-1deg);
}

.archive-lines {
    right: 34px;
    bottom: 26px;
    width: 140px;
    padding: 16px;
    background: #f8efe1;
    z-index: 2;
}

.archive-lines span {
    display: block;
    height: 7px;
    margin-bottom: 8px;
    border-radius: 999px;
    background: rgba(47, 118, 105, .28);
}

.archive-lines span:nth-child(2),
.archive-lines span:nth-child(4) {
    background: rgba(194, 149, 69, .46);
}

.archive-lines span:nth-child(2) {
    width: 78%;
}

.archive-lines span:nth-child(3) {
    width: 62%;
}

.archive-lines span:nth-child(4) {
    width: 88%;
    margin-bottom: 0;
}

.hero-logo-mark {
    position: absolute;
    right: 18px;
    bottom: 18px;
    z-index: 4;
    width: 118px;
    height: 118px;
    border-radius: 50%;
    background: rgba(255, 253, 248, .96);
    box-shadow: 0 18px 34px rgba(16, 43, 36, .24);
    object-fit: contain;
    padding: 8px;
}

.collection-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.portal-section {
    margin: 24px 0;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.section-heading h2 {
    color: var(--brand);
    font-size: 26px;
    margin: 0;
}

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

.collection-card {
    display: grid;
    grid-template-rows: 150px 1fr;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--shadow);
    color: var(--ink);
    text-decoration: none;
}

.collection-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: var(--brand-soft);
}

.collection-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff;
    font-size: 42px;
    font-weight: 900;
}

.collection-card > div {
    padding: 16px;
}

.collection-card strong {
    color: var(--brand);
    display: block;
    font-size: 20px;
    margin-bottom: 8px;
}

.collection-card p {
    color: var(--muted);
    margin-bottom: 12px;
}

.collection-card span {
    color: var(--gold);
    font-weight: 900;
}

.portal-two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

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

.mini-record {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: #fff;
    color: var(--ink);
    padding: 10px;
    text-decoration: none;
}

.mini-record img {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--brand-soft);
}

.mini-record strong {
    color: var(--brand);
    display: block;
}

.mini-record small {
    color: var(--muted);
    display: block;
    margin-top: 4px;
}

.collection-strip > div,
.collection-strip > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 74px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    box-shadow: 0 10px 24px rgba(38, 44, 50, .06);
    color: var(--ink);
    padding: 14px 16px;
    text-decoration: none;
}

.collection-strip strong {
    color: var(--brand);
    font-size: 24px;
    line-height: 1;
}

.collection-strip span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
}

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

.facet-panel,
.catalog-results,
.panel,
.admin-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 253, 248, .96);
    box-shadow: var(--shadow);
}

.facet-panel {
    position: sticky;
    top: 92px;
    padding: 18px;
}

.facet-title,
.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
    padding-bottom: 12px;
}

.facet-title h2,
.panel-title h2,
.panel-title h3 {
    color: var(--brand);
    font-size: 18px;
    margin: 0;
}

.facet-group,
.field {
    margin-bottom: 15px;
}

label {
    display: block;
    color: #47525d;
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 6px;
}

input,
select,
textarea,
button {
    width: 100%;
    border: 1px solid var(--line-dark);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    padding: 10px 12px;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-2);
    box-shadow: 0 0 0 4px rgba(44, 122, 123, .14);
    outline: none;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 42px;
    border: 1px solid var(--brand);
    border-radius: 9px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font-weight: 850;
    padding: 10px 16px;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: #0b3b47;
}

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

.icon-link {
    gap: 8px;
    border-color: rgba(15, 76, 92, .34);
    box-shadow: 0 8px 20px rgba(15, 76, 92, .08);
}

.icon-link span,
.icon-link small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 14px;
    line-height: 1;
}

.icon-link small {
    margin-left: 2px;
    background: #f3e7d1;
    color: #6c4a12;
    font-size: 12px;
}

.button.danger,
button.danger {
    background: var(--danger);
    border-color: var(--danger);
}

.catalog-results {
    overflow: hidden;
}

.result-controls {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto;
    gap: 18px;
    align-items: end;
    padding: 20px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fffdf8, #f9f5ee);
}

.result-controls h2 {
    color: var(--brand);
    font-size: 24px;
    margin-bottom: 4px;
}

.result-controls p {
    color: var(--muted);
    margin-bottom: 0;
}

.control-grid {
    display: grid;
    grid-template-columns: 112px 150px 100px auto;
    gap: 10px;
    align-items: end;
}

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px;
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: #40505b;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 10px;
}

.record-list {
    padding: 14px;
}

.record-card {
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr) 104px;
    gap: 18px;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 0 rgba(15, 76, 92, .05);
    cursor: pointer;
    margin-bottom: 10px;
    padding: 16px;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.record-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 86px;
    height: 86px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-soft), #fff);
    color: var(--brand);
    font-size: 34px;
    font-weight: 900;
}

.record-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.record-card:hover {
    border-color: rgba(44, 122, 123, .35);
    box-shadow: 0 18px 32px rgba(38, 44, 50, .10);
    transform: translateY(-1px);
}

.record-kind {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 13px;
    font-weight: 900;
    padding: 7px 11px;
}

.record-main h3 {
    color: #172b36;
    font-size: 20px;
    line-height: 1.25;
    margin-bottom: 10px;
}

.record-main h3 a {
    color: inherit;
    text-decoration: none;
}

.record-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    margin-bottom: 6px;
}

.record-meta strong {
    color: var(--brand);
}

.record-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.record-facts.labelled span {
    border-radius: 10px;
}

.record-facts strong {
    color: #293844;
}

.record-facts span {
    border-radius: 999px;
    background: #f6f2eb;
    color: #53616b;
    font-size: 12px;
    font-weight: 750;
    padding: 5px 9px;
}

.record-status {
    justify-self: end;
    text-align: right;
}

.record-status span {
    display: inline-flex;
    border-radius: 999px;
    background: #f3e7d1;
    color: #6c4a12;
    font-size: 12px;
    font-weight: 900;
    padding: 6px 10px;
}

.record-status small {
    display: block;
    color: var(--muted);
    font-weight: 750;
    margin-top: 8px;
}

.record-detail {
    border: 1px solid var(--line);
    border-left: 5px solid var(--gold);
    border-radius: 14px;
    background: #fffaf1;
    margin: -2px 14px 14px;
    padding: 18px;
}

.detail-highlight {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 14px;
    padding-bottom: 14px;
}

.detail-highlight strong {
    color: var(--brand);
}

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

.detail-item {
    min-height: 68px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
    padding: 12px 13px;
}

.detail-item strong {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.report-form {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 16px;
}

.report-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.report-toggle {
    min-height: 34px;
    padding: 7px 11px;
    font-size: 13px;
}

.compact-report {
    border-top: 0;
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
    padding-top: 0;
}

.report-card {
    width: min(100%, 520px);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 38px rgba(38, 44, 50, .12);
    padding: 14px;
}

.report-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.report-card-head strong {
    color: var(--brand);
}

.report-close {
    width: 30px;
    min-height: 30px;
    border-radius: 999px;
    padding: 0;
    background: #fff;
    color: var(--muted);
    border-color: var(--line);
    font-size: 18px;
    line-height: 1;
}

.compact-report textarea {
    min-height: 78px;
}

.report-grid,
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.report-grid > *,
.toolbar > * {
    flex: 1 1 180px;
}

.report-grid button,
.toolbar button,
.toolbar .button {
    flex: 0 0 auto;
}

.panel {
    padding: 20px;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}

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

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

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

.results th {
    background: #f8f4ed;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.flash {
    border: 1px solid #b8d9c5;
    border-radius: 10px;
    background: #e8f4ed;
    margin-bottom: 14px;
    padding: 12px 14px;
}

.error {
    color: var(--danger);
    font-weight: 800;
}

.empty-state {
    border: 1px dashed var(--line-dark);
    border-radius: 14px;
    background: #fff;
    color: var(--muted);
    margin: 18px;
    padding: 34px;
    text-align: center;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 20px;
}

.admin-filter-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(135deg, #fffdf8, #f7efe2);
    box-shadow: var(--shadow);
    padding: 18px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 8px;
}

.stat-card strong {
    color: var(--brand);
    font-size: 34px;
    line-height: 1;
}

.admin-stats-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 18px;
}

.public-record {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 253, 248, .96);
    box-shadow: var(--shadow);
    padding: 24px;
}

.public-record-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 24px;
    align-items: start;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    padding-bottom: 18px;
}

.public-record-head h1 {
    color: var(--brand);
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1.1;
}

.public-record-head img {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    object-fit: cover;
    background: var(--brand-soft);
}

.filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    grid-column: 1 / -1;
}

.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.nested-panel {
    margin: 18px 0;
    box-shadow: none;
}

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

tr.dragging {
    opacity: .45;
}

tr.drag-over {
    outline: 2px solid var(--gold);
}

.admin-shell .container {
    width: min(1360px, calc(100% - 40px));
}

@media (max-width: 1100px) {
    .catalog-hero,
    .catalog-layout,
    .result-controls {
        grid-template-columns: 1fr;
    }

    .archive-visual {
        display: none;
    }

    .facet-panel {
        position: static;
    }

    .control-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px 18px;
        position: static;
    }

    .brand-logo {
        height: 44px;
        max-width: 180px;
    }

    .container {
        width: min(100% - 24px, 1320px);
        margin-top: 16px;
    }

    .catalog-hero {
        border-radius: 14px;
        min-height: auto;
        padding: 26px;
    }

    .hero-search,
    .record-card,
    .detail-grid,
    .form-grid,
    .layout,
    .control-grid {
        grid-template-columns: 1fr;
    }

    .record-cover {
        width: 100%;
        height: 140px;
    }

    .admin-filter-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid,
    .admin-stats-layout,
    .collection-cards,
    .portal-two-col,
    .public-record-head {
        grid-template-columns: 1fr;
    }

    .record-status {
        justify-self: start;
        text-align: left;
    }
}
