/* Medicines, batches and stock workflow */
.inventory-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.86);
  scrollbar-width: thin;
}
.inventory-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 13px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}
.inventory-tabs a:hover { background: #f3faf7; color: var(--green-dark); }
.inventory-tabs a.active { background: var(--green-soft); color: var(--green-dark); box-shadow: inset 0 0 0 1px #c8e9dc; }
.inventory-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: linear-gradient(135deg, #fff, #eefaf6); }
.inventory-hero h2 { margin: 4px 0 8px; }
.inventory-hero p:last-child { margin-bottom: 0; }
.inventory-hero-actions, .inventory-actions, .inventory-badges { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.inventory-actions form { margin: 0; }
.usage-pill { padding: 9px 12px; border: 1px solid #cfe5dc; border-radius: 999px; background: #fff; color: var(--muted); font-weight: 800; white-space: nowrap; }
.usage-pill strong { color: var(--green-dark); }
.warning-badge { color: var(--warning); background: #fff6d8; }
.movement-badge { color: #315267; background: #edf5f8; }
.movement-in { color: var(--green-dark); font-weight: 900; }
.movement-out { color: var(--danger); font-weight: 900; }
.inventory-badges { margin-top: 5px; }
.inventory-filters { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(160px, .35fr) auto auto; align-items: end; gap: 10px; margin-bottom: 18px; }
.inventory-filters-wide { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

body.inventory-modal-open { overflow: hidden; }
.inventory-dialog {
  width: min(860px, calc(100vw - 32px));
  max-height: min(88dvh, 900px);
  margin: auto;
  padding: 0;
  overflow: auto;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(7, 43, 34, .26);
}
.inventory-dialog::backdrop { background: rgba(4, 25, 31, .62); backdrop-filter: blur(4px); }
.inventory-dialog > form, .inventory-dialog > .dialog-head, .inventory-dialog > .medicine-detail-card, .inventory-dialog > .detail-grid, .inventory-dialog > .dialog-actions { margin-inline: 24px; }
.inventory-dialog > form { margin: 0; padding: 24px; }
.inventory-dialog:not(:has(> form)) { padding: 24px; }
.inventory-dialog:not(:has(> form)) > * { margin-inline: 0; }
.compact-dialog { width: min(600px, calc(100vw - 32px)); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.dialog-head h2 { margin: 3px 0 6px; }
.dialog-head p:last-child { margin: 0; color: var(--muted); }
.dialog-close { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--muted); font-size: 27px; cursor: pointer; }
.dialog-close:hover { color: var(--danger); background: #fff7f6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.medicine-detail-card, .selected-identity, .current-stock-card { display: grid; gap: 5px; padding: 16px; border: 1px solid #cfe5dc; border-radius: 12px; background: linear-gradient(135deg, #f1fbf7, #fff); }
.medicine-detail-card > strong, .selected-identity > strong { font-size: 21px; }
.medicine-detail-card > span, .selected-identity > small { color: var(--muted); font-weight: 700; }
.detail-grid { margin-top: 18px; grid-template-columns: minmax(120px, .5fr) 1fr; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }

.wizard-progress { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 22px; padding: 0; list-style: none; }
.wizard-progress li { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 48px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); background: #f9fbfc; font-size: 13px; font-weight: 900; text-align: center; }
.wizard-progress li span { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: #e9eff2; color: #486176; }
.wizard-progress li.active { border-color: #b8e1d2; background: var(--green-soft); color: var(--green-dark); }
.wizard-progress li.active span { background: var(--green); color: #fff; }
.wizard-step { display: none; }
.wizard-step.active { display: block; animation: inventory-step-in .18s ease-out; }
@keyframes inventory-step-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.choice-card { display: grid; gap: 5px; min-height: 92px; padding: 16px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); cursor: pointer; }
.choice-card span { color: var(--muted); }
.choice-card:hover, .choice-card.active { border-color: var(--green); background: #f3fbf8; box-shadow: 0 8px 22px rgba(15,143,104,.1); }
.wizard-search-results { display: grid; gap: 8px; min-height: 90px; max-height: 310px; margin-top: 10px; padding: 8px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: #f9fcfb; }
.wizard-search-result { width: 100%; display: grid; gap: 5px; padding: 12px; text-align: left; border: 1px solid transparent; border-radius: 10px; background: #fff; cursor: pointer; }
.wizard-search-result:hover, .wizard-search-result:focus { outline: none; border-color: #abd8c7; background: #f0faf6; }
.wizard-search-result strong { font-size: 16px; }
.wizard-search-result > span { color: var(--muted); font-weight: 700; }
.selected-identity { margin-bottom: 16px; }
.selected-identity > span, .current-stock-card > span { color: var(--green-dark); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.identity-fields input[readonly] { border-color: #dce8e4; background: #f6faf8; color: #354c44; box-shadow: none; }
.identity-fields .check.readonly-check { pointer-events: none; opacity: .78; }
.wizard-section { display: grid; gap: 14px; margin-bottom: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fbfefd; }
.wizard-section h3 { margin: 2px 0 0; }
.adjustment-shell { max-width: 900px; }
.adjustment-form { display: grid; gap: 14px; }
.current-stock-card { margin-top: 14px; grid-template-columns: 1fr auto; align-items: center; }
.current-stock-card span, .current-stock-card small { grid-column: 1; }
.current-stock-card strong { grid-column: 2; grid-row: 1 / span 2; font-size: 30px; color: var(--green-dark); }

@media (max-width: 767px) {
  .inventory-tabs { width: 100%; margin-bottom: 14px; }
  .inventory-tabs a { flex: 0 0 auto; }
  .inventory-hero { align-items: stretch; flex-direction: column; }
  .inventory-hero-actions { align-items: stretch; }
  .inventory-hero-actions .btn { flex: 1; }
  .inventory-filters, .inventory-filters-wide { grid-template-columns: minmax(0, 1fr); }
  .inventory-dialog {
    inset: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .inventory-dialog > form { min-height: 100%; padding: 16px; }
  .inventory-dialog:not(:has(> form)) { padding: 16px; }
  .dialog-head { position: sticky; z-index: 4; top: -16px; margin: -16px -16px 16px; padding: 16px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
  .wizard-progress { position: sticky; z-index: 3; top: 77px; margin-inline: -16px; padding: 8px 16px; background: rgba(255,255,255,.96); }
  .wizard-progress li { min-height: 42px; font-size: 11px; }
  .wizard-progress li span { width: 22px; height: 22px; }
  .choice-grid { grid-template-columns: minmax(0, 1fr); }
  .dialog-actions { position: sticky; bottom: -16px; z-index: 3; margin-inline: -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97); box-shadow: 0 -8px 24px rgba(16,32,51,.08); }
  .dialog-actions .btn { flex: 1; }
  .inventory-actions { align-items: stretch; }
  .inventory-actions > *, .inventory-actions form .btn { flex: 1 1 105px; width: 100%; }
}

@media (max-width: 420px) {
  .wizard-progress li { display: grid; gap: 3px; }
  .wizard-progress li span { margin: auto; }
  .dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dialog-actions .btn { width: 100%; }
}

/* Automatic SKU patch */
.sku-line {
  display: block;
  margin-top: .3rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--primary, #0f8f5f);
}
.inventory-hero-actions .inline-form {
  margin-top: 0;
}
.form-grid label small {
  display: block;
  margin-top: .15rem;
  margin-bottom: .25rem;
  color: var(--muted, #6b7280);
  font-weight: 600;
}
@media (max-width: 720px) {
  .inventory-hero-actions .inline-form,
  .inventory-hero-actions .inline-form .btn {
    width: 100%;
  }
}

/* Factory barcode + internal SKU patch */
.small-tip {
  font-size: .88rem;
  margin-top: .35rem;
}
