:root {
    color-scheme: dark;
    font: 16px/1.5 system-ui, sans-serif;
    background: #101721;
    color: #eef4fa;
    --panel: #1a2532;
    --line: #364759;
    --muted: #b4c3d3;
    --accent: #73e5c4;
}
* { box-sizing: border-box; }
body, h1, h2 { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.shell { max-width: 1180px; margin: auto; padding: 22px; }
header { background: #141d29; border-bottom: 1px solid var(--line); }
.top { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { color: inherit; text-decoration: none; font-weight: 750; font-size: 1.25rem; }
.brand span { color: #09251d; background: var(--accent); border-radius: 6px; padding: 3px 6px; }
nav { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
nav a { color: var(--muted); text-decoration: none; padding: 7px 10px; border-radius: 7px; }
nav a[aria-current] { background: #294354; color: #fff; }
h1 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; margin: 12px 0; }
h2 { font-size: 1.25rem; margin-bottom: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 17px; margin-bottom: 14px; min-width: 0; }
.narrow, .login { max-width: 620px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats strong { display: block; color: var(--accent); font-size: 1.65rem; }
.muted, small, label { color: var(--muted); }
small { display: block; font-size: .88rem; }
label { display: block; min-width: 0; }
input, button, .button { font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; color: inherit; }
input:not([type=checkbox]) { display: block; width: 100%; background: #111a25; margin-top: 4px; }
input[type=checkbox] { accent-color: var(--accent); }
button, .button { background: #263749; cursor: pointer; text-decoration: none; }
.primary { background: var(--accent); color: #112922; font-weight: 750; justify-self: start; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.form { display: grid; gap: 11px; }
.form p { margin: 0; }
.notice { color: var(--accent); }
.notice.error { color: #ffb6ab; }
.notice:empty { margin: 0 0 20px; }
.movement { display: grid; gap: 12px; align-items: end; grid-template-columns: 1fr 1fr auto; }
.scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
th { color: var(--muted); }
td .code { overflow-wrap: anywhere; text-align: left; }
.tag { background: #25473e; color: #a9f2da; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.tag.out { background: #503c2b; color: #ffe0aa; }
summary { cursor: pointer; font-weight: 650; }
.calendar-head { display: flex; justify-content: space-between; align-items: center; gap: 5px; margin-bottom: 12px; }
.calendar-head h2 { margin: 0; text-align: center; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.weekday { text-align: center; color: var(--muted); }
.day { display: flex; flex-direction: column; min-height: 60px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; color: inherit; text-decoration: none; }
.day span { color: var(--accent); font-size: .88rem; }
.day.has-bookings { background: #203d3d; }
.day[aria-current] { border-color: var(--accent); }
.booking-columns, .dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0; max-height: 245px; overflow: auto; min-width: 0; }
.choice { display: flex; align-items: baseline; gap: 8px; padding: 4px; overflow-wrap: anywhere; }
.booking-list { list-style: none; padding: 0; margin: 0; }
.booking-list li { padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.cancel { margin-top: 6px; }
dialog { width: min(94vw, 480px); border: 1px solid var(--line); border-radius: 12px; text-align: center; }
dialog canvas { max-width: 100%; display: block; margin: auto; image-rendering: pixelated; }
dialog p { overflow-wrap: anywhere; }
dialog .actions { justify-content: center; }
@media (max-width: 790px) {
    .movement, .booking-columns { grid-template-columns: 1fr; }
    .day-word { display: none; }
}
@media (max-width: 500px) {
    .shell { padding: 12px; }
    .panel { padding: 10px; }
    .top { gap: 10px; }
    nav { flex-basis: 100%; order: 2; }
    .dates { grid-template-columns: 1fr; }
    .day { min-height: 46px; }
}
@media print {
    body > * { display: none; }
    #label[open] { display: block; position: absolute; inset: 0 auto auto 0; color: black; background: white; border: 0; width: auto; }
    #label::backdrop, #label .actions { display: none; }
}

.photo-fields { display: grid; gap: 10px; max-height: none; }
.product-photo { display: block; max-width: 100%; width: 220px; max-height: 180px; object-fit: contain; object-position: center; border-radius: 8px; background: #111a25; }
.scan-result { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }

.product-name { padding: 2px 0; border: 0; background: transparent; color: var(--accent); text-align: left; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }

.inventory-controls { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 16px; }
.inventory-controls select { display: block; width: 100%; margin-top: 4px; appearance: none; font: inherit; color: inherit; background: #111a25 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 6 5 5 5-5' fill='none' stroke='%23b4c3d3' stroke-width='1.5'/%3E%3C/svg%3E") right 10px center / 16px no-repeat; border: 1px solid var(--line); border-radius: 8px; padding: 8px 34px 8px 11px; }
.warehouse-group + .warehouse-group { margin-top: 20px; }
.warehouse-group h3 { margin: 0 0 8px; }
.warehouse-group h3 small { display: inline-block; margin-left: 5px; font-weight: normal; }
@media (max-width: 700px) {
    .inventory-controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .inventory-controls label:first-child { grid-column: 1 / -1; }
}

.type-sort { border: 0; border-radius: 0; padding: 0; color: inherit; background: transparent; font-weight: inherit; text-decoration: underline; text-underline-offset: 3px; }
.inventory-type-heading td { color: var(--accent); background: #223442; font-weight: 700; }

#label { width: min(96vw, 840px); }
.last-added { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.last-added h2 { margin-bottom: 4px; }

#inventory .code, #label-code {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}
#label #barcode { background: white; margin: 0 auto; }
#label-code { margin: 4px 0 12px; text-align: center; line-height: 1.2; }
#label-name { margin-bottom: 6px; }
@media print {
    #label[open] { max-width: 100%; margin: 0; padding: 2mm; }
    #label-name { font-size: 10pt; }
    #label-code { margin-bottom: 0; font-size: 9pt; }
}

.inventory-picker { position: relative; min-width: 0; }
.inventory-picker-input { position: relative; }
.inventory-picker-input input { padding-right: 44px; }
#inventory-search-toggle { position: absolute; inset: 0 0 0 auto; width: 40px; border: 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 6 5 5 5-5' fill='none' stroke='%23b4c3d3' stroke-width='1.5'/%3E%3C/svg%3E") center / 16px no-repeat; }
#inventory-suggestions { position: absolute; z-index: 3; inset: 100% 0 auto; max-height: 16rem; overflow: auto; margin: 4px 0 0; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; list-style: none; }
#inventory-suggestions li { padding: 6px 9px; border-radius: 4px; cursor: pointer; overflow-wrap: anywhere; }
#inventory-suggestions li:is(:hover, [aria-selected=true]) { background: #294354; color: white; }
@media (max-width: 700px) { .inventory-picker { grid-column: 1 / -1; } }

.inventory-type-heading td { padding: 0; }
.inventory-type-toggle { display: flex; align-items: center; gap: 9px; width: 100%; padding: 10px 12px; background: transparent; border: 0; border-radius: 0; text-align: left; font-weight: 700; }
.inventory-type-toggle::before { content: ""; flex: 0 0 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.inventory-type-toggle[aria-expanded=true]::before { transform: rotate(45deg); }
.inventory-type-toggle small { margin-left: auto; font-weight: 500; }

.detail-actions { margin-bottom: 14px; }
.detail-product { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
.detail-photo { display: block; width: 100%; max-height: 420px; object-fit: contain; border-radius: 8px; background: #111a25; }
.detail-fields { display: grid; grid-template-columns: minmax(105px, 1fr) minmax(0, 2fr); gap: 8px 14px; margin: 0; }
.detail-fields dt { color: var(--muted); }
.detail-fields dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.catalog-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: none; }
.catalog-editor p { grid-column: 1 / -1; margin: 0; }
.catalog-editor textarea, .catalog-editor select { display: block; width: 100%; margin-top: 4px; background: #111a25; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; }
@media (max-width: 550px) { .detail-product, .catalog-editor { grid-template-columns: 1fr; } }

#edit-popup { width: min(94vw, 820px); max-width: 100%; padding: 0; text-align: left; }
#edit-popup::backdrop { background: rgb(5 10 18 / 72%); }
.edit-popup-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.edit-popup-header h2 { margin: 0; }
#edit-popup-frame { display: block; width: 100%; height: min(75dvh, 760px); border: 0; }
.edit-frame-page main { padding: 14px; }
.edit-frame-page main > h1 { font-size: 1.25rem; }
.edit-frame-page .narrow { max-width: none; }

.inline-product-fields { display: block; min-width: 0; max-height: none; overflow: visible; border: 0; padding: 0; }
.inline-photo-fields { margin-top: 12px; }
.inline-product-fields .detail-fields input { margin-top: 0; }
.inline-product-fields .detail-fields select, .inline-product-fields .detail-fields textarea {
    display: block; width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #111a25; color: inherit; font: inherit;
}
.inline-product-fields .detail-fields .scan { margin-top: 5px; }

.inline-product-fields .detail-fields dd { white-space: normal; }
.inline-product-fields .detail-fields dd > [data-inline-read] { white-space: pre-wrap; }

.user-permissions { max-height: none; }
.user-account { border-top: 1px solid var(--line); padding-block: 12px; }
.user-account .form { padding-top: 12px; }

.project-calendar-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.project-products { margin: 8px 0; padding-left: 20px; }
.project-list .project-products li { border-top: 0; padding: 3px 0; }
.project-products small { display: inline; }
.project-list summary .tag { margin-left: 6px; font-size: .85rem; }

.project-scan { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.project-scan label { flex: 1 1 260px; }
.project-scan .actions { margin: 0; }
#project-scan-status.error { color: #ffb6ab; }

.project-columns { display: grid; grid-template-columns: minmax(270px, 320px) minmax(0, 1fr); gap: 16px; align-items: start; }
.project-sidebar .calendar-head { flex-wrap: wrap; }
.project-sidebar .calendar-head strong { text-align: center; }
@media (max-width: 860px) { .project-columns { grid-template-columns: 1fr; gap: 0; } }

.picking-actions { margin-bottom: 14px; }
.picking-location { margin: 18px 0; }
.picking-location h3 { margin: 0 0 5px; }
.picking-checkbox { display: inline-block; vertical-align: middle; width: 14px; height: 14px; border: 1px solid currentColor; }
.picking-code { font-family: ui-monospace, Menlo, Consolas, monospace; }
.picking-signoff { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 20px; }

@page picking { size: A4; margin: 12mm; }
@media print {
    body.picking-page { page: picking; color-scheme: light; color: #000; background: #fff; font-size: 10pt; }
    body.picking-page > main { display: block; padding: 0; max-width: none; }
    .picking-page .picking-actions, .picking-page #notice { display: none; }
    .picking-page h1 { font-size: 18pt; margin-top: 0; }
    .picking-page .picking-sheet { margin: 0; padding: 0; background: #fff; border: 0; }
    .picking-page .picking-location h3 { break-after: avoid; }
    .picking-page table { table-layout: auto; }
    .picking-page thead { display: table-header-group; }
    .picking-page tr, .picking-page .picking-signoff { break-inside: avoid; }
    .picking-page th, .picking-page td { padding: 4px 6px; border-color: #999; color: #000; }
}

.project-summary-period { margin-top: 3px; font-weight: 400; }
.project-sidebar .project-list details[open] > summary { margin-bottom: 8px; }

.issue-recipient { min-width: 0; }
.issue-recipient select {
    display: block; width: 100%; margin-top: 4px; padding: 8px 11px;
    background: #111a25; color: inherit; border: 1px solid var(--line); border-radius: 8px; font: inherit;
}
.issue-recipient label + label { margin-top: 8px; }

.inventory-quantity { text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.inventory-unit-toggle { display: inline-flex; gap: 8px; align-items: center; background: transparent; padding: 2px 0; border: 0; text-align: left; color: var(--accent); font-weight: 700; overflow-wrap: anywhere; }
.inventory-unit-toggle::before { content: ""; flex: 0 0 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.inventory-unit-toggle[aria-expanded=true]::before { transform: rotate(45deg); }
.inventory-unit-details > td { padding: 8px 12px 12px 24px; background: #141f2b; }

.quote-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(140px, .7fr); gap: 12px; }
#quote-form textarea, .quote-editor-table select {
    display: block; width: 100%; background: #111a25; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit;
}
.quote-editor-table { min-width: 700px; }
.quote-editor-table td:first-child { width: 48%; }
.quote-editor-table input, .quote-editor-table select { margin: 0; }
.quote-number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.quote-row-actions { justify-content: space-between; }
.quote-sheet .detail-fields { margin: 12px 0 20px; }
.quote-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 740px) { .quote-meta { grid-template-columns: 1fr; } }

.quote-import, .quote-calculation { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.quote-import label { flex: 1 1 260px; }
.quote-import select { display: block; width: 100%; margin-top: 4px; background: #111a25; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: inherit; }
.quote-calculation { justify-content: flex-end; text-align: right; }
.quote-calculation input { max-width: 180px; }
.quote-calculation > div { min-width: 160px; }
.quote-row-actions { justify-content: flex-start; }

.quote-recipient-search { position: relative; min-width: 0; }
.quote-recipient-search .choice { margin-top: 4px; padding-left: 0; }
.recipient-results { position: absolute; z-index: 4; left: 0; right: 0; top: 62px; max-height: 15rem; overflow: auto; margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.recipient-results button { width: 100%; background: transparent; border: 0; padding: 7px; text-align: left; }
.recipient-results button:is(:hover, :focus-visible) { background: #294354; }
.quote-recipient-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-height: none; }
@media (max-width: 610px) { .quote-recipient-details { grid-template-columns: 1fr; } }
