/* ==========================================================================
   Stockroom
   Visual language borrowed from the shelf-edge label: a status colour spine,
   a monospace SKU over a printed tick strip, and the count set large in
   tabular figures so it reads at arm's length.
   ========================================================================== */

:root {
  --paper:   #E9ECF0;
  --card:    #FFFFFF;
  --ink:     #0E1116;
  --muted:   #626C7A;
  --rule:    #D3D9E0;

  --action:  #0B3FA8;
  --action-2:#0A3287;
  --ok:      #10704A;
  --warn:    #B5620A;
  --danger:  #A6222F;

  --sans: "Archivo", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --r: 3px;                        /* labels are printed, not rounded */
  --shadow: 0 1px 0 rgba(14,17,22,.06), 0 1px 3px rgba(14,17,22,.08);
  --thumb: max(1rem, env(safe-area-inset-bottom));
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 5.5rem;          /* clears the thumb bar */
}

a { color: var(--action); }

h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 .5rem;
}
h1 { font-size: 1.5rem; }
h2 { font-size: 1.0625rem; }

.eyebrow {
  font: 600 .6875rem/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.mono { font-family: var(--mono); }

/* --- shell ---------------------------------------------------------------- */

.wrap { max-width: 860px; margin: 0 auto; padding: 0 1rem; }

.topbar {
  background: var(--ink);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.topbar .wrap {
  display: flex; align-items: center; gap: .75rem;
  min-height: 3.25rem;
}
.brand {
  font-weight: 800; letter-spacing: -.02em; color: #fff; text-decoration: none;
  font-size: 1.0625rem;
}
.brand span { color: #8FA9E8; }
.topbar .org {
  font: 500 .8125rem/1 var(--sans); color: #9AA4B2;
  margin-left: auto; text-align: right;
}
.topbar a.plain { color: #C7CED8; text-decoration: none; font-size: .8125rem; }

.locbar {
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  position: sticky; top: 3.25rem; z-index: 19;
}
.locbar .wrap { display: flex; align-items: center; gap: .5rem; padding-block: .5rem; }
.locbar select {
  font: 600 .875rem var(--sans); border: 1px solid var(--rule);
  border-radius: var(--r); padding: .35rem .5rem; background: #fff; color: var(--ink);
}

main { padding-block: 1.25rem; }

/* --- thumb bar: the primary navigation lives where the thumb is ----------- */

.thumbbar {
  position: fixed; inset: auto 0 0 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card);
  border-top: 1px solid var(--rule);
  padding-bottom: var(--thumb);
  box-shadow: 0 -2px 12px rgba(14,17,22,.07);
}
.thumbbar a {
  padding: .6rem .25rem .5rem;
  text-align: center; text-decoration: none;
  font: 600 .6875rem/1.3 var(--sans);
  color: var(--muted);
  border-top: 2px solid transparent;
}
.thumbbar a.is-active { color: var(--action); border-top-color: var(--action); }
.thumbbar b { display: block; font-size: 1.125rem; font-weight: 700; line-height: 1.1; }

/* --- cards and stats ------------------------------------------------------ */

.card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card > header {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .75rem 1rem; border-bottom: 1px solid var(--rule);
}
.card > .body { padding: 1rem; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--rule); }
@media (min-width: 620px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); padding: .9rem 1rem; }
.stat b { display: block; font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; }
.stat.is-warn b { color: var(--warn); }
.stat.is-danger b { color: var(--danger); }

/* --- the shelf-edge label ------------------------------------------------- */

.shelf { list-style: none; margin: 0; padding: 0; }

.label {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  align-items: center;
  gap: 0 .85rem;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
  text-decoration: none; color: inherit;
  padding-right: 1rem;
}
.label:last-child { border-bottom: 0; }
.label:hover, .label:focus-visible { background: #F6F8FA; }

.label .spine { align-self: stretch; background: var(--ok); }
.label[data-status="low"]     .spine { background: var(--warn); }
.label[data-status="reorder"] .spine { background: var(--warn); }
.label[data-status="out"]     .spine { background: var(--danger); }

.label .meta { padding: .7rem 0; min-width: 0; }
.label .sku {
  font: 500 .6875rem/1 var(--mono);
  letter-spacing: .08em; color: var(--muted);
  display: block; margin-bottom: .3rem;
}
/* printed tick strip: reads as the barcode on a real shelf tag */
.label .sku::after {
  content: ""; display: block; height: 7px; margin-top: .3rem; max-width: 96px;
  background-image: repeating-linear-gradient(90deg,
    var(--rule) 0 1px, transparent 1px 3px,
    var(--rule) 3px 5px, transparent 5px 6px,
    var(--rule) 6px 7px, transparent 7px 11px);
}
.label .name {
  font-weight: 600; font-size: .9375rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.label .sub { font-size: .75rem; color: var(--muted); }

.label .count {
  font: 700 1.75rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
  text-align: right;
}
.label .count small { display: block; font: 500 .625rem/1 var(--mono);
  letter-spacing: .1em; color: var(--muted); text-transform: uppercase; margin-top: .25rem; }

/* HTMX settle flash after a quantity changes */
.flash { animation: flash 900ms ease-out; }
@keyframes flash { from { background: #FFF4DC; } to { background: transparent; } }

/* --- the count, set large ------------------------------------------------- */

.bigcount {
  text-align: center; padding: 1.25rem 1rem .5rem;
}
.bigcount b {
  display: block;
  font-size: clamp(3.5rem, 18vw, 5rem);
  font-weight: 800; letter-spacing: -.05em; line-height: .9;
  font-variant-numeric: tabular-nums;
}
.bigcount .where { color: var(--muted); font-size: .875rem; }
.bigcount[data-status="low"] b, .bigcount[data-status="reorder"] b { color: var(--warn); }
.bigcount[data-status="out"] b { color: var(--danger); }

/* --- controls ------------------------------------------------------------- */

.field { margin-bottom: .9rem; }
.field label { display: block; font-weight: 600; font-size: .8125rem; margin-bottom: .3rem; }
.field .help { font-size: .75rem; color: var(--muted); margin-top: .25rem; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], select, textarea {
  width: 100%; font: 400 1rem var(--sans); color: var(--ink);
  padding: .6rem .7rem; background: #fff;
  border: 1px solid var(--rule); border-radius: var(--r);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--action); outline-offset: 2px;
}
input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 .9375rem var(--sans);
  padding: .65rem 1rem; min-height: 2.75rem;
  border: 1px solid transparent; border-radius: var(--r);
  background: var(--action); color: #fff; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--action-2); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--rule); }
.btn.ghost:hover { background: #F6F8FA; }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn.lg { min-height: 3.25rem; font-size: 1.0625rem; }

/* Segmented action picker: received / sold / correction */
.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; }
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment label {
  text-align: center; padding: .6rem .4rem; cursor: pointer;
  font: 600 .8125rem var(--sans); color: var(--muted);
  border: 1px solid var(--rule); margin-left: -1px; background: #fff;
}
.segment label:first-of-type { margin-left: 0; border-radius: var(--r) 0 0 var(--r); }
.segment label:last-of-type { border-radius: 0 var(--r) var(--r) 0; }
.segment input:checked + label {
  background: var(--ink); color: #fff; border-color: var(--ink);
}

/* Stepper: oversized on purpose. Cold hands, gloves, a phone held one-handed. */
.stepper { display: grid; grid-template-columns: 3.25rem 1fr 3.25rem; gap: .5rem; }
.stepper button {
  font: 700 1.5rem var(--sans); background: #fff; color: var(--ink);
  border: 1px solid var(--rule); border-radius: var(--r); cursor: pointer;
}
.stepper button:hover { background: #F6F8FA; }
.stepper input { text-align: center; font-size: 1.375rem; font-weight: 700; }

/* --- messages, alerts, empties -------------------------------------------- */

.note {
  padding: .7rem .9rem; border-radius: var(--r); margin-bottom: .9rem;
  font-size: .875rem; border: 1px solid var(--rule); background: #fff;
  border-left: 4px solid var(--muted);
}
.note.success { border-left-color: var(--ok); }
.note.warning { border-left-color: var(--warn); }
.note.error   { border-left-color: var(--danger); }

.empty { text-align: center; padding: 2.5rem 1.25rem; }
.empty p { color: var(--muted); margin: .35rem 0 1.1rem; }

.tag {
  display: inline-block; font: 600 .6875rem/1 var(--mono);
  letter-spacing: .08em; text-transform: uppercase;
  padding: .3rem .45rem; border-radius: var(--r);
  background: #EEF1F5; color: var(--muted);
}
.tag.low, .tag.reorder { background: #FCF0E1; color: var(--warn); }
.tag.out { background: #FBE9EB; color: var(--danger); }
.tag.ok { background: #E6F3ED; color: var(--ok); }

/* --- ledger --------------------------------------------------------------- */

.ledger { list-style: none; margin: 0; padding: 0; font-size: .875rem; }
.ledger li {
  display: grid; grid-template-columns: 4.5rem 1fr auto;
  gap: .75rem; align-items: baseline;
  padding: .6rem 0; border-bottom: 1px solid var(--rule);
}
.ledger li:last-child { border-bottom: 0; }
.ledger .delta { font: 700 1rem var(--mono); font-variant-numeric: tabular-nums; }
.ledger .delta.up { color: var(--ok); }
.ledger .delta.down { color: var(--danger); }
.ledger .when { color: var(--muted); font-size: .75rem; white-space: nowrap; }

.toolbar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.toolbar input[type=search] { flex: 1; }

.searching { visibility: hidden; }
.htmx-request .searching { visibility: visible; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition: none !important; }
}

/* --- slide-out menu ------------------------------------------------------- */

.menu-btn {
  font-size: 1.4rem; line-height: 1; background: none; border: 0;
  color: #fff; cursor: pointer; padding: .25rem .6rem .25rem 0;
}
.menu-scrim {
  position: fixed; inset: 0; z-index: 40; visibility: hidden;
  background: rgba(14,17,22,0);
  transition: background .2s ease, visibility 0s .2s;
}
.menu-scrim.open {
  visibility: visible; background: rgba(14,17,22,.4);
  transition: background .2s ease;
}
.menu-panel {
  position: absolute; inset: 0 auto 0 0; width: min(82vw, 300px);
  background: var(--card); box-shadow: 2px 0 20px rgba(14,17,22,.22);
  transform: translateX(-100%); transition: transform .2s ease;
  display: flex; flex-direction: column;
  padding-bottom: 2rem; overflow-y: auto;
}
.menu-scrim.open .menu-panel { transform: translateX(0); }
.menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; background: var(--card);
}
.menu-head strong { font-size: 1rem; letter-spacing: -.01em; }
.menu-head button {
  background: none; border: 0; font-size: 1.1rem; cursor: pointer;
  color: var(--muted); line-height: 1; padding: .25rem;
}
.menu-label {
  font: 600 .6875rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: 1.15rem 1.25rem .4rem;
}
.menu-panel > a {
  padding: .7rem 1.25rem; text-decoration: none; color: var(--ink);
  font-weight: 600; font-size: .9375rem;
}
.menu-panel > a:hover, .menu-panel > a:focus-visible { background: #F6F8FA; }
