:root {
    --bg: #f3efe2;
    --panel: #fffdf8;
    --ink: #13293d;
    --muted: #4a6178;
    --accent: #bb3e03;
    --accent-soft: #ffd9c9;
    --ok: #2a9d8f;
    --warn: #e76f51;
    --line: #d8cdb9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: radial-gradient(circle at 85% 15%, #f7d7b5 0%, transparent 35%), linear-gradient(135deg, #f5f2e9 0%, #e8f0f7 55%, #f1eadf 100%);
    font-family: "Trebuchet MS", "Gill Sans", sans-serif;
    min-height: 100vh;
}

.bg-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(45deg, transparent, transparent 18px, rgba(255, 255, 255, 0.2) 18px, rgba(255, 255, 255, 0.2) 36px);
    opacity: 0.3;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: rgba(19, 41, 61, 0.94);
    color: #fff;
    border-bottom: 4px solid #f4a261;
}

.topbar h1 {
    margin: 0;
    letter-spacing: 0.6px;
}

.topbar p {
    margin: 4px 0 0;
    color: #d8e4ef;
}

.logout-btn {
    background: #f4a261;
    color: #1c2e40;
    padding: 10px 14px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
}

.layout {
    display: grid;
    grid-template-columns: 390px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 10px 20px rgba(40, 52, 63, 0.08);
    overflow: hidden;
}

.setup-panel {
    padding: 14px;
}

.setup-panel h2,
.setup-panel h3 {
    margin: 10px 0;
}

label {
    display: block;
    margin-top: 10px;
    font-size: 0.92rem;
    color: var(--muted);
}

input[type="text"],
input[type="date"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #b8c2cc;
    border-radius: 10px;
    background: #fff;
}

.inline-checkbox {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--ink);
}

.actions-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

button {
    border: 0;
    border-radius: 10px;
    background: #264653;
    color: #fff;
    padding: 10px 12px;
    font-weight: 700;
    cursor: pointer;
}

button.accent {
    background: var(--accent);
}

.status-msg {
    min-height: 18px;
    margin-top: 12px;
    color: var(--muted);
}

.records-wrap {
    max-height: 48vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-top: 8px;
}

.records-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.records-table th,
.records-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #ebe1d0;
    text-align: left;
    vertical-align: top;
}

.table-btn {
    margin-bottom: 4px;
    width: 100%;
    font-size: 0.78rem;
    padding: 6px;
}

.table-btn.danger {
    background: #b3261e;
}

.checklist-panel {
    display: flex;
    flex-direction: column;
    min-height: 82vh;
}

.section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: #f8f3e6;
}

.section-tab {
    background: #7f5539;
}

.section-tab.active {
    background: #f4a261;
    color: #1f2933;
}

.section-panels {
    flex: 1;
    overflow: auto;
}

.section-panel {
    display: none;
    padding: 10px;
}

.section-panel.active {
    display: block;
    animation: fadeIn 220ms ease;
}

.subsection-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.subsection-tab {
    background: #8d99ae;
}

.subsection-tab.active {
    background: #2a9d8f;
}

.subsection-panel {
    display: none;
}

.subsection-panel.active {
    display: block;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
}

.items-table th,
.items-table td {
    border-bottom: 1px solid #efe7d7;
    padding: 8px;
    text-align: left;
}

.par-state-btn {
    min-width: 80px;
    text-align: center;
    transition: transform 140ms ease, background 160ms ease;
}

.par-state-btn:active {
    transform: scale(0.98);
}

.par-state-btn.state-unchecked {
    background: #6c757d;
}

.par-state-btn.state-at_par {
    background: var(--ok);
}

.par-state-btn.state-below_par {
    background: var(--warn);
}

.instock-input,
.exp-input {
    width: 130px;
}

.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.login-wrap {
    width: min(430px, 92vw);
}

.login-card {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fffdf8;
    padding: 20px;
    box-shadow: 0 18px 32px rgba(38, 70, 83, 0.14);
}

.login-card h1 {
    margin: 0;
}

.login-form {
    margin-top: 16px;
}

.login-form button {
    margin-top: 12px;
    width: 100%;
}

.error-msg {
    color: #b3261e;
    font-weight: 700;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 980px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .checklist-panel {
        min-height: 60vh;
    }

    .instock-input,
    .exp-input {
        width: 100%;
    }
}
