/* Syncrocon Inventory — self-contained stylesheet, no external fonts or CDNs. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #dfe4ea;
  --border-strong: #c7cfd8;
  --text: #16202b;
  --muted: #64748b;
  --brand: #12395c;
  --brand-2: #1c5f96;
  --accent: #e8720c;
  --ok: #1a7f52;
  --ok-bg: #e6f4ec;
  --warn: #9a6400;
  --warn-bg: #fdf3e0;
  --bad: #b3261e;
  --bad-bg: #fbeae9;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 43, .06), 0 2px 8px rgba(16, 32, 43, .05);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--brand);
  color: #cfdcea;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand .name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .3px; }
.brand .tag { font-size: 11px; color: #91a9c1; margin-top: 2px; }
.nav { padding: 10px 0; flex: 1; }
.nav .group { padding: 14px 18px 5px; font-size: 10px; letter-spacing: .09em;
  text-transform: uppercase; color: #7e97b1; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 18px; color: #cfdcea; font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.nav .ic { width: 16px; text-align: center; opacity: .85; font-size: 13px; }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.1); font-size: 11px; color: #7e97b1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 22px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 650; }
.topbar .spacer { flex: 1; }

.scanbox { position: relative; }
.scanbox input {
  width: 260px; padding: 6px 10px 6px 28px; font-size: 13px;
  border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface-2);
  font-family: var(--mono);
}
.scanbox input:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; background: #fff; }
.scanbox .ic { position: absolute; left: 9px; top: 6px; color: var(--muted); font-size: 12px; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-2); color: #fff;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: 0 0 auto;
}
.who { font-size: 12px; line-height: 1.25; }
.who .role { color: var(--muted); font-size: 11px; }

.content { padding: 20px 22px 60px; max-width: 1400px; width: 100%; }

/* ---------- Cards, tables ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
.card > h2, .card > .card-head {
  margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 650; letter-spacing: .02em;
  display: flex; align-items: center; gap: 10px;
}
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; align-items: start; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1000px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 680px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat .value { font-size: 25px; font-weight: 680; margin-top: 4px; letter-spacing: -.5px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.accent { border-left: 3px solid var(--accent); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 650; padding: 9px 12px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono);
  white-space: nowrap; }
.sku { font-family: var(--mono); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 11px; font-size: 11px;
  font-weight: 640; letter-spacing: .02em; white-space: nowrap;
  background: #eef1f5; color: #46566a; border: 1px solid transparent;
}
.badge.new   { background: #e7f0fa; color: #14508a; }
.badge.a     { background: var(--ok-bg); color: var(--ok); }
.badge.b     { background: #eef6e9; color: #4a7524; }
.badge.c     { background: var(--warn-bg); color: var(--warn); }
.badge.scrap { background: #eceff2; color: #5b6673; }
.badge.ok    { background: var(--ok-bg); color: var(--ok); }
.badge.warn  { background: var(--warn-bg); color: var(--warn); }
.badge.bad   { background: var(--bad-bg); color: var(--bad); }
.badge.info  { background: #e7f0fa; color: #14508a; }

/* ---------- Lab: lot expiry (red expired, amber inside the warning window) ---------- */
.exp-red   { color: var(--bad); background: var(--bad-bg); font-weight: 640; }
.exp-amber { color: var(--warn); background: var(--warn-bg); font-weight: 640; }

/* ---------- Forms ---------- */
label { display: block; font-size: 11.5px; font-weight: 620; color: #3d4a59;
  margin-bottom: 4px; letter-spacing: .01em; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 7px 9px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border-strong); border-radius: 6px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; }
input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 13px; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.row { display: grid; gap: 12px; }
.row.c2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.row.c3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.row.c4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 760px) { .row.c2, .row.c3, .row.c4 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 14px; font-size: 13px; font-weight: 620; font-family: inherit;
  border-radius: 6px; border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: #17527f; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: #cf6409; }
.btn.danger { color: var(--bad); border-color: #e3bdba; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toolbar { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .field { margin-bottom: 0; }
.toolbar .spacer { flex: 1; }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px;
  font-size: 13px; border: 1px solid transparent; }
.alert.success { background: var(--ok-bg); color: var(--ok); border-color: #bfe3d0; }
.alert.error { background: var(--bad-bg); color: var(--bad); border-color: #f0c9c6; }
.alert.info { background: #e7f0fa; color: #14508a; border-color: #c4dbf1; }

/* ---------- Progress / bars ---------- */
.bar { height: 7px; border-radius: 4px; background: #e6eaef; overflow: hidden; min-width: 70px; }
.bar > span { display: block; height: 100%; background: var(--brand-2); }
.bar.ok > span { background: var(--ok); }
.bar.warn > span { background: var(--accent); }

.split { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #e6eaef; }
.split > span { display: block; height: 100%; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 19px; font-weight: 660; letter-spacing: -.2px; }
.page-head .spacer { flex: 1; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 3px; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand-2); border-bottom-color: var(--brand-2); }

/* ---------- Labels sheet (print) ---------- */
.sheet { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5mm; }
.lbl {
  border: 1px dashed #b8c0c9; border-radius: 3px; padding: 4mm;
  display: grid; grid-template-columns: 22mm 1fr; gap: 3mm; align-items: center;
  break-inside: avoid; background: #fff; min-height: 30mm;
}
.lbl .qr { width: 22mm; height: 22mm; }
.lbl .qr svg { width: 100%; height: 100%; display: block; }
.lbl .txt { min-width: 0; }
.lbl .t { font-family: var(--mono); font-weight: 700; font-size: 13px; word-break: break-all; }
.lbl .s { font-size: 10.5px; color: #333; margin-top: 1px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lbl .m { font-size: 9.5px; color: #666; margin-top: 2px; }
.lbl .bc { margin-top: 2mm; height: 13mm; }
.lbl .bc svg { width: 100%; height: 100%; display: block; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; }
  .sheet { gap: 3mm; }
  @page { margin: 8mm; }
}

.camera-wrap { display: none; margin-top: 12px; }
.camera-wrap video { width: 100%; max-width: 420px; border-radius: var(--radius); background: #000; }

/* ==========================================================================
   Phones and tablets
   The warehouse uses phones one-handed, often in gloves, often in poor light.
   Targets get bigger, the sidebar becomes a bottom bar, and wide tables scroll
   sideways rather than squashing into unreadable columns.
   ========================================================================== */

.bottom-nav { display: none; }
.only-mobile { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .only-mobile { display: initial; }
  .only-desktop { display: none !important; }

  .shell { display: block; }
  .main { min-height: 100vh; }

  .topbar {
    padding: 8px 12px;
    gap: 8px;
    /* Keep clear of the notch on an iPhone. */
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  .topbar h1 { font-size: 15px; }
  .topbar .who { display: none; }
  .scanbox { display: none; }

  .content {
    padding: 14px 12px calc(84px + env(safe-area-inset-bottom));
  }

  /* Wide tables keep their shape and scroll, rather than wrapping to mush. */
  .card-body.tight { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card-body.tight > table { min-width: 560px; }

  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; gap: 12px; }
  .row.c2, .row.c3, .row.c4 { grid-template-columns: 1fr; }

  /* Stat boxes stay two-up: four stacked boxes is a lot of scrolling. */
  .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px; }
  .stat .value { font-size: 21px; }
  .stat .sub { font-size: 11px; }

  .page-head h2 { font-size: 17px; }
  .toolbar { gap: 10px; }
  .toolbar .field { width: 100%; }
  .toolbar select, .toolbar input { width: 100% !important; }

  /* Fingers, not mice. */
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn.sm { min-height: 36px; padding: 7px 12px; }
  input[type=text], input[type=password], input[type=number], input[type=date],
  input[type=email], input[type=search], select, textarea {
    padding: 11px 12px;
    font-size: 16px;  /* under 16px, iOS zooms the page on focus */
    min-height: 44px;
  }
  label { font-size: 12.5px; }

  .kv { grid-template-columns: 110px 1fr; }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tabs a { white-space: nowrap; }

  /* The bottom bar replaces the sidebar. */
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: var(--brand);
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 9px 2px 8px;
    color: #9fb4c9;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .01em;
    text-decoration: none;
    min-height: 54px;
  }
  .bottom-nav a .ic { font-size: 17px; line-height: 1; }
  .bottom-nav a.active { color: #fff; }
  .bottom-nav a.active .ic { color: var(--accent); }
  .bottom-nav a:active { background: rgba(255, 255, 255, .08); }
}

@media (max-width: 420px) {
  .grid.c4 { grid-template-columns: 1fr; }
  .btn-row { gap: 6px; }
}

/* ==========================================================================
   Mobile task screens (/m)
   Built for one thumb: few controls, each one big, the next step obvious.
   ========================================================================== */
.m-hero {
  background: linear-gradient(155deg, var(--brand), #0d2c47);
  border-radius: var(--radius);
  padding: 18px 16px;
  color: #fff;
  margin-bottom: 14px;
}
.m-hero .greet { font-size: 13px; color: #a9c0d6; }
.m-hero .name { font-size: 20px; font-weight: 680; margin-top: 2px; }
.m-hero .meta { font-size: 12px; color: #a9c0d6; margin-top: 6px; }

.m-scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(232, 114, 12, .3);
}
.m-scan-btn:active { background: #cf6409; }
.m-scan-btn .ic { font-size: 22px; }

.m-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.m-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  color: var(--text);
  box-shadow: var(--shadow);
  display: block;
}
.m-tile:active { background: var(--surface-2); }
.m-tile:hover { text-decoration: none; }
.m-tile .ic { font-size: 22px; color: var(--brand-2); display: block; margin-bottom: 6px; }
.m-tile .t { font-size: 13.5px; font-weight: 650; }
.m-tile .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* A row you tap — the mobile replacement for a table row. */
.m-list { display: flex; flex-direction: column; gap: 8px; }
.m-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--text);
  box-shadow: var(--shadow);
  min-height: 60px;
}
.m-row:hover, .m-row:active { text-decoration: none; background: var(--surface-2); }
.m-row .grow { flex: 1; min-width: 0; }
.m-row .t { font-weight: 640; font-size: 14px; }
.m-row .t .sku { font-size: 13px; }
.m-row .s { font-size: 12px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-row .n { font-family: var(--mono); font-weight: 700; font-size: 16px; text-align: right; }
.m-row .n small { display: block; font-size: 10px; font-weight: 600;
  color: var(--muted); font-family: var(--sans); letter-spacing: .04em; }
.m-row .chev { color: var(--border-strong); font-size: 18px; }

/* Camera viewfinder */
.m-camera {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 4 / 3;
  margin-bottom: 12px;
}
.m-camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-camera .frame {
  position: absolute; inset: 18% 12%;
  border: 3px solid rgba(255, 255, 255, .85);
  border-radius: 10px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}
.m-camera .hint {
  position: absolute; left: 0; right: 0; bottom: 8px;
  text-align: center; color: #fff; font-size: 12px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

/* A big number entry for counting and issuing */
.m-qty { display: flex; align-items: center; gap: 10px; }
.m-qty input {
  flex: 1; text-align: center; font-size: 26px !important; font-weight: 700;
  font-family: var(--mono); min-height: 58px !important;
}
.m-qty button {
  width: 54px; min-height: 58px; font-size: 24px; font-weight: 700;
  border: 1px solid var(--border-strong); border-radius: 6px;
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
.m-qty button:active { background: var(--border); }

.m-sticky {
  position: sticky;
  bottom: calc(12px + env(safe-area-inset-bottom));
  padding: 10px 0 4px;
  /* Opaque, so a field scrolling behind it never shows through half-read. */
  background: var(--bg);
  box-shadow: 0 -10px 12px -6px var(--bg);
}

/* Two small figures side by side, even on the narrowest phone: stacking them
   costs a whole screen of scrolling for two numbers. */
.m-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.m-stats .stat { padding: 12px; }
.m-stats .value { font-size: 21px; }
.m-sticky .btn { width: 100%; min-height: 52px; font-size: 15px; }

.m-step { font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 650; margin-bottom: 6px; }

.install-tip {
  display: none;
  align-items: center;
  gap: 10px;
  background: #e7f0fa;
  border: 1px solid #c4dbf1;
  color: #14508a;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 12px;
}
.install-tip.on { display: flex; }
.install-tip .grow { flex: 1; }

@media print {
  .bottom-nav { display: none !important; }
}
