/* =============================================================
   Workflow App — stylesheet
   Aesthetic: clean, utilitarian, industrial. IBM Plex pairing.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-alt: #faf8f3;
  --ink: #1d1d1b;
  --ink-muted: #6b6b65;
  --ink-faint: #9c9a92;
  --rule: #e2dfd6;
  --rule-strong: #c9c5b8;
  --accent: #b84a12;
  /* burnt orange */
  --accent-ink: #7a2f08;
  --accent-soft: #f5e3d6;
  --success: #2e7d48;
  --danger: #c23a2e;
  --warn: #b8860b;

  --radius: 6px;
  --radius-lg: 10px;

  --font-sans: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.08);
  overflow-wrap: anywhere;
}

a {
  color: var(--accent-ink);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

h1,
h2,
h3 {
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 0.6em;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 24px 0;
}

/* ---------- Topbar ----------
   Layout: three sibling blocks inside .topbar
     .topbar-brand   — fixed left
     .topbar-nav     — middle, scrolls horizontally when narrow
     .topbar-right   — fixed right (user + sign out)
   The nav strip has subtle vertical rules on either side to visually
   separate it from brand and sign-out.
*/
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.topbar-brand {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  flex-shrink: 0;
  padding: 4px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.topbar-brand:hover {
  text-decoration: none;
  background: var(--surface-alt);
}

.topbar-nav {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  /* Vertical dividers separate the nav strip from brand & sign-out */
  border-left: 1px solid var(--rule);
  border-right: 1px solid var(--rule);
  padding: 0 10px;
  margin: 0 4px;
  align-self: stretch;
  /* full topbar height so dividers reach edges */
}

.topbar-nav::-webkit-scrollbar {
  height: 3px;
}

.topbar-nav::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 3px;
}

.topbar-link {
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
  border-radius: var(--radius);
  white-space: nowrap;
  flex: 0 0 auto;
  line-height: 1.4;
}

.topbar-link:hover {
  background: var(--surface-alt);
  color: var(--ink);
  text-decoration: none;
}

.topbar-link.active {
  background: var(--ink);
  color: var(--surface);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.topbar-user {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ---------- Container ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

.container.narrow {
  max-width: 720px;
}

.container.wide {
  max-width: 1600px;
}

.container.full {
  max-width: none;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header .subtitle {
  color: var(--ink-muted);
  margin-top: 4px;
}

/* ---------- Cards / surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card+.card {
  margin-top: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: -20px -20px 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-alt);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-weight: 500;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}

.btn:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-muted);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--rule);
}

.btn-danger:hover {
  background: #fdeceb;
  border-color: var(--danger);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

label .req {
  color: var(--danger);
  margin-left: 2px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 74, 18, 0.15);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.field {
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row label {
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--ink);
}

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
}

th {
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  background: var(--surface-alt);
}

tbody tr:hover {
  background: var(--surface-alt);
}

td.num,
th.num {
  text-align: right;
  font-family: var(--font-mono);
}

/* Keep table column labels and in-cell controls on one line so they
   don't break mid-word (e.g. "RECEIVED", "Open", "active"). */
th {
  white-space: nowrap;
}

td .btn,
td .badge {
  white-space: nowrap;
}

/* If a wide table still overflows its card, let it scroll horizontally
   instead of wrapping/squashing the columns. */
.table-scroll {
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--surface-alt);
  color: var(--ink-muted);
  border: 1px solid var(--rule);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: #e8c7ae;
}

.badge-success {
  background: #e4f3e8;
  color: var(--success);
  border-color: #c0dfc8;
}

.badge-danger {
  background: #fdeceb;
  color: var(--danger);
  border-color: #f3c4c0;
}

.badge-warn {
  background: #f8efd2;
  color: var(--warn);
  border-color: #e4d19a;
}

/* ---------- Messages ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid;
  font-size: 14px;
}

.alert-error {
  background: #fdeceb;
  border-color: #f3c4c0;
  color: #8b2a22;
}

.alert-success {
  background: #e4f3e8;
  border-color: #c0dfc8;
  color: #1f5630;
}

.alert-info {
  background: #eaeef4;
  border-color: #cbd4dd;
  color: #3b4a5c;
}

.empty {
  text-align: center;
  color: var(--ink-faint);
  padding: 40px 20px;
  font-style: italic;
}

/* ---------- Form builder specifics ---------- */
.builder-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  align-items: start;
}

.field-palette .btn {
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 6px;
}

.field-list {
  min-height: 200px;
}

.field-list .empty {
  border: 2px dashed var(--rule-strong);
  border-radius: var(--radius);
}

.field-item {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: start;
}

.field-item .drag {
  color: var(--ink-faint);
  cursor: grab;
  font-family: var(--font-mono);
  user-select: none;
  padding-top: 4px;
}

.field-item .type-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  background: var(--surface-alt);
  color: var(--ink-muted);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 8px;
}

/* ---------- Workflow runner ---------- */
.step-strip {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.step-pill {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: 13px;
  font-family: var(--font-mono);
}

.step-pill.done {
  background: #e4f3e8;
  border-color: #c0dfc8;
  color: var(--success);
}

.step-pill.current {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.step-pill .n {
  display: inline-block;
  margin-right: 6px;
  font-weight: 500;
}

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(var(--bg), var(--bg)),
    radial-gradient(circle at 20% 20%, rgba(184, 74, 18, 0.08), transparent 40%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-card h1 .mark {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 3px;
}

.login-card .subtitle {
  color: var(--ink-muted);
  margin-bottom: 24px;
  font-size: 14px;
}

.login-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-faint);
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

/* ---------- Small utilities ---------- */
.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-3 {
  margin-bottom: 12px;
}

.mb-4 {
  margin-bottom: 16px;
}

.muted {
  color: var(--ink-muted);
}

.small {
  font-size: 13px;
}

.nowrap {
  white-space: nowrap;
}

/* ---------- Allergen chips ---------- */
.allergen-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.allergen-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  margin: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.allergen-chip:hover {
  background: var(--surface-alt);
}

.allergen-chip input {
  display: none;
}

.allergen-chip.on {
  background: #f8e4d5;
  border-color: #c86421;
  color: #7a2f08;
  font-weight: 500;
}

.allergen-chip.inherited {
  background: #fdf5d9;
  border-color: #d9b852;
  color: #6a4d0a;
  font-style: italic;
}

.allergen-chip.inherited::before {
  content: '↓';
  font-size: 11px;
  opacity: 0.7;
}

.allergen-chip.readonly {
  cursor: default;
}

/* ---------- Modal (.modal pattern) ---------- */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 10, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.open {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card .card-header {
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-body {
  padding: 20px;
}

/* ---------- Modal-overlay (used on production-schedule) ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 10, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-alt);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-close {
  background: none;
  border: 0;
  font-size: 18px;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  line-height: 1;
}

.modal-close:hover {
  background: var(--rule);
  color: var(--ink);
}

#batch-modal-body {
  padding: 20px;
}

/* ---------- Ingredient row (recipe editor) ---------- */
.ingredient-row {
  display: grid;
  grid-template-columns: 28px 1fr 120px 28px;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}

.ingredient-row .drag {
  color: var(--ink-faint);
  cursor: grab;
  font-family: var(--font-mono);
  user-select: none;
}

.ingredient-row input[type="number"] {
  text-align: right;
  font-family: var(--font-mono);
}

.ingredient-row .unit {
  font-family: var(--font-mono);
  color: var(--ink-muted);
  font-size: 13px;
  padding-right: 4px;
}

/* ---------- Instruction row (recipe method) ---------- */
.instruction-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}

.instruction-row .step-number {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 6px;
}

.instruction-row .drag {
  color: var(--ink-faint);
  cursor: grab;
  font-family: var(--font-mono);
  user-select: none;
  margin-top: 12px;
}

/* ---------- PO line row (purchase order builder) ---------- */
.po-line-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}

.po-line-row .line-number {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
  color: var(--ink-muted);
  border-radius: 50%;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  flex-shrink: 0;
}

/* ---------- Supplier row (raw material edit) ---------- */
.supplier-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.supplier-row>* {
  min-width: 0;
}

/* ---------- Page-level layout: sidebar on the left + main content ---------- */
.page-with-sidebar {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.page-with-sidebar .side-panel {
  position: sticky;
  top: 16px;
  width: 320px;
  flex-shrink: 0;
  padding: 24px 12px 24px 24px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  align-self: flex-start;
  box-sizing: border-box;
}

.page-with-sidebar .page-main {
  flex: 1;
  min-width: 0;
}

/* Materials panel rows */
.mat-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  line-height: 1.4;
}

.mat-row:last-child {
  border-bottom: 0;
}

.mat-row.short {
  background: rgba(194, 58, 46, 0.04);
  margin: 0 -14px;
  padding: 10px 14px;
  border-left: 3px solid var(--danger, #c23a2e);
}

.mat-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-weight: 500;
}

.mat-row-head .sku {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  margin-right: 4px;
}

.mat-row-body {
  margin-top: 4px;
  color: var(--ink-muted);
  font-size: 12px;
}

.mat-row .mat-status {
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

.mat-row.ok .mat-status {
  color: var(--success, #639922);
}

.mat-row.short .mat-status {
  color: var(--danger, #c23a2e);
}

.mat-row .supplier-hint {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* ---------- Progress bar for percent total ---------- */
.pct-bar {
  height: 6px;
  background: var(--rule);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.pct-bar .fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s, background 0.2s;
}

.pct-bar .fill.over {
  background: var(--danger);
}

.pct-bar .fill.good {
  background: var(--success);
}

/* ---------- Detail view ---------- */
.dl-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 6px 20px;
  font-size: 14px;
}

.dl-grid dt {
  color: var(--ink-muted);
}

.dl-grid dd {
  margin: 0;
}


/* =============================================================
   Responsive — tablet & phone overrides
   ============================================================= */

/* Tablet (≤ 1024px) — tighter container, scrollable horizontals */
@media (max-width: 1024px) {
  .container {
    padding: 24px 18px 60px;
  }

  .page-header {
    margin-bottom: 20px;
  }

  /* Tables in cards: scroll horizontally if columns overflow */
  .card {
    overflow-x: auto;
  }

  /* Page-with-sidebar collapses to stack */
  .page-with-sidebar {
    flex-direction: column;
  }

  .page-with-sidebar .side-panel {
    width: auto;
    position: static;
    max-height: none;
    padding: 16px;
  }
}

/* Phone (≤ 640px) — single-column, larger touch targets, near-full modals */
@media (max-width: 640px) {

  html,
  body {
    font-size: 14px;
  }

  .container {
    padding: 16px 12px 60px;
  }

  h1 {
    font-size: 22px;
  }

  h2 {
    font-size: 18px;
  }

  /* Topbar tightens further on phones */
  .topbar {
    padding: 4px 10px;
    gap: 8px;
    min-height: 44px;
  }

  .topbar-brand {
    font-size: 14px;
    padding: 4px 6px;
  }

  .topbar-nav {
    padding: 0 6px;
    margin: 0 2px;
  }

  .topbar-link {
    padding: 5px 8px;
    font-size: 13px;
  }

  .topbar-user {
    display: none;
  }

  /* hide username on tiny screens, keep Sign out */

  /* Cards: tighter padding */
  .card {
    padding: 14px;
    border-radius: var(--radius);
  }

  .card-header {
    margin: -14px -14px 12px;
    padding: 12px 14px;
  }

  /* Buttons: bigger tap targets */
  .btn {
    padding: 11px 14px;
    font-size: 14px;
    min-height: 40px;
  }

  .btn-sm {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 34px;
  }

  .btn-row {
    gap: 6px;
  }

  /* Inputs: 16px font prevents iOS Safari auto-zoom on focus */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  input[type="datetime-local"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px;
    padding: 10px 12px;
  }

  /* Two-up form rows collapse */
  .field-row {
    grid-template-columns: 1fr;
  }

  /* Definition list grid: stack label/value */
  .dl-grid {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .dl-grid dt,
  .dl-grid>div:nth-child(odd) {
    color: var(--ink-muted);
    font-size: 12px;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* Tables tighten */
  table {
    font-size: 13px;
  }

  th,
  td {
    padding: 8px 10px;
  }

  th {
    font-size: 11px;
    letter-spacing: 0.04em;
  }

  /* Grids of cards collapse */
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  /* Flex helpers wrap on small screens */
  .row {
    flex-wrap: wrap;
  }

  .row-between {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  /* Modals: bottom-sheet style on phones */
  .modal,
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal-card,
  .modal-box {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  #batch-modal-body {
    padding: 16px;
  }

  /* Recipe ingredient row */
  .ingredient-row {
    grid-template-columns: 24px 1fr 90px 24px;
    gap: 6px;
  }

  /* Form builder palette stacks above field list */
  .builder-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .field-item {
    grid-template-columns: 24px 1fr;
    gap: 8px;
    padding: 12px;
  }

  .field-item>*:nth-child(3) {
    grid-column: 1 / -1;
    margin-top: 4px;
  }

  /* Step strip already scrolls; just tighten */
  .step-strip {
    gap: 4px;
  }

  .step-pill {
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Alerts a touch tighter */
  .alert {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Empty states */
  .empty {
    padding: 24px 12px;
    font-size: 14px;
  }

  /* Materials panel: drop the negative-margin bleed on narrow cards */
  .mat-row.short {
    margin: 0;
    padding: 10px 12px;
  }
}

/* Very small phones (≤ 380px) — last-ditch tightening */
@media (max-width: 380px) {
  .container {
    padding: 12px 10px 60px;
  }

  h1 {
    font-size: 20px;
  }

  .badge {
    font-size: 11px;
    padding: 2px 6px;
  }

  th,
  td {
    padding: 6px 8px;
  }
}

/* Touch-only refinements (no hover, e.g. tablets / phones) */
@media (hover: none) {
  .btn:active {
    background: var(--surface-alt);
  }

  .btn-primary:active {
    background: var(--accent-ink);
  }

  tbody tr:hover {
    background: transparent;
  }

  tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.015);
  }
}

/* Print: hide the topbar and modals */
@media print {

  .topbar,
  .modal,
  .modal-overlay {
    display: none !important;
  }

  .card {
    overflow: visible !important;
  }
}