:root {
  --ink: #15211a;
  --muted: #67736b;
  --line: #dce4de;
  --paper: #f4f3ed;
  --card: #fff;
  --forest: #155b48;
  --mint: #d8f2df;
  --lime: #dff35b;
  --amber: #efb84f;
  --coral: #e36f53;
  --blue: #dcecf6;
  --shadow: 0 18px 55px #26372c17;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 72px; padding: 0 24px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand > span { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; background: var(--forest); color: var(--lime); font: 900 27px Georgia; }
.brand div { display: grid; }
.brand strong { font-size: 11px; letter-spacing: .15em; }
.brand small { font-size: 15px; font-weight: 800; }
.topbar nav { display: flex; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; }
.topbar nav a { padding: 9px 13px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 750; }
.topbar nav a.active { background: var(--ink); color: #fff; }
.profile-link { justify-self: end; color: var(--ink); text-decoration: none; font-weight: 800; }
.production-shell { min-height: calc(100vh - 72px); display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.sidebar { position: sticky; top: 72px; height: calc(100vh - 72px); overflow: auto; padding: 26px 22px; display: flex; flex-direction: column; gap: 22px; background: #fff; border-right: 1px solid var(--line); }
.eyebrow { color: var(--forest); font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.sidebar h1 { margin: 5px 0; font-size: 36px; letter-spacing: -.04em; }
.sidebar p, .dialog-help { color: var(--muted); font-size: 13px; line-height: 1.5; }
.organization-picker, .dialog-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.organization-picker select, .dialog-form input, .dialog-form select, .dialog-form textarea, .panel-tools input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: #fff; outline: none;
}
.section-nav { display: grid; gap: 7px; }
.section-nav button { min-height: 58px; display: grid; grid-template-columns: 32px 1fr; gap: 9px; align-items: center; padding: 9px 12px; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--ink); text-align: left; }
.section-nav button > span { font-size: 23px; color: var(--forest); }
.section-nav button div { display: grid; }
.section-nav button small { margin-top: 2px; color: var(--muted); }
.section-nav button.active { border-color: #bed9c9; background: #ebf5ef; }
.quick-actions { display: grid; gap: 8px; }
.primary, .secondary { min-height: 44px; border: 0; border-radius: 11px; padding: 10px 14px; font-weight: 850; }
.primary { background: var(--forest); color: #fff; }
.secondary { background: #edf0ed; color: var(--ink); }
.compact { min-height: 36px; padding: 7px 10px; font-size: 12px; }
.full { width: 100%; }
.back-link { margin-top: auto; color: var(--forest); text-decoration: none; font-weight: 800; }
.workspace { min-width: 0; padding: 30px; }
.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.workspace-heading h2 { margin: 5px 0 0; font-size: 35px; letter-spacing: -.04em; }
.metrics { margin: 22px 0 14px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.metric { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.metric span, .metric strong { display: block; }
.metric span { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.metric strong { margin-top: 7px; font-size: 21px; }
.metric.accent { border-color: var(--ink); background: var(--ink); color: #fff; }
.metric.accent span { color: #cbd4cd; }
.attention { display: flex; gap: 8px; overflow: auto; margin-bottom: 18px; }
.attention-pill { flex: 0 0 auto; padding: 8px 11px; border-radius: 999px; background: #fff1d8; color: #775317; font-size: 12px; font-weight: 800; }
.view-panel { display: none; }
.view-panel.active { display: block; }
.panel-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-tools input { max-width: 380px; }
.panel-tools label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.inventory-grid, .recipe-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.inventory-card, .recipe-card, .batch-card, .procurement-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 9px 30px #26372c0b; }
.card-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.card-head h3 { overflow: hidden; margin: 2px 0; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.card-head small { color: var(--muted); }
.chip { flex: 0 0 auto; padding: 4px 8px; border-radius: 999px; background: var(--mint); color: var(--forest); font-size: 10px; font-weight: 900; }
.chip.low, .chip.in_progress { background: #fff0cc; color: #75540c; }
.chip.cancelled { background: #fbe4df; color: #9e3b29; }
.chip.completed, .chip.received { background: var(--mint); color: var(--forest); }
.chip.planned, .chip.submitted { background: var(--blue); color: #215d79; }
.stock-number { margin: 19px 0; }
.stock-number strong { display: block; font-size: 28px; }
.stock-number span { color: var(--muted); font-size: 12px; }
.stock-track { height: 6px; overflow: hidden; border-radius: 99px; background: #e9ede9; }
.stock-track i { display: block; width: var(--stock-level, 50%); height: 100%; background: var(--forest); }
.inventory-card.low .stock-track i { background: var(--coral); }
.detail-list { display: grid; gap: 7px; margin: 14px 0; }
.detail-list div { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.detail-list b { color: var(--ink); }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.card-actions .full-row { grid-column: 1 / -1; }
.recipe-cost { margin: 14px 0; padding: 12px; border-radius: 13px; background: #f2f5ef; }
.recipe-cost strong { display: block; font-size: 21px; }
.recipe-cost span { color: var(--muted); font-size: 11px; }
.ingredient-list { display: grid; gap: 6px; margin: 14px 0; }
.ingredient-list div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; font-size: 12px; }
.ingredient-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ingredient-list small { color: var(--muted); }
.batch-board { display: grid; grid-template-columns: repeat(3, minmax(240px, 1fr)); gap: 13px; }
.batch-column { min-width: 0; }
.batch-column > header { display: flex; justify-content: space-between; padding: 0 4px 9px; }
.batch-column > header span { color: var(--muted); font-size: 12px; }
.batch-stack { display: grid; gap: 10px; }
.batch-card h3 { margin: 4px 0 0; }
.batch-progress { margin: 13px 0; padding: 10px; border-radius: 12px; background: #f2f4f0; color: var(--muted); font-size: 12px; }
.lot-box { margin-top: 12px; padding: 11px; border: 1px dashed #afcbb9; border-radius: 12px; background: #f2faf5; font-size: 12px; }
.procurement-list { display: grid; gap: 10px; }
.procurement-card { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 18px; align-items: center; }
.procurement-card h3 { margin: 0 0 3px; }
.procurement-card p { margin: 0; color: var(--muted); font-size: 12px; }
.procurement-value { text-align: right; }
.procurement-value strong, .procurement-value span { display: block; }
.procurement-value span { color: var(--muted); font-size: 11px; }
.procurement-actions { display: flex; gap: 7px; align-items: center; }
.procurement-actions a { display: grid; place-items: center; text-decoration: none; white-space: nowrap; }
.empty { grid-column: 1 / -1; padding: 50px 20px; border: 1px dashed #b9c6bd; border-radius: 18px; color: var(--muted); text-align: center; }
.mobile-nav { display: none; }
dialog { width: min(600px, calc(100% - 22px)); max-height: 92vh; padding: 0; border: 0; border-radius: 22px; box-shadow: var(--shadow); }
dialog::backdrop { background: #14201988; backdrop-filter: blur(3px); }
.wide-dialog { width: min(860px, calc(100% - 22px)); }
.dialog-form { max-height: 92vh; overflow: auto; padding: 23px; }
.dialog-form header, .builder-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-form h2 { margin: 4px 0; }
.close { min-width: 44px; min-height: 44px; border: 0; background: transparent; font-size: 28px; }
.dialog-form label { margin: 12px 0; }
.dialog-form textarea { resize: vertical; }
.two-cols, .three-cols { display: grid; gap: 10px; }
.two-cols { grid-template-columns: 1fr 1fr; }
.three-cols { grid-template-columns: repeat(3, 1fr); }
.ingredient-builder { margin: 16px 0; padding: 13px; border: 1px solid var(--line); border-radius: 15px; }
#ingredientRows { display: grid; gap: 8px; margin-top: 10px; }
.ingredient-row { display: grid; grid-template-columns: minmax(0, 1.5fr) 1fr .8fr 40px; gap: 7px; align-items: end; }
.ingredient-row label { margin: 0; }
.remove-ingredient { min-width: 40px; min-height: 44px; border: 0; border-radius: 10px; background: #fbe4df; color: #9e3b29; }
.batch-preview { min-height: 20px; margin: 14px 0; padding: 12px; border-radius: 13px; background: #edf5f0; color: var(--muted); font-size: 12px; }
.form-error { min-height: 18px; color: #a33b29; }
.toast { position: fixed; z-index: 90; left: 50%; bottom: 24px; opacity: 0; transform: translate(-50%, 20px); padding: 11px 17px; border-radius: 12px; background: var(--ink); color: #fff; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.signed-out { min-height: 80vh; display: grid; place-content: center; text-align: center; }
.signed-out a { padding: 12px; border-radius: 12px; background: var(--forest); color: #fff; text-decoration: none; }
@media (max-width: 1150px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .inventory-grid, .recipe-grid { grid-template-columns: 1fr 1fr; }
  .batch-board { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { padding-bottom: 70px; }
  .topbar { height: 62px; padding: 0 14px; grid-template-columns: 1fr auto; }
  .topbar nav { display: none; }
  .production-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 16px; border: 0; }
  .sidebar > div:first-child p, .section-nav, .quick-actions, .back-link { display: none; }
  .sidebar h1 { margin: 3px 0; font-size: 27px; }
  .workspace { padding: 4px 14px 24px; }
  .workspace-heading h2 { font-size: 29px; }
  .contextual-action { max-width: 145px; }
  .metrics { display: flex; overflow: auto; margin-top: 16px; scroll-snap-type: x mandatory; }
  .metric { flex: 0 0 155px; scroll-snap-align: start; }
  .panel-tools { align-items: stretch; flex-direction: column; }
  .panel-tools input { max-width: none; }
  .inventory-grid, .recipe-grid { grid-template-columns: 1fr; }
  .procurement-card { grid-template-columns: 1fr auto; gap: 10px; }
  .procurement-card .chip { justify-self: end; }
  .procurement-value { text-align: left; }
  .procurement-actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .mobile-nav { position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 5px; border-top: 1px solid var(--line); background: #fff; }
  .mobile-nav button, .mobile-nav a { min-height: 54px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); text-decoration: none; font-size: 10px; font-weight: 800; }
  .mobile-nav button.active { color: var(--forest); }
  .mobile-nav span { font-size: 19px; }
  .two-cols, .three-cols { grid-template-columns: 1fr; }
  .ingredient-row { grid-template-columns: 1fr 1fr 40px; }
  .ingredient-row label:first-child { grid-column: 1 / -1; }
  dialog { max-height: calc(100vh - 16px); }
  .dialog-form { max-height: calc(100vh - 16px); }
}
