:root {
  --bg: #f5f5ed;
  --surface: #fff;
  --surface-soft: #eef2e9;
  --text: #24362c;
  --muted: #59695f;
  --border: #dce2d7;
  --brand: #285e42;
  --brand-hover: #1c4931;
  --focus: #a65b00;
  --success: #e0f0de;
  --success-text: #245136;
  --warning: #fff0c9;
  --warning-text: #70500d;
  --danger: #9d302f;
  --danger-soft: #fbe7e3;
  --info: #e7eff5;
  --info-text: #31556e;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-interactive: 0 6px 20px rgb(36 54 44 / 8%);
  --shadow-floating: 0 -3px 20px rgb(36 54 44 / 8%);
  --container: 1280px;
  --font-sm: .875rem;
  --font-base: 1rem;
  --font-lg: 1.25rem;
  --font-xl: 2rem;
  --bottom-nav-space: 0px;
}
* { box-sizing: border-box; }
html { scroll-padding-bottom: 10rem; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--brand); text-underline-offset: 4px; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
:where(input, select, textarea) { scroll-margin-block: 6rem; }
:where(input, select, textarea, button, a, summary) { scroll-margin-bottom: calc(var(--bottom-nav-space) + 160px); }
img, svg { max-width: 100%; height: auto; }
img { display: block; }
p, td, th, h1, h2, h3, a, label { overflow-wrap: anywhere; }
form { margin: 0; }
fieldset { min-width: 0; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); }
legend { font-weight: 700; padding-inline: var(--space-2); }
summary { min-height: 44px; padding-block: 10px; cursor: pointer; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.75rem, 4vw, 2.875rem); line-height: 1.12; letter-spacing: -.04em; margin: 12px 0 24px; }
h2 { font-size: 1.5rem; line-height: 1.25; }
h3 { font-size: 1.125rem; line-height: 1.35; }
small { font-size: var(--font-sm); }
hr { border: 0; border-top: 1px solid var(--border); margin-block: var(--space-6); }
.muted { color: var(--muted); }
.panel { padding: clamp(16px, 3vw, 28px); margin-block: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.panel > h2:first-child { margin-top: 0; }
.panel form { max-width: 720px; }
.panel input[type="checkbox"] { width: auto; min-height: auto; }
.panel table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
.panel th, .panel td { padding: 12px 16px; vertical-align: top; border-bottom: 1px solid var(--border); }
.panel th { background: var(--surface-soft); }
.panel td { max-width: 440px; }
.eyebrow { text-transform: uppercase; font-size: .75rem; font-weight: 750; letter-spacing: .12em; color: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 8px; z-index: 100; background: white; padding: 12px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 8px; }

/* The unauthenticated shell retains the original login layout. */
.topbar { padding: 12px 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: inline-flex; align-items: baseline; min-height: 44px; font-size: 32px; font-weight: 850; letter-spacing: -2px; text-decoration: none; flex: 0 0 auto; }
.brand span { font-size: 12px; letter-spacing: 1px; margin-left: 8px; }
.local-badge { font-size: .75rem; color: var(--muted); margin-right: auto; max-width: 100px; }
.app-layout, .container { min-width: 0; }
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding: 24px 16px calc(32px + var(--bottom-nav-space)); }
.sidebar, .client-nav, .bottom-nav { display: none; }
.nav-link { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 44px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 600; line-height: 1.3; text-decoration: none; }
.nav-link:hover { color: var(--brand); background: var(--surface-soft); }
.nav-link.is-active { color: var(--brand); background: #e6efdf; font-weight: 750; }
.nav-link[aria-current="page"] { box-shadow: inset 3px 0 0 var(--brand); }
.notification-link { position: relative; display: inline-flex; min-height: 44px; min-width: 44px; align-items: center; justify-content: center; gap: 8px; border-radius: var(--radius-sm); text-decoration: none; }
.notification-link:hover { background: var(--surface-soft); }
.notification-label { display: none; }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 21px; padding: 1px 5px; border-radius: 12px; background: var(--brand); color: white; font-size: .75rem; font-weight: 700; }
.has-membership { --bottom-nav-space: calc(92px + env(safe-area-inset-bottom, 0px)); }
.has-membership .local-badge { display: none; }
.has-membership .brand { margin-right: auto; }
.mobile-menu { width: 100%; border-top: 1px solid var(--border); }
.mobile-menu summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 0; color: var(--brand); font-weight: 650; cursor: pointer; list-style: none; }
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.mobile-menu nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding-bottom: 12px; }
.bottom-nav { position: fixed; z-index: 30; bottom: 0; inset-inline: 0; display: flex; align-items: stretch; gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-floating); }
.bottom-nav .nav-link { flex: 1 1 0; padding: 10px 4px; justify-content: center; text-align: center; font-size: .75rem; min-height: 48px; }
.bottom-nav .nav-link[aria-current="page"] { box-shadow: inset 0 3px 0 var(--brand); }

/* Composable content, cards and mobile grids. */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.page-header > div { min-width: 0; flex: 1 1 250px; }
.page-header h1 { margin: 4px 0 12px; }
.page-header p { margin: 0 0 8px; }
.page-header > .button { flex-shrink: 0; }
.grid, .grid-2, .product-grid, .metric-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.grid > *, .grid-2 > *, .product-grid > *, .metric-grid > * { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack > * { margin-block: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; min-width: 0; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.card-header h2 { margin: 0; }
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease; }
.card-link:hover { border-color: #9fbaa1; box-shadow: var(--shadow-interactive); }
.product-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0; }
.product-card h2, .product-card h3, .product-card p { margin: 0; }
.product-card h2 { font-size: 1.125rem; }
.product-card form, .product-card > .actions { margin-top: auto; }
.product-art { min-height: 140px; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; border-radius: var(--radius); background: #edf0dc; color: #bd6d2c; font-size: 4.5rem; }
.product-art img { width: 100%; height: 100%; object-fit: cover; }
.product-card:nth-child(3n+2) .product-art { background: #f5ead7; color: #8b9a54; }
.product-card:nth-child(3n+3) .product-art { background: #e3ece3; color: #b8793f; }
.price { font-weight: 750; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.metric { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-width: 0; }
.metric > :first-child { margin-top: 0; }
.metric > :last-child { margin-bottom: 0; }
.metric-value, .metric strong { display: block; font-size: clamp(1.5rem, 3vw, 2.125rem); font-weight: 750; line-height: 1.2; margin-block: 8px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

/* Controls have a minimum 44px touch area and visible keyboard focus. */
.button, button { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; max-width: 100%; padding: 10px 18px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--brand); color: #fff; cursor: pointer; font-weight: 650; text-decoration: none; line-height: 1.4; text-align: center; gap: 8px; overflow-wrap: anywhere; }
.button:hover, button:hover { background: var(--brand-hover); }
.secondary, .button-secondary { background: transparent; color: var(--brand); border-color: #b6c4b9; }
.secondary:hover, .button-secondary:hover { background: #e9efe8; }
.danger, .button-danger { background: var(--danger); color: white; }
.danger:hover, .button-danger:hover { background: #7f2625; }
.button-quiet { background: transparent; color: var(--brand); }
.button-quiet:hover { background: var(--surface-soft); }
button:disabled, .button[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
input, select, textarea { display: block; width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid #9eada1; border-radius: var(--radius-sm); background: #fff; color: var(--text); }
input[type="hidden"] { display: none; }
textarea { min-height: 112px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { display: inline-block; width: 24px; min-height: 24px; height: 24px; padding: 0; margin: 10px 8px 10px 0; vertical-align: middle; accent-color: var(--brand); }
label { display: block; font-size: .875rem; font-weight: 650; margin-bottom: 6px; }
label:has(input[type="checkbox"]), label:has(input[type="radio"]) { min-height: 44px; }
.form-field { margin-bottom: 20px; }
.form-field:has(input[type="checkbox"]) { min-height: 44px; }
.form-field label:has(+ input[type="checkbox"]) { display: inline-block; margin-right: 8px; }
.form-field .checkbox-control { display: flex; align-items: center; gap: 12px; min-height: 44px; padding-block: 10px; margin-bottom: 0; cursor: pointer; }
.checkbox-control input[type="checkbox"] { flex: 0 0 24px; margin: 0; }
.checkbox-control span { min-width: 0; }
.helptext { display: block; margin-top: 6px; font-size: .8125rem; color: var(--muted); }
.errorlist { color: var(--danger); margin: 6px 0; padding-left: 20px; font-size: .875rem; }
.has-error input, .has-error select, .has-error textarea, [aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.toolbar, .actions, .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-width: 0; }
.toolbar { align-items: end; margin-bottom: 24px; }
.toolbar > *, .inline-form > :where(input, select, .form-field) { flex: 1 1 160px; min-width: 0; }
.toolbar .form-field { margin-bottom: 0; }
.toolbar > :where(.button, button), .inline-form > button { flex: 0 1 auto; }
.actions { margin-top: 20px; }
.actions form { max-width: 100%; }
.sticky-actions { position: sticky; bottom: var(--bottom-nav-space); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-floating); }
.sticky-actions .actions { margin-top: 0; }
.sticky-actions p { margin: 0; }

/* Semantic tables scroll only inside this wrapper. Add table-cards and
   data-label to each td for a mobile card layout; retain the real thead. */
.table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table-scroll-hint { color: var(--muted); font-size: .8125rem; margin: 8px 0; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .875rem; }
.data-table th, .data-table td { padding: 14px 16px; vertical-align: top; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--surface-soft); color: var(--muted); font-weight: 650; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8faf5; }
.data-table caption { text-align: left; font-weight: 700; padding: 16px; }
.data-table .actions { margin: 0; gap: 8px; }
.data-table td > * { min-width: 0; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; max-width: 100%; gap: 6px; border-radius: 20px; padding: 4px 10px; background: var(--surface-soft); color: #4b5b50; font-size: .75rem; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.status-draft, .status-cancelled { background: #e9ece7; color: #4e5c52; }
.status-submitted, .status-assigned { background: var(--info); color: var(--info-text); }
.status-confirmed, .status-delivered, .status-active { background: var(--success); color: var(--success-text); }
.status-picking, .status-packed, .status-departed, .status-arrived, .status-shipped { background: #f2eacf; color: #66521d; }
.status-partially_delivered, .status-returned, .status-low { background: var(--warning); color: var(--warning-text); }
.status-rejected, .status-delivery_failed, .status-failed, .status-blocked, .status-expired { background: var(--danger-soft); color: var(--danger); }
.alert { background: var(--warning); color: var(--warning-text); padding: 16px; border: 1px solid #e6d294; border-radius: var(--radius); margin-bottom: 16px; overflow-wrap: anywhere; }
.alert.success { background: var(--success); color: var(--success-text); border-color: #b6d6b3; }
.alert.error, .alert.danger { background: var(--danger-soft); color: var(--danger); border-color: #e5bbb5; }
.alert.info { background: var(--info); color: var(--info-text); border-color: #bdcfdc; }
.empty-state { text-align: center; padding-block: 40px; }
.empty-state p { max-width: 36rem; margin-inline: auto; }
.empty-state-mark { display: block; font-size: 3.5rem; line-height: 1; color: #b66e2d; margin-bottom: 20px; }
.empty-state h2 { margin-bottom: 12px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { position: relative; padding: 0 0 24px 28px; min-width: 0; }
.timeline > li::before { content: ""; position: absolute; top: 7px; left: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--brand); background: var(--surface); }
.timeline > li:not(:last-child)::after { content: ""; position: absolute; left: 5px; top: 22px; bottom: 5px; width: 2px; background: var(--border); }
.timeline > li:last-child { padding-bottom: 0; }
.timeline p { margin: 4px 0; }
.timeline time { color: var(--muted); font-size: .8125rem; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; margin-top: 24px; }
.pagination-current { padding: 10px 0; color: var(--muted); font-size: .875rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: 8px; }

.login-layout { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 20px; }
.welcome h1 { font-size: clamp(2rem, 7vw, 2.25rem); margin-block: 8px 16px; }
.welcome > p { margin-block: 8px; }
.food-art { display: none; font-size: 150px; color: #cc782c; line-height: 1; }
.login-card { max-width: 460px; width: 100%; }
.login-card .button { width: 100%; }

@media (max-width: 599px) {
  .toolbar, .inline-form { flex-direction: column; align-items: stretch; }
  .toolbar > *, .inline-form > * { flex: 0 1 auto; width: 100%; }
  .sticky-actions > .button, .sticky-actions > form { flex: 1 1 100%; }
  .sticky-actions > form > button { width: 100%; }
  .data-table.table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .data-table.table-cards, .data-table.table-cards tbody, .data-table.table-cards tr { display: block; }
  .data-table.table-cards tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .data-table.table-cards tr:last-child { border-bottom: 0; }
  .data-table.table-cards td { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; padding: 8px 0; border: 0; text-align: left; }
  .data-table.table-cards td::before { content: attr(data-label); color: var(--muted); font-weight: 600; }
  .data-table.table-cards td[colspan] { display: block; }
  .data-table.table-cards td[colspan]::before { content: none; }
  .table-cards .nowrap { white-space: normal; }
}
@media (min-width: 600px) {
  .product-grid, .metric-grid, .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 399px) {
  .data-table.table-cards td { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
@media (min-width: 768px) {
  .topbar { padding: 16px 24px; gap: 16px; }
  .local-badge { max-width: none; }
  .container { padding: 32px 24px calc(48px + var(--bottom-nav-space)); }
  .card { padding: 24px; }
  .notification-label { display: inline; }
  .login-layout { grid-template-columns: 1.2fr 1fr; gap: 48px; min-height: 70vh; }
  .welcome h1 { font-size: clamp(2.5rem, 5vw, 4.25rem); margin-block: 12px 24px; }
  .food-art { display: block; }
  .client-shell { --bottom-nav-space: 0px; }
  .client-shell .bottom-nav, .client-shell .mobile-menu { display: none; }
  .client-nav { display: flex; flex: 1 1 100%; flex-wrap: wrap; gap: 8px; order: 5; border-top: 1px solid var(--border); padding-top: 12px; }
  .client-nav .nav-link[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--brand); }
}
@media (min-width: 1024px) {
  .staff-shell { --bottom-nav-space: 0px; }
  .staff-shell .app-layout { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: calc(100vh - 80px); max-width: 1600px; margin-inline: auto; }
  .sidebar { display: flex; flex-direction: column; gap: 16px; padding: 28px 16px; border-right: 1px solid var(--border); }
  .sidebar .eyebrow { margin: 0 12px 4px; font-size: .6875rem; }
  .sidebar nav { display: grid; gap: 6px; }
  .sidebar-footer { margin-top: auto; padding: 32px 12px 0; color: var(--muted); font-size: .75rem; }
  .staff-shell .bottom-nav, .staff-shell .mobile-menu { display: none; }
  .has-membership .local-badge { display: inline; margin-right: auto; }
  .has-membership .brand { margin-right: 0; }
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .table-scroll-hint { display: none; }
}
@media (min-width: 1280px) {
  .client-nav { flex: 1 1 auto; order: 0; border: 0; padding: 0; }
  .client-shell .local-badge { margin-right: 0; }
  .login-layout { gap: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
/* Keep short screens and zoomed layouts usable when the keyboard takes space. */
@media (max-height: 500px) {
  .has-membership { --bottom-nav-space: 0px; }
  .bottom-nav { position: static; }
  .sticky-actions { position: static; }
}
@media (forced-colors: active) {
  .badge, .alert, .nav-link[aria-current="page"] { border: 1px solid CanvasText; }
}
@media print {
  .print-action, button, form, .actions { display: none !important; }
  .topbar, .sidebar, .bottom-nav, .sticky-actions, .skip-link { display: none !important; }
  .staff-shell .app-layout { display: block; }
  .container { max-width: none; padding: 0; }
  .card, .metric { break-inside: avoid; }
  body { background: white; }
}
