/* BakeryMargin by The Owner's Advocate — Warm Brioche, Buttercream & Cinnamon */
:root {
  --bg: #FDFBF7;
  --surface: #F7EFE2;
  --surface-2: #EFE3CE;
  --card: #FFFFFF;
  --border: #E6D7C3;
  --border-strong: #CBB89D;
  --ink: #191918;
  --ink-2: #4A433B;
  --ink-muted: #6E655B;
  --oxblood: #9A3412;
  --oxblood-hover: #7C2D12;
  --oxblood-soft: #FEF3C7;
  --forest: #15803D;
  --forest-soft: #E6F4EA;
  --amber: #D97706;
  --amber-soft: #FEF3C7;
  --red: #B91C1C;
  --red-soft: #FEF2F2;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(25, 25, 24, 0.04);
  --shadow: 0 4px 18px rgba(25, 25, 24, 0.05), 0 1px 3px rgba(25, 25, 24, 0.03);
  --shadow-lg: 0 22px 50px rgba(25, 25, 24, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.mono { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -9999px; }
.skip:focus { position: static; display: inline-block; padding: 8px 12px; background: var(--ink); color: #fff; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--oxblood); outline-offset: 2px; border-radius: 6px; }

.wrap { max-width: 1340px; margin: 0 auto; padding: 0 22px; }

h1, h2, h3 { color: var(--ink); margin: 0; letter-spacing: -0.025em; }
h2 { font-size: 17px; font-weight: 700; line-height: 1.25; }
h3 { font-size: 14.5px; font-weight: 700; }
.muted { color: var(--ink-muted); margin: 2px 0 0; }
.small { font-size: 12.5px; }
.sec-desc { margin: 4px 0 12px; }
.micro-hint { margin: 5px 0 0; color: var(--ink-muted); font-size: 11.8px; line-height: 1.4; }

/* Sticky App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}
.brand-group { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--ink);
  box-shadow: var(--shadow-sm);
  flex: none;
}
.brand-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand-group h1 { font-size: 20px; font-weight: 800; line-height: 1.1; }
.toa-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--border);
}
.brand-sub { margin: 2px 0 0; font-size: 12px; color: var(--ink-muted); }

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Help Trigger */
.help-trigger {
  background: var(--card);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  padding: 6px 11px;
  border-radius: 999px;
}
.help-trigger:hover { background: var(--ink); color: #fff; border-color: var(--ink); }
.help-q {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--oxblood-soft);
  color: var(--oxblood);
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.help-trigger:hover .help-q { background: #fff; color: var(--ink); }

/* View Mode Switcher */
.view-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.vs-btn {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}
.vs-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(25, 25, 24, 0.1);
}
.install-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* Main Container */
.app-main { padding-top: 18px; padding-bottom: 44px; }

/* Sample Bar */
.sample-bar {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 9px 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
}
.sample-bar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sample-pill {
  background: var(--ink);
  color: #FAF8F4;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
}

/* Action & Nav Bar */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.action-bar-right { display: flex; align-items: center; gap: 8px; }

.seg-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.seg-tab {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease;
}
.seg-tab:hover { color: var(--ink); }
.seg-tab.active {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 2px 8px rgba(25, 25, 24, 0.18);
}

.cta-add {
  padding: 9px 18px;
  border-radius: 11px;
  box-shadow: 0 4px 12px rgba(124, 45, 18, 0.22);
}

/* Buttons */
.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn.primary { background: var(--oxblood); color: #fff; border-color: var(--oxblood); }
.btn.primary:hover { background: var(--oxblood-hover); border-color: var(--oxblood-hover); }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.dark:hover { background: #33322f; }
.btn.outline { background: var(--card); color: var(--ink); border-color: var(--border-strong); }
.btn.outline:hover { background: var(--surface); }
.btn.outline-dark { background: var(--card); color: var(--ink); border-color: var(--ink); }
.btn.outline-dark:hover { background: var(--ink); color: #fff; }
.btn.ghost-ink { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn.ghost-ink:hover { background: var(--surface); color: var(--ink); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.danger:hover { background: #991b1b; }
.btn.danger-outline { background: var(--card); color: var(--red); border-color: #f0c2c2; }
.btn.danger-outline:hover { background: var(--red-soft); }
.btn.small { font-size: 12px; padding: 6px 11px; border-radius: 9px; }
.btn.tiny { font-size: 11.5px; padding: 5px 10px; border-radius: 8px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.sec-head-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.step-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
}
.step-pill.ox { background: var(--oxblood-soft); color: var(--oxblood); border-color: #f3d2c6; }

/* Blank Slate Card */
.blank-slate-card { margin-bottom: 16px; border-style: dashed; border-color: var(--border-strong); }
.bs-inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.bs-icon { width: 54px; height: 54px; border-radius: 14px; flex: none; }
.bs-copy { flex: 1 1 260px; }
.bs-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.kpi-card.kpi-good { border-color: #c8decb; background: #fafdfb; }
.kpi-head { display: flex; justify-content: space-between; align-items: center; }
.kpi-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); }
.kpi-icon {
  width: 24px; height: 24px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.kpi-ico-ox { background: var(--oxblood-soft); color: var(--oxblood); }
.kpi-ico-ink { background: var(--surface); color: var(--ink); }
.kpi-ico-good { background: var(--forest-soft); color: var(--forest); }
.kpi-val { font-size: 24px; font-weight: 700; color: var(--ink); line-height: 1.15; }
.kpi-card.kpi-good .kpi-val { color: var(--forest); }
.kpi-sub { font-size: 12px; color: var(--ink-muted); }

/* Artisanal Bakery Price Tag / Recipe Ticket */
.breakdown-card { margin-bottom: 16px; padding: 16px 20px; }
.bakery-ticket {
  background: linear-gradient(180deg, #FFFFFF 0%, #FDFBF7 100%);
  border: 1.5px solid var(--border-strong);
  border-top: 4px solid var(--oxblood);
  box-shadow: 0 6px 22px rgba(154, 52, 18, 0.07);
}
.breakdown-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ticket-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.margin-health-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--forest-soft);
  color: var(--forest);
  border: 1px solid #bbf7d0;
}
.margin-health-badge.thin {
  background: var(--red-soft);
  color: var(--red);
  border-color: #fecaca;
}
.margin-health-badge.premium {
  background: var(--amber-soft);
  color: var(--oxblood);
  border-color: #fde68a;
}
.ticket-srp-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.ticket-srp-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ticket-srp-badge.primary-tag {
  background: var(--ink);
  border-color: var(--ink);
  color: #FDFBF7;
}
.tsb-lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); }
.ticket-srp-badge.primary-tag .tsb-lbl { color: #EFE3CE; }
.tsb-val { font-size: 24px; font-weight: 800; line-height: 1.15; color: var(--oxblood); }
.ticket-srp-badge.primary-tag .tsb-val { color: #FDFBF7; }
.ticket-perf {
  border: 0;
  border-top: 1.5px dashed var(--border-strong);
  margin: 12px 0;
}
.margin-bar-track {
  height: 14px;
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  border: 1px solid var(--border);
}
.mb-seg { height: 100%; transition: width 0.25s ease; }
.mb-ing { background: var(--ink); }
.mb-oh { background: var(--oxblood); }
.mb-prof { background: var(--forest); }

.margin-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 10px;
  font-size: 12.2px;
  color: var(--ink-2);
}
.mbl-item { display: inline-flex; align-items: center; gap: 6px; }
.mbl-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.mbl-item strong { color: var(--ink); font-size: 12.2px; }

/* TOA Advisory Banner */
.toa-moment-banner {
  background: var(--oxblood-soft);
  border: 1px solid #ecc6b8;
  border-left: 4px solid var(--oxblood);
  border-radius: 12px;
  padding: 11px 14px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.tmb-content { display: flex; align-items: center; gap: 10px; flex: 1 1 320px; flex-wrap: wrap; }
.tmb-content p { margin: 0; font-size: 12.8px; color: var(--ink); }
.tmb-tag {
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--oxblood); color: #fff; padding: 2px 7px; border-radius: 999px; flex: none;
}
.tmb-actions { display: flex; align-items: center; gap: 8px; }
.tmb-dismiss {
  background: transparent; border: 0; font-size: 18px; color: var(--ink-muted);
  cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.tmb-dismiss:hover { background: rgba(25,25,24,0.08); color: var(--ink); }

/* Two-Column Workspace (Laptop) */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.95fr);
  gap: 16px;
  align-items: start;
}
.col-left { display: grid; gap: 14px; min-width: 0; }
.col-right { min-width: 0; }
.sticky { position: sticky; top: 76px; }

/* Forms & Inputs */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.grow { flex: 1 1 170px; }
label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
input[type="text"], input[type="number"], select {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 9px;
  width: 100%;
  min-height: 34px;
}
input:focus, select:focus { border-color: var(--oxblood); outline: none; box-shadow: 0 0 0 3px rgba(124, 45, 18, 0.12); }

.peso-in { display: flex; align-items: stretch; }
.peso-in span {
  display: flex; align-items: center; padding: 0 9px;
  background: var(--surface); border: 1px solid var(--border-strong); border-right: 0;
  border-radius: 8px 0 0 8px; color: var(--ink-2); font-weight: 700; font-size: 12.5px;
}
.peso-in input { border-radius: 0 8px 8px 0; }

.pct-in { display: flex; align-items: stretch; width: 88px; flex: none; }
.pct-in input { border-radius: 8px 0 0 8px; text-align: right; font-family: 'JetBrains Mono', monospace; font-weight: 700; }
.pct-in span {
  display: flex; align-items: center; padding: 0 8px;
  background: var(--surface); border: 1px solid var(--border-strong); border-left: 0;
  border-radius: 0 8px 8px 0; color: var(--ink-2); font-weight: 700; font-size: 12px;
}

/* Recipe Bar & Pantry Ingredient Picker */
.recipe-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 12px;
  padding: 11px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.pantry-picker-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
}
.pantry-picker-bar .pp-qty { width: 84px; flex: 0 0 84px; }
.pantry-picker-bar .pp-unit { width: 78px; flex: 0 0 78px; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--card);
}
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  position: sticky; top: 0; z-index: 2;
  text-align: left;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 7px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.grid td { padding: 5px 6px; border-bottom: 1px solid var(--surface); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid .num { text-align: right; white-space: nowrap; }
td.num { font-family: 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12.5px; }
table.grid td input, table.grid td select { min-height: 30px; padding: 4px 6px; font-size: 12.5px; }
.empty-row td { text-align: center; color: var(--ink-muted); padding: 18px; }

.x-btn {
  font: inherit; font-size: 16px; line-height: 1;
  width: 28px; height: 28px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--card); color: var(--ink-muted); cursor: pointer;
}
.x-btn:hover { color: var(--red); border-color: #f0c2c2; background: var(--red-soft); }

.use-btn {
  font: inherit; font-size: 11.5px; font-weight: 700;
  padding: 4px 8px; border-radius: 7px;
  border: 1px solid var(--oxblood); background: var(--oxblood-soft); color: var(--oxblood); cursor: pointer;
  white-space: nowrap;
}
.use-btn:hover { background: var(--oxblood); color: #fff; }
.pp-hint { color: var(--ink-muted); font-weight: 400; font-size: 11px; font-family: 'Plus Jakarta Sans', sans-serif; }
.rate-pill {
  display: inline-block; font-size: 11.2px; color: var(--ink-2); background: var(--surface);
  border-radius: 6px; padding: 2px 7px; font-weight: 500;
}

/* Waste & Overhead */
.sub-split {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.other-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 6px; }

/* Cost Strip */
.cost-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.cs-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cs-item span { font-size: 11px; color: var(--ink-muted); font-weight: 600; }
.cs-item strong { font-size: 14px; color: var(--ink); }
.cs-item.grand { background: var(--surface); border-color: var(--ink); }
.cs-item.grand strong { font-size: 15px; }

/* Right Column: Selling Price & Margin */
.price-subtitle { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--ink-muted); }
.main-result {
  padding: 14px 16px;
  text-align: center;
  background: var(--ink);
  color: #FAF8F4;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.r-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: #d6cfc2; font-weight: 700; }
.r-big { font-size: 36px; font-weight: 700; line-height: 1.1; color: #FAF8F4; }
.r-note { font-size: 11.5px; color: #cbc4b6; min-height: 15px; }

.slice-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  margin: 10px 0;
}
.sb-lbl { display: block; font-size: 11.5px; color: var(--ink-muted); font-weight: 600; }
.sb-val { font-size: 18px; color: var(--oxblood); font-weight: 700; }
.sb-val-sm { font-size: 14px; color: var(--ink); font-weight: 700; }

.margin-panel {
  margin: 10px 0 12px;
  padding: 11px 12px;
  background: var(--oxblood-soft);
  border: 1px solid #ecc6b8;
  border-radius: 11px;
}
.margin-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.margin-panel input[type="range"] { width: 100%; accent-color: var(--oxblood); cursor: pointer; }

dl { margin: 0; }
.results-list > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--surface);
  font-size: 12.8px;
}
.results-list dt { color: var(--ink-2); }
.results-list dd { margin: 0; font-weight: 700; color: var(--ink); }
.results-list .hl-profit dd { color: var(--forest); }

.opts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

.delta-box {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.delta-box h3 { font-size: 13.5px; margin-bottom: 4px; }
.r-empty { margin: 0; color: var(--ink-muted); font-size: 12px; }
.ro-label { margin: 0 0 6px; font-weight: 700; font-size: 12.2px; color: var(--ink); }
.ro-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 130px; overflow-y: auto; }
.ro-list li { font-size: 11.8px; padding: 6px 8px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.ro-list li.cur { border-color: var(--oxblood); background: var(--oxblood-soft); }
.up { color: var(--red); font-weight: 700; }
.down { color: var(--forest); font-weight: 700; }

/* Menu Summary Grid */
.menu-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.menu-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.menu-card.active { border-color: var(--oxblood); background: var(--card); box-shadow: var(--shadow-sm); }
.mc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mc-name { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.mc-margin {
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--forest-soft); color: var(--forest);
}
.mc-margin.thin { background: var(--oxblood-soft); color: var(--oxblood); }
.mc-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12px; }
.mc-nums div { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.mc-nums span { display: block; color: var(--ink-muted); font-size: 10.5px; }
.mc-nums strong { font-size: 13.5px; color: var(--ink); }
.mc-actions { display: flex; gap: 6px; margin-top: 2px; }

/* Flash */
@keyframes flash { from { background: var(--amber-soft); } to { background: transparent; } }
.flash { animation: flash 0.9s ease-out; border-radius: 4px; }
@keyframes flashDark { from { color: #f6c4a8; } to { color: #FAF8F4; } }
.main-result .r-big.flash { animation: flashDark 0.9s ease-out; }

/* TOA Footer Card */
.toa-footer-card {
  margin-top: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.toa-fc-left { display: flex; align-items: center; gap: 12px; flex: 1 1 300px; }
.toa-fc-logo { width: auto; max-width: 96px; height: 36px; border-radius: 8px; object-fit: contain; background: #FFFFFF; padding: 3px 6px; border: 1px solid var(--border); flex: none; }
.toa-fc-left strong { display: block; font-size: 13px; color: var(--ink); }
.toa-fc-left p { margin: 2px 0 0; font-size: 12px; color: var(--ink-muted); }

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: center;
}
.mb-item {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 10px;
}
.mb-item.active { color: var(--oxblood); }
.mb-add-circle {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--oxblood); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(124, 45, 18, 0.28);
  margin-top: -12px;
}

/* Dialogs & Bottom-Sheet Modals */
dialog.dlg {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0;
  max-width: 480px;
  width: calc(100% - 24px);
  box-shadow: var(--shadow-lg);
  background: var(--card);
  color: var(--ink);
}
dialog.dlg::backdrop { background: rgba(25, 25, 24, 0.5); backdrop-filter: blur(3px); }
.dlg-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg);
}
.dlg-head .num { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--oxblood); }
.dlg-head h3 { font-size: 17px; margin-top: 2px; }
.dlg-close {
  background: var(--card); border: 1px solid var(--border-strong); color: var(--ink);
  border-radius: 8px; width: 30px; height: 30px; font-size: 18px; cursor: pointer;
}
.dlg-body { padding: 16px 18px; }
.dlg-pad { padding: 18px 20px; }
.dlg-title { font-size: 17px; margin-bottom: 6px; }
.dlg-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg); }
.dlg-end-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.install-steps { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: 13px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: #FAF8F4;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 90;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Interactive Spotlight Help Overlay */
.help-overlay { position: fixed; inset: 0; z-index: 100; }
.help-svg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.help-labels { position: fixed; inset: 0; pointer-events: none; }
.help-callout {
  position: fixed;
  background: var(--card);
  border: 1.5px solid var(--oxblood);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}
.hc-num {
  display: inline-flex; width: 20px; height: 20px; border-radius: 999px;
  background: var(--oxblood); color: #fff; font-size: 11px; font-weight: 800;
  align-items: center; justify-content: center; margin-right: 6px;
}
.hc-title { font-weight: 800; font-size: 13px; color: var(--ink); }
.hc-desc { margin: 4px 0 0; font-size: 12px; color: var(--ink-2); }
.help-step-dock {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px));
  background: var(--card);
  border: 1.5px solid var(--ink);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  z-index: 102;
}
.help-step-dock.dock-top { bottom: auto; top: 18px; }

/* Price Cascade Alert & Notification Dot */
.notif-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--oxblood);
  box-shadow: 0 0 0 3px rgba(154, 52, 18, 0.22);
  flex: none;
}
.notif-dot.inline-dot { margin-left: 5px; vertical-align: middle; }
.price-alert-banner {
  background: #FFFBEB;
  border: 1.5px solid var(--amber);
  border-left: 4px solid var(--oxblood);
  border-radius: 11px;
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.4px;
  color: var(--ink);
}
.pab-left { display: flex; align-items: center; gap: 7px; flex: 1 1 240px; flex-wrap: wrap; }
.pab-pill {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--oxblood);
  color: #fff;
  padding: 2px 7px;
  border-radius: 999px;
  flex: none;
}
.margin-equiv-pill {
  display: inline-block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--forest);
  background: var(--forest-soft);
  padding: 2px 7px;
  border-radius: 999px;
}
.mc-alert-box {
  background: #FFFBEB;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 11.5px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mc-alert-head { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--oxblood); }
.hsd-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.help-badge { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; background: var(--oxblood-soft); color: var(--oxblood); padding: 3px 9px; border-radius: 999px; }
.hsd-mode-btns { display: flex; align-items: center; gap: 8px; }
.hsd-link { background: transparent; border: 0; font: inherit; font-size: 11.5px; font-weight: 700; color: var(--ink-2); text-decoration: underline; cursor: pointer; }
.hsd-x { background: var(--surface); border: 0; width: 26px; height: 26px; border-radius: 999px; font-size: 16px; cursor: pointer; color: var(--ink); }
.hsd-title { font-size: 15.5px; margin: 0 0 4px; }
.hsd-desc { margin: 0 0 12px; font-size: 12.8px; color: var(--ink-2); }
.hsd-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hsd-btn { font: inherit; font-size: 12.5px; font-weight: 700; padding: 7px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--card); color: var(--ink); cursor: pointer; }
.hsd-btn.primary { background: var(--oxblood); border-color: var(--oxblood); color: #fff; }
.hsd-dots { display: flex; gap: 5px; }
.hsd-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--border-strong); }
.hsd-dot.active { background: var(--oxblood); width: 18px; }

/* Strict 430px Mobile Frame Mode */
html[data-view="mobile"] body { background: #EAE5DC; }
html[data-view="mobile"] .app-header,
html[data-view="mobile"] .app-main,
html[data-view="mobile"] .mobile-bottom-nav {
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
}
html[data-view="mobile"] .app-main {
  background: var(--bg);
  min-height: calc(100vh - 64px);
  padding: 14px 14px 92px;
  box-shadow: 0 0 30px rgba(25, 25, 24, 0.08);
}
html[data-view="mobile"] .wrap { padding: 0 12px; }
html[data-view="mobile"] .brand-sub,
html[data-view="mobile"] .install-group,
html[data-view="mobile"] .seg-tabs,
html[data-view="mobile"] #btnNewRecipeTop { display: none; }
html[data-view="mobile"] .mobile-bottom-nav { display: flex; }
html[data-view="mobile"] .kpi-strip { grid-template-columns: 1fr; gap: 10px; }
html[data-view="mobile"] .workspace-grid { grid-template-columns: 1fr; }
html[data-view="mobile"] .sticky { position: static; }
html[data-view="mobile"] .sub-split { grid-template-columns: 1fr; }
html[data-view="mobile"] .cost-strip { grid-template-columns: 1fr 1fr; }
html[data-view="mobile"] .other-grid { grid-template-columns: 1fr; }
html[data-view="mobile"] .toast { bottom: 80px; }

/* Bottom-Sheet Modals on Mobile */
html[data-view="mobile"] dialog.dlg {
  margin: auto auto 0;
  width: 100%;
  max-width: 430px;
  border-radius: 20px 20px 0 0;
  max-height: 88vh;
  overflow-y: auto;
}

@media (max-width: 1020px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .sub-split { grid-template-columns: 1fr; }
  .cost-strip { grid-template-columns: repeat(2, 1fr); }
}

/* Menu Board First View, Clickable Cards, Dual-Action Price Alert, Costing Guide */
.tab-notif-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--oxblood);
  color: #FFFFFF;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}
.seg-tab.active .tab-notif-pill {
  background: #C5A059;
  color: #002040;
}
.menu-summary-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 16px;
}
.menu-card {
  background: #FFFFFF;
  border: 1px solid #DDD7CC;
  border-top: 3px solid #9A3412;
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease;
}
.menu-card:hover {
  border-color: #002040;
  transform: translateY(-1px);
}
.menu-card.has-alert {
  border-top-color: #B45309;
  background: #FFFCF5;
}
.menu-card .mc-name {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
  color: #002040;
}
.mc-hero-srp {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #FAF8F4;
  border: 1px solid #DDD7CC;
}
.mc-hero-srp .mc-srp-lbl {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #57534E;
}
.mc-hero-srp .mc-srp-val {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  color: #002040;
  font-variant-numeric: tabular-nums;
}
.mc-sub-srp {
  font-size: 12px;
  color: #57534E;
}
.mc-hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #ECE7DC;
}
.mc-tap-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: #7A5C26;
  font-weight: 600;
}
.retained-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #F59E0B;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
}
.editor-back-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: #F3EFE6;
  border: 1px solid #DDD7CC;
  border-radius: 10px;
}
.editor-back-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.editor-active-name {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 20px;
  font-weight: 600;
  color: #002040;
}
.pab-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 16px;
  margin-top: 14px;
}
.guide-card {
  background: #FAF8F4;
  border: 1px solid #DDD7CC;
  border-radius: 12px;
  padding: 18px;
}
.guide-card h3 {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 20px;
  color: #002040;
  margin: 4px 0 8px;
}
.guide-card p, .guide-card li {
  font-size: 14px;
  line-height: 1.55;
  color: #374151;
}
.guide-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.guide-formula {
  margin: 10px 0;
  padding: 10px 12px;
  background: #FFFFFF;
  border: 1px solid #DDD7CC;
  border-left: 3px solid #C5A059;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: #002040;
}
.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}
.guide-table th, .guide-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #DDD7CC;
}
.guide-table th {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #57534E;
  background: #F3EFE6;
}
/* Help Tour Dock: Navy + Gold polish */
.help-badge {
  background: #F3EFE6 !important;
  color: #002040 !important;
  border: 1px solid #C5A059;
}
.hsd-btn.primary {
  background: #002040 !important;
  border-color: #002040 !important;
  color: #FFFFFF !important;
}
.hsd-dot.active {
  background: #002040 !important;
}

/* Mobile-First Responsive Stacking: Zero horizontal overflow on 360px-430px and Mobile toggle */
html[data-view="mobile"] .wrap {
  padding-left: 14px;
  padding-right: 14px;
}
html[data-view="mobile"] .card {
  padding: 14px;
}
html[data-view="mobile"] .btn-row,
html[data-view="mobile"] .sec-head-row,
html[data-view="mobile"] .pab-actions {
  flex-wrap: wrap;
}
html[data-view="mobile"] .btn {
  white-space: normal;
  text-align: center;
}
html[data-view="mobile"] .mc-hero-srp {
  flex-wrap: wrap;
}
html[data-view="mobile"] .mc-hint-row {
  flex-wrap: wrap;
}
html[data-view="mobile"] .guide-table {
  display: block;
  overflow-x: auto;
}
html[data-view="mobile"] .table-wrap {
  overflow-x: visible;
  border: 0;
  background: transparent;
}
html[data-view="mobile"] table.grid.mats,
html[data-view="mobile"] table.grid.lines {
  display: block;
  width: 100%;
  min-width: 0 !important;
}
html[data-view="mobile"] table.grid.mats thead,
html[data-view="mobile"] table.grid.lines thead {
  display: none;
}
html[data-view="mobile"] table.grid.mats tbody,
html[data-view="mobile"] table.grid.lines tbody {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
html[data-view="mobile"] table.grid.mats tbody tr,
html[data-view="mobile"] table.grid.lines tbody tr {
  display: grid;
  grid-template-columns: 1fr 78px 1fr;
  gap: 8px;
  padding: 12px;
  background: #FAF8F4;
  border: 1px solid #DDD7CC;
  border-radius: 10px;
  position: relative;
}
html[data-view="mobile"] table.grid.mats tbody tr.empty-row,
html[data-view="mobile"] table.grid.lines tbody tr.empty-row {
  display: block;
}
html[data-view="mobile"] table.grid.mats tbody td,
html[data-view="mobile"] table.grid.lines tbody td {
  display: block;
  padding: 0;
  border: 0;
  min-width: 0;
}
html[data-view="mobile"] table.grid.mats tbody td:nth-child(1),
html[data-view="mobile"] table.grid.lines tbody td:nth-child(1) {
  grid-column: 1 / -1;
  padding-right: 36px;
}
html[data-view="mobile"] table.grid.mats tbody td:nth-child(5),
html[data-view="mobile"] table.grid.lines tbody td:nth-child(5),
html[data-view="mobile"] table.grid.lines tbody td:nth-child(6) {
  grid-column: span 1;
  text-align: left;
  font-size: 12px;
  color: #57534E;
}
html[data-view="mobile"] table.grid.mats tbody td:nth-child(5) {
  grid-column: 1 / -1;
  padding-top: 4px;
  border-top: 1px dashed #DDD7CC;
}
html[data-view="mobile"] table.grid.mats tbody td:nth-child(6),
html[data-view="mobile"] table.grid.lines tbody td:nth-child(7) {
  position: absolute;
  top: 10px;
  right: 10px;
}
html[data-view="mobile"] table.grid.mats input,
html[data-view="mobile"] table.grid.mats select,
html[data-view="mobile"] table.grid.lines input,
html[data-view="mobile"] table.grid.lines select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
html[data-view="mobile"] .pantry-picker-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
html[data-view="mobile"] .pantry-picker-bar .field.grow,
html[data-view="mobile"] .pantry-picker-bar .btn-row {
  grid-column: 1 / -1;
}
html[data-view="mobile"] .recipe-bar,
html[data-view="mobile"] .opts-grid,
html[data-view="mobile"] .other-grid,
html[data-view="mobile"] .ticket-srp-row {
  grid-template-columns: 1fr;
}
html[data-view="mobile"] .help-step-dock {
  width: min(360px, calc(100vw - 24px));
}
@media print { .no-print { display: none !important; } }
