/* Stock Genie base styles. Flat design: industrial slate with stock green, no gradients.
   Phone first. Wider layouts are in wide.css. Text sizes are in rem so they follow the
   reader's own text-size setting (page zoom is off by design, like an app). */
:root {
  --bg: #f8fafc; --card: #ffffff; --fg: #0f172a; --muted: #475569; --border: #d9dee5;
  --primary: #334155; --accent: #047857; --accent-hover: #065f46; --on-accent: #ffffff;
  --danger: #b91c1c; --ok-bg: #dcfce7; --ok-fg: #14532d; --warn-bg: #fef3c7; --warn-fg: #78350f;
  --err-bg: #fee2e2; --err-fg: #7f1d1d; --info-bg: #e0e7ff; --info-fg: #312e81; --off-bg: #e2e8f0; --off-fg: #334155;
  --radius: 8px; --nav-h: 3.75rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-size: 1rem; line-height: 1.5; touch-action: manipulation; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; line-height: 1.25; }
h2 { font-size: 1.125rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .25rem; }
p { margin: 0 0 .5rem; }
a { color: var(--accent); }
[hidden] { display: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.muted { color: var(--muted); font-size: .875rem; }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); }
.notice { background: var(--warn-bg); color: var(--warn-fg); padding: .75rem 1rem; border-radius: var(--radius); }
:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

/* shell */
.shell { min-height: 100dvh; }
.side { display: none; }
.main { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 1rem); }
.top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .5rem 1rem; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; font-size: 1.125rem; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.who { display: none; color: var(--muted); font-size: .875rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker select { min-height: 2.75rem; max-width: 11rem; }
#content { padding: 1rem; max-width: 80rem; margin: 0 auto; }
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--card); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .125rem; min-height: var(--nav-h); padding: .25rem; color: var(--muted); text-decoration: none; font-size: .75rem; text-align: center; cursor: pointer; transition: color .15s ease, background-color .15s ease; }
.nav-item svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-item.active { color: var(--accent); font-weight: 600; }
.nav-item:hover { color: var(--fg); }

/* pieces */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; min-width: 0; }
fieldset.card { min-inline-size: 0; }
legend { font-weight: 600; padding: 0 .375rem; }
.head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.head h2 { margin: 0; overflow-wrap: anywhere; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; }
.tile { display: flex; flex-direction: column; text-decoration: none; color: var(--fg); margin: 0; cursor: pointer; transition: border-color .15s ease; }
.tile:hover { border-color: var(--accent); }
.tile-value { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-label { color: var(--muted); font-size: .875rem; }
.grid2, .grid4 { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
.more-list { display: grid; gap: .75rem; }
.more-item { display: flex; align-items: center; gap: .75rem; margin: 0; text-decoration: none; color: var(--fg); min-height: 3.5rem; cursor: pointer; }
.more-item svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.search { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1 1 16rem; }
.search input, .search select { flex: 1 1 9rem; min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: .75rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .375rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 2.75rem; padding: .5rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--card); color: var(--fg); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; transition: background-color .15s ease, border-color .15s ease; }
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--off-bg); }
.btn:disabled { opacity: .55; cursor: progress; }

.badge { display: inline-block; padding: .125rem .5rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; white-space: nowrap; background: var(--off-bg); color: var(--off-fg); }
.badge.s-new { background: var(--info-bg); color: var(--info-fg); }
.badge.s-packed, .badge.u-exists { background: var(--warn-bg); color: var(--warn-fg); }
.badge.s-received, .badge.s-shipped, .badge.u-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.u-error { background: var(--err-bg); color: var(--err-fg); }
.pos { color: var(--ok-fg); font-weight: 600; }
.neg { color: var(--danger); font-weight: 600; }
