/* Ladu — "1b / Modern SaaS" skin. Tokens and specs come from the design
   handoff; nothing here knows about routes or stock. */

:root {
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  --bg:        #fafafa;
  --card:      #ffffff;
  --border:    #ececef;
  --row:       #f2f2f4;
  --row-2:     #f5f5f6;

  --text:      #18181b;
  --muted:     #71717a;
  --faint:     #9b9ba3;
  --fainter:   #b4b4bb;
  --chev:      #c7c7cf;

  --accent:    #4f46e5;
  --accent-bg: #eef0ff;

  --green:     #16a34a;
  --green-bg:  #eefaf1;
  --red:       #dc2626;
  --red-bg:    #fdecec;
  --amber:     #b45309;
  --amber-bg:  #fef3c7;
  --fill:      #efeff2;
  --fill-2:    #f4f4f5;

  --tabbar: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

input, select, button, textarea { font-family: inherit; color: var(--text); }
button { cursor: pointer; }
.fld:focus { outline: none; }

/* Scrollbars are noise on a phone. */
.scr { scrollbar-width: none; }
.scr::-webkit-scrollbar { width: 0; height: 0; }

/* Shell -------------------------------------------------------------------- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 402px;
  margin: 0 auto;
}

header {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 18px 20px 14px;
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--faint); letter-spacing: 0.02em; }
h1 { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }

.account {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid #e4e4e8;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.account .ico { font-size: 15px; line-height: 1; }

main {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--tabbar) + 24px + env(safe-area-inset-bottom));
}

.hint { margin: 2px 4px 14px; font-size: 13px; line-height: 1.45; color: var(--faint); }
.hint.tight { margin: -4px 4px 10px; }

.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 2px 8px;
}

.section-label > span:first-child {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.legend { display: flex; gap: 14px; font-size: 11px; color: var(--fainter); }
.legend span { text-align: right; }
.legend .l, .legend .t { width: 34px; }
.legend .tot { width: 40px; }

/* Cards and list rows ------------------------------------------------------ */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
}

/* A card's title bar. Phones need it too: it used to live only in the desktop
   block, which left every mobile card title jammed against the border. */
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--row);
}

.card-head .t { font-weight: 700; font-size: 15px; }

.card-head .count {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.card-head .more { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }


.cell {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 15px 16px;
  border: 0;
  border-bottom: 1px solid var(--row);
  background: none;
  text-align: left;
  text-decoration: none;
  color: var(--text);
}

.cell:last-child { border-bottom: 0; }
.cell .grow { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; }
.cell .ico { font-size: 20px; line-height: 1; }
.chev { color: var(--chev); font-size: 18px; transition: transform 0.2s; }

/* Field rows (location selects, note, sheet inputs) */

.field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--row);
}

.field:last-child { border-bottom: 0; }
.field > .lbl { font-size: 13.5px; color: var(--muted); min-width: 108px; }
.card.filters .field > .lbl { min-width: 96px; }

.field input,
.field select {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  text-align: right;
  font-size: 14.5px;
  color: var(--text);
  padding: 0;
  appearance: none;
}

.field input::placeholder { color: var(--fainter); }

/* A native select with no chrome reads as plain text, so the value carries the
   accent and a decorative caret follows it. */
.field select {
  font-weight: 700;
  color: var(--accent);
  text-align-last: right;
}

.field .caret {
  color: var(--accent);
  font-size: 13px;
  margin-left: 4px;
  pointer-events: none;
}

.field input[type="date"] { font-weight: 700; color: var(--accent); }

/* Buttons ------------------------------------------------------------------ */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

/* A submit in flight: greyed and unclickable, so a double-tap does nothing. */
button.busy { opacity: 0.55; pointer-events: none; }

.btn.plain {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--accent);
}

.btn.quiet {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn.danger {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--red);
}

.row2 { display: flex; gap: 8px; }
.row2 .btn { flex: 1; }

/* Segmented control (Kööki / Maha) ----------------------------------------- */

.seg {
  display: flex;
  gap: 8px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--fill);
  border-radius: 12px;
}

.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }

.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.seg input:checked + span { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.seg .kook input:checked + span { color: var(--text); }
.seg .maha input:checked + span { color: var(--red); }

/* Date strip --------------------------------------------------------------- */

.dates { display: flex; gap: 8px; margin-bottom: 16px; }
.day { flex: 1; position: relative; }
.day input { position: absolute; opacity: 0; pointer-events: none; }

/* Direct child only: the tile holds a .wd and a .num span, and a descendant
   selector would draw the border and padding around each of those too. */
.day > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px;
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 12px;
}

/* border-color as its own declaration: the shorthand above would reset the
   width when only the color is meant to toggle. */
.day > span { border-color: var(--border); }
.day .wd { font-size: 11px; line-height: 1.2; color: var(--faint); }
.day .num { font-size: 18px; font-weight: 700; line-height: 1.2; color: var(--text); }

.day input:checked + span { border-color: var(--accent); }
.day input:checked + span .wd,
.day input:checked + span .num { color: var(--accent); }

/* Calendar ----------------------------------------------------------------- */

.cal {
  padding: 12px;
  margin-bottom: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.cal[hidden] { display: none; }

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cal-title { font-size: 14.5px; font-weight: 700; text-transform: capitalize; }

.cal-nav {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: var(--fill);
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.cal-nav:disabled { color: var(--fainter); }

.cal-wd, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.cal-wd span {
  padding-bottom: 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--fainter);
}

.cal-grid button {
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.cal-grid button:disabled { color: var(--fainter); }
.cal-grid button.today { color: var(--accent); }
.cal-grid button.on { background: var(--accent); color: #fff; }

/* Product picker ----------------------------------------------------------- */

.product { border-bottom: 1px solid var(--row); background: var(--card); }
.product:last-child { border-bottom: 0; }
.product[hidden] { display: none; }
.product.has { background: #f9f9ff; }
.product.open { background: #f7f7fb; }
.product.short { background: var(--red-bg); box-shadow: inset 3px 0 0 var(--red); }
.product.short .picked { background: var(--red); }

.product .top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  background: none;
  text-align: left;
}

.product .emoji { font-size: 22px; width: 26px; text-align: center; line-height: 1; }
.product .name { flex: 1; min-width: 0; }
.product .name .n { display: block; font-weight: 600; font-size: 15px; color: var(--text); }
.product .name .sub { display: block; font-size: 12px; color: var(--faint); }

.product .picked {
  padding: 3px 9px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.product.open .chev { transform: rotate(90deg); }

.panel { display: none; padding: 2px 16px 16px; }
.product.open .panel { display: block; }

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.stepper button {
  flex: none;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
}

.stepper button:active { background: #e2e5ff; }
.stepper .amount { flex: 1; text-align: center; }

.stepper .amount input {
  width: 100%;
  border: 0;
  background: none;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  padding: 0;
}

.stepper .amount .unit { display: block; font-size: 12px; color: var(--faint); }

.panel .btn { min-height: 44px; border-radius: 11px; }
.panel .diff { margin: 0 0 12px; text-align: center; font-size: 13px; color: var(--faint); }

/* Batched units: a varras or ämber is a button you tap, not a number you type.
   A grid of them, each showing its weight and date; tapped ones fill in. */
.units {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  padding: 2px 0;
}

.unit-pick, .deck-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 60px;
  padding: 10px 8px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

.unit-pick:active, .deck-pick:active { transform: scale(0.97); }
.unit-pick .uw, .deck-pick .uw { font-size: 15px; font-weight: 700; color: var(--text); }
.unit-pick .ud, .deck-pick .ud { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.unit-pick.on, .deck-pick.on {
  background: var(--accent);
  border-color: var(--accent);
}
.unit-pick.on .uw, .deck-pick.on .uw { color: #fff; }
.unit-pick.on .ud, .deck-pick.on .ud { color: #d9d7fb; }
.panel .diff.up { color: var(--green); font-weight: 700; }
.panel .diff.down { color: var(--red); font-weight: 700; }

/* Take-along note: the handoff list on Võta kaasa, and the builder on the
   day-end page. A row per requested product, with tick / pencil / cross. */

.ta-note .card-head, .ta-builder .card-head { padding-bottom: 6px; }
.ta-list { list-style: none; margin: 0; padding: 0 14px 8px; }
.ta-list.plain { padding-bottom: 12px; }

.ta-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-top: 1px solid var(--row);
}
.ta-item:first-child { border-top: none; }
.ta-item.taken { opacity: 0.5; }

.ta-name { flex: 1; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.ta-name .emoji { font-size: 17px; }
.ta-qty { color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; }
.ta-why {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 1px 7px;
  border-radius: 999px;
}

.ta-marks { display: flex; gap: 6px; }
.ta-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.ta-mark.yes { color: var(--green); }
.ta-mark.no { color: var(--red); }
.ta-mark.edit { color: var(--accent); }
.ta-mark:active { transform: scale(0.95); }

.ta-edit-row { display: flex; gap: 6px; align-items: center; }
.ta-edit-row[hidden] { display: none; }
.ta-edit-qty { width: 5rem; text-align: center; }

/* The take-along deck: one full-screen card per request, swiped like a pile. */
.btn.deck-open { min-height: 56px; margin: 4px 0 12px; gap: 10px; font-size: 17px; cursor: pointer; box-shadow: 0 6px 18px rgba(80, 70, 230, 0.28); }
.deck-open-n { min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px; background: #fff; color: var(--accent); font-size: 14px; line-height: 26px; }
.deck[hidden] { display: none; }
.deck {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
}
body.deck-on { overflow: hidden; }
.deck-top { display: flex; align-items: center; justify-content: space-between; }
.deck-count { font-size: 14px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.deck-stack { position: relative; flex: 1; margin: 18px 0; }
.deck-card {
  position: absolute; inset: 0;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  touch-action: pan-y; user-select: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.deck-card.current, .deck-card.next, .deck-card.gone.out-left, .deck-card.gone.out-right { display: flex; }
.deck-card.next { transform: scale(0.95) translateY(12px); z-index: 0; }
.deck-card.current { z-index: 1; }
.deck-card.dragging { transition: none; }
.deck-card.gone { pointer-events: none; opacity: 0; z-index: 2; }
.deck-card.out-right { transform: translateX(120%) rotate(18deg); }
.deck-card.out-left { transform: translateX(-120%) rotate(-18deg); }
.deck-emoji { font-size: 72px; line-height: 1; }
.deck-name { font-size: 24px; font-weight: 800; text-align: center; padding: 0 18px; }
.deck-why {
  font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-bg);
  border-radius: 999px; padding: 4px 10px;
}
.deck-qty { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.deck-qty > button {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--fill-2); font-size: 26px; font-weight: 700; color: var(--text); cursor: pointer;
}
.deck-qty > span { display: flex; align-items: baseline; gap: 6px; }
.deck-qty input {
  width: 3.2ch; text-align: right; font-size: 34px; font-weight: 800;
  border: 0; background: none; padding: 0; font-variant-numeric: tabular-nums;
}
.deck-qty em { font-style: normal; font-size: 16px; font-weight: 700; color: var(--muted); }
.deck-hint { margin: 16px 0 0; font-weight: 700; color: var(--muted); }
.deck-picks { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; padding: 0 16px; }
.deck-pick { min-width: 110px; min-height: 72px; justify-content: center; }
.deck-pick .uw { font-size: 18px; }
.deck-card.need .deck-hint { color: var(--red); animation: deck-nudge 0.3s; }
@keyframes deck-nudge { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.deck-stamp {
  position: absolute; top: 22px; padding: 6px 12px; border-radius: 10px;
  font-size: 18px; font-weight: 800; text-transform: uppercase; border: 3px solid; opacity: 0;
}
.deck-stamp.yes { left: 20px; color: var(--green); transform: rotate(-12deg); }
.deck-stamp.no { right: 20px; color: var(--red); transform: rotate(12deg); }
.deck-card[data-lean="yes"] .deck-stamp.yes, .deck-card[data-lean="no"] .deck-stamp.no { opacity: 1; }
.deck-done { position: absolute; inset: 0; display: none; flex-direction: column; justify-content: center; gap: 12px; text-align: center; }
.deck-done .t { font-size: 22px; font-weight: 800; }
.deck-done .sub { color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.deck.finished .deck-done { display: flex; }
.deck.finished .deck-actions { visibility: hidden; }
.deck-actions { display: flex; justify-content: center; gap: 36px; }
.deck-btn {
  width: 72px; height: 72px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); font-size: 30px; font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}
.deck-btn.yes { color: var(--green); }
.deck-btn.no { color: var(--red); }
.deck-btn:active { transform: scale(0.94); }
.btn.small { width: auto; min-height: 34px; padding: 0 14px; font-size: 13px; }

.ta-picker { padding: 4px 14px 14px; }
.ta-picker .finder { margin: 0 0 8px; }

/* No inner scroll -- the list flows with the page, search narrows it. */
.ta-options { display: flex; flex-direction: column; }

.ta-opt { border-top: 1px solid var(--row); }
.ta-opt:first-child { border-top: none; }
.ta-opt[hidden] { display: none; }

.ta-opt-top {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 6px;
  border: none;
  background: none;
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.ta-opt-top .emoji { font-size: 18px; }
.ta-opt-name { flex: 1; }
.ta-opt-top .chev { color: var(--chev); font-size: 20px; transition: transform 0.15s; }
.ta-opt.open .ta-opt-top { color: var(--accent); }
.ta-opt.open .ta-opt-top .chev { transform: rotate(90deg); color: var(--accent); }

.ta-opt-panel { display: none; flex-direction: column; gap: 12px; padding: 4px 4px 16px; }
.ta-opt.open .ta-opt-panel { display: flex; }
.ta-opt-panel .stepper { margin: 0; }
.ta-opt-panel .quick:empty { display: none; }
.ta-opt-panel .btn { width: 100%; }

/* Role hub: the department's actions as big cards, one tap each. */

.hub { display: flex; flex-direction: column; gap: 10px; }

.hub-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.hub-card:active { background: var(--row); }

.hub-ico {
  flex: none;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: var(--accent-bg);
  border-radius: 13px;
}

.hub-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hub-label { font-size: 16px; font-weight: 700; }
.hub-sub { font-size: 13px; color: var(--muted); }
.hub-go { color: var(--chev); font-size: 22px; }

@media (min-width: 700px) {
  .hub { display: grid; grid-template-columns: 1fr 1fr; }
}

/* Basket ------------------------------------------------------------------- */

.basket {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom));
  z-index: 12;
  width: min(372px, calc(100vw - 30px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  background: #18181b;
  border-radius: 16px;
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.4);
  transform: translateX(-50%) translateY(200%);
  transition: transform 0.24s cubic-bezier(0.32, 0.72, 0, 1);
}

.basket.on { transform: translateX(-50%); }
.basket .count { flex: 1; font-size: 14px; font-weight: 600; color: #d4d4d8; }

.basket .btn {
  width: auto;
  min-height: 0;
  padding: 10px 18px;
  border-radius: 11px;
  font-size: 15px;
}

/* Tab bar ------------------------------------------------------------------ */

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  z-index: 10;
  width: min(402px, 100vw);
  display: flex;
  padding: 8px 6px calc(10px + env(safe-area-inset-bottom));
  background: rgba(250, 250, 250, 0.9);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
}

.tabbar .ico { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: 0.4; }
.tabbar .lbl { font-size: 10.5px; font-weight: 600; color: #a1a1aa; }
.tabbar a.on .ico { filter: none; opacity: 1; }
.tabbar a.on .lbl { color: var(--accent); }

/* Overview ----------------------------------------------------------------- */

.kpis { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

/* Two to a row on a phone: /statistika's four ran off the right edge. */
.kpi {
  flex: 1 1 calc(50% - 5px);
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
}

.kpi .lbl { font-size: 11.5px; font-weight: 600; color: var(--faint); }

.kpi .val {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi .val.accent { color: var(--accent); }
.kpi .sub { font-size: 12px; color: var(--faint); margin-top: 2px; }

.stock-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--row);
}

.stock-row:last-child { border-bottom: 0; }
.stock-row .emoji { font-size: 19px; width: 24px; text-align: center; }
.stock-row .name { flex: 1; min-width: 0; font-weight: 600; font-size: 14.5px; }
.stock-row .num { font-variant-numeric: tabular-nums; text-align: right; }
.stock-row .at { width: 34px; font-size: 13px; color: var(--faint); }
/* Spent on the way out: no per-location split, just the one stock under
   kokku. The spacer holds both location columns (34 + gap + 34) so the
   totals stay in a line down the card. */
.stock-row .at.carried { width: 79px; }
.stock-row .tot { width: 40px; font-size: 14px; font-weight: 700; color: var(--text); }

.badge {
  margin-left: 7px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

/* Log ---------------------------------------------------------------------- */

.entry { padding: 13px 15px; border-bottom: 1px solid var(--row); }
.entry:last-child { border-bottom: 0; }
.entry.voided { opacity: 0.5; }
.entry.voided .what strong { text-decoration: line-through; }

.entry .head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--faint);
}

.entry .head .who { margin-left: auto; }

.pill {
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--fill-2);
  color: #3f3f46;
  font-size: 11px;
  font-weight: 700;
}

.pill.t-purchase { background: var(--green-bg); color: var(--green); }
.pill.t-transfer,
.pill.t-inventory_adjustment { background: var(--accent-bg); color: var(--accent); }
.pill.t-waste { background: var(--red-bg); color: var(--red); }
.pill.t-consumption { background: var(--fill-2); color: #3f3f46; }
.pill.t-kaup { background: var(--fill-2); color: var(--muted); }

.entry .what { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.entry .what .emoji { font-size: 17px; }
.entry .what strong { font-size: 15px; font-weight: 700; }
.entry .what .qty { font-weight: 600; color: #3f3f46; font-variant-numeric: tabular-nums; }
.entry .what .meta { font-size: 13px; color: var(--faint); }
.entry .note { margin: 6px 0 0; font-size: 13px; color: var(--faint); }
.entry .note.struck { color: var(--red); }

.entry .batch {
  list-style: none;
  margin: 8px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--row);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.entry .batch li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
}
.entry .batch li span { font-variant-numeric: tabular-nums; color: var(--faint); }
.entry .actions { display: flex; gap: 8px; margin-top: 10px; }
.entry .actions form { display: flex; gap: 8px; flex: 1; }

.entry .actions input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 13px;
}

.entry .actions .btn { width: auto; min-height: 38px; padding: 0 14px; border-radius: 10px; font-size: 13px; }

/* Sheet -------------------------------------------------------------------- */

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.4); }
.scrim[hidden] { display: none; }

.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  bottom: 0;
  z-index: 41;
  width: min(402px, 100vw);
  max-height: 88dvh;
  overflow-y: auto;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-radius: 22px 22px 0 0;

  /* Hidden by visibility, not by being shoved off-screen. translateY(100%)
     only clears the viewport when the sheet sits flush at bottom:0; lift it by
     any amount and the same transform leaves that much of it on screen. */
  visibility: hidden;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.28s;
}

.sheet.on { transform: translateX(-50%); visibility: visible; }
.grabber { width: 36px; height: 5px; border-radius: 4px; background: #d4d4d8; margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 14px; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
}

.emoji-grid label { position: relative; display: block; }
.emoji-grid input { position: absolute; opacity: 0; pointer-events: none; }

.emoji-grid span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 10px;
  font-size: 22px;
}

.emoji-grid input:checked + span { background: var(--accent); }

/* A switch reads as a setting; a checkbox reads as a form field. */
.switch { position: relative; display: flex; align-items: center; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch span {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: #d4d4d8;
  transition: background 0.2s;
}

.switch span::after {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

/* Flash -------------------------------------------------------------------- */

.flash {
  padding: 11px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 13.5px;
  font-weight: 600;
}

.flash.ok { background: var(--green-bg); color: var(--green); }
.flash.err { background: var(--red-bg); color: var(--red); }

/* Account picker ----------------------------------------------------------- */

.pick {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 360px;
  margin: 0 auto;
  padding: 40px 28px;
}

.brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; }

.brand .mark {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand .word { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.pick p { margin: 0 0 32px; text-align: center; color: var(--faint); font-size: 15px; }
.pick form { display: flex; flex-direction: column; gap: 12px; }

.pick button {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.pick button .ico {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: var(--accent-bg);
  font-size: 21px;
}

.pick button .go { margin-left: auto; color: var(--chev); font-size: 20px; }

/* Department heading above a group, on the picker and the people screen. */
.pick-dept {
  margin: 20px 4px 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.pick .pick-dept:first-of-type { margin-top: 0; }

/* Login form. The card rows elsewhere are borderless and right-aligned -- label
   on the left, value on the right -- which reads as flat grey text here and
   starts typing from the wrong side. The login gets real boxes instead. */
.pick .field {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 0;
  border-bottom: 0;
  text-align: left;
}

.pick .field .lbl {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pick .field input {
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  font-size: 16px;   /* 16px keeps iOS from zooming the page on focus */
  color: var(--text);
}

.pick .field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.pick .login .btn { width: 100%; margin-top: 6px; min-height: 46px; }

/* A password shown once, right after it is created. */
.reveal { border: 1px solid var(--accent); background: var(--accent-bg); padding: 14px 16px; }
.reveal .t { margin: 0 0 10px; font-weight: 700; font-size: 14px; }
.reveal .creds {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  align-items: center;
}
.reveal .creds span { font-size: 13px; color: var(--muted); }
.reveal .creds code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.reveal .sub { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* Permission checkboxes on /kasutajad. */
.rights { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.rights .right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
}
.rights .right input { accent-color: var(--accent); }
.person.off .ico { opacity: 0.5; }
.person.off .grow { color: var(--faint); }
.person .mark.off { margin-left: 8px; }


/* Viewport switch ----------------------------------------------------------
   The phone and the laptop want genuinely different overviews: two lists and
   two numbers versus a table, a rail and four. Both render; CSS picks. At 19
   products the duplicate markup is a rounding error against the round trip. */

.only-desktop { display: none; }
.tabbar .brand-nav, .tabbar .side-account, .tabbar .lbl-d, .tabbar a.desktop { display: none; }
.tabbar .nav-head { display: none; }
.head-actions { display: none; }

/* Desktop ------------------------------------------------------------------
   The owner reads on a laptop: the tab bar unrolls into a sidebar and the
   overview becomes the oversight view. */

@media (min-width: 900px) {
  :root { --tabbar: 0px; }

  .only-mobile { display: none; }
  .only-desktop { display: block; }

  .app { max-width: none; margin: 0; padding-left: 248px; }

  main { padding: 24px 32px 40px; }

  /* Topbar */

  header { padding: 20px 32px; }
  .head-row { gap: 16px; }
  h1 { font-size: 22px; }
  .chip-account { display: none; }
  .head-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

  .search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 240px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    font-size: 13.5px;
  }

  .search input { flex: 1; min-width: 0; border: 0; background: none; font-size: 13.5px; }
  .search input:focus { outline: none; }
  .search input::placeholder { color: var(--faint); }

  .btn.small {
    width: auto;
    min-height: 0;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    white-space: nowrap;
  }

  /* Sidebar */

  .tabbar {
    left: 0;
    top: 0;
    bottom: 0;
    transform: none;
    width: 248px;
    flex-direction: column;
    gap: 3px;
    padding: 22px 16px;
    background: var(--card);
    border-top: 0;
    border-right: 1px solid var(--border);
    backdrop-filter: none;
    overflow-y: auto;
  }

  .tabbar .lbl { display: none; }
  .tabbar .lbl-d { display: block; flex: 1; }
  .tabbar a.mobile { display: none; }
  .tabbar a.desktop { display: flex; }
  .tabbar .nav-head {
    display: block;
    padding: 15px 12px 5px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fainter);
  }

  .tabbar .brand-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 22px;
    text-decoration: none;
  }

  .tabbar .brand-nav .mark {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    font-size: 17px;
  }

  .tabbar .brand-nav .word { display: block; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; color: var(--text); }
  .tabbar .brand-nav .sub { display: block; font-size: 11px; font-weight: 600; color: var(--faint); }

  .tabbar a {
    flex: none;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .tabbar .ico { font-size: 17px; width: 20px; text-align: center; filter: none; opacity: 1; }
  .tabbar .lbl-d { font-size: 14.5px; font-weight: 600; color: #3f3f46; }
  .tabbar a.on { background: var(--accent-bg); }
  .tabbar a.on .lbl-d { color: var(--accent); }

  .tabbar .side-account { margin-top: auto; border-top: 1px solid var(--row); padding-top: 14px; }

  .tabbar .side-account button {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
  }

  .tabbar .side-account .ico {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    background: var(--accent-bg);
    font-size: 20px;
  }

  .tabbar .side-account .who { flex: 1; min-width: 0; }
  .tabbar .side-account .n { display: block; font-weight: 700; font-size: 14px; }
  .tabbar .side-account .sub { display: block; font-size: 12px; color: var(--faint); }
  .tabbar .side-account .go { color: var(--chev); font-size: 18px; }

  /* KPI row */

  .only-desktop .kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
  .only-desktop .kpi { border-radius: 16px; padding: 18px 20px; }

  .only-desktop .kpi .lbl {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--muted);
    font-weight: 600;
  }

  .only-desktop .kpi .lbl .ico { font-size: 18px; }
  .only-desktop .kpi .val { font-size: 32px; margin-top: 8px; }
  .only-desktop .kpi .sub { font-size: 12.5px; color: var(--faint); margin-top: 2px; }

  /* Two columns */

  .cols { display: grid; grid-template-columns: 1fr 356px; gap: 20px; align-items: start; }
  .rail .card:last-child { margin-bottom: 0; }
  .card { border-radius: 16px; }
  .card-head { padding: 15px 18px; }
  .kpis { flex-wrap: nowrap; }
  .kpi { flex: 1 1 0; }

  /* Stock table */

  .table .card-head { padding: 16px 20px; }

  .seg-mini {
    margin-left: auto;
    display: flex;
    gap: 6px;
    padding: 3px;
    border-radius: 9px;
    background: var(--fill-2);
  }

  .seg-mini button {
    border: 0;
    border-radius: 7px;
    padding: 6px 14px;
    background: none;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
  }

  .seg-mini button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }

  .thead, .trow { display: grid; grid-template-columns: 2.2fr 0.8fr 0.8fr 0.9fr 1fr; align-items: center; }

  .thead {
    padding: 10px 20px;
    border-bottom: 1px solid var(--row);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #a1a1aa;
  }

  /* A category banner across the table, above the products in it. */
  .cat-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--row-2);
    border-bottom: 1px solid var(--row);
  }
  .cat-head .n {
    margin-left: auto;
    font-size: 12px;
    color: var(--fainter);
    font-variant-numeric: tabular-nums;
  }

  .trow { padding: 12px 20px; border-bottom: 1px solid var(--row-2); }
  .trow:last-child { border-bottom: 0; }
  .trow.low { background: #fbfaff; }
  .trow.warn { background: #fffdf5; }
  .status.warn { background: var(--amber-bg); color: var(--amber); }
  .trow[hidden] { display: none; }

  /* The numeric headings must sit over their own column. Without this they
     stay left-aligned in the grid cell while the values under them are right-
     aligned, so every figure reads under the wrong heading. */
  .thead .num { text-align: right; }

  .trow .p { display: flex; align-items: center; gap: 11px; min-width: 0; }
  .trow .p .emoji { font-size: 20px; }
  .trow .p .n { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .trow .num { text-align: right; font-variant-numeric: tabular-nums; }
  .trow .at { font-size: 14px; color: var(--muted); }
  .trow .at.carried { grid-column: span 2; }
  .trow .tot { font-weight: 700; font-size: 15px; }
  .trow .tot .u { font-size: 11px; font-weight: 500; color: var(--fainter); }

  .tag {
    padding: 3px 9px;
    border-radius: 7px;
    background: var(--fill-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }

  .status { padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; }
  .status.laos { background: var(--green-bg); color: var(--green); }
  .status.tellida { background: var(--accent-bg); color: var(--accent); }

  /* Right rail */

  .rail { display: flex; flex-direction: column; gap: 20px; }
  .rail-row { display: flex; align-items: center; gap: 11px; padding: 11px 18px; border-bottom: 1px solid var(--row-2); }
  .rail-row:last-child { border-bottom: 0; }
  .rail-row.voided { opacity: 0.5; }
  .rail-row .emoji { font-size: 19px; }
  .rail-row .grow { flex: 1; min-width: 0; }
  .rail-row .n { font-size: 13.5px; font-weight: 600; }
  .rail-row .n strong { font-weight: 700; }
  .rail-row .n .q { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
  .rail-row .sub { font-size: 11.5px; color: var(--faint); }
  .rail-row .num { text-align: right; }
  .rail-row .num .v { font-weight: 700; font-size: 15px; color: var(--accent); font-variant-numeric: tabular-nums; }
  .rail-row .num .u { font-size: 11px; color: var(--fainter); }

  .empty { margin: 0; padding: 18px; text-align: center; font-size: 13px; color: var(--faint); }

  /* Overlays */

  .basket { left: auto; right: 32px; bottom: 24px; transform: translateY(200%); }
  .basket.on { transform: none; }
  .sheet { left: calc(50% + 124px); max-width: 480px; border-radius: 22px; bottom: 5dvh; }
}

/* Kitchen ------------------------------------------------------------------ */

.becomes {
  margin: 0 0 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

/* What a meat batch draws down beside the meat: the mix and onion recipe. */
.recipe-note {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--soft, #f4f4f5);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted, #666);
}

/* The reorder notification on the overview: what is low, how much is left, X to
   close once ordered. A warm tint so it reads as an alert, not just a list. */
.reorder-note { border: 1px solid var(--red); }
.reorder-note .card-head .t { color: var(--red); }
/* The yellow "hakkab otsa saama" line: same card, warmer tone. */
.reorder-note.yellow { border-color: var(--amber); }
.reorder-note.yellow .card-head .t { color: var(--amber); }

/* An import that could not account for part of a day. Amber, not red: the day
   is recorded and the shop is not blocked, but somebody has to map a PLU. */
.warn-import {
  display: block;
  padding: 13px 14px;
  border-color: var(--amber);
  color: inherit;
  text-decoration: none;
}
.warn-import .lbl { margin: 0 0 4px; font-weight: 700; color: var(--amber); }
.warn-import p.hint { margin: 0; }
.warn-import ul, .warn-import details { margin: 8px 0 0; }
.warn-import ul { padding-left: 18px; }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.status.warn { background: var(--amber-bg); color: var(--amber); }
.ro-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-top: 1px solid var(--line, #eee);
}
.ro-row .emoji { font-size: 20px; }
.ro-row .grow { flex: 1; min-width: 0; }
.ro-row .n { font-weight: 600; }
.ro-row .sub { font-size: 12.5px; color: var(--muted, #666); }
.ro-row form { margin: 0; }
/* Type what was ordered, confirm, and it books as a purchase. */
.ro-order { display: flex; align-items: center; gap: 6px; }
.ro-qty {
  width: 62px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 15px;
  text-align: center;
}
.ro-ok {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  line-height: 1;
  flex: 0 0 auto;
}
.ro-x {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted, #666);
  font-size: 20px;
  line-height: 1;
  flex: 0 0 auto;
}
.ro-x:active { background: #fdeaea; color: var(--red); }

/* Day-end close: each open onion is one tidy card -- name and how much is on the
   truck on top, the amount the day used up below. */
.bin-item { padding: 14px 16px; }
.bin-item .bin-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.bin-item .bin-top .emoji { font-size: 22px; }
.bin-item .bin-top .n { font-weight: 600; }
.bin-item .bin-top .sub {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--muted, #666);
  white-space: nowrap;
}
.bin-item .stepper { margin: 0; }
.bin-item .stepper .unit { white-space: nowrap; }
.hint.yellow { color: var(--amber); }

/* Small, centered, red -- a deliberate act, not a page-wide bar. */
.bin-submit { margin: 22px auto 4px; }

/* Threshold stepper on the products form: -/+ around a small number field. */
/* The stepper never shrinks or grows; the label gives way instead. With the
   label's usual 108px floor the row overran a 375px phone and the card's
   overflow: hidden clipped the + off the screen. */
.num-step { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }
.field:has(> .num-step) > .lbl { min-width: 0; }
.num-step button {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--card); color: var(--accent); font-size: 20px; line-height: 1; flex: 0 0 auto;
}
.num-step .num-in { flex: 0 0 60px; width: 60px; text-align: center; }

/* Quick-amount chips: type a number, +, ×-to-remove. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 5px 5px 11px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent); font-weight: 700; font-size: 14px;
}
.chip-x {
  width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .07); color: inherit; font-size: 14px; line-height: 1;
}
.chip-add { display: inline-flex; align-items: center; gap: 5px; }
.chip-add-in {
  width: 54px; min-height: 34px; padding: 0 8px; text-align: center;
  border: 1px solid var(--border); border-radius: 9px; background: var(--card); font-size: 14px;
}
.chip-add-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 0;
  background: var(--accent); color: #fff; font-size: 18px; line-height: 1; flex: 0 0 auto;
}

/* Product arranging mode: a quiet toggle, then up/down per product. */
.tooted-modes { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.reorder-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; border-top: 1px solid var(--line, #eee);
}
.reorder-row .emoji { font-size: 20px; }
.reorder-row .n { flex: 1; font-weight: 600; }
.reorder-row .move { display: flex; gap: 6px; }
.reorder-row .move form { margin: 0; }
.mv {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--accent); font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.mv.off { opacity: .28; }

/* Add a product: a small centered blue button that opens the form below it. */
.new-product { margin-top: 6px; }
.new-product > summary {
  list-style: none;
  cursor: pointer;
  display: block;
  width: max-content;
  margin: 6px auto 0;
  padding: 11px 26px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}
.new-product > summary::-webkit-details-marker { display: none; }
.new-product[open] > summary { margin-bottom: 14px; }
.new-product .emoji-grid { margin-bottom: 10px; }
.new-product .btn { margin-top: 14px; }

/* The bags-per-meat table on the products page. */
.bags-card .hint { padding: 0 2px 10px; }
.bags-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 12px;
}
.bags-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #666);
  padding: 4px 8px;
}
.bags-table td {
  padding: 6px 8px;
  border-top: 1px solid var(--line, #eee);
}
.bags-table td:last-child { text-align: right; width: 40px; }
.bags-table .small { padding: 2px 8px; font-size: 18px; line-height: 1; }
.bags-add {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.bags-add .field { flex: 1; min-width: 110px; }
.bags-add .btn { flex: 0 0 auto; }

/* The kilos a bucket count commits to, shown under the ämbrit stepper. */
.bucket-sum {
  margin: -4px 0 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.bucket-sum[hidden] { display: none; }

.acts { display: flex; gap: 8px; }
.acts[hidden] { display: none; }
.acts .act { flex: 1; display: flex; }
.acts .act .btn { flex: 1; }
.acts > .btn { flex: 1; }
.panel .acts .btn { min-height: 44px; border-radius: 11px; }

.confirm { padding-top: 4px; }
.confirm[hidden] { display: none; }

.confirm > p {
  margin: 0 0 10px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
}

.confirm .act { flex-direction: column; gap: 8px; }

.confirm .reason {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 13.5px;
  text-align: left;
}

.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }

/* Finding a product -------------------------------------------------------- */

.finder {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.finder .ico { font-size: 15px; opacity: 0.6; }

.finder .find {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  padding: 13px 0;
  font-size: 16px;   /* 16px keeps iOS from zooming on focus */
  color: var(--text);
  appearance: none;
}
.finder .find:focus { outline: none; }
.finder .find::placeholder { color: var(--fainter); }
.finder:focus-within { border-color: var(--accent); }
.finder .find::-webkit-search-cancel-button { appearance: none; }

/* A category banner inside a picker, matching the overview's grouping. */
.cat-group[hidden] { display: none; }

.cat-row {
  padding: 10px 14px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--row-2);
  border-bottom: 1px solid var(--row);
}

/* Quick amounts ------------------------------------------------------------ */

.quick { display: flex; gap: 6px; margin-bottom: 12px; }

.quick button {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 9px;
  background: var(--card);
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.quick button:active { background: var(--accent-bg); }

/* Marinade mix calculator -------------------------------------------------- */

.mix { padding: 16px 16px 18px; margin-bottom: 14px; }

.mix-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

.mix-head .emoji {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 24px;
  border-radius: 12px;
  background: var(--accent-bg);
}

.mix-titles { display: flex; flex-direction: column; gap: 2px; }
.mix-name { font-size: 15px; font-weight: 700; }
.mix-ceiling { font-size: 13px; color: var(--muted); }
.mix-ceiling strong { color: var(--accent); font-variant-numeric: tabular-nums; }

.mix-make { margin-bottom: 16px; }
.mix-make .stepper { margin-bottom: 8px; }
.mix-make .quick { margin-bottom: 0; }
.mix-bags { font-variant-numeric: tabular-nums; }

.mix-ings {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ing { display: flex; flex-direction: column; gap: 5px; }

.ing-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.ing-name { font-size: 13.5px; font-weight: 600; }

.ing-need {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ing-need b { color: var(--text); font-weight: 700; }

/* A thin track that fills toward what is on the shelf. The spice that fills
   first is the bottleneck; when one overflows there is not enough. */
.ing-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--fill);
  overflow: hidden;
}

.ing-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.12s ease-out;
}

.ing.over .ing-fill { background: var(--red); }
.ing.over .ing-need b { color: var(--red); }

.ing-foot {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 6px;
}
.ing-foot [data-ing-left] { color: var(--muted); }

.mix-warn {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--red-bg);
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.mix-warn[hidden] { display: none; }

.mix > .btn { width: 100%; }
.mix > .btn:disabled { opacity: 0.45; }

/* Product editor ----------------------------------------------------------- */

.pedit { border-bottom: 1px solid var(--row); }
.pedit:last-child { border-bottom: 0; }
.pedit.open { background: #f7f7fb; }
.pedit.off .top { opacity: 0.5; }

.pedit .top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  background: none;
  text-align: left;
}

.pedit .emoji { font-size: 22px; width: 26px; text-align: center; line-height: 1; }
.pedit .name { flex: 1; min-width: 0; }
.pedit .name .n { display: block; font-weight: 600; font-size: 15px; }
.pedit .name .sub { display: block; font-size: 12px; color: var(--faint); }
.pedit.open .chev { transform: rotate(90deg); }

.marks { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

.mark {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--fill-2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.mark.made { background: var(--accent-bg); color: var(--accent); }
.mark.off { background: var(--red-bg); color: var(--red); }

.pedit .panel { display: none; padding: 2px 14px 16px; }
.pedit.open .panel { display: block; }
.pedit .panel .card { margin-bottom: 12px; }
.pedit .panel .hint { margin: 0 0 12px; }

/* The product form. Section labels break the settings into what each one is
   about, a switch explains itself on a second line, and the settings that
   depend on another switch nest under it and hide with it. .field is
   display:flex, so hidden needs saying again. */
.field[hidden], .sub[hidden] { display: none; }
.sect {
  padding: 12px 14px 2px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--faint);
}
.field > .lbl small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--faint);
}
.sub[data-needs] { margin-left: 14px; border-left: 2px solid var(--row); }
.sub[data-needs] .field:last-child { border-bottom: 0; }
.new-product form .card { margin-bottom: 12px; }
.sheet form .card { margin-bottom: 12px; }

/* Sales statistics ---------------------------------------------------------
   One hue throughout. Every chart here compares magnitude and every row is
   labelled, so colour never carries identity and no palette is needed. */

.kpi .val.warn { color: var(--orange); }
.card-head .note-r { margin-left: auto; font-size: 12.5px; color: var(--faint); }
.card-head .note-r strong { color: var(--text); font-weight: 700; }

/* Hourly columns. The wrapper carries an explicit height so the inline
   percentage on each column resolves against something definite. */

.hours { display: flex; gap: 2px; padding: 16px 18px 10px; }
.hour { flex: 1; min-width: 0; }

.col-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 170px;
  border-bottom: 1px solid var(--row);
}

/* A track behind each column: the empty space above a bar reads as the room it
   could have filled, which makes a short bar legible as "little", not "narrow". */
.col-wrap::before {
  content: "";
  position: absolute;
  width: 100%;
  max-width: 22px;
  height: 100%;
  border-radius: 4px 4px 0 0;
  background: var(--fill-2);
}

.hour { position: relative; }
.col-wrap { position: relative; }

.col {
  position: relative;
  width: 100%;
  max-width: 22px;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  transform-origin: bottom;
  animation: grow-up 1100ms cubic-bezier(0.85, 0, 0.15, 1) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}

/* An hour with takings is the data; a closed hour is context. */
.col { background: var(--accent); }
.hour.shut .col { background: var(--row); }
.hour.peak .col { background: #3b32c4; }

@keyframes grow-up { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes grow-right { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Hovering one bar recedes the others, so the eye holds the one it is reading
   without the chart losing its shape. */
.hours:hover .hour { transition: opacity 140ms ease; }
.hours:hover .hour:not(:hover) { opacity: 0.3; }

.tick {
  display: block;
  padding-top: 6px;
  text-align: center;
  font-size: 10px;
  color: var(--fainter);
  font-variant-numeric: tabular-nums;
  min-height: 1rem;
}

.hour:hover .col { filter: brightness(1.08); }

/* The weekday x hour grid. One hue in four steps plus an empty step: this is
   magnitude, so darker is simply more, and "shut" is its own step rather than
   the bottom of the ramp. */

.heat { padding: 14px 18px 6px; }

.heat-grid {
  display: grid;
  grid-template-columns: 1.4rem repeat(var(--cols), minmax(0, 1fr));
  gap: 2px;
  align-items: center;
}

.heat-hour, .heat-day {
  font-size: 10px;
  color: var(--fainter);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.heat-day { font-size: 11px; font-weight: 700; color: var(--faint); text-align: left; }

/* A fixed row height rather than square cells: squares only stay small when
   there are fifty-odd columns, and ten trading hours would blow them up into
   blocks the eye reads as a table. */
.heat-cell {
  height: 26px;
  border-radius: 2px;
  background: var(--fill-2);
  animation: fade-in 900ms ease both;
  animation-delay: calc(var(--i, 0) * 18ms);
}

.heat-cell.lvl-1 { background: #dcdafa; }
.heat-cell.lvl-2 { background: #b9b5f5; }
.heat-cell.lvl-3 { background: #8d87ee; }
.heat-cell.lvl-4 { background: #4f46e5; }

@keyframes fade-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }

.heat-grid:hover .heat-cell { transition: opacity 140ms ease; }
.heat-grid:hover .heat-cell:not(:hover) { opacity: 0.3; }

.heat-key {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  padding: 12px 0 6px;
}

.heat-key .heat-cell { width: 11px; height: 11px; min-height: 0; animation: none; }
.heat-key .lbl { font-size: 10.5px; color: var(--fainter); }
.heat-key .lbl:first-child { margin-right: 3px; }
.heat-key .lbl:last-child { margin-left: 3px; }

@media (max-width: 899px) {
  /* Ten columns on a phone leave no room for ten labels; every other hour
     still says which way the axis runs. */
  .heat-hour.odd { visibility: hidden; }
  .heat-cell { height: 22px; }
}

/* Ranked horizontal bars: payment, departments, best sellers. */

.ranked { padding: 6px 18px 14px; }

.ranked-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr auto 3rem;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.ranked-row .lbl {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ranked-row .track { height: 14px; background: var(--fill-2); border-radius: 999px; overflow: hidden; }

.ranked-row .fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transform-origin: left;
  animation: grow-right 1100ms cubic-bezier(0.85, 0, 0.15, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

.ranked:hover .ranked-row { transition: opacity 140ms ease; }
.ranked:hover .ranked-row:not(:hover) { opacity: 0.3; }

/* Motion is decoration here: the numbers are already on screen, so anyone who
   asked the system for less of it gets the chart with none. */
@media (prefers-reduced-motion: reduce) {
  .col, .ranked-row .fill, .heat-cell { animation: none; }
}
.ranked-row .val { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ranked-row .pct { font-size: 12.5px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }

/* The table view: the values the chart does not label, and the accessible
   route to all of them. */

.table-view { border-top: 1px solid var(--row); }
.table-view summary { padding: 12px 18px; font-size: 13.5px; font-weight: 600; color: var(--accent); cursor: pointer; }
.table-view table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.table-view th, .table-view td { padding: 6px 18px; font-size: 13px; text-align: left; }
.table-view th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--fainter); }
.table-view td.num, .table-view th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-view tbody tr:nth-child(odd) { background: #fbfbfc; }

@media (max-width: 899px) {
  .ranked-row { grid-template-columns: 6.5rem 1fr auto; }
  .ranked-row .pct { display: none; }
  .col-wrap { height: 130px; }
}

/* Two calendars side by side, for a range. */

.two-cal { display: flex; gap: 10px; flex: 1; min-width: 0; flex-wrap: wrap; }
.two-cal .cal { flex: 1; min-width: 15rem; margin-bottom: 0; }
.field.range { align-items: flex-start; flex-wrap: wrap; }
.field.range[hidden] { display: none; }
.period-says { margin: -6px 4px 14px; font-weight: 600; color: var(--muted); }
.cal-grid .pad { display: block; }

/* Kadu: where the meat went ------------------------------------------------ */

.kadu-row { padding: 12px 18px; border-bottom: 1px solid var(--row); }
.kadu-row:last-of-type { border-bottom: 0; }
.kadu-row .who { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.kadu-row .who .emoji { font-size: 17px; }

/* One whole, split: sold on the left, lost on the right, the 2px surface gap
   between them doing the separating rather than a stroke. */
.kadu-row .bar {
  display: flex;
  gap: 2px;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--row);
}

.kadu-row .bar .sold { background: var(--accent); }
.kadu-row .bar .lost { background: var(--fainter); }

.kadu-row .nums { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 7px; }
.kadu-row .nums .num { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.kadu-row .nums .sold-n { color: var(--accent); font-weight: 600; }
.kadu-row .nums .lost-n { color: var(--muted); font-weight: 600; }

/* The role action strip at the top of a role's pages: switch action without
   going back to the menu. Scrolls sideways if it outgrows a phone. */
.subnav {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin: 0 0 18px;
  background: var(--fill-2);
  border-radius: 11px;
  overflow-x: auto;
}
.subnav a {
  flex: none;
  padding: 8px 15px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.subnav a.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

/* The Raha / Kulu view switch, top-left of the stats page. */
.stat-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin: 0 0 16px;
  background: var(--fill-2);
  border-radius: 11px;
}
.stat-toggle a {
  padding: 7px 18px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
}
.stat-toggle a.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

/* Marination throughput rows on the Kulu view. */
.usage-row { padding: 11px 18px; border-bottom: 1px solid var(--row); }
.usage-row:last-of-type { border-bottom: 0; }
.usage-row .who { font-size: 14px; font-weight: 600; }
.usage-row .who .emoji { font-size: 17px; }
.usage-row .nums { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; }
.usage-row .nums .num { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.usage-row .nums .made-n { color: var(--accent); font-weight: 600; }
.usage-row .nums .lost-n { color: var(--muted); font-weight: 600; }
.ranked-row .lbl .emoji { font-size: 16px; margin-right: 4px; }

/* A field whose control sits under its label rather than beside it. */
.field.stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.field.stacked > .lbl { min-width: 0; }

/* Stock below zero is not a state to be reassured about: the log says more left
   than ever arrived, so it reads as a problem until a count settles it. */
.badge.owes { background: var(--red-bg); color: var(--red); }
.status.owes { background: var(--red-bg); color: var(--red); }

/* Auto-save state under a product panel's button. */
.save-state { display: block; min-height: 18px; margin-top: 6px; font-size: 13px; text-align: center; }
.save-state.ok { color: var(--green); }
.save-state.err { color: var(--red); }
