/* ============================================================================
   OrderPoint design system
   ----------------------------------------------------------------------------
   Same design language as hacc.app — OKLCH tokens, Hanken Grotesk with Geist Mono
   for numerics, generous radii, soft tinted shadows, semantic status colours —
   with a different palette so the two products are clearly distinct.

     hacc.app    warm greys (hue 60-75) + burnt-orange accent (hue 42)
     OrderPoint  cool greys (hue ~230)  + deep teal accent    (hue 195)

   Teal sits well away from the status hues (fresh 155, soon 78, urgent 28), so an
   accent never reads as a status, and it stays food-neutral rather than
   appetite-suggesting.

   No Bootstrap. The ordering app is mobile-first and bundle size is a feature, so
   this is written directly rather than overriding a framework — which also avoids
   the class-collision problems hacc.app had to work around.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;500;600;700;800&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
    /* ── Surfaces and ink ── */
    --surface: #ffffff;
    --surface-2: oklch(0.985 0.004 230);
    --surface-3: oklch(0.968 0.006 230);
    --ink: oklch(0.24 0.015 235);
    --ink-2: oklch(0.46 0.013 235);
    --ink-3: oklch(0.62 0.011 235);
    --line: oklch(0.915 0.007 228);
    --line-2: oklch(0.945 0.005 228);

    /* ── Accent: deep teal ── */
    --accent: oklch(0.58 0.115 195);
    --accent-ink: oklch(0.44 0.10 195);
    --accent-hover: oklch(0.52 0.12 195);
    --accent-soft: oklch(0.962 0.028 195);
    --accent-line: oklch(0.88 0.05 195);

    /* ── Semantic status ── */
    --fresh: oklch(0.52 0.12 155);
    --fresh-bg: oklch(0.958 0.05 158);
    --soon: oklch(0.58 0.12 78);
    --soon-bg: oklch(0.96 0.08 85);
    --urgent: oklch(0.54 0.18 28);
    --urgent-bg: oklch(0.957 0.06 32);

    /* Offers are deliberately warm so they stand out against a cool accent. */
    --offer: oklch(0.56 0.16 40);
    --offer-bg: oklch(0.962 0.055 48);

    /* ── Shape and depth ── */
    --r-panel: 18px;
    --r-card: 14px;
    --r-row: 12px;
    --r-control: 10px;
    --r-chip: 999px;
    --shadow-card: 0 1px 2px oklch(0.2 0.02 235 / .06), 0 4px 12px -6px oklch(0.2 0.02 235 / .12);
    --shadow-lift: 0 24px 60px -18px oklch(0.2 0.02 235 / .35);
    --scrim: oklch(0.26 0.02 235 / .45);

    /* ── Type ── */
    --font: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
    --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', monospace;

    /* Safe-area aware bottom bar height, for phones with a home indicator. */
    --bar-h: calc(64px + env(safe-area-inset-bottom, 0px));
}

/* Wholesaler branding overrides --accent at runtime; everything else follows. */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--surface-2);
    -webkit-font-smoothing: antialiased;
    /* Stops iOS zooming when a form field is focused. */
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.015em; color: var(--ink); }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; color: var(--ink-2); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Numerics — prices, quantities, weights, counts — always monospace so columns
   line up and digits don't jitter as values change. */
.num, .price, .qty { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.eyebrow {
    font-size: 11px; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--ink-3);
}

/* ── Layout ────────────────────────────────────────────────────────── */

.op-shell { min-height: 100dvh; display: flex; flex-direction: column; }

.op-header {
    position: sticky; top: 0; z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 10px 16px;
    display: flex; align-items: center; gap: 12px;
}
.op-header img.logo { height: 30px; width: auto; }
.op-header .title { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }

.op-main { flex: 1; padding: 16px; padding-bottom: calc(var(--bar-h) + 16px); }
.op-main.no-bar { padding-bottom: 16px; }

.container-narrow { max-width: 760px; margin: 0 auto; }

/* Ordering-for banner. Deliberately prominent: with an active-customer switcher
   the real risk is human — placing an order against the wrong account. */
.acting-as {
    display: flex; align-items: center; gap: 10px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-line);
    color: var(--accent-ink);
    border-radius: var(--r-row);
    padding: 9px 12px;
    font-size: 13.5px;
    margin-bottom: 14px;
}
.acting-as strong { font-weight: 700; }
.acting-as button { margin-left: auto; }

/* ── Cards and rows ────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    padding: 14px;
    box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 12px; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    overflow: hidden;
}

.row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r-row);
    background: var(--surface);
    border: 1px solid var(--line);
}
.row + .row { margin-top: 8px; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; letter-spacing: -.01em; }
/* min-width:0 on the flex child so long product names truncate instead of
   forcing the row wider than a phone screen. */
.row .name, .row .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 12.5px; color: var(--ink-3); }

.list-sep > * + * { border-top: 1px solid var(--line-2); }

/* ── Buttons ───────────────────────────────────────────────────────── */

.btn {
    appearance: none;
    font-family: inherit; font-size: 14.5px; font-weight: 600;
    border-radius: var(--r-control);
    border: 1px solid transparent;
    padding: 10px 16px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    /* 44px is the accepted minimum touch target; these are used in a cold shop
       with gloved or wet hands. */
    min-height: 44px;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }

.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ── Inputs ────────────────────────────────────────────────────────── */

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }

.input, select.input, textarea.input {
    width: 100%;
    font-family: inherit;
    /* 16px minimum: anything smaller makes iOS zoom the viewport on focus. */
    font-size: 16px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    padding: 10px 12px;
    min-height: 44px;
}
.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── Badges and chips ──────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
    padding: 3px 9px; border-radius: var(--r-chip);
    white-space: nowrap;
}
.badge-offer { background: var(--offer-bg); color: var(--offer); }
.badge-weighed { background: var(--surface-3); color: var(--ink-2); }
.badge-fresh { background: var(--fresh-bg); color: var(--fresh); }
.badge-soon { background: var(--soon-bg); color: var(--soon); }
.badge-urgent { background: var(--urgent-bg); color: var(--urgent); }

.chip {
    font-family: inherit; font-size: 13.5px; font-weight: 600;
    padding: 8px 14px; border-radius: var(--r-chip);
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
    cursor: pointer; min-height: 40px;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Quantity entry ────────────────────────────────────────────────── */

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
    width: 40px; height: 40px; flex: none;
    border-radius: var(--r-control);
    border: 1px solid var(--line); background: var(--surface);
    font-size: 20px; font-weight: 600; color: var(--ink-2); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.stepper button:hover { background: var(--surface-2); }
.stepper input {
    width: 62px; text-align: center;
    font-family: var(--font-mono); font-size: 16px;
    border: 1px solid var(--line); border-radius: var(--r-control);
    padding: 8px 4px; min-height: 40px;
}

/* Weighed goods can only ever be priced approximately — the butcher cuts to
   roughly the requested weight — so estimated totals are always marked. */
.approx::before { content: "approx "; color: var(--ink-3); font-family: var(--font); }

/* ── Sticky bottom bar (basket / submit) ───────────────────────────── */

.op-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    display: flex; align-items: center; gap: 12px;
}
.op-bar .total { font-family: var(--font-mono); font-weight: 600; }

/* ── Empty states ──────────────────────────────────────────────────── */
/* Every empty state explains what to do next — never a bare "no results". */

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink-2); margin-bottom: 6px; }

/* ── Scrim and dialog ──────────────────────────────────────────────── */

.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 1000; }
.dialog {
    position: fixed; z-index: 1001; left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: min(440px, calc(100vw - 32px));
    max-height: min(600px, calc(100dvh - 48px));
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-panel); box-shadow: var(--shadow-lift);
    overflow: hidden;
}
.dialog-h { padding: 15px 18px; border-bottom: 1px solid var(--line); font-weight: 700; }
.dialog-b { padding: 16px 18px; overflow-y: auto; }
.dialog-f { padding: 13px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* On a phone a centred dialog is worse than a sheet that comes up from the
   bottom — it is closer to the thumb and matches platform convention. */
@media (max-width: 560px) {
    .dialog {
        top: auto; bottom: 0; left: 0; transform: none;
        width: 100%; max-height: 88dvh;
        border-radius: var(--r-panel) var(--r-panel) 0 0;
        border-bottom: none;
    }
}

/* ── Loading ───────────────────────────────────────────────────────── */

.skeleton {
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.3s infinite;
    border-radius: var(--r-row);
}
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Favourite star ────────────────────────────────────────────────── */

.fav {
    background: none; border: none; cursor: pointer;
    font-size: 20px; line-height: 1; color: var(--ink-3);
    width: 34px; height: 34px; flex: none;
    display: flex; align-items: center; justify-content: center;
    align-self: flex-start;
}
.fav.on { color: var(--offer); }

/* ── Header nav ─────────────────────────────────────────────────────── */

.op-nav { display: flex; gap: 4px; margin-left: auto; }
.op-nav a {
    font-size: 13.5px; font-weight: 600; color: var(--ink-2);
    padding: 7px 11px; border-radius: var(--r-control);
}
.op-nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.op-nav a:hover { text-decoration: none; background: var(--surface-2); }

/* ── Boot and error ────────────────────────────────────────────────── */

.boot {
    min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    color: var(--ink-3); font-size: 14.5px;
}

#blazor-error-ui {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 2000;
    background: var(--urgent-bg); color: var(--urgent);
    border-top: 1px solid var(--urgent);
    padding: 12px 16px; font-size: 14px;
}
#blazor-error-ui .reload { color: var(--urgent); text-decoration: underline; margin-left: 8px; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; font-size: 18px; line-height: 1; }

/* ============================================================================
   Admin console — a desktop back-office layout on the same tokens as the
   customer app. Sidebar + content, dense data tables, stat cards.
   ========================================================================== */
.adm-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
@media (max-width: 820px) { .adm-shell { grid-template-columns: 1fr; } }

.adm-side {
    background: var(--surface-2); border-right: 1px solid var(--line);
    padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
}
.adm-brand { font-weight: 700; font-size: 18px; color: var(--ink); padding: 4px 10px 16px; }
.adm-brand small { display: block; font-weight: 500; font-size: 12px; color: var(--ink-3); }
.adm-nav a {
    display: block; padding: 9px 12px; border-radius: var(--r-control);
    color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500;
}
.adm-nav a:hover { background: var(--surface-3); color: var(--ink); }
.adm-nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.adm-side .spacer { flex: 1; }

.adm-main { padding: 22px 26px 60px; min-width: 0; }
.adm-top {
    display: flex; align-items: center; gap: 14px; margin-bottom: 22px;
    flex-wrap: wrap;
}
.adm-top .who { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.adm-top .who .name { font-size: 13px; color: var(--ink-2); }

.adm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.adm-stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
    padding: 16px; box-shadow: var(--shadow-card);
}
.adm-stat .v { font-size: 28px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.adm-stat .k { font-size: 12px; color: var(--ink-3); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }

.adm-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
table.adm { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.adm th, table.adm td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.adm th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); background: var(--surface-2); position: sticky; top: 0; }
table.adm tbody tr:last-child td { border-bottom: none; }
table.adm tbody tr.clickable { cursor: pointer; }
table.adm tbody tr.clickable:hover { background: var(--surface-2); }
table.adm td.num, table.adm th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.adm .dim { color: var(--ink-3); }

.adm-select { padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--surface); color: var(--ink); font-size: 13px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.ok { background: var(--fresh-bg); color: var(--fresh); }
.pill.warn { background: var(--soon-bg); color: var(--soon); }
.pill.bad { background: var(--urgent-bg); color: var(--urgent); }
.pill.mute { background: var(--surface-3); color: var(--ink-3); }
.adm-h { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.adm-h h1 { margin: 0; }

/* Onboarding form: a two-column grid that collapses on a narrow window, and the once-only
   API key shown as something obviously meant to be selected and copied. */
.adm-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.adm-checks { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 13px; }
.adm-checks label { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.adm-key {
    margin: 0; padding: 12px 14px; overflow-x: auto; user-select: all;
    background: var(--surface-2); border: 1px solid var(--accent); border-radius: var(--r-control);
    font-family: ui-monospace, "IBM Plex Mono", monospace; font-size: 13px; color: var(--ink);
}

/* Log viewer: a filter row, and messages that are allowed to wrap — unlike the rest of the
   console's tables, the interesting column here is prose of unpredictable length. */
.adm-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; }
.adm-input {
    padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-control);
    background: var(--surface); color: var(--ink); font-size: 13px; min-width: 220px;
}
table.adm td.nowrap { white-space: nowrap; }
table.adm .adm-msg { white-space: normal; min-width: 380px; }
.adm-trace summary { cursor: pointer; color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.adm-trace pre {
    margin: 6px 0 0; padding: 10px; overflow-x: auto; max-height: 260px;
    background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-control);
    font-size: 12px; color: var(--ink-2); white-space: pre-wrap;
}

/* Inline result banners. The console previously repeated
   `class="badge badge-urgent" style="display:block;padding:10px 12px"` at each call site;
   this is the same thing with a name, and a success variant. */
.note {
    display: block;
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-control);
    background: var(--surface-2);
    font-size: 13px;
    color: var(--ink-2);
}
.note.ok { background: var(--fresh-bg); border-color: var(--fresh); color: var(--fresh); }
.note.warn { background: var(--soon-bg); border-color: var(--soon); color: var(--soon); }
.note a { margin-left: 8px; }

/* A row of controls that belong together — a date, a reason and the button that adds them. */
.adm-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.adm-inline .input { width: auto; }

/* Seven day checkboxes inside a table cell, where the default 16px gap wraps badly. */
.adm-checks.tight { gap: 8px; margin-top: 0; }
.adm-checks.tight label { gap: 3px; }
