:root {
    --mb-cocoa: #4a2c17;
    --mb-cocoa-dark: #3a2212;
    --mb-caramel: #b07a3c;
    --mb-cream: #faf6f1;
    --mb-gold: #c9a24b;
}

/* ---- W16 Theme Studio (ADR-0055): admin-overridable custom properties ----
   Every var() below reads var(--mb-X, <original hardcoded value>) — i.e. the fallback IS this
   stylesheet's own long-standing default. Nothing changes unless base.html actually injects a
   :root override (only when a theme is active), so an inactive theme leaves this file's look
   untouched. Only the four ADR-0055 §1 colour properties + font-family are wired up here. */
body {
    background: var(--mb-background, var(--mb-cream));
    color: var(--mb-text, #2b2118);
    font-family: var(--mb-font-family, inherit);
}

.mb-brand-bar {
    background: linear-gradient(90deg, var(--mb-cocoa-dark), var(--mb-primary, var(--mb-cocoa)));
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.mb-brand-mark { font-size: 1.2rem; }
.navbar-brand .fw-light { color: var(--mb-gold); }

.btn-mb {
    background: var(--mb-primary, var(--mb-cocoa));
    border-color: var(--mb-primary, var(--mb-cocoa));
    color: #fff;
}
.btn-mb:hover { background: var(--mb-cocoa-dark); border-color: var(--mb-cocoa-dark); color: #fff; }
.btn-outline-mb {
    color: var(--mb-primary, var(--mb-cocoa));
    border-color: var(--mb-accent, var(--mb-caramel));
}
.btn-outline-mb:hover { background: var(--mb-accent, var(--mb-caramel)); color: #fff; border-color: var(--mb-accent, var(--mb-caramel)); }

.metric-card {
    border: none;
    border-left: 4px solid var(--mb-accent, var(--mb-caramel));
    box-shadow: 0 1px 4px rgba(74, 44, 23, 0.08);
}
.metric-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
    color: #8a7a68;
}
.metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--mb-cocoa);
}

.location-card {
    border: none;
    box-shadow: 0 1px 6px rgba(74, 44, 23, 0.1);
}
.location-card .card-header {
    background: #fff;
    border-bottom: 2px solid var(--mb-cream);
}

.form-select:focus, .form-control:focus {
    border-color: var(--mb-caramel);
    box-shadow: 0 0 0 0.2rem rgba(176, 122, 60, 0.2);
}

/* ---- Item picker combobox (W1/W2/W1a) ---- */
.item-picker-control { position: relative; }
.item-picker-caret {
    position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%);
    color: #8a7a68; pointer-events: none; font-size: 0.8rem;
}
.item-picker-search { padding-right: 1.6rem; }
.item-picker-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 1060;
    max-height: 280px; overflow-y: auto;
    background: #fff; border: 1px solid #d9ccbb; border-top: none;
    border-radius: 0 0 6px 6px; box-shadow: 0 6px 16px rgba(74, 44, 23, 0.15);
}
.item-picker-results:empty { display: none; }
.item-result { cursor: pointer; border-radius: 0; }

/* ---- Stock readouts (W6) ---- */
.stock-readout {
    background: var(--mb-cream);
    border: 1px solid #e7ddd1;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
}
.readout-label {
    display: block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #8a7a68;
}
.readout-value { font-weight: 700; font-size: 1.15rem; color: var(--mb-cocoa); }

/* ---- Help icon (W12) + manual (W11) ---- */
.help-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.2rem; height: 1.2rem; border-radius: 50%;
    background: var(--mb-caramel); color: #fff;
    font-size: 0.78rem; font-weight: 700; line-height: 1;
    text-decoration: none; margin-left: 0.45rem; vertical-align: middle;
}
.help-icon:hover { background: var(--mb-cocoa); color: #fff; }
.manual-body h1 { font-size: 1.5rem; }
.manual-body h2 { font-size: 1.2rem; margin-top: 1.4rem; }
.manual-body table { width: auto; }
.manual-body table th, .manual-body table td { padding: 0.3rem 0.7rem; border: 1px solid #e7ddd1; }

footer { border-top: 1px solid #e7ddd1; margin-top: 2rem; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline; }

/* ---- App shell: sidebar + main ---- */
.mb-shell { display: flex; align-items: stretch; min-height: calc(100vh - 56px); }
.mb-sidebar {
    width: 264px;
    flex: 0 0 264px;
    background: #fff;
    border-right: 1px solid #e7ddd1;
    overflow-y: auto;
    max-height: calc(100vh - 56px);
    position: sticky;
    top: 56px;
}
.mb-main { flex: 1 1 auto; min-width: 0; }

.mb-nav { padding: 0.5rem 0; }
.mb-nav-roadmap {
    display: block;
    padding: 0.5rem 1rem;
    margin: 0;
    border-radius: 6px;
    font-weight: 600;
    color: var(--mb-cocoa);
    text-decoration: none;
    background: var(--mb-cream);
}
.mb-nav-roadmap:hover, .mb-nav-roadmap.active { background: var(--mb-caramel); color: #fff; }

.mb-nav-module { margin-bottom: 0.2rem; }
.mb-nav-module-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0.4rem 1rem 0.3rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8a7a68;
    font-weight: 700;
    text-align: left;
}
.mb-nav-module-head:hover { color: var(--mb-cocoa); background: var(--mb-cream); }
.mb-nav-module-label { flex: 1 1 auto; }
.mb-nav-caret { font-size: 0.6rem; transition: transform 0.15s ease; }
.mb-nav-module.collapsed .mb-nav-caret { transform: rotate(-90deg); }
.mb-nav-module.collapsed .mb-nav-features { display: none; }

/* Views — top-level parent categories (2026-07-09). Collapsible; modules nest as sub-groups. */
.mb-nav-view { margin-bottom: 0.35rem; }
.mb-nav-view-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0.5rem 1rem 0.45rem;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mb-cocoa);
    font-weight: 700;
    text-align: left;
    border-left: 3px solid transparent;
}
.mb-nav-view-head:hover { background: var(--mb-cream); border-left-color: var(--mb-caramel); }
.mb-nav-view-label { flex: 1 1 auto; }
.mb-nav-view.collapsed .mb-nav-caret { transform: rotate(-90deg); }
.mb-nav-view.collapsed .mb-nav-view-body { display: none; }
.mb-nav-group { margin-bottom: 0.1rem; }
.mb-nav-group-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    padding: 0.35rem 1rem 0.25rem 1.5rem;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
    color: #6f6252;
    font-weight: 700;
}
.mb-nav-group-label:hover { color: var(--mb-cocoa); background: var(--mb-cream); }
.mb-nav-group-name { flex: 1 1 auto; }
.mb-nav-caret-sm { font-size: 0.5rem; }
.mb-nav-group.collapsed .mb-nav-caret { transform: rotate(-90deg); }
.mb-nav-group.collapsed .mb-nav-features { display: none; }

.mb-nav-top { padding: 0.5rem 0.5rem 0.25rem; }
.nav-toggle-all {
    width: 100%;
    margin-top: 0.4rem;
    border: 1px solid #e2d8cb;
    background: #fff;
    color: #8a7a68;
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
    cursor: pointer;
}
.nav-toggle-all:hover { background: var(--mb-cream); color: var(--mb-cocoa); }
.mb-phase {
    font-size: 0.62rem;
    background: #efe7dd;
    color: #8a7a68;
    border-radius: 10px;
    padding: 0.05rem 0.45rem;
    white-space: nowrap;
}
.mb-nav-features { list-style: none; padding: 0; margin: 0; }
/* Feature leaves sit one clear step right of their sub-category heading, on a tree rail
   (2026-07-11). Ladder: view head 1rem → group label 1.5rem → rail 2.1rem → leaf text 3.1rem.
   The old 1.8rem was only 0.3rem past the heading, so leaves read as flush with it. */
.mb-nav-feature {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 1rem 0.25rem 3.1rem;
    font-size: 0.72rem;
    color: #3a2f25;
    text-decoration: none;
    /* Sits under the rail/ticks so its hover+active background never paints over them. */
    position: relative;
    z-index: 1;
}

/* Tree rail: a vertical spine down the leaf list with a branch tick into each leaf.
   Built per-<li> rather than as one spine on the <ul> so it self-sizes to the row height —
   the last item's segment is halved, stopping the spine at its own tick. Colour comes from
   the Bootstrap border token, so retro inherits dark chrome (Theming rule) — see retro.css
   for the palette-matched override. */
.mb-nav-group:not(.mb-nav-group-nolabel) .mb-nav-features > li { position: relative; }
.mb-nav-group:not(.mb-nav-group-nolabel) .mb-nav-features > li::after {
    content: "";
    position: absolute;
    left: 2.1rem;
    top: 0;
    height: 100%;
    width: 1px;
    background: var(--mb-nav-rail, #ddd2c4);
    z-index: 2;
}
.mb-nav-group:not(.mb-nav-group-nolabel) .mb-nav-features > li:last-child::after { height: 50%; }
.mb-nav-group:not(.mb-nav-group-nolabel) .mb-nav-features > li::before {
    content: "";
    position: absolute;
    left: 2.1rem;
    top: 50%;
    width: 0.6rem;
    height: 1px;
    background: var(--mb-nav-rail, #ddd2c4);
    z-index: 2;
}
/* A group with no sub-heading (a View whose single group echoes its name) has nothing to
   branch from — keep its leaves shallow and railless. */
.mb-nav-group-nolabel .mb-nav-feature { padding-left: 1.8rem; }
.mb-nav-feature:hover { background: var(--mb-cream); color: var(--mb-cocoa); }
.mb-nav-feature.active { background: var(--mb-cream); color: var(--mb-cocoa); font-weight: 600; border-left: 3px solid var(--mb-caramel); }
.mb-nav-feature.planned { color: #a99c8c; }
.mb-dot-built { width: 8px; height: 8px; border-radius: 50%; background: #2e9e5b; display: inline-block; }
.mb-soon {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #b0a292;
    border: 1px solid #e2d8cb;
    border-radius: 8px;
    padding: 0 0.35rem;
}
/* ---- ADR-0063: sidebar group readiness lights (green=all built, amber=some, red=none) ---- */
.mb-ready { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.mb-ready-ready { background: #2e9e5b; }
.mb-ready-partial { background: #d8952a; }
.mb-ready-none { background: #c0503f; }

/* ---- W31: in-row expand panels (light default; retro override in retro.css) ---- */
.expand-panel { background: #f1ebe3; }

/* ---- WIP + roadmap ---- */
.wip-card { border: none; }
.wip-emoji { font-size: 3rem; }
.roadmap-card { border: none; box-shadow: 0 1px 6px rgba(74,44,23,0.08); }
.roadmap-card .card-header { background: #fff; border-bottom: 2px solid var(--mb-cream); }

/* ---- W47: PO calendar ---- */
.mb-cal-cell { overflow: hidden; }
/* Bootstrap's own `.table>:not(caption)>*>*` cell reset (specificity 0,1,1) outranks a plain
   .mb-cal-today class (0,1,0) and silently wins regardless of load order — qualify with the
   cell's own always-present class to beat it (0,2,0). */
.mb-cal-cell.mb-cal-today { background: var(--mb-cream); box-shadow: inset 0 0 0 2px var(--mb-caramel); }

/* ---- Batch 7: native date/time pickers ---- */
/* Bootstrap's reset strips the calendar indicator, so date fields looked like plain boxes that
   never opened a calendar. Restore a visible, clickable indicator + pointer cursor; date-picker.js
   also calls showPicker() so a click anywhere on the field opens the native calendar. */
input[type="date"], input[type="datetime-local"], input[type="month"],
input[type="week"], input[type="time"] { cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator { opacity: 1; cursor: pointer; }

/* ---- ADR-0068: process map (workflow → data graph on the feature map) --------------------
   Every fill/stroke is a token, never a literal — an SVG full of #fff is exactly how the
   retro theme has been broken four times before. Retro overrides live in retro.css. */
.pm-scroll { overflow-x: auto; overflow-y: hidden; }
.pm-svg { display: block; }

/* Lifecycle stage headers across the top. */
.pm-stage {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    fill: var(--pm-stage-fg, #a99c8c);
}

/* Process nodes. <a> when reachable, <g> when the user has no access. */
.pm-node rect {
    fill: var(--pm-node-bg, #fff);
    stroke: var(--pm-node-border, #e2d8cb);
    stroke-width: 1;
}
.pm-node text {
    font-size: 11px;
    fill: var(--pm-node-fg, #3a2f25);
}
/* Process nodes are <a> elements, so the default link underline lands on the SVG label and
   makes every node look struck-through. Kill it on the anchor (SVG text inherits it). */
.pm-node { cursor: pointer; text-decoration: none; }
.pm-node text { text-decoration: none; }
.pm-proc:hover .pm-node rect {
    fill: var(--pm-node-bg-hover, #f6efe6);
    stroke: var(--pm-accent, #b98a4b);
    stroke-width: 2;
}
/* No access (ADR-0056): still on the map, but plainly inert — not a link, not clickable. */
.pm-node--locked { cursor: default; opacity: 0.45; }
.pm-node--locked rect { stroke-dasharray: 3 2; }

/* Data clusters. */
.pm-cluster rect {
    fill: var(--pm-cluster-bg, #f1ebe3);
    stroke: var(--pm-cluster-border, #ddd2c4);
    stroke-width: 1;
}
.pm-cluster text {
    font-size: 10px;
    fill: var(--pm-cluster-fg, #6f6252);
}
.pm-cluster { cursor: help; }

/* Edges. Faint by default so the overall texture reads without becoming spaghetti; a process's
   own edges light up when you hover it. The rule works because each process's edges live inside
   its own <g class="pm-proc"> — see _process_map.html. */
.pm-edge {
    stroke: var(--pm-edge, #c9bcac);
    stroke-width: 1.25;
    opacity: 0.12;
    transition: opacity 0.12s ease;
}
.pm-edge--read { stroke-dasharray: 4 3; }
.pm-proc:hover .pm-edge { opacity: 1; stroke: var(--pm-accent, #b98a4b); }
.pm-legend-line { opacity: 1; stroke: var(--pm-edge, #c9bcac); }
.pm-legend-item { margin-right: 1rem; white-space: nowrap; }

/* Delivery day view — the driver's run (ADR-0075 §8).
   Colours are driven from Bootstrap --bs-* tokens ONLY. Retro maps those tokens onto its own
   palette (the 2026-07-09 root-cause fix), so this inherits dark chrome automatically and cannot
   reintroduce the white-panel bug for a sixth time. No light literals — tests/core/test_theme_overrides.py
   fails the tree for one. */
.delivery-stop {
    cursor: grab;
}
.delivery-stop.is-dragging {
    opacity: 0.5;
    background: var(--bs-secondary-bg);
}
.delivery-stop-handle {
    cursor: grab;
    font-size: 1.3rem;
    line-height: 1;
    user-select: none;
}

/* Proof-of-delivery signature pad (ADR-0075 §7).
   Surface AND ink are driven from --bs-* tokens, which retro re-points: a white pad with black ink
   would be an invisible signature on the dark HUD. The JS reads the resolved `color` for the
   stroke. touch-action:none is not cosmetic — without it a finger scrolls the page instead of
   signing, which is the whole point of the day view being mobile-first. */
.signature-pad {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    touch-action: none;
    display: block;
    cursor: crosshair;
}
