/* Theme sampled from logo.png: bg #0b203d, electric blue #18b0e8, teal #14ecbc, orange #f48424 */
:root {
  --bg: #0b203d;
  --card: #12305a;
  --card-2: #193d6e;
  --line: #27507f;
  --text: #eef3f9;
  --muted: #9db2cc;
  --blue: #18b0e8;
  --teal: #14ecbc;
  --orange: #f48424;
  --danger: #ff8a80;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--blue); }
h1 { font-size: 1.4rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; color: var(--teal); letter-spacing: .02em; }
h2 small { color: var(--muted); font-weight: 400; margin-left: .3rem; }
main { max-width: 760px; margin: 0 auto; padding: 8px 14px 48px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* Banner: same navy as the logo's own background so the image has no visible edge */
.banner { background: var(--bg); padding: 10px 12px 2px; }
.banner img { display: block; margin: 0 auto; width: 100%; max-width: 440px; height: auto; }
.topnav {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; gap: 6px; justify-content: center; align-items: center;
  padding: 6px 12px 10px; border-bottom: 1px solid var(--line);
}
.topnav a, .linkbtn {
  color: var(--text); text-decoration: none; padding: 9px 12px; border-radius: 999px;
  background: transparent; border: 0; font: inherit; cursor: pointer;
}
.topnav a.active { background: var(--card-2); color: var(--teal); }
.topnav form { margin: 0; margin-left: auto; }
.linkbtn { color: var(--muted); }

/* Header counts */
.counts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.tile { background: var(--card); border-radius: var(--radius); padding: 10px 6px; text-align: center; }
.tile b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .78rem; }
.tile.warn b { color: var(--orange); }
.tile.bad b { color: var(--danger); }

/* Search + filter */
.toolbar { display: grid; gap: 10px; margin: 6px 0 10px; }
.chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chips .btn { margin-left: auto; }
.chip { padding: 8px 14px; border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; }
.chip.on { background: var(--blue); color: #06203a; font-weight: 600; }

/* Parts */
.group { margin-bottom: 4px; }
.part {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
  background: var(--card); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px;
}
.name { color: var(--text); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sku { font-family: ui-monospace, Consolas, monospace; }
.badge { padding: 1px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; color: #06203a; }
.badge.low { background: var(--orange); }
.badge.out { background: var(--danger); }
.rowerr { color: var(--danger); font-size: .85rem; margin-top: 4px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.qty { min-width: 2.6ch; text-align: center; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.step {
  width: 56px; height: 56px; border: 0; border-radius: 14px; font-size: 2rem; font-weight: 700; line-height: 1;
  color: #06203a; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.step.minus { background: var(--orange); }
.step.plus { background: var(--teal); }
.step:active { transform: scale(.94); }
.step:disabled { opacity: .3; cursor: not-allowed; }

/* Buttons and forms */
.btn {
  display: inline-block; padding: 12px 18px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--card-2); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  touch-action: manipulation;
}
.btn.primary { background: var(--blue); color: #06203a; }
.btn.good { background: var(--teal); color: #06203a; }
.btn.warn { background: var(--orange); color: #06203a; }
.btn.block { width: 100%; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card.narrow, .form.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.form { display: grid; gap: 12px; }
.form .row, .row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.grow { flex: 1 1 140px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: .85rem; }
label.inline { display: flex; align-items: center; gap: 8px; }
label.check { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--text); }
input, select, textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #0e2a4f; color: var(--text); font: inherit; font-size: 16px; /* 16px stops iOS zoom */
}
input[type=checkbox] { width: 22px; height: 22px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .step:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
.btnrow { display: flex; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 10px; margin: 8px 0; background: var(--card-2); }
.flash.ok { border-left: 4px solid var(--teal); }
.flash.error { border-left: 4px solid var(--danger); color: var(--danger); }

/* Part detail + history */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.bigqty { font-size: 2.6rem; font-weight: 800; text-align: right; line-height: 1; font-variant-numeric: tabular-nums; }
.bigqty small { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); }
.bigqty.warn { color: var(--orange); }
.bigqty.bad { color: var(--danger); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 12px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.list { padding: 4px 14px; }
.mv { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mv:last-child { border-bottom: 0; }
.when { color: var(--muted); font-size: .8rem; }
.delta { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; align-self: center; }
.delta.pos { color: var(--teal); }
.delta.neg { color: var(--orange); }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }

@media (min-width: 640px) {
  .banner img { max-width: 520px; }
}
@media (max-width: 380px) {
  .step { width: 50px; height: 50px; }
  .qty { font-size: 1.4rem; }
}

/* Stacked forms inside one card (Change stock / Set count) */
.card .form + .form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }

/* Purchase orders */
.badge.ord { background: var(--blue); }
.badge.st-draft { background: var(--muted); }
.badge.st-ordered { background: var(--blue); }
.badge.st-received { background: var(--teal); }
.badge.st-cancelled { background: var(--danger); }
.po-card { text-decoration: none; color: inherit; }
.chev { font-size: 1.8rem; color: var(--muted); }
details > summary { cursor: pointer; list-style: none; display: inline-block; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 8px; }
.recv { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.recv:last-of-type { border-bottom: 0; }

/* Builds */
.over { color: var(--danger); }
.budget { margin: 10px 0 4px; }
.budget-line { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.bar-track { height: 12px; border-radius: 999px; background: #0e2a4f; overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); }
.bar-fill.over { background: var(--danger); }
.badge.st-planning { background: var(--muted); }
.badge.st-active { background: var(--blue); }
.badge.st-done { background: var(--teal); }
.tline { padding: 10px 0; border-top: 1px solid var(--line); }
.tline-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tq { font-weight: 700; font-variant-numeric: tabular-nums; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

/* Five nav tabs must fit a 390px phone without wrapping */
.topnav { gap: 2px; padding-left: 6px; padding-right: 6px; }
.topnav a, .linkbtn { white-space: nowrap; padding: 9px 10px; }
