/* Touch-first baseline (§5, §8): tap targets ≥ 44px, no hover-only affordances,
   readable in tablet portrait and landscape. Later screens extend this file. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[x-cloak] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, sans-serif;
  /* 1rem ≥ 16px keeps mobile browsers from zooming when an input takes focus. */
  font-size: 1rem;
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
}

:focus-visible {
  outline: 3px solid var(--accent-ink);
  outline-offset: 1px;
}

/* 046 (Vic): one var pins the sticky tabs' height for two layers — the nav
   itself, and any element inside that wants to stick beneath it. */
/* The palette (092): every colour the app paints with is a variable here,
   the light values by default. An explicit Dark choice sets
   data-theme="dark" on <html> (lib/theme.js); Follow the phone — the
   default, no key stored — leaves the attribute off and lets the
   prefers-color-scheme block answer, which is also what makes live OS
   tracking free. That pair is why the dark values are stated twice below;
   keep the two blocks identical. Whites painted ON the green and red fills
   (the CTAs' and the danger button's own text) stay literal — they ride
   their fills, which hold their contrast in both themes. */
:root {
  --nav-h: 3.5rem;
  color-scheme: light;
  --paper: #f7f6f3;               /* the body and the sticky search box's backdrop */
  --surface: #ffffff;             /* the white card idiom: nav, cards, dialogs, inputs, buttons */
  --ink: #20242b;                 /* body text */
  --muted: #6f6b62;               /* grey text: hints, meta lines, note previews, footer */
  --ink-soft: #4a4e56;            /* subgroup headings, the order summary */
  --line-strong: #d9d5cd;         /* card, dialog, banner and nav borders */
  --line-tab: #e7e3da;            /* the tab bars' internal dividers */
  --divider: #eeeae1;             /* the row dividers */
  --control-line: #b5b0a6;        /* input and bordered-button borders */
  --accent: #2f6f4f;              /* the green as fill: CTAs, checkbox accents, the save panel's edge */
  --accent-ink: #2f6f4f;          /* the green as text/focus: saved chip, focus rings, the active tab's underline */
  --accent-soft: #e2efe9;         /* the saved chip's tinted background */
  --amber: #a2700a;               /* §5.2's warning amber: banners, the pending chip's text */
  --amber-soft: #f4ead2;          /* the pending chip's tinted background */
  --danger: #9d2b2b;              /* the red as fill: the danger button, the error panel's edge */
  --danger-ink: #9d2b2b;          /* the red as text: errors and save warnings */
  --chip-bg: #efede7;             /* the archived chip's background */
  --tan: #efe9dc;                 /* the photo pickers' button coat */
  --tan-line: #d8d0bf;
  --scrim: rgba(32, 36, 43, 0.4); /* the dialogs' backdrop */
  --toast-bg: #20242b;            /* the toast's own coat — dark in both themes */
  --toast-ink: #ffffff;
  --toast-line: rgba(255, 255, 255, 0.5);
}

/* The dark values, stated twice: this block for an explicit Dark choice,
   the media query below for Follow the phone. Keep the two identical.
   The green/red fills lift a step so they still read against dark cards;
   the text accents (accent-ink, amber, danger-ink) lift further, since
   small coloured text needs more contrast than a 44px fill does. */
[data-theme='dark'] {
  color-scheme: dark;
  --paper: #1d1f23;
  --surface: #26292f;
  --ink: #e8e6e1;
  --muted: #9d998f;
  --ink-soft: #b9bdc6;
  --line-strong: #3d414a;
  --line-tab: #33373f;
  --divider: #2e323a;
  --control-line: #6e6a61;
  --accent: #35795a;
  --accent-ink: #8cc7a5;
  --accent-soft: #234636;
  --amber: #d3a24a;
  --amber-soft: #443a22;
  --danger: #b04a4a;
  --danger-ink: #e58a8a;
  --chip-bg: #32363e;
  --tan: #3a362c;
  --tan-line: #57503e;
  --scrim: rgba(0, 0, 0, 0.65);
  --toast-bg: #3d4149;
  --toast-ink: #f2f1ee;
  --toast-line: rgba(255, 255, 255, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --paper: #1d1f23;
    --surface: #26292f;
    --ink: #e8e6e1;
    --muted: #9d998f;
    --ink-soft: #b9bdc6;
    --line-strong: #3d414a;
    --line-tab: #33373f;
    --divider: #2e323a;
    --control-line: #6e6a61;
    --accent: #35795a;
    --accent-ink: #8cc7a5;
    --accent-soft: #234636;
    --amber: #d3a24a;
    --amber-soft: #443a22;
    --danger: #b04a4a;
    --danger-ink: #e58a8a;
    --chip-bg: #32363e;
    --tan: #3a362c;
    --tan-line: #57503e;
    --scrim: rgba(0, 0, 0, 0.65);
    --toast-bg: #3d4149;
    --toast-ink: #f2f1ee;
    --toast-line: rgba(255, 255, 255, 0.4);
  }
}

nav {
  display: flex;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface);
  /* 046 (Vic): the tabs stay put while a long list scrolls — own sticky
     layer, fixed height (border-box), above the search box's sticky layer,
     which stops --nav-h short of the viewport top so it never tucks in
     under the bar it belongs to. */
  position: sticky;
  top: 0;
  z-index: 6;
  height: var(--nav-h);
}

nav button {
  flex: 1 1 0;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 4px;
  border: 0;
  border-left: 1px solid var(--line-tab);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

nav button:first-child {
  border-left: 0;
}

nav button.active {
  font-weight: 700;
  box-shadow: inset 0 -4px 0 var(--accent-ink);
}

main {
  flex: 1;
  width: 100%;
  max-width: 48rem;
  margin: 0 auto;
  padding: 1rem;
}

main h2 {
  margin-top: 0.25rem;
}

/* Login screen (§4 client half, issue 032): centred card, touch-sized controls. */
#gate-checking {
  padding: 2rem 1rem;
  color: var(--muted);
}

#screen-login form {
  display: grid;
  gap: 0.75rem;
  max-width: 24rem;
  margin: 12dvh auto 0;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

#screen-login .hint {
  margin: 0;
  color: var(--muted);
}

#screen-login label {
  font-weight: 600;
}

#screen-login input {
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
}

/* The green CTA: the login submit, the notes dialog's Save, the add-item
   dialog's Add, the edit order dialog's Save, the category and supplier
   adds (054, 055) and To Order's Save orders. */
#screen-login button,
.note-actions .save,
.form-actions :is(.add, .save),
.category-add .add,
.supplier-add .add,
.save-orders {
  min-height: 44px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

#screen-login :is(input, button):disabled {
  opacity: 0.6;
}

.error {
  margin: 0;
  color: var(--danger-ink);
}

/* Stock Check (§5.1, issue 034): touch-first grouped list.

   Button baseline: everything clickable inside main is a touch-sized control
   (§5); nav and the login screen sit outside main and keep their own styles. */
/* §5.1's search box (issue 037): pinned above the list — sticky keeps it
   reachable while a long list scrolls under the box's own background. */
.search-box {
  /* §5.1's search box (issue 037): pinned above the list — sticky keeps it
     reachable while a long list scrolls under the box's own background. top
     clears the sticky tabs' height (--nav-h), so the box pins just beneath
     them instead of sliding under them. */
  position: sticky;
  top: var(--nav-h);
  z-index: 5;
  display: flex;
  gap: 0.5rem;
  margin: 0.25rem 0 0.75rem;
  padding: 0.25rem 0;
  background: var(--paper);
}

.search-box input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
}

/* The app owns the (x): the UA's type=search cross cannot be told to strip
   the No-matches state and keep focus in the box, so hide it and let the
   .clear-search button be the only one. */
.search-box input::-webkit-search-cancel-button {
  display: none;
}

.search-box .clear-search {
  flex: 0 0 auto;
  width: 44px;
  padding: 0;
  font-size: 1.1rem;
  border: 1px solid var(--control-line);
  background: var(--surface);
}

/* 085's Add item button rides the sticky box on Manage's Items card — the
   bordered-white control the toolbar buttons share, beside the search it
   stays reachable while the list scrolls. */
.search-box .add-item {
  flex: 0 0 auto;
  border: 1px solid var(--control-line);
  background: var(--surface);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

main button {
  min-height: 44px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}

.toolbar button,
.banner button,
.note-button,
.unflag-button,
.back-button,
.row-edit,
.row-rename,
.row-delete,
.row-view,
.row-archive,
.row-restore,
.manage-account-row button {
  border: 1px solid var(--control-line);
  background: var(--surface);
}

.toolbar button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* §7's offline banner (issue 059): one screen-wide notice above the list,
   §5.2's warning amber at its edge — being offline is the condition, not a
   failed save, so not §6's error red. Its single string slot is what 061's
   "N changes waiting to sync" joins. */
.banner {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
}

/* A visible error with a way back: the load failure otherwise dead-ends the
   screen (or a dialog, 036); a flag failure rolls its row back and needs only
   the next tap. */
.retry {
  padding: 8px 12px;
  color: inherit;
  text-decoration: underline;
}

.flagged-only,
.group-by,
.show-archived,
.theme-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}

.flagged-only input,
.group-by input,
.show-archived input,
.theme-option input {
  width: 1.5rem;
  height: 1.5rem;
  accent-color: var(--accent);
}

.muted {
  color: var(--muted);
}

/* §5.1's No-matches end (037): the message and the Add-as-new-item shortcut
   sit side by side and wrap apart when the needle is long. */
.no-matches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}

.no-matches .add-shortcut {
  border: 1px solid var(--control-line);
  background: var(--surface);
}

/* The white card idiom: Stock Check's categories, To Order's review items and
   Manage's sections are the same card. */
.category,
.manage-section {
  margin-bottom: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.category h3 {
  margin: 0;
}

/* The whole header bar toggles: a 44px-wide target already, name left. */
.category-toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 10px 12px;
  font-weight: 700;
  text-align: left;
}

.chevron {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); /* collapsed: pointing right */
  transition: transform 150ms ease;
}

.category-toggle[aria-expanded='true'] .chevron {
  transform: rotate(45deg); /* expanded: pointing down */
}

.items {
  margin: 0;
  padding: 0 12px 8px;
  list-style: none;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 7px 0;
}

.item-row + .item-row {
  border-top: 1px solid var(--divider);
}

.item-details {
  flex: 1;
  min-width: 0;
}

.item-name {
  overflow-wrap: anywhere;
}

.last-ordered {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
}

/* §5.1 (038 phone pass): the note shows in full — Vic's notes are short
   strings ("we only need stud earrings"), so a one-line ellipsis only
   truncated usefully-readable previews; the full note wraps, bounded by
   the notes dialog's 250-char cap. */
.note-preview {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
}

/* §5.1, D37: the save's §6 message belongs at its failing row. */
.row-error {
  margin: 4px 0 0;
  color: var(--danger-ink);
}

.saved-chip {
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 999px;
  animation: saved-in 150ms ease-out;
}

/* §7's pending marker (061): the change is applied on this device but still
   riding the offline queue — the banner's amber, not the saved green, because
   the server has not answered yet. */
.pending-chip {
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--amber);
  background: var(--amber-soft);
  border-radius: 999px;
}

@keyframes saved-in {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .saved-chip,
  .chevron {
    animation: none;
    transition: none;
  }
}

/* 038, D37: word stacked over its box — narrow column; the label is the 44px tap target. */
.reorder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 44px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}

.reorder input {
  width: 1.75rem;
  height: 1.75rem;
  accent-color: var(--accent);
}

/* To Order (§5.2, issue 041): the flagged list, two levels deep — the outer
   card and its collapsible header reuse Stock Check's .category rules; the
   inner subgroup heading and the qty entry are this screen's own. Laptop-first,
   but §5's touch-first rule holds app-wide. */
.subgroup + .subgroup {
  border-top: 1px solid var(--divider);
}

.subgroup h4 {
  margin: 8px 12px 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink-soft);
}

/* §5.2's Qty ordered entry: min=1 step=1 mirror §6's positive integer (the
   042 save re-validates); digits right-aligned into a narrow column. */
.item-row .qty-input {
  width: 6.5rem;
  min-height: 44px;
  padding: 8px 10px;
  font: inherit;
  text-align: right;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
}

/* §5.2's save form (issue 042): the two header fields and the CTA in one
   wrapping row — the laptop's natural layout, §5's 44px floor intact.
   The mirror stops where the browser cannot: an impossible input sails and
   surfaces §6's message in the panel (epic 039). */
.save-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 1rem;
  margin: 0.25rem 0 0.75rem;
}

.save-form .field {
  display: grid;
  gap: 2px;
}

.save-form label {
  font-size: 0.875rem;
  font-weight: 600;
}

.save-form input {
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
}

/* The Ordered by column holds its width across reflows; the date keeps the
   UA's own. */
.save-form .name-input {
  width: 16rem;
}

/* §5.2's confirmation (042): a card under the form, the last save action's
   one slot. Warnings edge it amber; a rejected batch edges it red. Nothing
   here can be scrolled away or dismissed — the next save replaces it. */
.save-panel {
  margin: 0 0 0.75rem;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
}

.save-panel-error {
  border-left-color: var(--danger);
}

.save-panel-warning {
  border-left-color: var(--amber);
}

/* The report's spacing is one grid gap; the UA's own p/ul margins are
   zeroed at the panel so the gap is the only rhythm. */
.save-panel :is(p, ul) {
  margin: 0;
}

.save-panel > div {
  display: grid;
  gap: 0.5rem;
}

.save-panel ul {
  padding-left: 1.25rem;
}

.save-panel .warn-heading {
  font-weight: 700;
  color: var(--amber);
}

.save-panel .save-warnings li {
  color: var(--danger-ink);
}

/* 046 (3a): the warned flag's surviving note under §6's message — the thing
   "review the item" asks for. Row-note scale (.note-preview's), grey so the
   note reads as content, not as the alarm the message is. */
.save-panel .warn-note {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* History (§5.3, issue 044): one flat card holding the recent-50, the picker
   matches, and the per-item rows — .item-row reuses Stock Check's divider and
   its tap baseline; the date/name/meta lines and the picker buttons are this
   screen's own. The archived chip marks §5.3's archived matches. */
.orders {
  margin: 0 0 0.75rem;
  padding: 0 12px 8px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}

.order-date {
  display: block;
  font-weight: 700;
}

.order-item {
  display: block;
  overflow-wrap: anywhere;
}

.order-meta {
  display: block;
  font-size: 0.875rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* The picker row is the tap target: one full-width button per match. 079's
   thumbnail joins the row as a sibling, so the button flexes beside it —
   with the thumbnail hidden (a photo-less item) it fills the row as before. */
.match-button {
  display: block;
  flex: 1;
  min-height: 44px;
  padding: 6px 0;
  text-align: left;
}

.match-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.archived-chip {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--chip-bg);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
}

/* §5.3's row actions (045): Edit and Delete, touched targets in a cluster
   that drops below the entry's text when the row runs tight — the buttons
   size off main's own button rule and take their coat from the bordered
   group up top. */
.orders .item-row {
  flex-wrap: wrap;
}

.row-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
}

/* §5.3's delete confirm: the identification line shrinks under the heading;
   053's archive confirm extends the same slot to its cost sentence. */
.delete-dialog h2 {
  margin-bottom: 0.25rem;
}

.order-identity,
.archive-cost {
  margin: 0 0 1rem;
  overflow-wrap: anywhere;
}

.back-button {
  margin-bottom: 0.75rem;
}

.item-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  overflow-wrap: anywhere;
}

.order-summary {
  margin: 0 0 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
}

/* §8's dialogs are native <dialog> sheets — the notes dialog (035) landed the
   style; the add-item dialog (036) joins the selectors rather than
   re-declaring. showModal() owns the trap/Escape/focus-restore; the styles
   only lay it out, over the UA sheet's own centering. 086's clamp is the
   shared height guarantee: content taller than the viewport scrolls inside
   its own dialog, so no photo, list or error line can push its actions off
   screen — the edit card's overflow was the case that named it. */
.note-dialog,
.add-dialog,
.edit-dialog,
.delete-dialog,
.review-dialog {
  width: min(28rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  padding: 1.25rem 1.5rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.note-dialog::backdrop,
.add-dialog::backdrop,
.edit-dialog::backdrop,
.delete-dialog::backdrop,
.review-dialog::backdrop {
  background: var(--scrim);
}

.note-dialog h2,
.add-dialog h2,
.edit-dialog h2,
.delete-dialog h2,
.review-dialog h2 {
  margin: 0 0 0.75rem;
  overflow-wrap: anywhere;
}

.note-dialog label,
.add-dialog label,
.edit-dialog label {
  font-weight: 600;
}

.note-dialog textarea,
.add-dialog :is(input, select),
.edit-dialog :is(input, select) {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
}

/* The note textarea keeps its own breathing room; the add dialog stacks as a
   grid, whose gaps replace per-field margins. */
.note-dialog textarea {
  margin: 0.25rem 0;
  resize: vertical;
}

.add-dialog form,
.edit-dialog form {
  display: grid;
  gap: 0.3rem;
}

/* The action pair the dialogs share: flex-end on its own — its row has no
   .clear auto-margin to anchor it, and flex-end must not touch the note row,
   whose pair sits differently when Clear is hidden (035). The add (036),
   edit and delete dialogs (045) all use it. */
.note-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.form-actions {
  justify-content: flex-end;
}

.note-counter {
  display: block;
  text-align: right;
  font-size: 0.875rem;
  color: var(--muted);
}

.note-actions :is(.clear, .cancel),
.form-actions .cancel,
.restore {
  border: 1px solid var(--control-line);
  background: var(--surface);
}

/* Clear anchors left so the confirm/cancel pair stays right; with no note
   (Add note) Clear is hidden and the pair closes up against the edge. */
.note-actions .clear {
  margin-right: auto;
}

.note-actions button:disabled,
.form-actions button:disabled,
.category-add button:disabled,
.supplier-add button:disabled,
.save-orders:disabled {
  opacity: 0.5;
  cursor: default;
}

/* 045's destructive confirm: the Delete that means it, red beside the
   green it sits next to — size off main's button rule like the rest. */
.form-actions .danger {
  color: #ffffff;
  background: var(--danger);
}

/* 048's review-before-record dialogue: the changed items as cards, one
   checkbox per card, the live state (D46's note voice) reading before the
   choice. The lede is grey like a row note; the checkbox's row is the tap
   target's own. */
.review-lede {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.review-dialog .review-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-height: 50dvh;
  overflow: auto;
}

.review-dialog .item-row {
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
}

.review-dialog :is(.item-name, .review-include) {
  font-weight: 700;
}

.review-include {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.review-dialog .review-qty {
  font-size: 0.875rem;
  color: var(--muted);
}

/* §5.1's untick-undo toast: one fixed slot at the bottom edge of the screen. */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: calc(100vw - 2rem);
  padding: 6px 8px 6px 16px;
  background: var(--toast-bg);
  color: var(--toast-ink);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  z-index: 10;
}

.toast button {
  padding: 8px 14px;
  color: var(--toast-ink);
  border: 1px solid var(--toast-line);
}

/* Manage (§5.4, issue 050): each §5.4 section renders as 078's one white
   card under its subtab — the card is .category's, joined at its selector;
   D90 replaced the four-card scroll with the tab bar above. */
/* 078's subtabs (§5.4, D90): the header nav's idiom one level down — a
   class, not the `nav` element, whose app-wide sticky rules must not
   reach in here; these tabs scroll with the screen. */
.manage-tabs {
  display: flex;
  margin-bottom: 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.manage-tabs button {
  flex: 1 1 0;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 4px;
  border: 0;
  border-left: 1px solid var(--line-tab);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.manage-tabs button:first-child {
  border-left: 0;
}

.manage-tabs button.active {
  font-weight: 700;
  box-shadow: inset 0 -4px 0 var(--accent-ink);
}

.manage-section {
  padding: 10px 12px 12px;
}

.manage-section .muted {
  margin: 0;
}

/* §5.4's Items list (issue 051): one flat card of every item — archived
   rows riding 078's default hide (D90) — the white card idiom the
   sections ship with is the ul's own (.category/.orders's idiom),
   .item-row reuses Stock Check's divider and baseline exactly as
   History's list does. The filter's D36 box needs no CSS of its own:
   .search-box already pins beneath the tabs wherever it sits, and inside
   the Items card it stays pinned only while that card is on screen. The
   Categories rows (054) are the list's second tenant, Suppliers' (055)
   the third. */
.manage-items,
.manage-categories,
.manage-suppliers {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* §5.4's inline add rows (054, 055): input and its green Add on one line,
   a rejection's message wrapping full-width beneath; the min-height keeps
   the box a touch target like every row control. */
.category-add,
.supplier-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.category-add input,
.supplier-add input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  border: 1px solid var(--control-line);
  border-radius: 6px;
  background: var(--surface);
}

.category-add .add,
.supplier-add .add {
  flex: 0 0 auto;
}

/* §5.4's row actions (052–055): the D42 chip, Edit and the row's write
   control share one right-side cluster, and the row drops it below the text
   when it runs tight — History's rows (045) wrap the same way, sized off
   main's own button rule. */
.manage-items .item-row,
.manage-categories .item-row,
.manage-suppliers .item-row {
  flex-wrap: wrap;
}

/* The Account row: the logout button and its failure message share one
   height so the message never shoves the button down the screen. 092's
   theme radios ride the flagged-only idiom (.theme-option, joined at its
   selector group up top) — the label is the 44px tap target. */
.manage-account-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

footer {
  padding: 10px 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

/* 073: item photos (D78/D79). The row thumbnail is a 44px-plus tap target
   (§5.1's touch rule) that opens the fullscreen viewer; the img inside is
   decorative (empty alt, the button's aria-label carries the name). A failed
   load drops its own src — the offline-without-cache case — instead of
   showing the browser's broken-image icon. */
.photo-button {
  flex: 0 0 auto;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}

.item-photo {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.photo-viewer img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin: 12px 0;
  border-radius: 8px;
}

/* The add dialog's staged photo: the resize's answer is both preview and
   upload, the (x) clears it. */
.add-photo-preview {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 8px;
}

.add-photo-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
}

/* The edit dialog's photo section: preview, a replace label over a clipped
   file input (the label is the picker; :focus-within keeps it reachable from
   the keyboard), and the state-named remove. */
.edit-photo {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-bottom: 8px;
}

/* 079: the edit card's photo at reading size — full width up to 086's 12rem
   cap, object-fit contain keeping the whole photo visible; a flex child of
   the wrapping .edit-photo row, so the pickers wrap beneath. The lists'
   .item-photo square is untouched. */
.edit-photo-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 12rem;
  object-fit: contain;
  border-radius: 8px;
}

.edit-photo input[type='file'] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* 079 adds the camera picker: one clipped input behind its own label, the
   capture attribute opening the camera on the tablet, the same button coat
   as the picker. */
.edit-photo .photo-replace,
.edit-photo .photo-camera {
  padding: 6px 12px;
  font-size: 1rem;
  background: var(--tan);
  border: 1px solid var(--tan-line);
  border-radius: 8px;
  cursor: pointer;
}

.edit-photo .photo-replace:focus-within,
.edit-photo .photo-camera:focus-within {
  outline: 2px solid var(--accent-ink);
}

.photo-remove {
  padding: 6px 12px;
}
