/* IPME Inventory — shared tokens and styles (INV-001 §6.2). */
:root {
  --inv-blue:        #1a5e6e;   /* primary: buttons, links, active states */
  --inv-blue-hover:  #21748a;
  --inv-red:         #b3261e;   /* errors and failures ONLY */
  --inv-orange:      #c26a00;   /* pending, queued, waiting for review, stale */
  --inv-green:       #2e7d32;   /* ok, synced, consistent */
  --inv-gray:        #8a8f98;   /* not yet processed, inactive */
  --inv-bg:          #f6f7f9;
  --inv-text:        #1d2129;
  --inv-surface:     #ffffff;
  --inv-border:      #dde1e6;
  --inv-muted:       #5c636e;
  --inv-row-hover:   #eef4f6;
  --inv-row-active:  #dcebef;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--inv-bg);
  color: var(--inv-text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--inv-blue); text-decoration: none; }
a:hover { color: var(--inv-blue-hover); text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; font-weight: 600; }
h2 { font-size: 16px; margin: 16px 0 8px; font-weight: 600; }
h3 { font-size: 14px; margin: 12px 0 6px; font-weight: 600; }
.muted { color: var(--inv-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.hidden { display: none !important; }

/* ── Nav ── */
.topnav {
  display: flex; align-items: center; gap: 16px;
  background: var(--inv-surface); border-bottom: 1px solid var(--inv-border);
  padding: 6px 16px; position: sticky; top: 0; z-index: 20;
}
.topnav img.logo { height: 32px; }
.topnav .links { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.topnav .links a { padding: 6px 10px; border-radius: 4px; color: var(--inv-text); }
.topnav .links a:hover { background: var(--inv-row-hover); text-decoration: none; }
.topnav .links a.active { background: var(--inv-blue); color: #fff; }
.topnav .right { display: flex; align-items: center; gap: 12px; white-space: nowrap; }

main { padding: 16px; max-width: 1600px; margin: 0 auto; }

/* ── Status dots and pills ── */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--inv-gray); vertical-align: middle; }
.dot.green { background: var(--inv-green); }
.dot.orange { background: var(--inv-orange); }
.dot.red { background: var(--inv-red); }
.dot.gray { background: var(--inv-gray); }
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600;
  border: 1px solid currentColor; white-space: nowrap; line-height: 18px;
}
.pill.green { color: var(--inv-green); }
.pill.orange { color: var(--inv-orange); }
.pill.red { color: var(--inv-red); }
.pill.gray { color: var(--inv-gray); }
.pill.blue { color: var(--inv-blue); }

/* ── Buttons and forms ── */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 4px; padding: 6px 12px;
  border: 1px solid var(--inv-blue); background: var(--inv-blue); color: #fff;
}
button:hover, .btn:hover { background: var(--inv-blue-hover); border-color: var(--inv-blue-hover); }
button.secondary { background: var(--inv-surface); color: var(--inv-blue); }
button.secondary:hover { background: var(--inv-row-hover); }
button.danger { background: var(--inv-surface); color: var(--inv-red); border-color: var(--inv-red); }
button.small { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  font: inherit; padding: 5px 8px; border: 1px solid var(--inv-border); border-radius: 4px; background: #fff; color: var(--inv-text);
}
textarea { width: 100%; min-height: 60px; }
label { display: block; font-size: 12px; color: var(--inv-muted); margin: 8px 0 2px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > div { min-width: 140px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar .spacer { flex: 1; }

/* ── Tables ── */
.card { background: var(--inv-surface); border: 1px solid var(--inv-border); border-radius: 6px; padding: 12px; }
.scroll { max-height: calc(100vh - 230px); min-height: 400px; overflow: auto; }
table.grid { width: 100%; border-collapse: collapse; background: var(--inv-surface); }
table.grid th, table.grid td { padding: 6px 8px; border-bottom: 1px solid var(--inv-border); text-align: left; vertical-align: top; }
table.grid th { position: sticky; top: 0; background: #eef0f3; font-weight: 600; font-size: 12px; z-index: 1; user-select: none; }
table.grid th.sortable { cursor: pointer; }
table.grid th .arrow { color: var(--inv-muted); font-size: 10px; }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr.clickable:hover { background: var(--inv-row-hover); }
table.grid tbody tr.active { background: var(--inv-row-active); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.group-head td { background: #f1f3f5; font-weight: 600; cursor: pointer; }
table.grid tr.group-head .chev { display: inline-block; width: 14px; transition: transform .1s; }
table.grid tr.group-head.collapsed .chev { transform: rotate(-90deg); }
.empty { padding: 24px; text-align: center; color: var(--inv-muted); }

/* ── List + blade layout ── */
.split { display: flex; gap: 12px; align-items: flex-start; }
.split > .list { flex: 1; min-width: 0; }
.blade {
  width: 560px; max-width: 50vw; flex-shrink: 0; background: var(--inv-surface);
  border: 1px solid var(--inv-border); border-radius: 6px; position: sticky; top: 60px;
  max-height: calc(100vh - 80px); overflow: auto;
}
.blade header { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--inv-border); }
.blade header h2 { margin: 0; flex: 1; }
.blade .tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--inv-border); flex-wrap: wrap; }
.blade .tabs button, .tabs-bar button {
  background: none; color: var(--inv-muted); border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 10px;
}
.blade .tabs button.active, .tabs-bar button.active { color: var(--inv-blue); border-bottom-color: var(--inv-blue); }
.blade .body { padding: 12px; }
.tabs-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--inv-border); margin-bottom: 12px; }

dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; margin: 0; }
dl.kv dt { color: var(--inv-muted); }
dl.kv dd { margin: 0; }

/* ── Banners ── */
.banner { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.banner.error { color: var(--inv-red); border-color: var(--inv-red); background: #fdf1f0; }
.banner.warn { color: var(--inv-orange); border-color: var(--inv-orange); background: #fdf6ec; }
.banner.ok { color: var(--inv-green); border-color: var(--inv-green); background: #f1f8f1; }
#toast {
  position: fixed; bottom: 16px; right: 16px; z-index: 100; max-width: 420px;
}
#toast .banner { box-shadow: 0 4px 12px rgba(0,0,0,.12); }

/* ── Dashboard tiles ── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile { background: var(--inv-surface); border: 1px solid var(--inv-border); border-radius: 6px; padding: 14px; }
.tile .big { font-size: 28px; font-weight: 600; }
.tile .label { color: var(--inv-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }

/* ── Photos ── */
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-thumb { width: 160px; border: 1px solid var(--inv-border); border-radius: 4px; overflow: hidden; background: #fafafa; font-size: 12px; }
.photo-thumb img { width: 100%; height: 120px; object-fit: cover; display: block; cursor: zoom-in; }
.photo-thumb .cap { padding: 4px 6px; }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-by-side img { width: 100%; border: 1px solid var(--inv-border); border-radius: 4px; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 200; cursor: zoom-out; }
.lightbox img { max-width: 95vw; max-height: 95vh; }

/* ── Slot grid ── */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
.slot { border: 1px solid var(--inv-border); border-radius: 4px; padding: 6px; min-height: 52px; font-size: 12px; background: #fff; }
.slot .n { color: var(--inv-muted); font-size: 11px; }
.slot.empty-slot { background: #f7f8f9; color: var(--inv-gray); }
.slot.hold { border-color: var(--inv-orange); }
button.slot { color: var(--inv-text); text-align: left; }
button.slot.empty-slot:hover { background: var(--inv-row-hover); }

/* ── Print (labels, pack lists) ── */
@media print {
  .topnav, .no-print, .toolbar { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
}

/* ── Mobile pages (stocker, picker): ≥60pt targets, ≥18px text ── */
body.mobile { font-size: 18px; }
body.mobile main { max-width: 640px; padding: 12px; }
body.mobile .topnav { padding: 6px 12px; }
body.mobile button, body.mobile .btn { min-height: 60px; font-size: 20px; width: 100%; margin: 6px 0; padding: 12px; border-radius: 8px; }
body.mobile button.inline { width: auto; min-height: 48px; font-size: 18px; }
body.mobile input, body.mobile select { font-size: 20px; min-height: 52px; width: 100%; padding: 8px 12px; }
body.mobile label { font-size: 16px; }
body.mobile .screen { background: var(--inv-surface); border: 1px solid var(--inv-border); border-radius: 10px; padding: 16px; }
body.mobile .big-code { font-size: 34px; font-weight: 700; letter-spacing: .02em; }
body.mobile .fullscreen { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 24px; text-align: center; color: #fff; }
body.mobile .fullscreen.orange { background: var(--inv-orange); }
body.mobile .fullscreen.red { background: var(--inv-red); }
body.mobile .fullscreen h1 { font-size: 30px; color: #fff; }
body.mobile .fullscreen button { background: #fff; color: var(--inv-text); border-color: #fff; }
body.mobile table.grid td, body.mobile table.grid th { padding: 10px 6px; font-size: 17px; }
body.mobile .qty-input { width: 110px; text-align: center; }
video.scan { width: 100%; border-radius: 8px; background: #000; }
.conn-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 300; background: var(--inv-orange); color: #fff; padding: 14px; text-align: center; font-size: 18px; cursor: pointer; }
.short { color: var(--inv-orange); font-weight: 600; }

@media (max-width: 900px) {
  .split { flex-direction: column; }
  .blade { width: 100%; max-width: none; position: static; }
}
