:root {
    --bg: #f7f5ef;
    --panel: #ffffff;
    --ink: #1f2523;
    --muted: #65706b;
    --line: #d9ddd5;
    --accent: #256f68;
    --accent-strong: #174d48;
    --warn: #9a5b10;
    --danger: #b42318;
    --shadow: 0 12px 30px rgba(25, 33, 31, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

button,
.button {
    min-height: 42px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 700;
    padding: 0.62rem 0.9rem;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--accent-strong);
    text-decoration: none;
}

.button.small {
    min-height: 36px;
    padding: 0.45rem 0.75rem;
}

.button.ghost {
    background: transparent;
    border: 1px solid var(--line);
    color: var(--ink);
}

.topbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 0.85rem clamp(1rem, 3vw, 2rem);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand {
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 800;
}

.topbar nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.shell {
    margin: 0 auto;
    max-width: 1180px;
    padding: 1.4rem clamp(1rem, 3vw, 2rem) 3rem;
}

.flash {
    background: #e9f4ef;
    border-bottom: 1px solid #bdd9cf;
    color: #16463f;
    padding: 0.8rem clamp(1rem, 3vw, 2rem);
}

.page-head {
    align-items: end;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.page-head h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    line-height: 1.05;
    margin: 0 0 0.35rem;
}

.page-head p {
    color: var(--muted);
    margin: 0;
}

.filters,
.form-grid {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
    padding: 1rem;
}

.filters {
    grid-template-columns: minmax(220px, 1fr) minmax(170px, 0.45fr) minmax(150px, 0.35fr) auto auto;
}

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

label span {
    color: var(--muted);
    display: block;
    font-size: 0.87rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--ink);
    font: inherit;
    min-height: 42px;
    padding: 0.58rem 0.7rem;
    width: 100%;
}

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

.field-wide,
.form-actions {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.check {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    display: flex;
    gap: 0.6rem;
    min-height: 42px;
    padding: 0.58rem 0.7rem;
}

.check input {
    min-height: 0;
    width: auto;
}

.check span {
    margin: 0;
}

.item-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

.item-card,
.location-row,
.empty {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.item-card {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1rem;
}

.item-main {
    align-items: start;
    display: flex;
    gap: 0.8rem;
    justify-content: space-between;
}

.item-card h2,
.location-row h2,
.empty h2 {
    font-size: 1.12rem;
    line-height: 1.2;
    margin: 0 0 0.35rem;
}

.item-card p,
.location-row p,
.empty p {
    color: var(--muted);
    margin: 0;
}

.status {
    border-radius: 999px;
    flex: 0 0 auto;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 0.22rem 0.55rem;
}

.status-available {
    background: #dff1ea;
    color: #155247;
}

.status-loaned {
    background: #fff1d8;
    color: var(--warn);
}

.status-missing {
    background: #ffe0dc;
    color: var(--danger);
}

.status-archived {
    background: #eef0f2;
    color: #555f66;
}

.meta {
    display: grid;
    gap: 0.5rem;
    margin: 0;
}

.meta div {
    display: grid;
    gap: 0.25rem;
    grid-template-columns: 6.5rem 1fr;
}

.meta dt {
    color: var(--muted);
    font-weight: 700;
}

.meta dd {
    margin: 0;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 0.5rem;
}

.chips span {
    background: #eef2ed;
    border-radius: 999px;
    color: #3d4743;
    font-size: 0.82rem;
    padding: 0.2rem 0.55rem;
}

.actions {
    align-items: center;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 0.8rem;
    margin-top: auto;
    padding-top: 0.75rem;
}

.actions form {
    margin: 0;
}

.link-danger {
    background: transparent;
    color: var(--danger);
    font-weight: 700;
    min-height: 0;
    padding: 0;
}

.link-danger:hover {
    background: transparent;
    text-decoration: underline;
}

.location-list {
    display: grid;
    gap: 0.8rem;
}

.location-row {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 1rem;
}

.location-row span,
.location-side span {
    color: var(--muted);
}

.location-side {
    align-items: end;
    display: grid;
    gap: 0.15rem;
    min-width: 7rem;
    text-align: right;
}

.location-side form {
    margin: 0;
}

.location-side strong {
    font-size: 1.8rem;
    line-height: 1;
}

.empty {
    padding: 2rem;
}

.empty.error pre {
    background: #f4f4f4;
    border-radius: 7px;
    overflow: auto;
    padding: 1rem;
}

@media (max-width: 760px) {
    .topbar,
    .page-head,
    .location-row {
        align-items: stretch;
        flex-direction: column;
    }

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

    .location-side {
        align-items: start;
        text-align: left;
    }

    .meta div {
        grid-template-columns: 1fr;
    }
}
