/* ---------------------------------------------------------------------------
   F. BINSABBAR - Stockroom : LOCAL LAYOUT ONLY.
   Everything visual (colours, controls, cards, pills, modals, toasts) comes from
   fb-ui.css. This file adds only the grid + card + history structures the kit
   does not ship. Kit tokens only - no parallel design tokens.
--------------------------------------------------------------------------- */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--s-4) max(var(--s-6), env(safe-area-inset-right)) 140px max(var(--s-6), env(safe-area-inset-left));
}

/* The `hidden` attribute MUST win over class display rules (a class selector
   otherwise outranks the UA [hidden]{display:none}). */
#sr-bar[hidden], #sr-stats[hidden], #sr-view[hidden], #sr-empty[hidden],
#sr-loading[hidden], #sr-preview[hidden], #f-qty-help[hidden] { display: none !important; }

/* Preview banner (localhost). */
.sr-preview-banner {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); margin: var(--s-6) 0 0;
  border-radius: var(--radius-card);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(247,72,39,0.28);
  color: var(--text); font-size: 12.5px; line-height: 1.45;
}
.sr-preview-banner svg { width: 18px; height: 18px; flex: 0 0 auto; }
.sr-preview-banner code { font-size: 11.5px; background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 5px; }

/* Toolbar. */
.sr-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3);
  margin: var(--s-6) 0 var(--s-5);
}
/* Category segmented control takes its own full-width row so long labels
   (e.g. "Findings & Locks") never clip; the search + controls flow below. */
.sr-cats { width: 100%; flex: 1 1 100%; min-width: 0; height: var(--s-9); }
.sr-cats label { padding: 0 var(--s-4); white-space: nowrap; }

.sr-search-wrap { position: relative; flex: 1 1 300px; min-width: 180px; }
.sr-search-wrap svg {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; z-index: 2;
}
/* The kit's `:root input[type=search] { padding: 0 … }` (0,0,2,1) out-specifies a
   class rule, which collapsed the icon gutter. The input's id wins decisively. */
#sr-search { -webkit-appearance: none; appearance: none; padding-left: 41px !important; }
.sr-search::-webkit-search-decoration, .sr-search::-webkit-search-cancel-button { -webkit-appearance: none; }

.sr-lowtoggle {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: var(--s-9); padding: 0 var(--s-4);
  border-radius: var(--radius-pill); background: rgba(255,255,255,0.55);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.10);
  font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted); cursor: pointer; white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.sr-lowtoggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.sr-lowtoggle:has(input:checked) { background: var(--warning-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--warning); }
.sr-bar .btn svg { width: 15px; height: 15px; }

/* Stat strip. */
.sr-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s-3); margin: 0 0 var(--s-5);
}
.sr-stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--s-5) var(--s-4); border-radius: var(--radius-card);
  background: rgba(255,255,255,0.55); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
  text-align: center;
}
.sr-stat .v { font-size: 23px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.1; }
.sr-stat .v.warn { color: var(--warning); }
.sr-stat .k { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-top: 5px; }

/* Item grid. */
.sr-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--s-4);
}
.sr-card {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-4); border-radius: var(--radius-card);
  background: rgba(255,255,255,0.55); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
  cursor: pointer; text-align: left;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.sr-card:hover { transform: translateY(-2px); background: rgba(255,255,255,0.75); box-shadow: 0 6px 20px rgba(0,0,0,0.07), inset 0 0 0 1px rgba(0,0,0,0.06); }
.sr-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-card.low { box-shadow: inset 0 0 0 1px var(--warning); }

.sr-card-top { display: flex; align-items: flex-start; gap: var(--s-3); }
.sr-card-thumb {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.05) center/cover no-repeat; display: grid; place-items: center;
  color: var(--text-faint);
}
.sr-card-thumb svg { width: 20px; height: 20px; }
.sr-card-head { flex: 1 1 auto; min-width: 0; }
.sr-card-name { font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sr-card-code { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: 0.02em; }

.sr-card-meta { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.sr-card-meta .tag { font-size: 10px; }
/* Auto-deduction timing badge: Manufacturing reads accent, Purchase reads quiet. */
.tag.sr-auto { letter-spacing: 0.02em; }
.tag.sr-auto-mfg { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tag.sr-auto-pur { color: var(--text-faint); }
.tag.sr-auto-man { color: var(--text-faint); border-style: dashed; }

.sr-card-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); margin-top: auto; }
.sr-qty { display: flex; align-items: baseline; gap: 4px; }
.sr-qty .n { font-size: 22px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1; }
.sr-qty .n.warn { color: var(--warning); }
.sr-qty .u { font-size: 11px; color: var(--text-faint); text-transform: lowercase; }
.sr-loc { font-size: 11px; color: var(--text-faint); text-align: right; }

/* Card MOVEMENT button (replaces the old +/- steppers) - opens stock in/out. */
.sr-move {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; cursor: pointer;
  height: 32px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--control-border, rgba(0,0,0,0.12)); background: transparent; color: var(--text);
  font: inherit; font-size: 12px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.1s;
}
.sr-move svg { width: 15px; height: 15px; }
.sr-move:hover { background: var(--accent); color: var(--premium-yellow); border-color: var(--accent); }
.sr-move:active { transform: scale(0.96); }

.sr-empty { padding: var(--s-8) var(--s-5); text-align: center; color: var(--text-faint); font-size: 13px; line-height: 1.6; }
.sr-empty svg { width: 34px; height: 34px; color: var(--text-faint); opacity: 0.6; margin: 0 auto var(--s-3); display: block; }

/* Loading: a skeleton grid that mirrors the item grid while data is fetched.
   Kit skeleton primitives (.skel / .skel-line / .skel-btn) supply the shimmer
   + theme handling; the local rules only lay them out like a card. */
.sr-loading { padding: 0; }
.sr-skel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--s-4); }
.sr-skel-card {
  display: flex; flex-direction: column; gap: var(--s-4);
  padding: var(--s-4); min-height: 132px; border-radius: var(--radius-card);
  background: rgba(255,255,255,0.55); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}
.sr-skel-top { display: flex; align-items: flex-start; gap: var(--s-3); }
.sr-skel-thumb { width: 44px; height: 44px; flex: 0 0 auto; border-radius: var(--radius-sm); }
.sr-skel-head { flex: 1 1 auto; display: flex; flex-direction: column; gap: var(--s-2); padding-top: 5px; }
.sr-skel-head .skel-line:first-child { width: 82%; }
.sr-skel-head .skel-line:last-child { width: 46%; }
.sr-skel-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); margin-top: auto; }
.sr-skel-num { width: 54px; height: 22px; border-radius: 6px; }
.sr-skel-move { width: 96px; height: 32px; }

/* Modals: form layout inside the kit .modal. */
.req { color: var(--accent); }
.sr-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.sr-textarea { padding: var(--s-3) var(--s-4); line-height: 1.5; }
.modal-body .field { margin-block: 0; }
/* Auto-generated item code is read-only. */
.text-input[readonly] { color: var(--text-muted); cursor: default; }

/* Returnable (and any inline check row) inside a form field. Scoped under
   .modal-body so it out-specifies the kit's uppercase/tracked `.field label`
   (this is descriptive copy, not a field label). */
.modal-body .sr-checkline { display: flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); text-transform: none; letter-spacing: normal; }
.sr-checkline input { margin-top: 2px; width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--accent); cursor: pointer; }
.modal-body .sr-checkline strong { color: var(--text); font-weight: 500; text-transform: none; letter-spacing: normal; }

/* Category manager. */
.sr-cat-list { list-style: none; margin: 0 0 var(--s-4); padding: 0; display: flex; flex-direction: column; }
.sr-cat-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
.sr-cat-row:last-child { border-bottom: 0; }
.sr-cat-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.sr-cat-name { font-size: 14px; font-weight: 500; color: var(--text); }
.sr-cat-sub { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.sr-cat-code { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); background: rgba(0,0,0,0.06); padding: 1px 6px; border-radius: 5px; font-variant-numeric: tabular-nums; }
.sr-cat-used { font-size: 11px; color: var(--text-faint); }
.sr-cat-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.sr-cat-btn { width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; background: rgba(0,0,0,0.06); color: var(--text-muted); display: grid; place-items: center; flex: 0 0 auto; transition: background 0.12s, color 0.12s; }
.sr-cat-btn svg { width: 15px; height: 15px; }
.sr-cat-btn:hover { background: rgba(0,0,0,0.10); color: var(--text); }
.sr-cat-btn.danger:hover { background: var(--accent); color: var(--premium-yellow); }
.sr-cat-empty { font-size: 12.5px; color: var(--text-faint); padding: var(--s-3) 0; text-align: center; }
/* Skeleton category rows (inside the real .sr-cat-row shell). */
.sr-skel-catname { width: 140px; }
.sr-skel-catcode { width: 52px; margin-top: 3px; }
.sr-skel-catbtn { width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; }
.sr-cat-form { border-top: 1px solid rgba(0,0,0,0.08); padding-top: var(--s-4); }
.sr-cat-form-actions { align-items: end; }
.sr-cat-form-actions .btn { width: 100%; }
.sr-cat-form > .field-help { margin-top: var(--s-3); }

/* Detail: "Used by" - products whose bill of materials consumes this item. */
.sr-uses { list-style: none; margin: 0 0 var(--s-2); padding: 0; display: flex; flex-direction: column; }
.sr-use-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
.sr-use-row:last-child { border-bottom: 0; }
.sr-use-type { flex: 0 0 auto; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); background: rgba(0,0,0,0.06); padding: 1px 7px; border-radius: 5px; }
.sr-use-label { flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Photo upload control (add/edit form). */
.sr-photo-row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.sr-photo-preview {
  width: 56px; height: 56px; flex: 0 0 auto; border-radius: var(--radius-sm);
  background: rgba(0,0,0,0.05) center/cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  display: grid; place-items: center; color: var(--text-faint); overflow: hidden;
}
.sr-photo-preview svg { width: 22px; height: 22px; }
.sr-photo-row .btn { flex: 0 0 auto; }
/* .btn's display:inline-flex outranks the UA [hidden] rule, so force it. */
#f-photo-remove[hidden] { display: none !important; }

.sr-detail-actions { flex-wrap: wrap; }
.sr-detail-actions .spacer { flex: 1 1 auto; }
.sr-danger { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-soft); }

/* Detail: spec grid + movement history. */
.sr-detail-spec { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--s-3) var(--s-4); }
.sr-spec { display: flex; flex-direction: column; gap: 2px; }
.sr-spec .k { font-size: 10px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--text-faint); }
.sr-spec .v { font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }
.sr-spec .v.warn { color: var(--warning); }
.sr-detail-notes { font-size: 13px; color: var(--text-muted); line-height: 1.55; white-space: pre-wrap; }

/* Detail: tappable summary rows that open the scrollable list modals. */
.sr-detail-links { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-2); }
.sr-detail-link {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: var(--s-3) var(--s-4); border: 0; cursor: pointer; text-align: left;
  background: rgba(0,0,0,0.04); border-radius: var(--radius-card); color: var(--text);
  transition: background 0.12s;
}
.sr-detail-link:hover { background: rgba(0,0,0,0.07); }
.sr-dl-label { flex: 1 1 auto; font-size: 13px; font-weight: 500; }
.sr-dl-count { flex: 0 0 auto; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.sr-dl-chev { flex: 0 0 auto; width: 16px; height: 16px; color: var(--text-faint); }

.sr-hist-title { font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase; color: var(--text-faint); margin: var(--s-2) 0 0; }
.sr-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sr-hist-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; border-bottom: 1px solid rgba(0,0,0,0.06); }
.sr-hist-row:last-child { border-bottom: 0; }
.sr-hist-delta { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 500; font-size: 14px; width: 58px; text-align: right; }
.sr-hist-delta.up { color: var(--success); }
.sr-hist-delta.down { color: var(--accent); }
.sr-hist-body { flex: 1 1 auto; min-width: 0; font-size: 12.5px; color: var(--text); line-height: 1.4; }
.sr-hist-body .sub { display: block; font-size: 11px; color: var(--text-faint); margin-top: 1px; }
.sr-hist-time { flex: 0 0 auto; font-size: 11px; color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sr-hist-empty { font-size: 12.5px; color: var(--text-faint); padding: var(--s-3) 0; }

/* Skeleton rows for the Used-by / Movement-history list modal (sit inside the
   real .sr-use-row / .sr-hist-row shells so spacing + dividers match). */
.sr-skel-tag { width: 60px; flex: 0 0 auto; }
.sr-skel-delta { width: 44px; height: 14px; border-radius: 5px; flex: 0 0 auto; }
.sr-skel-time { width: 40px; height: 12px; border-radius: 5px; flex: 0 0 auto; }
.sr-skel-fill { flex: 1 1 auto; max-width: 220px; }

.sr-move-ctx { font-size: 13px; color: var(--text-muted); margin: 0 0 var(--s-2); }
.sr-move-seg { height: var(--s-9); }

@media (max-width: 560px) {
  .sr-field-row { grid-template-columns: 1fr; }
  .sr-bar .btn { flex: 1 1 auto; }
}
