/* ============================================================
   The Candle Lab — styling
   Inspired by the Makers Manager / Candle Lab aesthetic:
   cream background, dark olive accents, serif headings, cards.
============================================================ */

:root {
  --bg: #ecebe4;
  --bg-2: #e7e6df;
  --surface: #fdfcf8;
  --surface-2: #f5f4ef;
  --line: #d8d6cc;
  --line-soft: #e8e6dd;
  --text: #1a1a18;
  --text-muted: #6e6c63;
  --text-subtle: #908d83;
  --accent: #3b4a2c;       /* dark olive — used for tab pills, primary buttons */
  --accent-soft: #4d5e3a;
  --accent-tint: #e8ebde;
  --warm: #d97644;         /* the orange in the Makers Manager logo */
  --warm-soft: #f5e8de;
  --danger: #a13a2a;
  --shadow: 0 1px 2px rgba(20, 22, 14, 0.04), 0 6px 18px rgba(20, 22, 14, 0.04);
  --shadow-pop: 0 6px 22px rgba(20, 22, 14, 0.10);
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif; font-weight: 600; letter-spacing: -0.005em; }
.kicker { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-subtle); }
.muted { color: var(--text-muted); font-size: 13px; }
.hint  { color: var(--text-subtle); font-size: 12px; margin-top: 4px; }
.hidden { display: none !important; }

/* ---------- Login screen ---------- */
.login-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 36px 36px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-pop);
  text-align: center;
}
.login-mark { margin-bottom: 12px; }
.login-card h1 { font-size: 32px; margin: 6px 0 8px; }
.login-card p  { margin: 0 auto 22px; max-width: 320px; }
.login-card .lbl { text-align: left; }
.login-message {
  margin-top: 14px;
  font-size: 13px;
  min-height: 18px;
}
.login-message.success { color: var(--accent); }
.login-message.error   { color: var(--danger); }

/* ---------- Cloud sync indicator ---------- */
.sync-indicator {
  font-size: 18px;
  line-height: 1;
  padding: 4px 8px;
  color: var(--accent);
  cursor: default;
  user-select: none;
  transition: color 0.18s;
}
.sync-indicator.syncing { color: var(--warm); }
.sync-indicator.error   { color: var(--danger); }
.sync-indicator.offline { color: var(--text-subtle); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 6px; flex-shrink: 0; }
.primary-nav {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.primary-nav button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
}
.primary-nav button:hover { color: var(--text); }
.primary-nav button.active {
  background: var(--accent);
  color: #fafaf3;
}
.brand-mark {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 14px;
  color: var(--warm);
}
.brand-mark--muted { color: var(--text); opacity: 0.85; }
.topbar-meta { display: flex; align-items: center; gap: 16px; }
.units-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.units-toggle button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
}
.units-toggle button.active {
  background: var(--accent);
  color: #fafaf3;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 57px);
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--line-soft);
  padding: 18px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 57px;
  height: calc(100vh - 57px);
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.sidebar-head h2 { margin: 0; font-size: 22px; }
.sidebar-search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
}
.recipe-list { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.recipe-list li {
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid transparent;
  margin-bottom: 4px;
}
.recipe-list li:hover { background: var(--surface-2); }
.recipe-list li.active {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}
.recipe-list .ri-name { font-weight: 600; font-size: 13px; }
.recipe-list .ri-meta { font-size: 11px; color: var(--text-subtle); }
.sidebar-foot { padding-top: 8px; border-top: 1px solid var(--line-soft); display: flex; gap: 6px; }
.sidebar-foot .btn { flex: 1; }

/* ---------- Main ---------- */
.main { padding: 32px 40px 80px; max-width: 1100px; }

/* ---------- Empty state ---------- */
.empty { display: flex; align-items: center; justify-content: center; min-height: 70vh; }
.empty-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 48px 56px;
  max-width: 640px;
  text-align: center;
  box-shadow: var(--shadow);
}
.empty-icon { font-size: 32px; margin-bottom: 12px; }
.empty .xl { font-size: 44px; margin: 8px 0 14px; line-height: 1.05; }
.lede { color: var(--text-muted); font-size: 15px; max-width: 440px; margin: 0 auto 24px; }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 32px; text-align: left; }
.how-step {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.how-step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.how-step-title { font-weight: 600; font-size: 13px; }
.how-step-text  { font-size: 12px; color: var(--text-muted); }

/* ---------- Recipe header ---------- */
.recipe-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}
.recipe-header h1 {
  font-size: 38px;
  margin: 6px 0 4px;
  outline: none;
  border-radius: 4px;
  padding: 0 2px;
}
.recipe-header h1:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent-tint); }
.recipe-meta { font-size: 12px; color: var(--text-subtle); }
.recipe-actions { display: flex; gap: 8px; align-items: center; }

/* Locked recipe: subtle visual cue that the formulation is read-only. */
.recipe-view.locked .recipe-header h1 {
  background: var(--surface-2);
  cursor: default;
}
.recipe-view.locked input[readonly],
.recipe-view.locked textarea[readonly],
.recipe-view.locked select:disabled {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
  border-color: var(--line-soft);
}
.recipe-view.locked .pill { opacity: 0.55; cursor: not-allowed; }
.recipe-view.locked .pill.active { opacity: 1; }
.recipe-view.locked .ing-section-add,
.recipe-view.locked .row-x,
.recipe-view.locked #recipeSaveBtn,
.recipe-view.locked #addIngredientBtn,
.recipe-view.locked #applyScaleBtn,
.recipe-view.locked #deleteBtn { display: none; }
.recipe-view.locked .ing-pick-supply { display: none; }
/* Scale preview stays visible when locked — the scaler is preview-only
   and doesn't mutate the recipe. */
#lockBtn.locked {
  background: var(--accent-tint);
  color: var(--accent);
  border-color: var(--accent-soft);
}

/* Lock icon inside sidebar list items. */
.recipe-list .ri-lock {
  font-size: 11px;
  color: var(--accent);
  margin-left: 4px;
}

/* Pulsing orange dot that appears next to the Save button when there
   are unsaved changes — fades away once the user clicks Save. */
.dirty-dot {
  display: inline-block;
  color: var(--warm);
  font-size: 14px;
  line-height: 1;
  animation: dirty-pulse 1.6s ease-in-out infinite;
}
@keyframes dirty-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ---------- Tabs ---------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 6px;
  gap: 4px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.tab {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  color: var(--text-muted);
  font-family: inherit;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active {
  background: var(--accent);
  color: #fafaf3;
  box-shadow: 0 1px 3px rgba(20, 22, 14, 0.18);
}
.tab.active .tab-sub { color: rgba(250, 250, 243, 0.75); }
.tab-icon { font-size: 18px; }
.tab-title { display: block; font-weight: 600; font-size: 13px; }
.tab-sub { display: block; font-size: 11px; color: var(--text-subtle); margin-top: 1px; }

/* ---------- Panels & cards ---------- */
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 14px;
}
.panel-head h2 { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: 24px; margin: 0 0 2px; }
.panel-head p { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  margin-bottom: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-section {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.card-section:last-child { border-bottom: 0; }
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.flex-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

/* ---------- Forms ---------- */
.lbl {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.lbl-unit { color: var(--text-subtle); font-weight: 400; }
input[type=text],
input[type=number],
input[type=search],
input[type=date],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { resize: vertical; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; padding: 16px 20px; align-items: end; }

/* ---------- Pills ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0 4px; }
.pill {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.pill:hover { background: var(--surface); color: var(--text); }
.pill.active {
  background: var(--accent);
  color: #fafaf3;
  border-color: var(--accent);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: var(--text); color: #fafaf3; }
.btn-primary:hover { background: #2c2c28; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn-danger:hover { background: #fbeae5; border-color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.ing-table,
table.cogs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.ing-table thead th,
.cogs-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.ing-table td, .cogs-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.ing-table tr:last-child td, .cogs-table tr:last-child td { border-bottom: 0; }
.ing-table input, .ing-table select { padding: 6px 8px; font-size: 12px; }
.ing-table .row-x {
  background: transparent;
  border: 0;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 16px;
}
.ing-table .row-x:hover { background: #f5e0de; color: var(--danger); }

.cogs-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- COGS totals ---------- */
.cogs-totals { padding: 14px 20px; }
.cogs-sub { color: var(--text-subtle); font-size: 11px; font-weight: 400; letter-spacing: 0.04em; }
.cogs-line {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.cogs-total {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.inline-num {
  width: 90px;
  padding: 4px 8px;
  font-size: 12px;
  text-align: right;
}

.margin-cards { padding: 0 20px 20px; }
.margin-card {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 14px 16px;
}
.margin-row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.margin-row.strong {
  color: var(--text);
  font-weight: 600;
  border-top: 1px dashed var(--line);
  margin-top: 6px;
  padding-top: 8px;
}

/* ---------- Scaler preview ---------- */
.scale-preview {
  margin: 0 20px 20px;
  background: var(--accent-tint);
  border: 1px dashed var(--accent-soft);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  display: none;
}
.scale-preview.show { display: block; }
.scale-preview .sp-row { display: flex; justify-content: space-between; padding: 2px 0; gap: 12px; }
.scale-preview .sp-section { padding: 4px 0; }
.scale-preview .sp-section + .sp-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--accent-soft);
}
.scale-preview .sp-title {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.scale-preview .sp-sub {
  font-size: 11px;
  color: var(--text-subtle);
  margin-bottom: 6px;
}
.scale-preview .sp-batch { color: var(--text-subtle); font-weight: 400; }
.scale-preview .sp-total {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--accent-soft);
}
.scale-preview .sp-ok   { color: var(--accent); margin-left: 4px; }
.scale-preview .sp-warn { color: var(--warm); margin-left: 4px; font-weight: 500; }

/* ---------- Formulation COGS card ---------- */
.formulation-cogs { padding: 10px 20px 18px; }
.cogs-empty {
  text-align: center;
  color: var(--text-subtle);
  font-size: 13px;
  padding: 14px 6px 6px;
}
.cogs-cat-section + .cogs-cat-section { margin-top: 12px; }
.cogs-cat-title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--accent-tint);
}
.cogs-line {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr auto;
  gap: 10px;
  align-items: baseline;
  padding: 5px 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.cogs-line .cogs-name { color: var(--text); font-weight: 500; }
.cogs-line .cogs-rate { color: var(--text-subtle); font-size: 12px; }
.cogs-line .cogs-cost { text-align: right; font-weight: 600; color: var(--text); white-space: nowrap; }
.cogs-line.muted-line .cogs-cost { color: var(--text-subtle); font-style: italic; font-weight: 400; }
.cogs-cat-subtotal {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  font-size: 12px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  padding-top: 4px;
}
.cogs-totals-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cogs-grand {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.cogs-grand.major {
  font-size: 18px;
  font-weight: 600;
  font-family: 'Cormorant Garamond', serif;
  letter-spacing: -0.005em;
}
.cogs-grand .cogs-grand-label { color: var(--text-muted); }
.cogs-grand.major .cogs-grand-label { color: var(--text); }
.cogs-grand-sub {
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.06em;
}

/* ---------- Save indicator ---------- */
.save-indicator {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 4px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  align-self: center;
}
.save-indicator.saving { color: var(--warm); border-color: var(--warm-soft); background: var(--warm-soft); }
.save-indicator.saved  { color: var(--accent); border-color: var(--accent-tint); background: var(--accent-tint); }

/* ---------- Journal sessions ---------- */
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.summary-card .kicker { display: block; margin-bottom: 4px; }
.summary-card .num {
  font-size: 22px;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sessions { display: flex; flex-direction: column; gap: 12px; }
.session-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.session-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.session-head h4 { margin: 0; font-size: 15px; }
.session-head .session-date { font-size: 12px; color: var(--text-subtle); }
.session-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 8px 0;
  font-size: 12px;
}
.session-grid .stat { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.session-grid .stat-label { color: var(--text-subtle); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; }
.session-grid .stat-val { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.session-flags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.flag-chip {
  font-size: 11px;
  background: #fbeae5;
  color: var(--danger);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #f3d5cf;
}
.session-notes {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}
.session-actions { display: flex; gap: 6px; }
.empty-sessions {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-subtle);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}
.star-row { display: inline-block; color: var(--warm); letter-spacing: 1px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(20, 22, 14, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-pop);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: transparent; border: 0; font-size: 22px; cursor: pointer; color: var(--text-muted);
  width: 28px; height: 28px; line-height: 1; border-radius: 6px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 8px 0 16px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line-soft);
}
.flag-row { display: flex; flex-wrap: wrap; gap: 10px; padding: 8px 0; }
.flag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}
.flag input { accent-color: var(--accent); }

/* ---------- Supplies view ---------- */
.supplies-view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 40px 80px;
}
.supplies-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.supplies-header h1 { font-size: 38px; margin: 4px 0 6px; }
.supplies-header p  { margin: 0; max-width: 540px; }
.supplies-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.supplies-actions input[type=search] {
  width: 240px;
}
.supplies-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.supply-section {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.supply-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}
.supply-section-head h3 {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 20px;
}
.supply-section-head .count {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}
.supply-section-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-subtle);
  font-size: 13px;
}
.supply-section-empty button {
  margin-top: 8px;
}
.supply-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.supply-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.supply-table tbody tr { cursor: pointer; }
.supply-table tbody tr:hover { background: var(--surface-2); }
.supply-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.supply-table tr:last-child td { border-bottom: 0; }
.supply-table .col-name { font-weight: 500; }
.supply-table .col-num { font-variant-numeric: tabular-nums; text-align: right; }
.supply-table .col-actions { text-align: right; width: 80px; }

/* Amount + unit pair (used in supply modal) */
.amount-unit { display: flex; gap: 6px; }
.amount-unit input[type=number] { flex: 1.5; }
.amount-unit select { flex: 1; min-width: 80px; }

/* Vessel-only fields wrapper */
.vessel-fields {
  background: var(--accent-tint);
  border: 1px dashed var(--accent-soft);
  border-radius: 10px;
  margin: 0 20px 4px;
  padding: 4px 4px 0;
}
.vessel-fields .grid-2 { padding: 14px 16px; }
.vessel-fields .lbl-unit { color: var(--accent); }

/* Fragrance-only fields wrapper (rating block) */
.fragrance-fields {
  background: var(--warm-soft);
  border: 1px dashed #e7c5a8;
  border-radius: 10px;
  margin: 0 20px 4px;
  padding: 4px;
}
.rating-block { padding: 12px 16px 14px; }
.rating-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.rating-clear {
  background: transparent;
  border: 0;
  color: var(--text-subtle);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.rating-clear:hover { background: var(--surface); color: var(--text); }
.rating-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.rating-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rating-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent-soft);
}
/* Filled = the user's selected number, plus everything below it */
.rating-btn.filled {
  background: var(--warm);
  color: #fafaf3;
  border-color: var(--warm);
}
.rating-btn.current {
  box-shadow: 0 0 0 3px var(--warm-soft);
  transform: scale(1.06);
}
.rating-row[data-value="0"] .rating-btn.filled { /* no-op safeguard */ }
#supRatingLabel { margin-top: 6px; }

/* Compact rating shown in the supplies table for fragrance rows.
   Block-level flex so it drops onto its own line below the name and the
   margin-top inline style gives breathing room between the two. */
.supply-rating {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--warm);
  font-weight: 600;
  margin-top: 6px;
}
.supply-rating .bar {
  display: inline-block;
  width: 60px;
  height: 4px;
  background: var(--line-soft);
  border-radius: 2px;
  overflow: hidden;
}
.supply-rating .bar-fill {
  display: block;
  height: 100%;
  background: var(--warm);
  border-radius: 2px;
}

/* Ingredient row supply selector (legacy table) */
.ing-table .ing-name-cell { display: flex; gap: 4px; }
.ing-table .ing-name-cell select { flex: 1; min-width: 0; }
.ing-table .ing-name-cell input { flex: 1; min-width: 0; }

/* Sectioned ingredients (per-category groups) */
.ing-sections {
  display: flex;
  flex-direction: column;
  padding: 6px 14px 14px;
  gap: 4px;
}
.ing-section {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 8px 10px;
}
.ing-section.has-rows {
  background: var(--surface-2);
  border-color: var(--line-soft);
}
.ing-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px;
  gap: 8px;
}
.ing-section-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ing-section-title .count {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ing-section-add {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.ing-section-add:hover { background: var(--surface); color: var(--text); border-color: var(--accent-soft); }
.ing-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.ing-row {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) 90px 90px 110px 140px 36px;
  gap: 6px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 6px 8px;
}
.ing-row select, .ing-row input {
  padding: 6px 8px;
  font-size: 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}
.ing-row select:hover, .ing-row input:hover { background: var(--surface-2); }
.ing-row select:focus, .ing-row input:focus { background: var(--surface); border-color: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-tint); }
.ing-row .ing-name-cell { display: flex; gap: 4px; }
.ing-row .ing-name-cell select, .ing-row .ing-name-cell input { flex: 1; min-width: 0; }
.ing-row .row-x {
  background: transparent;
  border: 0;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 16px;
  justify-self: end;
}
.ing-row .row-x:hover { background: #f5e0de; color: var(--danger); }
.ing-row-empty {
  font-size: 12px;
  color: var(--text-subtle);
  font-style: italic;
  padding: 4px 8px;
}
.ing-pick-supply { padding: 4px 8px; font-size: 11px; }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; max-height: 320px; }
  .main { padding: 24px 18px 80px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .session-grid { grid-template-columns: repeat(2, 1fr); }
  .tabs { grid-template-columns: 1fr; }
  .empty .xl { font-size: 32px; }
  .how { grid-template-columns: 1fr; }
  .supplies-view { padding: 24px 18px 80px; }
  .supplies-actions { width: 100%; }
  .supplies-actions input[type=search] { flex: 1; width: auto; }
  .primary-nav button { padding: 7px 12px; font-size: 12px; }
  .topbar { flex-wrap: wrap; gap: 10px; }
}
