:root {
    /* Palette borrowed loosely from ohokay.ca */
    --bg: #f8fcfd;          /* cool white   */
    --card: #ffffff;
    --ink: #2d3953;         /* navy         */
    --muted: #6b7280;
    --line: #e7e3ee;        /* soft lavender-grey */
    --accent: #dba7d4;      /* pink/lavender */
    --accent-ink: #2d3953;  /* text on accent */
    --cream: #fbf6e4;
    --ok: #16a34a;
    --low: #e0a15a;      /* soft amber  */
    --critical: #db6b6b; /* soft red    */
    /* Chart marks — validated separately from the UI palette above (--ink/
       --accent fail the chart-mark lightness/chroma checks; these extend the
       same navy/pink brand families at values that pass). */
    --chart-bar: #e87ba4;   /* pink family — daily sales bars */
    --chart-line: #2a78d6;  /* navy family — 4-day average line */
    --chart-bar-today: #a8adb8; /* neutral grey — today, still incomplete */
    --font-body: "Karla", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-display: "Gluten", "Karla", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
}

h1, h2, h3, .brand-sub, .build-count { font-family: var(--font-display); }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ink);
    color: #fff;
    padding: 0.75rem 1.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: #fff;
}
.brand-logo {
    height: 34px;
    width: auto;
    display: block;
    background: #fff;          /* logo has a solid light background */
    padding: 3px 6px;
    border-radius: 6px;
}
.brand-sub { font-weight: 700; font-size: 1.25rem; letter-spacing: .01em; }

/* Folder-tab navigation — big, centred, touch-friendly */
.tabbar {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--ink);
    padding: 0 1rem;
}
.tab {
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
    background: #e7dced;                 /* inactive tab */
    padding: 0.95rem 2rem;
    min-height: 54px;
    display: flex;
    align-items: center;
    border-radius: 14px 14px 0 0;
    position: relative;
    top: 2px;
    opacity: 0.8;
    transition: opacity .15s, background .15s;
}
.tab:hover { opacity: 1; }
.tab-short { display: none; }   /* shown instead of the full label on phones */
.tab-minor { font-size: 0.85rem; padding: 0.65rem 1.3rem; min-height: 40px; opacity: 0.55; }
.tab-minor:hover, .tab-minor.active { opacity: 0.85; }
.tab.active {
    background: var(--bg);               /* connects to the page below */
    color: var(--ink);
    opacity: 1;
    top: 0;
    padding-top: 1.15rem;
    box-shadow: 0 -3px 8px rgba(0,0,0,.12);
}

main { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card h2 { margin-top: 0; font-size: 1.15rem; }

.muted { color: var(--muted); font-size: .9rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--line); }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

button {
    background: var(--accent);
    color: var(--accent-ink);
    border: 0;
    border-radius: 999px;
    padding: 0.7rem 1.5rem;
    min-height: 46px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-body);
}
button:hover { filter: brightness(1.03); }

/* Per-row Save + Remove controls */
.row-actions { display: flex; gap: .6rem; align-items: center; }

/* Trash / icon-only button (Remove item) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.55rem;
    min-height: 46px;
    min-width: 46px;
    line-height: 0;
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:hover { background: #fef2f2; color: var(--critical); border-color: #f3c4c4; filter: none; }

/* Ghost button used inside the modal */
.btn-ghost {
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.7rem 1.5rem;
    min-height: 46px;
    font-weight: 700;
    text-decoration: none;
}
.btn-ghost:hover { background: var(--cream); }

/* Compact ghost button — for de-emphasized bulk actions (e.g. "Mark all
   fulfilled"). Still ~40px tall, close to the app's touch-target floor. */
.btn-small {
    padding: 0.4rem 1rem;
    min-height: 40px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
}

/* Size-only compact variant (keeps the button's own colours) — the
   Outstanding table's per-row "Label" + "Mark fulfilled" pair, sized alike
   so the row reads as one control group. */
.btn-compact {
    padding: 0.45rem 1rem;
    min-height: 40px;
    font-size: .85rem;
    white-space: nowrap;   /* keep "Mark fulfilled" on one line at this size */
}

/* The Outstanding table's "📦 Label" button — blue, matching the standby
   tiles' palette, so shipping-related controls read as one family. */
.btn-label { background: #eff6ff; border-color: #93c5fd; color: #35618f; }
.btn-label:hover { background: #dbeafe; }

/* Low-emphasis text-link-style button (e.g. "Undo" in a history row) —
   deliberately smaller/quieter than .btn-ghost's touch-target pill, for a
   reversible action inside an already-compact table row. */
.btn-link {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--ink);
    text-decoration: underline;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.3rem 0.2rem;
    min-height: 0;
    cursor: pointer;
}
.btn-link:hover { color: var(--muted); }
.btn-link:disabled { background: none; color: var(--muted); text-decoration: none; cursor: not-allowed; }
button:disabled { background: #cbd5e1; cursor: not-allowed; }

input, select {
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 1rem;
    min-height: 46px;
    background: #fff;
}

.save-bar { margin-top: 1rem; }
/* Hide stock rows for items not used in any kit when the toggle is on */
.hide-unused .not-in-kit { display: none; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end; }
.inline-form label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; }

.badge {
    display: inline-block; background: var(--accent); color: var(--accent-ink);
    border-radius: 999px; padding: 0 .5rem; font-size: .8rem; font-weight: 700; vertical-align: middle;
}

.pagination {
    display: flex; align-items: center; justify-content: center; gap: 1rem;
    margin-top: 1rem;
}

.pill { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.pill-ok { background: #dcfce7; color: var(--ok); }
.pill-critical { background: #fdeaea; color: #b45454; }
.pill-ship { background: #e3edf7; color: #35618f; }
/* Softer than .pill-critical — cancelled is just history, not an active
   warning like "Short on stock" (which keeps the stronger red). */
.pill-cancelled { background: #f7ecec; color: #b08383; }

/* Cancelled order rows in the recent-history table — a faint tint, and the
   same dimmed text weight as the fulfilled (.muted) rows above/below it, so
   it doesn't read as "bolder" than its neighbours by contrast. */
.cancelled-row td { background: #fbf5f5; color: var(--muted); font-size: .9rem; }

/* Inline checkbox (e.g. Needs shipping) sized for touch */
.checkbox-label { display: flex; align-items: center; gap: .5rem; font-size: .95rem; color: var(--ink); }
.checkbox-label input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; }

.flash { padding: .6rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.flash a { color: inherit; font-weight: 700; text-decoration: underline; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* Stock level colouring */
.qty { font-weight: 700; padding: .1rem .5rem; border-radius: 6px; }
.qty-ok { color: var(--ok); }
.qty-low { color: #8a5a12; background: #fbeacd; }       /* dark amber on pale amber */
.qty-critical { color: #8f3535; background: #f7dad7; }  /* dark red on pale red */

.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: middle; }
.swatch.low { background: var(--low); }
.swatch.critical { background: var(--critical); }

/* Upcoming Orders — row tinted by urgency, same palette as .qty-low/.qty-critical */
.order-row-critical td { background: #f7dad7; }
.order-row-low td { background: #fbeacd; }
.order-row-critical .status-pill { color: #8f3535; font-weight: 700; }
.order-row-low .status-pill { color: #8a5a12; font-weight: 700; }
.order-row-ok .status-pill { color: var(--ok); font-weight: 700; }

/* Buildable box tiles */
.build-grid { display: flex; flex-wrap: wrap; gap: 1rem; }
.build-tile {
    min-width: 150px; max-width: 220px; padding: 1rem; border-radius: 10px; text-align: center;
    border: 1px solid var(--line);
}
.build-limit {
    margin-top: .4rem; font-size: .78rem; color: var(--muted);
    border-top: 1px dashed var(--line); padding-top: .4rem;
}
.build-tile.ok { background: #f0fdf4; }
.build-tile.low { background: #fffbeb; border-color: var(--low); }
.build-tile.critical { background: #fef2f2; border-color: var(--critical); }
.build-tile.neutral { background: var(--cream); } /* a plain count, not a red/yellow/green warning */
.build-tile.standby { background: #eff6ff; border-color: #93c5fd; } /* Outstanding Orders standby totals */
.build-count { font-size: 2rem; font-weight: 800; }
.build-name { font-size: .85rem; color: var(--muted); }

/* Smaller variant — Pre-made Boxes / standby totals (Orders page) only;
   Stock page's "Possible boxes to be made" tiles keep the full .build-tile
   size. flex: 1 1 0 lets the tiles shrink to share the row instead of
   wrapping at a fixed floor, so all box types stay on one line even in a
   small laptop window. */
.build-grid-compact { gap: .6rem; }
.build-tile-compact { flex: 1 1 0; min-width: 92px; max-width: 150px; padding: .5rem; }
.build-tile-compact .build-count { font-size: 1.2rem; }
.build-tile-compact .build-name { font-size: .72rem; }
.build-tile-compact .btn-ghost { padding: .3rem .8rem; min-height: 36px; font-size: .8rem; }
.build-tile-compact .btn-link { font-size: .8rem; }

/* In-place fulfilment (Orders page): fulfilled rows fade out, and success/
   error messages appear as transient toasts instead of a reload's flash bar. */
.row-fade { opacity: 0; transition: opacity .35s ease; }
#toast-wrap {
    position: fixed; bottom: 1rem; right: 1rem; z-index: 1100;
    display: flex; flex-direction: column; gap: .5rem; max-width: 340px;
}
#toast-wrap .flash { margin: 0; box-shadow: 0 4px 14px rgba(45, 57, 83, .18); transition: opacity .4s ease; }
#toast-wrap .toast-out { opacity: 0; }

/* Background-import progress stripe (Orders + Stock pages). Sits in the navy
   band between the brand bar and the folder tabs — both are var(--ink), so a
   pink stripe reads as part of the chrome. Deliberately NOT on the
   tabbar/page seam, which is where the active tab's var(--bg) background
   connects the tab to the page below.

   Idle state is just the "Check now" button; the sweeping stripe is
   absolutely positioned so starting a run causes no reflow. */
.import-bar { position: relative; background: var(--ink); padding: 0 1.5rem; }
.import-bar-track {
    position: absolute; left: 0; right: 0; top: 0; height: 3px;
    overflow: hidden; display: none;
}
.import-bar.is-running .import-bar-track { display: block; }
.import-bar-track::after {
    content: ''; position: absolute; top: 0; height: 100%; width: 35%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
    animation: import-sweep 1.15s ease-in-out infinite;
}
@keyframes import-sweep {
    from { left: -35%; }
    to { left: 100%; }
}
.import-bar-body {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 0.75rem; padding: 0.3rem 0;
}
/* The label only has something to say mid-run or once a run has landed. */
.import-bar-text { display: none; color: #fff; font-size: 0.85rem; opacity: .85; }
.import-bar.is-running .import-bar-text,
.import-bar.is-done .import-bar-text { display: inline; }
.import-bar.is-done .import-bar-text { opacity: 1; font-weight: 700; }
.import-check-btn, .import-refresh-btn {
    min-height: 34px; padding: 0.25rem 1rem; font-size: 0.8rem;
    background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .35);
}
.import-check-btn:hover, .import-refresh-btn:hover { background: rgba(255, 255, 255, .12); }
.import-refresh-btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
/* Mid-run, and once a run has landed, the label carries the state — there is
   nothing useful to re-check. */
.import-bar.is-running .import-check-form,
.import-bar.is-done .import-check-form { display: none; }

@media (prefers-reduced-motion: reduce) {
    .import-bar-track::after { animation: none; left: 0; width: 100%; opacity: .55; }
}

/* Sales — Actuals: only the 5 most recent month tiles show by default. */
.month-tile-extra { display: none; }
#sales-actuals-grid.show-all .month-tile-extra { display: block; }
#sales-actuals-toggle { margin-bottom: .8rem; }

/* Sales — Actuals tiles are shaded by volume (see orders.php) — once the
   background gets dark enough the default dark text stops being legible,
   so switch to light text past that point. */
.build-tile-dark-text .build-count { color: #fff; }
.build-tile-dark-text .build-name { color: rgba(255, 255, 255, .85); }
.build-tile-dark-text .build-limit { color: rgba(255, 255, 255, .85); border-top-color: rgba(255, 255, 255, .35); }

/* Box management — each recipe in its own coloured card */
.box-block {
    border: 1px solid var(--line);
    border-left: 6px solid var(--accent);
    border-radius: 10px;
    padding: .85rem 1.1rem;
    margin-bottom: 1rem;
}
.box-block:last-child { margin-bottom: 0; }
/* Cycle a soft palette so adjacent boxes are easy to tell apart */
.box-c0 { border-left-color: #dba7d4; background: #faf5fb; }
.box-c1 { border-left-color: #9fc3ba; background: #f3f9f7; }
.box-c2 { border-left-color: #e0c07a; background: #fbf8ef; }
.box-c3 { border-left-color: #9db8d6; background: #f5f8fc; }
.box-head { display: flex; align-items: center; gap: .75rem; }
.box-head h3 { margin: 0; }

/* Marketplace product-code fields on a box */
.product-codes { margin: .2rem 0 .7rem; gap: 1rem; }
.product-codes input { min-width: 12rem; }

/* Tighter recipe rows so more items are visible at once */
table.recipe { max-width: 440px; margin: .4rem 0; }
table.recipe th, table.recipe td { padding: .18rem .5rem; }
table.recipe input { min-height: 34px; padding: .3rem .5rem; }

/* Fulfilment stats + profit */
.stat-row { display: flex; flex-wrap: wrap; gap: 1rem; margin: .5rem 0 1rem; }
.stat-tile {
    background: var(--cream); border: 1px solid var(--line); border-radius: 10px;
    padding: .9rem 1.25rem; min-width: 180px;
}
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 800; line-height: 1; }
.stat-label { font-weight: 700; margin-top: .2rem; }
.profit-details { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .9rem; margin-bottom: 1rem; }
.profit-details summary { cursor: pointer; font-weight: 700; font-family: var(--font-display); }

/* Workshop Clay page — upcoming-workshop squares, coloured by clay coverage */
.workshop-grid { display: flex; flex-wrap: wrap; gap: .6rem; }
.workshop-slot {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 74px; min-height: 74px; border-radius: 10px; color: #fff; text-align: center;
    padding: .4rem;
}
.workshop-slot-date { font-weight: 700; font-size: .9rem; }
.workshop-slot-count { font-size: .85rem; opacity: .9; }
.workshop-slot-ok { background: var(--ok); }
.workshop-slot-low { background: #8a5a12; }
.workshop-slot-critical { background: #8f3535; }
.profit-details[open] summary { margin-bottom: .5rem; }
.stat-weekly { font-size: 1.05rem; margin: .6rem 0 .2rem; }

/* Plan-a-build results */
.plan-table { max-width: 520px; margin-top: .5rem; }
.plan-table th, .plan-table td { padding: .3rem .5rem; }
.plan-table .plan-group-header td {
    background: var(--cream);
    font-weight: 700;
    border-top: 2px solid var(--line);
    padding-top: .5rem;
}
.plan-table .plan-total-row td {
    font-weight: 700;
    border-top: 2px solid var(--ink);
    border-bottom: 2px solid var(--ink);
    padding: .5rem;
}

/* Distributor group colours — neutral, not red/yellow: needing to buy stock
   here is the expected outcome, not a warning. Cycled across groups.
   (.plan-table .plan-group-header td above sets the cream default; these
   need matching specificity to override it per group.) */
.plan-table .plan-group-header.plan-group-blue td   { background: #dbe7f5; border-top-color: #7ea3cc; }
.plan-table .plan-group-header.plan-group-purple td { background: #e8dcf0; border-top-color: #a87fc7; }
.plan-table .plan-group-header.plan-group-teal td   { background: #d8efec; border-top-color: #5fab9f; }
.plan-table .plan-group-header.plan-group-sage td   { background: #e3ecd8; border-top-color: #90ab77; }

/* Sales-over-time chart (bars = daily units, line = 4-day trailing average) */
.sales-chart { position: relative; margin: .75rem 0; }
.sales-chart svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis-label {
    font-size: 10px; fill: var(--muted); font-family: var(--font-body);
    font-variant-numeric: tabular-nums;
}
.chart-bar { fill: var(--chart-bar); }
.chart-bar-today { fill: var(--chart-bar-today); }
.chart-line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-line-dot { fill: var(--chart-line); stroke: var(--card); stroke-width: 2; }
.chart-end-label { font-size: 11px; font-weight: 700; fill: var(--ink); font-family: var(--font-body); }
.chart-hit { fill: transparent; cursor: pointer; }
.chart-hit:hover, .chart-hit:focus { fill: rgba(45, 57, 83, 0.06); outline: none; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; margin: .5rem 0 0; font-size: .85rem; color: var(--muted); }
.chart-legend-item { display: inline-flex; align-items: center; gap: .4rem; }
.chart-legend-swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
.chart-legend-bar { background: var(--chart-bar); }
.chart-legend-line { height: 3px; border-radius: 1.5px; background: var(--chart-line); }
.chart-legend-today { background: var(--chart-bar-today); }

/* "Sales" chart range picker — month-increment presets, toggled client-side
   (no reload); .chart-range-panel visibility is swapped by app.js. */
.chart-range-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.chart-range-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chart-range-btn.active:hover { background: var(--ink); }

.chart-tooltip {
    position: absolute; pointer-events: none; transform: translate(-50%, -100%);
    background: var(--ink); color: #fff; font-size: .8rem; line-height: 1.4;
    padding: .4rem .65rem; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.18);
    white-space: nowrap; z-index: 5;
}
.chart-tooltip strong { font-weight: 800; }

/* Login page */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--ink);
}
.login-card {
    background: var(--card); border-radius: 16px; padding: 2rem 2.25rem;
    width: 100%; max-width: 340px; box-shadow: 0 12px 40px rgba(0,0,0,.3);
    display: flex; flex-direction: column; gap: 1rem; text-align: center;
}
.login-logo { height: 40px; width: auto; align-self: center; background: #fff; padding: 4px 8px; border-radius: 8px; }
.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-card label { display: flex; flex-direction: column; text-align: left; gap: .3rem; font-size: .85rem; color: var(--muted); }
.login-card button { margin-top: .5rem; }

/* Blocking modal — covers the page so the user must press OK */
.modal-overlay[hidden] { display: none; }   /* JS-toggled modals also use hidden, not just PHP-omitted */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(45, 57, 83, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}
.modal {
    background: var(--card);
    border-radius: 14px;
    padding: 1.5rem 1.75rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(45, 57, 83, 0.3);
    border-top: 6px solid var(--accent);
}
.modal-msg { margin: 0 0 1.25rem; font-size: 1rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; align-items: center; }
.modal input[type="date"] {
    width: 100%;
    min-height: 46px;
    margin-bottom: 1rem;
    box-sizing: border-box;
}
.modal-error { color: #8f3535; font-size: .9rem; margin: -.5rem 0 1rem; }
.predict-window-choice {
    border: none;
    padding: 0;
    margin: 0 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.predict-window-choice legend { font-size: .8rem; margin-bottom: .3rem; width: 100%; }
.predict-window-choice label { display: flex; align-items: center; gap: .35rem; font-weight: 600; }

/* Full-screen burndown chart (Upcoming Orders) — a lot of lines, so it takes
   the whole viewport: item menu down the left, SVG filling the rest. */
.modal-burndown {
    max-width: none;
    width: calc(100vw - 2rem);
    height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}
.burndown-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.burndown-head .modal-msg { margin: 0; font-weight: 700; flex: 1; }
.burndown-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.burndown-legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.burndown-caveat { margin: .35rem 0 .5rem; font-size: .8rem; }
.burndown-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .6rem;
    font-size: .85rem;
}
.burndown-controls label {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    color: var(--muted);
    font-weight: 600;
}
.burndown-controls input[type="number"] { width: 5.5rem; min-height: 40px; }
.burndown-body { display: flex; gap: 1rem; flex: 1; min-height: 0; }
.burndown-body.menu-collapsed .burndown-menu { display: none; }
/* Item menu hidden: drop the description paragraph and tighten the frame so
   the chart gets the extra height. */
.modal-overlay.menu-collapsed .burndown-caveat { display: none; }
.modal-overlay.menu-collapsed .modal-burndown { padding: .6rem .8rem; }
.modal-overlay.menu-collapsed .burndown-head { gap: .6rem; }
.modal-overlay.menu-collapsed .burndown-controls { margin-bottom: .3rem; }
.burndown-menu {
    width: 240px;
    flex-shrink: 0;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    padding-right: .75rem;
}
.burndown-menu-actions { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .6rem; }
.burndown-menu-actions label {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .78rem;
    font-weight: 700;
    color: var(--muted);
}
.burndown-menu-actions select { min-height: 40px; width: 100%; }
.burndown-group {
    margin: .7rem 0 .15rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}
.burndown-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    min-height: 44px;   /* iPad tap target */
    font-size: .9rem;
    cursor: pointer;
}
.burndown-chip { display: inline-block; width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }
.burndown-chart { flex: 1; min-width: 0; position: relative; }   /* anchors the hover tooltip */
.burndown-chart svg { width: 100%; height: 100%; display: block; cursor: crosshair; }
.burndown-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.burndown-line-active { stroke-width: 4; }
.burndown-line-dim { opacity: .22; }
.burndown-lead-line { stroke-dasharray: 5 4; stroke-width: 1.5; }
.burndown-today-line { stroke: var(--ink); stroke-width: 1.5; }

/* ---------------------------------------------------------------------------
   Mobile / narrow phones (≤640px). The app is designed for iPad, so tablets
   keep the full layout; only phones get this compact treatment. Elements with
   .hide-mobile (lower-priority table columns) are dropped, and any table that's
   still wide scrolls inside its own card rather than stretching the page.
--------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .hide-mobile { display: none; }

    .topbar { padding: 0.55rem 0.9rem; }
    .brand-sub { font-size: 1.05rem; }
    .brand-logo { height: 28px; }

    main { padding: 1rem 0.85rem; }
    h1 { font-size: 1.25rem; }

    /* Tabs: short labels, tighter, so all three fit on one row */
    .tabbar { gap: 0.3rem; padding: 0 0.4rem; }
    .tab { font-size: 1rem; padding: 0.7rem 0.9rem; }
    .tab-full { display: none; }
    .tab-short { display: inline; }

    .card { padding: 1rem; overflow-x: auto; }   /* wide tables scroll here, not the page */
    .card h2 { font-size: 1.05rem; }

    /* Denser tables */
    table { font-size: 0.92rem; }
    th, td { padding: 0.45rem 0.4rem; }

    /* Let paired action buttons stack instead of overflowing a cell */
    .row-actions { flex-wrap: wrap; gap: 0.4rem; }

    /* Stack form fields into a single column */
    .inline-form { flex-direction: column; align-items: stretch; gap: 0.6rem; }
    .inline-form label { width: 100%; }

    /* Stat tiles span the full width on their own row */
    .stat-tile { min-width: 0; flex: 1 1 100%; }

    /* Burndown chart: menu stacks above the chart on a phone */
    .burndown-body { flex-direction: column; }
    .burndown-menu {
        width: auto;
        max-height: 32%;
        border-right: none;
        border-bottom: 1px solid var(--line);
        padding-right: 0;
        padding-bottom: .5rem;
    }
}
