:root {
    color-scheme: light;
    --bg: #f7f4ee;
    --ink: #17201c;
    --muted: #66706a;
    --line: #d8d3c8;
    --panel: #fffdf8;
    --accent: #256a5a;
    --accent-ink: #ffffff;
    --warn: #9f4d2e;
    --soft: #eaf1ec;
}

* {
    box-sizing: border-box;
}

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

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

button,
.button,
input,
select,
textarea {
    font: inherit;
}

button,
.button {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #ffffff;
    color: var(--ink);
    padding: 0 14px;
    cursor: pointer;
}

button:hover,
.button:hover {
    border-color: #9ca89f;
}

.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
}

.danger {
    border-color: var(--warn);
    color: var(--warn);
}

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    border-right: 1px solid var(--line);
    background: #eee9de;
    padding: 22px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 7px;
    background: var(--accent);
    color: white;
    font-size: 24px;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
    font-size: 13px;
}

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

.nav a {
    min-height: 40px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 14px;
}

.nav a.active {
    background: var(--soft);
    border-color: #abc3b6;
}

.nav-button {
    width: 100%;
    justify-content: flex-start;
    border: 1px solid var(--line);
    background: transparent;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.auth-card {
    display: grid;
    width: min(100%, 420px);
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--panel);
    padding: 28px;
}

.auth-form {
    display: grid;
    gap: 16px;
}

main {
    min-width: 0;
    padding: 28px;
}

.notice {
    margin-bottom: 16px;
    border: 1px solid #abc3b6;
    border-radius: 8px;
    background: var(--soft);
    padding: 12px 14px;
}

.notice.error {
    border-color: #c7a18e;
    background: #fff0e9;
}

.topbar {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 22px;
}

h1,
h2,
p {
    margin: 0;
}

h1 {
    font-size: 30px;
    line-height: 1.15;
}

h2 {
    font-size: 18px;
}

.muted,
.meta {
    color: var(--muted);
}

.meta {
    font-size: 13px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.summary-card,
.panel,
.item-card,
.batch-card,
.event-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

.summary-card {
    padding: 16px;
}

.summary-card span {
    color: var(--muted);
    font-size: 13px;
}

.summary-card strong {
    display: block;
    margin-top: 6px;
    font-size: 24px;
    line-height: 1.15;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 170px 150px 170px auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.toolbar-actions,
.button-row,
.batch-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

label {
    display: grid;
    gap: 6px;
}

label span,
.detail-cell span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    padding: 10px 11px;
}

textarea {
    resize: vertical;
}

.split,
.detail-layout {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.panel {
    padding: 16px;
}

.form-panel {
    margin-bottom: 16px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.count {
    color: var(--muted);
    font-size: 13px;
}

.item-list,
.batch-list,
.event-list {
    display: grid;
    gap: 10px;
}

.item-card,
.batch-card,
.event-row {
    padding: 13px;
}

.row,
.event-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    padding: 4px 8px;
    color: var(--muted);
    font-size: 12px;
}

.batch-actions,
.button-row {
    margin-top: 12px;
}

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

.wide {
    grid-column: 1 / -1;
}

.detail-cell {
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 10px;
}

.detail-cell strong {
    display: block;
    margin-top: 3px;
}

.action-grid {
    margin-top: 16px;
}

.action-grid form,
.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}

.label-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.label {
    display: grid;
    width: 180px;
    align-content: start;
    justify-items: center;
    gap: 7px;
    border: 1px dashed #777;
    border-radius: 4px;
    background: white;
    padding: 12px;
    color: #000;
    text-align: center;
}

.label-name {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.1;
}

.label-value {
    font-size: 16px;
    line-height: 1.1;
}

.qr-code {
    display: grid;
    width: 116px;
    height: 116px;
    place-items: center;
}

.qr-code svg {
    display: block;
    width: 116px;
    height: 116px;
}

.label-code {
    font-size: 14px;
    font-weight: 800;
}

.label-download-status {
    margin-top: 7px;
    font-size: 13px;
}

.empty {
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    padding: 24px;
    text-align: center;
}

nav[role="navigation"] {
    margin-top: 14px;
}

nav[role="navigation"] > div:first-child {
    display: none;
}

nav[role="navigation"] > div:last-child {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}

nav[role="navigation"] a,
nav[role="navigation"] span {
    display: inline-flex;
    min-height: 36px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    padding: 0 10px;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        align-content: start;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 2;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 14px;
    }

    .brand {
        margin-bottom: 12px;
    }

    .nav {
        display: flex;
        overflow-x: auto;
    }

    .nav a {
        white-space: nowrap;
    }

    main {
        padding: 18px;
    }

    .summary-grid,
    .toolbar,
    .split,
    .detail-layout,
    .form-grid,
    .detail-grid,
    .action-grid,
    .action-grid form,
    .inline-form {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
    }
}

@media print {
    body {
        background: white;
    }

    .sidebar,
    .label-actions,
    .topbar,
    .notice,
    .panel:not(:has(.label)),
    .detail-layout > .panel:first-child {
        display: none !important;
    }

    .app-shell,
    main {
        display: block;
        min-height: auto;
        padding: 0;
    }

    .label-grid {
        grid-template-columns: repeat(3, 180px);
        gap: 8mm;
    }
}
