/*
 * Kleren Inventory — Design System
 * Hybrid: Vasy-style info-density + modern SaaS polish (Linear/Stripe vibe).
 *
 * Usage: Every /inventory-*.html page includes this CSS and uses iv-* classes.
 * Keep page-specific styles to a minimum — push reusable patterns up to here.
 *
 * Naming: every class is prefixed `iv-` so it can't clash with shared style.css.
 */

/* === Design tokens ====================================================== */
:root {
  /* Surfaces */
  --iv-bg:           #f7f8fa;
  --iv-surface:      #ffffff;
  --iv-surface-2:    #f8fafc;     /* subtle alt rows, table headers */

  /* Borders */
  --iv-border:       #e4e7ec;
  --iv-border-strong:#cbd5e1;

  /* Ink */
  --iv-text:         #0f172a;
  --iv-text-muted:   #64748b;
  --iv-text-faint:   #94a3b8;
  --iv-text-on-dark: #f8fafc;

  /* Semantic */
  --iv-primary:        #2563eb;       /* was navy — now the accent blue (user pref) */
  --iv-primary-hover:  #1d4ed8;
  --iv-primary-shadow: rgba(37, 99, 235, 0.20);
  --iv-dark:           #0f172a;       /* kept for text + iv-btn-dark */
  --iv-dark-hover:     #1e293b;
  --iv-accent:         #2563eb;
  --iv-accent-hover:   #1d4ed8;
  --iv-accent-soft:    #eff6ff;
  --iv-accent-tint:    #f5f9ff;       /* even lighter, for backdrops */
  --iv-success:        #059669;
  --iv-success-soft:   #d1fae5;
  --iv-warn:           #d97706;
  --iv-warn-soft:      #fef3c7;
  --iv-danger:         #dc2626;
  --iv-danger-soft:    #fee2e2;
  --iv-purple-soft:    #ede9fe;
  --iv-purple:         #6d28d9;

  /* Geometry */
  --iv-radius-sm:    6px;
  --iv-radius:       8px;
  --iv-radius-lg:    12px;

  /* Shadows */
  --iv-shadow-sm:    0 1px 2px rgba(15, 23, 42, 0.05);
  --iv-shadow:       0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --iv-shadow-md:    0 4px 8px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
  --iv-shadow-lg:    0 10px 20px rgba(15, 23, 42, 0.08), 0 4px 8px rgba(15, 23, 42, 0.04);

  /* Focus ring */
  --iv-ring:         0 0 0 3px rgba(37, 99, 235, 0.18);
  --iv-ring-danger:  0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* === Base layout ======================================================== */
/* One font for the entire Inventory module — Inter first (loaded by
   style.css), system-ui fall-backs match it closely on macOS / Windows.
   font-feature-settings adds tabular numerals + a slashed zero so
   identifiers like VRF# and SKUs read cleanly without switching to a
   monospace family (which used to create the jarring "second font" effect
   the screenshots flagged). */
body.iv-app {
  background: var(--iv-bg);
  color: var(--iv-text);
  font-family: var(--kl-font-sans, 'InterVariable', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "tnum", "zero", "cv02", "cv03", "cv04", "cv11";
  letter-spacing: -0.005em;
  text-rendering: optimizeLegibility;
}

.iv-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}
@media (max-width: 768px) {
  .iv-shell { padding: 14px; }
}

/* === Page header ======================================================== */
.iv-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--iv-border);
}
.iv-page-head-l { min-width: 0; }
.iv-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.015em;
  color: var(--iv-text);
  line-height: 1.2;
}
.iv-page-sub {
  font-size: 0.86rem;
  color: var(--iv-text-muted);
  margin-top: 4px;
}
.iv-breadcrumb {
  font-size: 0.78rem;
  color: var(--iv-text-muted);
  margin-bottom: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.iv-breadcrumb a {
  color: var(--iv-text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.iv-breadcrumb a:hover { color: var(--iv-accent); }
.iv-breadcrumb .iv-bc-sep { color: var(--iv-text-faint); }
.iv-page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* === Cards ============================================================== */
.iv-card {
  background: var(--iv-surface);
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  box-shadow: var(--iv-shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.iv-card.iv-card-tight { padding: 14px 16px; }
.iv-card.iv-card-flush { padding: 0; overflow: hidden; }
.iv-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--iv-border);
}
.iv-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: var(--iv-text);
  letter-spacing: -0.005em;
}
.iv-card-sub {
  font-size: 0.82rem;
  color: var(--iv-text-muted);
  margin-top: 2px;
}
.iv-card-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--iv-border);
}
.iv-card-section:last-child { border-bottom: none; }
.iv-card-section-title {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--iv-text-muted);
  margin: 0 0 10px;
}

/* === Buttons ============================================================ */
.iv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: var(--iv-radius-sm);
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  user-select: none;
}
.iv-btn:focus-visible { outline: none; box-shadow: var(--iv-ring); }
.iv-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.iv-btn-primary {
  background: var(--iv-primary);
  color: white;
  border-color: var(--iv-primary);
  box-shadow: 0 1px 2px var(--iv-primary-shadow);
}
.iv-btn-primary:hover:not(:disabled) {
  background: var(--iv-primary-hover);
  border-color: var(--iv-primary-hover);
  box-shadow: 0 4px 12px var(--iv-primary-shadow);
  transform: translateY(-1px);
}
.iv-btn-primary:active:not(:disabled) { transform: translateY(0); }

/* Dark variant kept for contexts where the navy ink reads better */
.iv-btn-dark {
  background: var(--iv-dark);
  color: white;
  border-color: var(--iv-dark);
}
.iv-btn-dark:hover:not(:disabled) {
  background: var(--iv-dark-hover);
  border-color: var(--iv-dark-hover);
  box-shadow: var(--iv-shadow-md);
}

.iv-btn-secondary {
  background: var(--iv-surface);
  color: var(--iv-text);
  border-color: var(--iv-border-strong);
}
.iv-btn-secondary:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: var(--iv-text-muted);
}

.iv-btn-ghost {
  background: transparent;
  color: var(--iv-text-muted);
}
.iv-btn-ghost:hover:not(:disabled) {
  background: #f1f5f9;
  color: var(--iv-text);
}

.iv-btn-accent {
  background: var(--iv-accent);
  color: white;
  border-color: var(--iv-accent);
}
.iv-btn-accent:hover:not(:disabled) {
  background: var(--iv-accent-hover);
  border-color: var(--iv-accent-hover);
  box-shadow: var(--iv-shadow-md);
}

.iv-btn-danger {
  background: var(--iv-danger-soft);
  color: var(--iv-danger);
  border-color: #fecaca;
}
.iv-btn-danger:hover:not(:disabled) {
  background: var(--iv-danger);
  color: white;
  border-color: var(--iv-danger);
}

.iv-btn-success {
  background: var(--iv-success);
  color: white;
  border-color: var(--iv-success);
}
.iv-btn-success:hover:not(:disabled) {
  background: #047857;
  border-color: #047857;
  box-shadow: var(--iv-shadow-md);
}

.iv-btn-sm  { padding: 6px 11px; font-size: 0.78rem; }
.iv-btn-lg  { padding: 11px 18px; font-size: 0.92rem; }
.iv-btn-xs  { padding: 4px 8px;  font-size: 0.72rem; }

.iv-btn-icon {
  padding: 6px;
  min-width: 32px;
  min-height: 32px;
}

/* === Form fields ======================================================== */
.iv-field { margin-bottom: 12px; }
.iv-field.iv-field-tight { margin-bottom: 0; }

.iv-field-row {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.iv-field-row-2 { grid-template-columns: 1fr 1fr; }
.iv-field-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.iv-field-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.iv-field-row-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) {
  .iv-field-row-3, .iv-field-row-4, .iv-field-row-5 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .iv-field-row-2, .iv-field-row-3, .iv-field-row-4, .iv-field-row-5 { grid-template-columns: 1fr; }
}

.iv-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--iv-text);
  margin-bottom: 5px;
  letter-spacing: -0.002em;
}
.iv-label .iv-req { color: var(--iv-danger); margin-left: 2px; }
.iv-label .iv-opt { color: var(--iv-text-faint); font-weight: 400; margin-left: 4px; }

.iv-help {
  font-size: 0.74rem;
  color: var(--iv-text-muted);
  margin-top: 5px;
  line-height: 1.4;
}

.iv-input,
.iv-select,
.iv-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 11px;
  border: 1px solid var(--iv-border-strong);
  border-radius: var(--iv-radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  background: white;
  color: var(--iv-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.iv-input:focus, .iv-select:focus, .iv-textarea:focus {
  outline: none;
  border-color: var(--iv-accent);
  box-shadow: var(--iv-ring);
}
.iv-input:disabled, .iv-select:disabled, .iv-textarea:disabled {
  background: #f1f5f9;
  color: var(--iv-text-muted);
  cursor: not-allowed;
}
.iv-input::placeholder, .iv-textarea::placeholder { color: var(--iv-text-faint); }
.iv-textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.iv-input.iv-is-error,
.iv-select.iv-is-error { border-color: var(--iv-danger); }
.iv-input.iv-is-error:focus { box-shadow: var(--iv-ring-danger); }

.iv-input-sm { padding: 6px 9px; font-size: 0.82rem; }

/* Inline-label horizontal field (Vasy style) */
.iv-field-inline {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}
.iv-field-inline:last-child { border-bottom: none; }
.iv-field-inline .iv-label { margin-bottom: 0; }
@media (max-width: 700px) {
  .iv-field-inline { grid-template-columns: 1fr; gap: 6px; }
}

/* Checkbox / switch */
.iv-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.iv-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--iv-accent);
  cursor: pointer;
}

/* Pill toggle (used for attribute picker, status filters) */
.iv-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--iv-border-strong);
  border-radius: 999px;
  background: white;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--iv-text);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.iv-pill:hover { border-color: var(--iv-text-muted); background: #f8fafc; }
.iv-pill.on {
  background: var(--iv-primary);
  border-color: var(--iv-primary);
  color: white;
}
.iv-pill .iv-pill-tail { opacity: 0.6; margin-left: 4px; }

/* === Tables ============================================================= */
.iv-table-wrap {
  background: white;
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  overflow: hidden;
  box-shadow: var(--iv-shadow);
}
.iv-table-scroll { overflow-x: auto; }

.iv-table {
  width: 100%;
  border-collapse: collapse;
}
.iv-table th {
  background: var(--iv-surface-2);
  color: var(--iv-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--iv-border);
  white-space: nowrap;
}
.iv-table th.num { text-align: right; }
.iv-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
  color: var(--iv-text);
  vertical-align: middle;
}
.iv-table tbody tr:last-child td { border-bottom: none; }
.iv-table tbody tr.iv-row-click {
  cursor: pointer;
  transition: background 0.1s;
}
.iv-table tbody tr.iv-row-click:hover { background: var(--iv-surface-2); }
.iv-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Identifier cells (VRF#, SKU, barcode): same family as the rest of the
   table, just tabular+slashed-zero for clean alignment and slightly
   tighter tracking. No more monospace switch. nowrap so things like
   VRF-20260516-001 don't break across two lines on narrower screens. */
.iv-table .mono {
  font-feature-settings: "tnum", "zero";
  letter-spacing: -0.01em;
  color: var(--iv-text);
  white-space: nowrap;
}
/* Date cells — keep dates on one line; mobile card view overrides. */
.iv-table .iv-cell-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.iv-table .iv-cell-strong { font-weight: 600; }
.iv-table .iv-cell-sub { color: var(--iv-text-muted); font-size: 0.78rem; margin-top: 2px; }

.iv-table-empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--iv-text-muted);
  font-size: 0.9rem;
}

/* Mobile: stack rows as cards */
@media (max-width: 700px) {
  .iv-table-mobile thead { display: none; }
  .iv-table-mobile, .iv-table-mobile tbody, .iv-table-mobile tr, .iv-table-mobile td {
    display: block;
    width: 100%;
  }
  .iv-table-mobile tr {
    background: white;
    border: 1px solid var(--iv-border);
    border-radius: var(--iv-radius);
    margin-bottom: 10px;
    padding: 12px 14px;
    box-shadow: var(--iv-shadow-sm);
  }
  .iv-table-mobile td {
    border: none;
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
  }
  .iv-table-mobile td::before {
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--iv-text-muted);
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }
  .iv-table-mobile td.num { text-align: right; }
  .iv-table-wrap { background: transparent; border: none; box-shadow: none; overflow: visible; }
  .iv-table-mobile { background: transparent; }
}

/* === Badges ============================================================= */
.iv-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  line-height: 1.4;
}
.iv-badge-success { background: var(--iv-success-soft); color: #065f46; }
.iv-badge-warn    { background: var(--iv-warn-soft); color: #92400e; }
.iv-badge-danger  { background: var(--iv-danger-soft); color: #991b1b; }
.iv-badge-info    { background: var(--iv-accent-soft); color: #1d4ed8; }
.iv-badge-purple  { background: var(--iv-purple-soft); color: var(--iv-purple); }
.iv-badge-neutral { background: #f1f5f9; color: var(--iv-text-muted); }
.iv-badge-outline { background: white; border: 1px solid var(--iv-border-strong); color: var(--iv-text-muted); }
.iv-badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* === Stat tiles ========================================================= */
.iv-stats {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}
.iv-stats-2 { grid-template-columns: repeat(2, 1fr); }
.iv-stats-3 { grid-template-columns: repeat(3, 1fr); }
.iv-stats-4 { grid-template-columns: repeat(4, 1fr); }
.iv-stats-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) {
  .iv-stats-4, .iv-stats-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .iv-stats-3, .iv-stats-4, .iv-stats-5 { grid-template-columns: 1fr 1fr; }
}

.iv-stat {
  background: white;
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  padding: 16px;
  box-shadow: var(--iv-shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.iv-stat:hover { box-shadow: var(--iv-shadow); border-color: var(--iv-border-strong); }
.iv-stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--iv-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.iv-stat-value {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--iv-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.iv-stat-value.success { color: var(--iv-success); }
.iv-stat-value.danger  { color: var(--iv-danger); }
.iv-stat-value.warn    { color: var(--iv-warn); }
.iv-stat-foot {
  font-size: 0.78rem;
  color: var(--iv-text-muted);
  margin-top: 4px;
}
.iv-stat-foot.up   { color: var(--iv-success); }
.iv-stat-foot.down { color: var(--iv-danger); }

/* === Toolbar (filters strip) ============================================ */
.iv-toolbar {
  background: white;
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  box-shadow: var(--iv-shadow-sm);
}
.iv-toolbar .iv-field { margin-bottom: 0; min-width: 140px; flex: 0 1 auto; }
.iv-toolbar .iv-field.grow { flex: 1 1 240px; }
.iv-toolbar .iv-toolbar-end { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* === Tabs =============================================================== */
.iv-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--iv-border);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.iv-tab {
  padding: 11px 16px;
  border: none;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--iv-text-muted);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}
.iv-tab:hover { color: var(--iv-text); }
.iv-tab.active {
  color: var(--iv-accent);
  border-bottom-color: var(--iv-accent);
}
.iv-tab .iv-tab-badge {
  display: inline-flex;
  padding: 1px 7px;
  margin-left: 6px;
  background: #f1f5f9;
  color: var(--iv-text-muted);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.iv-tab.active .iv-tab-badge { background: var(--iv-accent-soft); color: var(--iv-accent); }

/* === Sticky bottom action bar =========================================== */
.iv-action-bar {
  position: sticky;
  bottom: 0;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--iv-border);
  padding: 14px 24px;
  margin: 24px -24px -24px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.08);
  z-index: 10;
}
@media (max-width: 768px) {
  .iv-action-bar { margin: 16px -14px -14px; padding: 12px 14px; gap: 8px; }
}
.iv-action-bar .iv-action-info {
  font-size: 0.82rem;
  color: var(--iv-text-muted);
}

/* Save status pill — colour-coded by data-state */
.iv-save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.81rem;
  font-weight: 600;
  line-height: 1;
  margin-right: auto;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.iv-save-status[data-state="saved"]   { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.iv-save-status[data-state="dirty"]   { background: #fffbeb; color: #92400e; border-color: #fcd34d; }
.iv-save-status[data-state="invalid"] { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }
.iv-save-status[data-state="saving"]  { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.iv-save-status-icon { width: 14px; height: 14px; flex-shrink: 0; }

/* Primary save button — beefed-up sizing so it reads as a CTA, not a chip */
.iv-action-bar .iv-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 4px 14px -2px rgba(37, 99, 235, 0.35);
}
.iv-action-bar .iv-save-btn:disabled {
  background: var(--iv-surface-2, #e5e7eb);
  color: var(--iv-text-muted, #94a3b8);
  cursor: not-allowed;
  box-shadow: none;
}
.iv-action-bar .iv-save-discard {
  padding: 9px 14px;
  font-size: 0.86rem;
  font-weight: 600;
}

/* Mobile: stack neatly */
@media (max-width: 540px) {
  .iv-action-bar { flex-direction: column; align-items: stretch; }
  .iv-action-bar .iv-save-status { margin-right: 0; justify-content: center; }
  .iv-action-bar .iv-save-btn,
  .iv-action-bar .iv-save-discard { width: 100%; justify-content: center; }
}

/* === Modal ============================================================== */
.iv-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: iv-fade 0.15s ease;
}
.iv-modal-backdrop.show { display: flex; }
@keyframes iv-fade { from { opacity: 0; } to { opacity: 1; } }
.iv-modal {
  background: white;
  border-radius: var(--iv-radius-lg);
  box-shadow: var(--iv-shadow-lg);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: iv-slide-up 0.2s ease;
}
@keyframes iv-slide-up {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.iv-modal.iv-modal-wide { max-width: 720px; }
.iv-modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--iv-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.iv-modal-title { font-size: 1.05rem; font-weight: 700; margin: 0; }
.iv-modal-close {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--iv-text-muted);
  font-size: 1.5rem;
  padding: 0 6px;
  line-height: 1;
}
.iv-modal-close:hover { color: var(--iv-text); }
.iv-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.iv-modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--iv-border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--iv-surface-2);
}

/* === Empty state ======================================================== */
.iv-empty {
  background: white;
  border: 1px dashed var(--iv-border-strong);
  border-radius: var(--iv-radius);
  padding: 56px 24px;
  text-align: center;
}
.iv-empty-icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 14px;
  opacity: 0.5;
}
.iv-empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--iv-text);
  margin: 0 0 6px;
}
.iv-empty-desc {
  font-size: 0.88rem;
  color: var(--iv-text-muted);
  margin: 0 auto 18px;
  max-width: 380px;
  line-height: 1.5;
}
.iv-empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* === Searchable combobox ================================================ */
.iv-combo { position: relative; }
.iv-combo-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--iv-border-strong);
  border-radius: var(--iv-radius-sm);
  font-size: 0.9rem;
  background: white;
  font-family: inherit;
}
.iv-combo-input:focus {
  outline: none;
  border-color: var(--iv-accent);
  box-shadow: var(--iv-ring);
}
.iv-combo-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--iv-text-muted);
  pointer-events: none;
  font-size: 0.78rem;
}
.iv-combo-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  box-shadow: var(--iv-shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 50;
  display: none;
}
.iv-combo.open .iv-combo-menu { display: block; }
.iv-combo-option {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.iv-combo-option:last-child { border-bottom: none; }
.iv-combo-option:hover,
.iv-combo-option.highlighted { background: var(--iv-accent-soft); }
.iv-combo-option-sub { font-size: 0.76rem; color: var(--iv-text-muted); margin-top: 2px; }
.iv-combo-empty {
  padding: 18px;
  text-align: center;
  color: var(--iv-text-muted);
  font-size: 0.85rem;
}

/* === Scan box (shared — Supplier Bill / Transfer / Verification / future) ===
   Designed as a single compact component so every scan-enabled page in
   Inventory looks identical. Use with /public/js/iv-scan.js to also get
   the product-name autocomplete dropdown for free. */
.iv-scan-box {
  background: linear-gradient(135deg, var(--iv-accent-tint) 0%, var(--iv-accent-soft) 100%);
  border: 1px solid #bfdbfe;
  border-radius: var(--iv-radius);
  padding: 10px 12px;
  margin-bottom: 14px;
  position: sticky;
  top: 12px;
  z-index: 10;
  box-shadow: var(--iv-shadow-sm);
}
.iv-scan-label {
  display: flex; align-items: center; gap: 6px;
  color: var(--iv-accent-hover);
  font-size: 0.66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.iv-scan-input {
  width: 100%; box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid #bfdbfe;
  border-radius: var(--iv-radius-sm);
  font-size: 0.92rem;
  font-family: inherit;
  font-feature-settings: "tnum", "zero";
  letter-spacing: -0.005em;
  background: white;
  color: var(--iv-text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.iv-scan-input::placeholder { color: var(--iv-text-faint); }
.iv-scan-input:focus {
  outline: none;
  border-color: var(--iv-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}
.iv-scan-hint {
  color: #64748b;
  font-size: 0.72rem;
  margin-top: 5px;
}

/* Autocomplete suggestions panel (rendered by IvScan helper).
   Works in any parent — POS, the inventory scan-box, future surfaces.
   Whatever element wraps the scan input must declare position:relative
   to anchor the dropdown. The .iv-scan-box override below tightens the
   panel to the box's interior padding; other containers use the default
   full-width positioning. */
.iv-ss-panel {
  position: absolute; top: calc(100% - 4px); left: 0; right: 0;
  background: white; border: 1px solid var(--iv-border); border-radius: var(--iv-radius);
  box-shadow: var(--iv-shadow-lg); max-height: 280px; overflow-y: auto;
  z-index: 30; display: none;
}
.iv-ss-panel.show { display: block; }
.iv-scan-box { position: relative; }  /* anchor for the panel inside scan boxes */
.iv-scan-box .iv-ss-panel { left: 12px; right: 12px; }
.iv-ss-item {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #f1f5f9;
  font-size: 0.86rem;
}
.iv-ss-item:last-child { border-bottom: none; }
.iv-ss-item:hover, .iv-ss-item.iv-ss-hl { background: var(--iv-accent-soft); }
.iv-ss-meta { font-size: 0.74rem; color: var(--iv-text-muted); margin-top: 2px; font-feature-settings: "tnum", "zero"; letter-spacing: -0.005em; }

/* === Toast (top-right) ================================================== */
.iv-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--iv-primary);
  color: white;
  padding: 12px 18px;
  border-radius: var(--iv-radius);
  box-shadow: var(--iv-shadow-lg);
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  pointer-events: none;
  z-index: 9999;
  max-width: 360px;
}
.iv-toast.show { opacity: 1; transform: translateY(0); }
.iv-toast.err { background: var(--iv-danger); }
.iv-toast.ok  { background: var(--iv-success); }

/* === Skeletons (loading placeholders) =================================== */
@keyframes iv-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
.iv-skeleton {
  background: #e2e8f0;
  border-radius: 4px;
  animation: iv-pulse 1.4s ease-in-out infinite;
  display: inline-block;
}
.iv-skeleton-line { height: 14px; width: 100%; margin-bottom: 8px; }
.iv-skeleton-card {
  background: white;
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* === Tile grid (used by inventory home) ================================= */
.iv-tiles {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  margin-top: 16px;
}
.iv-tile {
  background: white;
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  padding: 18px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: all 0.15s;
  box-shadow: var(--iv-shadow-sm);
}
.iv-tile:hover {
  transform: translateY(-2px);
  border-color: var(--iv-border-strong);
  box-shadow: var(--iv-shadow-md);
}
.iv-tile.iv-tile-disabled {
  opacity: 0.55;
  pointer-events: none;
}
.iv-tile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.iv-tile-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--iv-radius-sm);
  background: var(--iv-accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.iv-tile-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--iv-text);
  margin-top: 12px;
}
.iv-tile-sub {
  color: var(--iv-text-muted);
  font-size: 0.82rem;
  margin-top: 3px;
  line-height: 1.4;
}
.iv-tile-arrow {
  color: var(--iv-text-faint);
  font-size: 0.9rem;
  transition: transform 0.15s, color 0.15s;
}
.iv-tile:hover .iv-tile-arrow { color: var(--iv-accent); transform: translateX(2px); }

/* === Tree (categories / brands) ========================================= */
.iv-tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}
.iv-tree-row:last-child { border-bottom: none; }
.iv-tree-row.is-child { padding-left: 36px; }
.iv-tree-row.is-child::before {
  content: "↳";
  color: var(--iv-text-faint);
  margin-right: 4px;
}
.iv-tree-row.is-archived { opacity: 0.55; }

/* === Utility ============================================================ */
.iv-mute    { color: var(--iv-text-muted); }
.iv-faint   { color: var(--iv-text-faint); }
.iv-num     { font-variant-numeric: tabular-nums; }
/* Kept for backwards-compat — used to switch to a monospace family, now
   it just enables tabular figures + slashed zero for identifier alignment
   without breaking visual rhythm with surrounding sans-serif text. */
.iv-mono    { font-feature-settings: "tnum", "zero"; letter-spacing: -0.005em; }
.iv-hidden  { display: none !important; }
.iv-flex    { display: flex; gap: 8px; align-items: center; }
.iv-flex-between { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.iv-row-gap { display: flex; gap: 12px; flex-wrap: wrap; }

.iv-text-success { color: var(--iv-success); font-weight: 600; }
.iv-text-danger  { color: var(--iv-danger); font-weight: 600; }
.iv-text-warn    { color: var(--iv-warn); font-weight: 600; }

.iv-mb-0  { margin-bottom: 0 !important; }
.iv-mb-2  { margin-bottom: 8px; }
.iv-mb-3  { margin-bottom: 12px; }
.iv-mb-4  { margin-bottom: 16px; }
.iv-mt-0  { margin-top: 0 !important; }
.iv-mt-2  { margin-top: 8px; }
.iv-mt-3  { margin-top: 12px; }
.iv-mt-4  { margin-top: 16px; }
.iv-mt-6  { margin-top: 24px; }

.iv-grow { flex: 1; }
.iv-w-full { width: 100%; }
.iv-text-right { text-align: right; }
.iv-text-center { text-align: center; }

/* Sticky multi-select action bar — appears below the toolbar when rows
   are selected. Use on any list that supports bulk operations. */
.iv-bulk-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  background: var(--iv-accent-soft, #eff6ff);
  border: 1px solid #bfdbfe;
  border-radius: var(--iv-radius);
  padding: 8px 12px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}
.iv-bulk-bar .iv-bulk-count { font-size: 0.86rem; color: var(--iv-text); }
.iv-bulk-bar .iv-bulk-count strong { color: var(--iv-accent-hover); }

/* ─── Paginator (iv-paginator.js) ───────────────────────────────────────
   Vasy-style page-size dropdown + numbered nav. Sits inside any list
   page's footer; one widget per page. */
.iv-paginator {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  background: white;
  border: 1px solid var(--iv-border);
  border-radius: var(--iv-radius);
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 0.85rem;
}
.iv-paginator-meta { color: var(--iv-text-muted); }
.iv-paginator-meta strong { color: var(--iv-text); }
.iv-paginator-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.iv-paginator-size { display: flex; align-items: center; gap: 6px; color: var(--iv-text-muted); }
.iv-paginator-size select {
  padding: 4px 8px;
  border: 1px solid var(--iv-border);
  border-radius: 6px;
  background: white;
  font-size: 0.82rem;
  cursor: pointer;
}
.iv-paginator-pages { display: flex; align-items: center; gap: 4px; }
.iv-pag-btn {
  min-width: 28px; height: 28px; padding: 0 8px;
  border: 1px solid var(--iv-border);
  background: white;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--iv-text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.iv-pag-btn:hover:not(:disabled) { background: var(--iv-bg-muted, #f8fafc); border-color: #cbd5e1; }
.iv-pag-btn.active {
  background: #1e40af; color: white; border-color: #1e40af; font-weight: 700;
}
.iv-pag-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.iv-pag-ellipsis { color: var(--iv-text-muted); padding: 0 4px; }
