:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #627083;
    --line: #d9e0e8;
    --panel: #ffffff;
    --bg: #f4f7f9;
    --accent: #146c94;
    --accent-dark: #0f526f;
    --good: #13795b;
    --warn: #9a5b00;
    --bad: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
}

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

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 24px;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 24px;
}

.brand {
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.nav a {
    border-radius: 6px;
    color: var(--ink);
    padding: 10px 12px;
}

.nav a:hover {
    background: #eef4f7;
}

.shell {
    margin: 0 auto;
    max-width: 1180px;
    padding: 28px 20px 48px;
}

.page-head {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 20px;
}

h1 {
    font-size: 30px;
    letter-spacing: 0;
    margin: 0;
}

h2 {
    font-size: 20px;
    margin: 0 0 16px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
}

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

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

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

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

.products-flow {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
    align-items: start;
}

.products-flow > .panel:first-child {
    max-height: calc(100vh - 92px);
    overflow: auto;
    position: sticky;
    top: 82px;
}

.product-entry-grid {
    align-items: start;
}

.field {
    display: grid;
    gap: 7px;
    margin-bottom: 14px;
}

label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid #bcc8d4;
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
    min-height: 46px;
    padding: 10px 12px;
    width: 100%;
}

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

input[type="checkbox"] {
    min-height: auto;
    padding: 0;
    width: auto;
}

input.scan {
    font-size: 24px;
    min-height: 66px;
}

.barcode-camera-input {
    align-items: stretch;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.camera-scan-button {
    align-items: center;
    gap: 7px;
    justify-content: center;
    min-width: 116px;
}

.barcode-camera-panel {
    background: #101820;
    border: 1px solid #2e3d4c;
    border-radius: 8px;
    color: #fff;
    grid-column: 1 / -1;
    margin-bottom: 14px;
    overflow: hidden;
    padding: 12px;
}

.barcode-camera-head {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 10px;
}

.barcode-camera-head p {
    color: #c6d0da;
    margin: 5px 0 0;
}

.barcode-camera-reader {
    background: #000;
    border-radius: 6px;
    min-height: 220px;
    overflow: hidden;
}

.barcode-camera-reader video {
    max-height: 62vh;
    object-fit: cover;
}

input.short-number {
    max-width: 140px;
}

.button,
button {
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    min-height: 44px;
    padding: 11px 16px;
}

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

.button.compact,
button.compact {
    min-height: 34px;
    padding: 7px 10px;
}

.button.secondary {
    background: #e9eef2;
    color: var(--ink);
}

.button.secondary:hover {
    background: #dce5eb;
}

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

button.danger:hover,
.button.danger:hover {
    background: #8f1c14;
}

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.catalog-quick-add {
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 18px;
    padding: 16px;
}

.catalog-quick-add-head {
    align-items: flex-start;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.catalog-quick-add-head p {
    margin: 4px 0 0;
}

.checkbox-list {
    border: 1px solid var(--line);
    border-radius: 6px;
    display: grid;
    gap: 8px;
    max-height: 220px;
    overflow: auto;
    padding: 12px;
}

.checkbox-list label {
    align-items: center;
    color: var(--ink);
    display: flex;
    font-size: 15px;
    font-weight: 400;
    gap: 8px;
}

.table-wrap {
    overflow-x: auto;
}

.product-table-wrap {
    overflow-x: visible;
}

.product-table-wrap table {
    table-layout: fixed;
}

.product-table-wrap th,
.product-table-wrap td {
    padding: 12px 8px;
    word-break: break-word;
}

.product-table-wrap th:nth-child(1) {
    width: 22%;
}

.product-table-wrap th:nth-child(2) {
    width: 11%;
}

.product-table-wrap th:nth-child(3) {
    width: 16%;
}

.product-table-wrap th:nth-child(4),
.product-table-wrap th:nth-child(5) {
    width: 11%;
}

.product-table-wrap th:nth-child(6) {
    width: 17%;
}

.product-table-wrap th:nth-child(7) {
    width: 12%;
}

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

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

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.metric {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.metric strong {
    display: block;
    font-size: 28px;
    margin-top: 8px;
}

.metrics-row,
.report-section {
    margin-top: 18px;
}

.loop-order-import {
    margin-bottom: 18px;
}

.loop-order-import summary {
    cursor: pointer;
    font-size: 18px;
}

.loop-order-import[open] summary {
    margin-bottom: 12px;
}

.loop-order-checklist {
    max-height: 440px;
}

.par-checklist-head {
    align-items: flex-start;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 18px;
}

.par-checklist-head h2 {
    margin-bottom: 4px;
}

.par-checklist-head p {
    font-size: 14px;
    margin: 0;
}

.par-checklist-head > strong {
    background: #eef4f7;
    border-radius: 999px;
    flex: 0 0 auto;
    padding: 6px 10px;
}

.par-checklist {
    display: grid;
    gap: 8px;
    list-style: none;
    margin: 14px 0 0;
    max-height: 360px;
    overflow-y: auto;
    padding: 0 4px 0 0;
}

.par-checklist li {
    align-items: flex-start;
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex;
    gap: 10px;
    padding: 10px;
}

.par-checklist li.complete {
    background: #e9f7f1;
    color: var(--good);
}

.par-checklist li.js-par-product,
.par-checklist li.js-beer-par-product {
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.par-checklist li.js-par-product:hover,
.par-checklist li.js-par-product:focus-visible,
.par-checklist li.js-beer-par-product:hover,
.par-checklist li.js-beer-par-product:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(18, 91, 135, 0.16);
    outline: none;
}

.par-checkmark {
    border: 2px solid #9aa8b5;
    border-radius: 50%;
    display: grid;
    flex: 0 0 22px;
    font-size: 14px;
    font-weight: 700;
    height: 22px;
    place-items: center;
    width: 22px;
}

.par-checklist li.complete .par-checkmark {
    background: var(--good);
    border-color: var(--good);
    color: #fff;
}

.par-checklist-product {
    display: grid;
    gap: 3px;
}

.par-checklist-product > span {
    color: var(--muted);
    font-size: 13px;
}

.par-checklist li.complete .par-checklist-product strong {
    text-decoration: line-through;
}

.par-checklist-empty {
    margin-bottom: 0;
}

.checklist-group-title {
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0.04em;
    margin: 16px 0 8px;
    text-transform: uppercase;
}

.checklist-group-title + .par-checklist {
    margin-top: 0;
}

.beer-count-grid {
    align-items: end;
}

.beer-barcode-field {
    max-width: 720px;
}

.beer-picker-instruction {
    margin: 18px 0 10px;
}

.beer-product-picker {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 360px;
    overflow-y: auto;
    padding: 2px;
}

button.beer-product-choice {
    align-items: flex-start;
    background: #f7fafc;
    border: 1px solid var(--line);
    color: var(--ink);
    display: grid;
    gap: 4px;
    justify-content: stretch;
    min-height: 88px;
    padding: 12px;
    text-align: left;
}

button.beer-product-choice:hover {
    background: #eef7fb;
    border-color: var(--accent);
}

button.beer-product-choice.selected {
    background: #e6f4fa;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.beer-product-choice span,
.beer-product-choice small {
    color: var(--muted);
    font-weight: 400;
}

.beer-inventory-entry {
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 16px;
    padding: 16px;
}

.beer-inventory-entry h3 {
    margin: 0 0 14px;
}

.product-image-preview {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    height: 150px;
    margin-top: 8px;
    object-fit: contain;
    width: 150px;
}

.product-thumbnail {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 5px;
    float: left;
    height: 46px;
    margin-right: 8px;
    object-fit: contain;
    width: 38px;
}

.catalog-match-card {
    background: #eef7fb;
    border: 1px solid #b9d8e7;
    border-radius: 7px;
    display: grid;
    gap: 6px;
    margin-bottom: 16px;
    padding: 12px;
}

.metric strong.metric-date {
    font-size: 16px;
    line-height: 1.35;
}

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

.session-card {
    align-items: center;
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 7px;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 12px;
}

.session-card > div {
    display: grid;
    gap: 4px;
}

.session-card .button {
    flex: 0 0 auto;
}

.lookup-preview {
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 14px;
}

.inventory-product-image {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    float: right;
    height: 100px;
    margin: 0 0 8px 12px;
    object-fit: contain;
    width: 80px;
}

.session-count-notice {
    background: #fff4db;
    border: 1px solid #e3bd69;
    border-radius: 6px;
    color: var(--warn);
    font-weight: 700;
    margin: 12px 0;
    padding: 10px 12px;
}

.quick-full {
    align-items: end;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(90px, 130px) auto;
    margin-top: 12px;
}

.quick-full label {
    grid-column: 1 / -1;
}

.count-entry-panel {
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 16px;
    padding: 16px;
}

.count-entry-fields {
    margin-top: 12px;
}

.count-entry-panel .field {
    margin-top: 0;
}

.scale-status {
    background: #f7fafc;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    margin-top: 12px;
    padding: 10px 12px;
}

.scale-status.ok {
    background: #e9f7f1;
    color: var(--good);
}

.scale-status.warn {
    background: #fff4db;
    color: var(--warn);
}

.auto-count-status {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    margin-top: 8px;
    padding: 10px 12px;
}

.auto-count-status.detecting {
    background: #fff4db;
    border-color: #e3bd69;
    color: var(--warn);
    font-weight: 700;
}

.auto-count-status.confirmed {
    background: #e9f7f1;
    border-color: #8fcbb5;
    color: var(--good);
    font-weight: 700;
}

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

.positive {
    color: var(--good);
    font-weight: 700;
}

.negative {
    color: var(--bad);
    font-weight: 700;
}

.flash {
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.flash.success {
    background: #e9f7f1;
    color: var(--good);
}

.flash.error {
    background: #fdecec;
    color: var(--bad);
}

.status {
    border-radius: 999px;
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 9px;
}

.status.open {
    background: #fff4db;
    color: var(--warn);
}

.status.completed {
    background: #e5f5ee;
    color: var(--good);
}

.status.failed {
    background: #fee2e2;
    color: #991b1b;
}

.status.draft {
    background: #fff4db;
    color: var(--warn);
}

@media (max-width: 1080px) {
    .products-flow {
        grid-template-columns: 1fr;
    }

    .products-flow > .panel:first-child {
        max-height: none;
        overflow: visible;
        position: static;
    }
}

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

    .grid.two,
    .grid.three,
    .grid.four {
        grid-template-columns: 1fr;
    }

    .beer-product-picker {
        grid-template-columns: 1fr;
        max-height: 420px;
    }

    .shell {
        padding: 18px 12px 36px;
    }

    .product-table-wrap {
        overflow-x: auto;
    }

    .product-table-wrap table {
        table-layout: auto;
    }

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

    .session-card .button {
        justify-content: center;
    }

    .barcode-camera-input {
        grid-template-columns: 1fr;
    }

    .camera-scan-button {
        min-height: 52px;
        width: 100%;
    }

    .barcode-camera-head {
        align-items: stretch;
        flex-direction: column;
    }
}
