/*
 * Head Office components. Every colour, font and size comes from tokens.css.
 * Components: app bar, page header, panel, stat, table, form/field, button, badge, notice, filters.
 */

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-ui);
    font-size: var(--text-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1 { font-size: var(--text-xl); font-weight: var(--weight-bold); line-height: 1.25; margin: 0; }
h2 { font-size: var(--text-lg); font-weight: var(--weight-bold); line-height: 1.3; margin: 0 0 var(--space-2); }
p { margin: 0 0 var(--space-2); }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); font-size: 0.93em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-text-muted); }
.hint { color: var(--color-text-muted); font-size: var(--text-sm); }

/* ---------- Shell: left sidebar, top bar with search ---------- */
:root { --sidebar-width: 232px; }
.brand { font-weight: var(--weight-bold); color: var(--color-text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand span { color: var(--color-text-muted); font-weight: var(--weight-medium); }

.sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-width); z-index: 30;
    background: var(--color-surface); border-right: 1px solid var(--color-border);
    overflow-y: auto; padding: var(--space-2) var(--space-1) var(--space-4);
}
.sidebar > .brand { display: block; padding: var(--space-half) var(--space-1) var(--space-2); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
    display: block; color: var(--color-text-muted); font-weight: var(--weight-medium);
    padding: 6px var(--space-1) 6px var(--space-2); border-radius: var(--radius); font-size: var(--text-sm);
}
.side-link:hover { background: var(--color-surface-muted); color: var(--color-text); text-decoration: none; }
.side-link.active { background: var(--color-primary-tint); color: var(--color-primary); font-weight: var(--weight-bold); }
.side-nav > .side-link { padding-left: var(--space-1); font-size: var(--text-md); }
.side-group { margin-top: var(--space-1); }
.side-group summary {
    list-style: none; cursor: pointer; user-select: none;
    padding: var(--space-half) var(--space-1); font-size: var(--text-xs); font-weight: var(--weight-bold);
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted);
    display: flex; justify-content: space-between; align-items: center; border-radius: var(--radius);
}
.side-group summary::-webkit-details-marker { display: none; }
.side-group summary::after { content: "▾"; font-size: 11px; transition: transform 0.15s; }
.side-group:not([open]) summary::after { transform: rotate(-90deg); }
.side-group summary:hover { background: var(--color-surface-muted); color: var(--color-text); }

.shell.with-sidebar { margin-left: var(--sidebar-width); }
.topbar { background: var(--color-surface); border-bottom: 1px solid var(--color-border); position: sticky; top: 0; z-index: 20; }
.topbar-inner {
    max-width: var(--page-width); margin: 0 auto; padding: 0 var(--space-2); min-height: 56px;
    display: flex; align-items: center; gap: var(--space-2);
}
.topbar-brand { display: none; }
.global-search { flex: 1; max-width: 520px; }
.global-search input { width: 100%; height: var(--control-height-small); }
.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.hamburger { display: none; width: 40px; height: 40px; border-radius: var(--radius); cursor: pointer; flex-direction: column; justify-content: center; align-items: center; gap: 5px; }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--color-text); border-radius: 1px; }
.hamburger:hover { background: var(--color-surface-muted); }
.nav-scrim { display: none; }

@media (max-width: 900px) {
    .shell.with-sidebar { margin-left: 0; }
    .sidebar { transform: translateX(-100%); transition: transform 0.2s; box-shadow: none; }
    .nav-toggle:checked ~ .sidebar { transform: none; }
    .nav-toggle:checked ~ .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 25; }
    .hamburger { display: inline-flex; flex-shrink: 0; }
    .topbar-brand { display: inline; }
    .topbar-inner { flex-wrap: wrap; gap: var(--space-1); padding-top: var(--space-1); padding-bottom: var(--space-1); }
    .global-search { order: 10; flex-basis: 100%; max-width: none; }
}

/* ---------- Page ---------- */
main { max-width: var(--page-width); margin: 0 auto; padding: var(--space-3) var(--space-2) var(--space-6); }

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}
.back-link { display: inline-block; font-size: var(--text-sm); margin-bottom: var(--space-half); }
.page-lede { margin: var(--space-half) 0 0; color: var(--color-text-muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); }

/* ---------- Panel ---------- */
.panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    min-width: 0;
}
.panel > :last-child { margin-bottom: 0; }
.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}
.panel-head h2 { margin: 0; }
.panel.flush { padding: 0; }
.panel.flush .panel-head { padding: var(--space-2) var(--space-3) 0; }
.panel.flush .panel-empty { padding: var(--space-3); margin: 0; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}
.grid .panel { margin-bottom: 0; }
.grid .panel.wide { grid-column: 1 / -1; }

/* ---------- Stat ---------- */
.stat-label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-muted); margin: 0 0 var(--space-half); }
.stat-value { font-size: var(--text-2xl); font-weight: var(--weight-bold); line-height: 1.2; margin: 0; font-variant-numeric: tabular-nums; }
.stat-note { font-size: var(--text-sm); color: var(--color-text-muted); margin: var(--space-1) 0 0; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
th {
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
    white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
th.num, td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th.center, td.center { text-align: center; }
td.nowrap { white-space: nowrap; }
tr.inactive td { color: var(--color-text-muted); }
tr.group-row th { background: var(--color-bg); color: var(--color-text); }
.cell-sub { display: block; color: var(--color-text-muted); font-size: var(--text-sm); }
.table-foot { padding: var(--space-1) 12px 0; }
.panel.flush .table-foot { padding: var(--space-1) var(--space-3) var(--space-2); }

/* Definition lists (facts) */
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); margin: 0; }
dl.facts dt { color: var(--color-text-muted); font-weight: var(--weight-medium); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

pre.exception {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-1);
    margin: var(--space-1) 0 0;
    max-height: 18rem;
    overflow-y: auto;
}

ul.plain { margin: 0; padding-left: var(--space-3); }
ul.plain li { margin: var(--space-half) 0; }

/* ---------- Button ---------- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--control-height);
    padding: 0 var(--space-2);
    font-family: var(--font-ui);
    font-size: var(--text-md);
    font-weight: var(--weight-bold);
    line-height: 1;
    white-space: nowrap;
    color: var(--color-on-primary);
    background: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
}
.button:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); text-decoration: none; }
.button.secondary { color: var(--color-text); background: var(--color-surface); border-color: var(--color-border-strong); }
.button.secondary:hover { background: var(--color-surface-muted); }
.button.danger { color: var(--color-on-danger); background: var(--color-danger); border-color: var(--color-danger); }
.button.danger:hover { background: var(--color-danger-hover); border-color: var(--color-danger-hover); }
.button.small { height: var(--control-height-small); padding: 0 12px; font-size: var(--text-sm); }
.button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-focus-ring); }
.button:disabled, .button[disabled] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.inline-form { display: inline; margin: 0; }

/* ---------- Form ---------- */
.form, .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); }
/* .form-grid / .form-row: the same as .form / .field (older pages use these names). */
.form-row { display: flex; flex-direction: column; gap: var(--space-half); min-width: 0; }
.form-row.full, .form-grid > .form-actions, .form-grid > h3, .form-grid > p { grid-column: 1 / -1; }
.form-row > label { font-size: var(--text-sm); font-weight: var(--weight-bold); }
.form.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: var(--space-half); min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label, .field-label { font-size: var(--text-sm); font-weight: var(--weight-bold); }

input[type=text], input[type=email], input[type=tel], input[type=url], input[type=number],
input[type=password], input[type=search], .form input[type=date], .form-grid input[type=date], .form input:not([type]), .form-grid input:not([type]), .form input[type=time], .form-grid input[type=time], select, textarea {
    width: 100%;
    height: var(--control-height);
    padding: 0 12px;
    font-family: var(--font-ui);
    font-size: var(--text-md);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
}
textarea { height: auto; min-height: 96px; padding: var(--space-1) 12px; resize: vertical; line-height: 1.5; }
input.mono, textarea.mono { font-family: var(--font-mono); font-size: var(--text-sm); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-focus-ring); }
.input-validation-error { border-color: var(--color-danger) !important; }

.check { display: flex; align-items: center; gap: var(--space-1); min-height: var(--control-height); font-weight: var(--weight-medium); }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--color-primary); }
.check-cell input { width: 18px; height: 18px; margin: 0; accent-color: var(--color-primary); }

.field-validation-error { color: var(--color-danger); font-size: var(--text-sm); }
.validation-summary-valid { display: none; }
.validation-summary-errors {
    background: var(--color-danger-tint);
    border: 1px solid var(--color-danger-border);
    border-radius: var(--radius);
    color: var(--color-danger);
    padding: 12px var(--space-2);
    margin-bottom: var(--space-2);
    grid-column: 1 / -1;
}
.validation-summary-errors ul { margin: 0; padding-left: var(--space-2); }

/* Primary action bottom-right; secondary actions to its left. */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid var(--color-border);
}
.form-actions .spacer { flex: 1; }

[data-for-types][hidden] { display: none; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin-bottom: var(--space-2); }
.filters input[type=search] { flex: 2 1 240px; width: auto; }
.filters select { flex: 1 1 160px; width: auto; }
.filters .check { flex: none; }
.filters.keg-add { margin-bottom: 0; }
.filters.keg-add select { flex: 0 1 220px; }

/* ---------- Badge ---------- */
.badge {
    display: inline-block;
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    line-height: 22px;
    padding: 0 var(--space-1);
    border-radius: var(--radius);
    white-space: nowrap;
    vertical-align: baseline;
}
.badge.ok { background: var(--color-primary-tint); color: var(--color-primary); }
.badge.warn { background: var(--color-warning-tint); color: var(--color-warning-text); }
.badge.bad { background: var(--color-danger-tint); color: var(--color-danger); }
.badge.neutral { background: var(--color-surface-muted); color: var(--color-text-muted); }

/* ---------- Notice ---------- */
.notice { border: 1px solid; border-radius: var(--radius); padding: 12px var(--space-2); margin-bottom: var(--space-3); }
.notice.success { background: var(--color-primary-tint); border-color: var(--color-primary-border); color: var(--color-primary-hover); }
.notice.warning { background: var(--color-warning-tint); border-color: var(--color-warning); color: var(--color-warning-text); }
.notice.error { background: var(--color-danger-tint); border-color: var(--color-danger-border); color: var(--color-danger); }

/* ---------- Phone ---------- */
@media (max-width: 720px) {
    .form, .form.three, .form-grid { grid-template-columns: 1fr; }
    .panel { padding: var(--space-2); }
    .panel.flush .panel-head { padding: var(--space-2) var(--space-2) 0; }
    .panel.flush .table-foot { padding: var(--space-1) var(--space-2) var(--space-2); }
    .form-actions { flex-direction: column-reverse; align-items: stretch; }
    .form-actions .button { width: 100%; }
    .form-actions .spacer { display: none; }
    dl.facts { grid-template-columns: 1fr; gap: 0; }
    dl.facts dd { margin-bottom: var(--space-1); }
}

/* Product page: other container versions, quick-add rows, cost summary */
.versions { margin: 0 0 var(--space-2); color: var(--color-text-muted); display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }
.quick-add { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); padding: var(--space-2) var(--space-3) var(--space-1); }
.quick-add .field-label { margin-right: var(--space-1); }
.quick-add .button .muted { margin-left: var(--space-half); font-size: var(--text-xs); }
.quick-add-link { font-size: var(--text-sm); margin-left: var(--space-1); }
.cost-summary { margin: 0 0 var(--space-1); }

/* A number box with its unit beside it (4 | cans) */
.input-pair { display: flex; gap: var(--space-1); }
.input-pair input { flex: 1 1 auto; min-width: 0; }
.input-pair select { flex: 0 0 auto; width: auto; min-width: 96px; }
.input-suffix { display: flex; align-items: center; color: var(--color-text-muted); padding: 0 var(--space-1); }
.field[hidden] { display: none; }

/* Tabs: a row of links for switching between views of one page */
.tabs { display: flex; gap: var(--space-half); overflow-x: auto; scrollbar-width: none; margin-bottom: var(--space-2); border-bottom: 1px solid var(--color-border); }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: var(--space-1) 12px; color: var(--color-text-muted); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--color-text); text-decoration: none; }
.tabs a.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: var(--weight-bold); }

/* Padding inside a flush panel, and tables of inputs */
.panel-pad { padding-left: var(--space-3); padding-right: var(--space-3); }
.panel.flush .form-actions.panel-pad { margin-top: 0; padding-bottom: var(--space-2); }
.validation-summary-errors.panel-pad { margin: var(--space-2) var(--space-3) 0; }
.edit-table td { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.edit-table td.num input { text-align: right; max-width: 140px; margin-left: auto; display: block; }
.edit-table td input[type=text] { min-width: 140px; }
.edit-table td.num input[type=text] { min-width: 88px; }
.edit-table select { min-width: 96px; }

/* Keymap designer */
.settings-panel summary { cursor: pointer; font-weight: var(--weight-bold); }
.settings-panel[open] summary { margin-bottom: var(--space-2); }
.tabs .muted { font-weight: var(--weight-regular); margin-left: var(--space-half); }
.tab-add { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; padding-bottom: var(--space-half); }
.tab-add input { width: 140px; height: var(--control-height-small); }
.designer { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-2); align-items: start; }
.designer .panel { margin-bottom: 0; }
.key-grid { display: grid; gap: var(--space-1); }
.key {
    display: flex; flex-direction: column; justify-content: center; gap: 2px;
    min-height: 72px; padding: var(--space-1); border-radius: var(--radius);
    border: 1px solid var(--color-border); border-left-width: 6px;
    color: var(--color-text); font-weight: var(--weight-bold); line-height: 1.2; overflow: hidden;
}
.key:hover { text-decoration: none; filter: brightness(0.97); }
.key.empty { align-items: center; color: var(--color-text-muted); font-size: var(--text-lg); border-style: dashed; border-left-width: 1px; background: var(--color-surface); }
.key.selected { outline: 3px solid var(--color-primary); outline-offset: 1px; }
.key.unavailable { opacity: 0.55; }
.key-label { font-size: var(--text-sm); overflow-wrap: anywhere; }
.key-sub { font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--color-text-muted); }
.key-legend { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-2) 0 0; }
.legend-chip { padding: 2px var(--space-1); border-radius: var(--radius); border: 1px solid var(--color-border); border-left-width: 6px; color: var(--color-text); }
.editor-panel h2 .muted { font-size: var(--text-sm); font-weight: var(--weight-regular); }
.editor-panel .field { margin-bottom: var(--space-2); }
select.picker { height: auto; padding: var(--space-half); }
select.picker option { padding: var(--space-half) var(--space-1); }
.cat-draught { background: var(--cat-draught); border-left-color: var(--cat-draught-edge); }
.cat-packaged { background: var(--cat-packaged); border-left-color: var(--cat-packaged-edge); }
.cat-wine { background: var(--cat-wine); border-left-color: var(--cat-wine-edge); }
.cat-spirits { background: var(--cat-spirits); border-left-color: var(--cat-spirits-edge); }
.cat-nonalcoholic { background: var(--cat-nonalcoholic); border-left-color: var(--cat-nonalcoholic-edge); }
.cat-food { background: var(--cat-food); border-left-color: var(--cat-food-edge); }
.cat-merch { background: var(--cat-merch); border-left-color: var(--cat-merch-edge); }
.cat-other { background: var(--cat-other); border-left-color: var(--cat-other-edge); }
@media (max-width: 900px) {
    .designer { grid-template-columns: 1fr; }
    .key { min-height: 56px; }
}

/* A price worked out from a setting (e.g. takeaway + on-premise charge) */
.calc { margin-right: var(--space-1); padding: 0 var(--space-half); border: 1px solid var(--color-border); border-radius: var(--radius); color: var(--color-text-muted); font-family: var(--font-ui); font-size: var(--text-xs); }

/* Keystroke log */
.panel.narrow { max-width: 420px; }
.filters.log-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); align-items: end; }
.log-filters .filter { display: flex; flex-direction: column; gap: var(--space-half); font-size: var(--text-sm); color: var(--color-text-muted); }
.log-filters .filter input, .log-filters .filter select { flex: none; width: 100%; }
.log-filters .filter-actions { display: flex; gap: var(--space-1); }
.replay-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.replay-pos { margin-left: auto; color: var(--color-text-muted); font-size: var(--text-sm); }
.replay-now { margin-top: var(--space-1); font-family: var(--font-mono); font-size: var(--text-sm); white-space: pre-wrap; overflow-wrap: anywhere; }
.log-table tbody tr { cursor: pointer; }
.log-table tbody tr.current td { background: var(--color-primary-tint); }
.log-details { font-family: var(--font-mono); font-size: var(--text-xs); overflow-wrap: anywhere; min-width: 240px; }

/* Signed-in account, and the test environment banner */
.account-menu { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; font-size: var(--text-sm); white-space: nowrap; }
.link-button { background: none; border: 0; padding: 0; color: var(--color-primary); font: inherit; cursor: pointer; text-decoration: underline; }
.test-banner { background: var(--color-warning); color: var(--color-text); text-align: center; font-weight: var(--weight-bold); padding: var(--space-half) var(--space-2); font-size: var(--text-sm); letter-spacing: 0.04em; }
.steps { padding-left: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); }
.secret { font-size: var(--text-lg); letter-spacing: 0.08em; padding: var(--space-1) var(--space-2); background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: var(--radius); user-select: all; }

/* Staff profile */
.check-row { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
.staff-photo { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--color-border); }
.panel.personal { border-color: var(--color-warning); }
.access-grid td, .access-grid th { text-align: center; }
.access-grid td:first-child, .access-grid th:first-child { text-align: left; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; margin-top: var(--space-2); }
.button-row .inline-form { display: inline-flex; gap: var(--space-1); align-items: center; }

/* Designer: buttons can span squares; type marks */
.key-image { max-width: 40px; max-height: 32px; object-fit: contain; display: block; margin-bottom: 2px; }
.key-image.preview { max-width: 64px; max-height: 64px; }
.key.type-tap { border-style: solid; border-width: 2px; }
.key.type-page .key-label::after { content: " ›"; }
.key.type-function { font-style: italic; }

/* Dashboard notices with a list and a Dismiss button */
.notice-card { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); }
.notice-lines { margin: var(--space-half) 0 0; padding-left: var(--space-3); font-size: var(--text-sm); }

/* Table map designer: tables are placed in the area's own units (percentages of the canvas) */
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin-bottom: var(--space-2); }
.table-canvas { position: relative; width: 100%; background: var(--color-surface-muted); border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; touch-action: none; }
.table-shape {
    position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: var(--color-surface); border: 2px solid var(--color-border-strong); border-radius: var(--radius);
    cursor: grab; user-select: none; font-size: var(--text-sm);
}
.table-shape.round { border-radius: 50%; }
.table-shape:active { cursor: grabbing; border-color: var(--color-primary); }
.table-shape span { color: var(--color-text-muted); font-size: var(--text-xs); }

/* Product page: the sell-unit table is a form (names, takes off, prices and barcodes typed in place) */
.sell-unit-table .cell-input { width: auto; min-width: 0; padding: var(--space-half) var(--space-1); font-size: var(--text-md); }
.sell-unit-table .num-input { width: 5.5em; text-align: right; }
.sell-unit-table .price-input { width: 6.5em; text-align: right; }
.sell-unit-table td { vertical-align: middle; }
.sell-unit-table input[data-field="Name"] { width: 9em; margin-right: var(--space-1); }
.sell-unit-table .calc { margin-right: var(--space-1); }
.sell-unit-table .invalid { border-color: var(--color-danger); outline: 1px solid var(--color-danger); }
.sell-unit-table tr[data-new] { background: var(--color-surface-muted); }
.link-button { background: none; border: 0; padding: 0; color: var(--color-danger); cursor: pointer; font: inherit; font-size: var(--text-sm); }
.small-link { font-size: var(--text-sm); }

/* Keymap designer: "Set up a tap" on the Draught page */
.tap-setup { border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--space-2); margin-bottom: var(--space-3); }
.tap-setup summary { cursor: pointer; font-weight: var(--weight-medium); }
.check-row { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); }

/* Draught: one colour per tap (tap-c1 to tap-c12, from the tokens) */
.key.tap-c1 { background: var(--tap-1); border-left-color: var(--tap-1-edge); }
.key.tap-c2 { background: var(--tap-2); border-left-color: var(--tap-2-edge); }
.key.tap-c3 { background: var(--tap-3); border-left-color: var(--tap-3-edge); }
.key.tap-c4 { background: var(--tap-4); border-left-color: var(--tap-4-edge); }
.key.tap-c5 { background: var(--tap-5); border-left-color: var(--tap-5-edge); }
.key.tap-c6 { background: var(--tap-6); border-left-color: var(--tap-6-edge); }
.key.tap-c7 { background: var(--tap-7); border-left-color: var(--tap-7-edge); }
.key.tap-c8 { background: var(--tap-8); border-left-color: var(--tap-8-edge); }
.key.tap-c9 { background: var(--tap-9); border-left-color: var(--tap-9-edge); }
.key.tap-c10 { background: var(--tap-10); border-left-color: var(--tap-10-edge); }
.key.tap-c11 { background: var(--tap-11); border-left-color: var(--tap-11-edge); }
.key.tap-c12 { background: var(--tap-12); border-left-color: var(--tap-12-edge); }

/* Receiving: does the delivery add up to the invoice? */
.totals-table { border-collapse: collapse; min-width: 320px; }
.totals-table td { padding: var(--space-half) var(--space-2) var(--space-half) 0; }
.totals-table tr.total td { font-weight: var(--weight-bold); border-top: 1px solid var(--color-border); }

/* Product page tabs: beer details, packs (how it's received, then pricing), keg (sizes, then pricing) */
.product-tabs { margin-bottom: var(--space-3); }
.product-tabs a.create { color: var(--color-text-muted); font-style: italic; }
.versions a.active { font-weight: var(--weight-bold); text-decoration: none; color: var(--color-text); }
.selling-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.selling-stack > * { margin: 0; }

/* Products list: a banner row per producer */
tr.group-row th { background: var(--color-surface-muted); text-align: left; font-weight: var(--weight-bold); padding-top: var(--space-1); padding-bottom: var(--space-1); }
tr.group-row th .muted { font-weight: var(--weight-regular); margin-left: var(--space-1); }

/* "Adding a product for delivery N" banner on the product pages */
.delivery-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.delivery-banner .banner-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }

/* Receiving lines: "Counted in" shows its whole name (Case of 16 or 24, 50 L keg), and the product name has room */
.receiving-lines select { width: auto; min-width: 9.5em; }
.receiving-lines td:first-child { min-width: 14em; }

/* Product page: on to the next product */
.next-product { margin-top: var(--space-3); }

/* Receiving: merch sizes and colours as a grid; a wide product search */
.variant-grid { border-collapse: collapse; margin-left: auto; }
.variant-grid th { font-weight: var(--weight-medium); color: var(--color-text-muted); padding: 2px 6px; text-align: center; }
.variant-grid td { padding: 2px; }
.variant-grid .qty-cell { width: 3.5em; text-align: right; }
.add-row { display: flex; gap: var(--space-1); align-items: center; flex-wrap: wrap; }
.add-row input[name="product"] { flex: 1 1 420px; min-width: 0; font-size: var(--text-lg); padding: var(--space-1) var(--space-2); }

/* An input with a button beside it (e.g. the Untappd link and "Fill from Untappd"). */
.row-inline { display: flex; gap: var(--space-1); align-items: center; }
.row-inline input { flex: 1; min-width: 0; }
.row-inline .button { flex: none; white-space: nowrap; }

/* Add a product: what kind, as big buttons (the lookup starts in a different place for each). */
.kind-choice { border: 0; padding: 0; margin: 0 0 var(--space-3); display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-1); }
.kind-choice legend { margin-bottom: var(--space-1); }
.kind-option { position: relative; display: flex; flex-direction: column; gap: 2px; padding: var(--space-2); border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); cursor: pointer; }
.kind-option input { position: absolute; opacity: 0; pointer-events: none; }
.kind-option .kind-label { font-weight: var(--weight-bold); }
.kind-option .kind-hint { font-size: var(--text-xs); color: var(--color-text-muted); }
.kind-option:has(input:checked) { border-color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary); background: var(--color-primary-tint); }
.kind-option:has(input:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Products: a tree of types and producers beside the list (as in Bepoz). Above the list on a phone. */
.tree-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--space-2); align-items: start; }
.product-tree { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--space-1); max-height: 75vh; overflow: auto; font-size: var(--text-sm); }
.product-tree a { color: var(--color-text); text-decoration: none; }
.product-tree a:hover { color: var(--color-primary); text-decoration: underline; }
.product-tree a.active { color: var(--color-primary); font-weight: var(--weight-bold); }
.product-tree .tree-all { display: block; padding: var(--space-half) var(--space-1); }
.product-tree summary { padding: var(--space-half) var(--space-1); cursor: pointer; }
.product-tree ul { list-style: none; margin: 0; padding: 0 0 var(--space-half) var(--space-3); }
.product-tree li { padding: 2px 0; }
.product-tree .muted { font-size: var(--text-xs); }
@media (max-width: 800px) {
    .tree-layout { grid-template-columns: 1fr; }
    .product-tree { max-height: 240px; }
}

/* A heading inside a form, splitting it into parts (e.g. a supplier's bank details). */
.form-section { border-top: 1px solid var(--color-border); padding-top: var(--space-2); margin-top: var(--space-1); }
.form-section h3 { margin: 0; font-size: var(--text-md); font-weight: var(--weight-bold); }

/* Transfers: a line that takes more than the sending location has. */
.leaves.short { color: var(--color-danger); font-weight: var(--weight-bold); }

/* Stock on hand: a column per location; the total stands out; negatives in red. */
.soh-table td.strong { font-weight: var(--weight-bold); }
.soh-table td.muted { color: var(--color-text-muted); }
.soh-table td.negative { color: var(--color-danger); font-weight: var(--weight-bold); }

/* Receiving: a cost against the last invoice's. Up is a warning (it may need repricing). */
.cost-change.up { color: var(--color-warning-text); font-weight: var(--weight-bold); }
.cost-change.down { color: var(--color-primary); }
.model-price { color: var(--color-primary); }

/* Receiving: prices at this invoice's cost, a block per product. A box that will change the price stands out. */
.price-panel { border-top: 1px solid var(--color-border); }
.price-panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); padding: var(--space-2) var(--space-3); }
.price-panel-head .hint { flex: 1 1 16rem; margin: 0; }
.price-table input.price-box { width: 7em; text-align: right; }
.price-table input.price-box.changing { border-color: var(--color-primary); font-weight: var(--weight-bold); }
.price-table .cell-sub { display: block; }

/* Delivery lines: "pass on __%" under the discount (how much of it reaches the prices). */
.pass-on { white-space: nowrap; }
.pass-on input { width: 3.5em; padding: 2px 4px; text-align: right; }

/* Product page: the container and size of this one SKU, on its Packs / Keg tab. */
.sku-panel { padding: 12px 16px; }
.sku-panel form { align-items: center; margin: 0; }
.sku-panel .hint { flex: 1 1 320px; }
.sku-intro { margin: 0; }

/* "+ Packs" / "+ Keg" tabs are buttons (they make the SKU straight away). */
.tabs .tab-form { display: contents; }
.tabs .tab-form button { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: var(--space-1) 12px; color: var(--color-text-muted); font: inherit; font-style: italic; cursor: pointer; white-space: nowrap; }
.tabs .tab-form button:hover { color: var(--color-primary); }
.sku-panel .sku-add { margin-top: var(--space-1); padding-top: var(--space-1); border-top: 1px solid var(--color-border); }

/* Delivery lines: one block per line, labels above boxes that wrap, so nothing scrolls sideways or hides. */
.rlines { display: flex; flex-direction: column; }
.rline { padding: 12px 16px; border-top: 1px solid var(--color-border); border-left: 3px solid transparent; }
.rline.flagged { border-left-color: var(--color-warning); background: var(--color-warning-tint); }
.rline-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-bottom: 8px; }
.rline-name { font-weight: var(--weight-bold); flex: 1 1 260px; }
.rline-fields { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-start; }
.rf { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--color-text-muted); margin: 0; }
.rf > span:first-child { white-space: nowrap; }
.rf input, .rf select { color: var(--color-text); }
.rf-inline { display: flex; align-items: center; gap: 4px; }
.rf-wide { flex: 1 1 240px; }
.rf-wide input { width: 100%; }
.rf .cost-change { font-size: 12px; }
.rline-foot { margin-top: 6px; font-size: 13px; color: var(--color-text-muted); }
.cost-warning { margin-top: 8px; padding: 8px 12px; background: var(--color-surface); border: 1px solid var(--color-warning); border-radius: 6px; color: var(--color-warning-text); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.cost-warning .check { margin-left: auto; color: var(--color-text); }
.rline-fix { margin-top: 8px; }
.rline-fix summary { cursor: pointer; color: var(--color-primary); font-size: 13px; }
.rf[hidden], .cost-warning[hidden] { display: none; }
.rline-fields .rf input { width: 8.5em; }
.rline-fields .rf select { width: auto; max-width: 16em; }
.rline-fields .rf-qty input { width: 4.5em; }
.rline-fields .rf-passon input { width: 3.5em; }
.rline-fields .rf-wide input { width: 100%; }

/* Reports: one-click periods, figures with their comparisons. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--space-1); }
.chip { padding: 4px 12px; border: 1px solid var(--color-border); border-radius: 999px; font-size: var(--text-sm); color: var(--color-text); background: var(--color-surface); white-space: nowrap; }
.chip:hover { border-color: var(--color-primary); text-decoration: none; }
.chip.active { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.period-picker .filters { margin-bottom: var(--space-1); }
.period-picker .filters input[type=date] { width: auto; }
.delta { font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.delta.up { color: var(--color-primary); }
.delta.down { color: var(--color-danger); }
.report-table td.best { font-weight: var(--weight-bold); background: var(--color-primary-tint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
