/* css/style.css
 * Recipe App design system — premium mobile-first PWA for Thai food-tech.
 * Mobile target 390px; centered shell on tablet/desktop.
 */

:root {
  /* Surface */
  --bg:           #F6F7F4;
  --bg-deep:      #EFF1EC;
  --surface:      #FFFFFF;
  --surface-soft: #F3F7F1;
  --surface-tint: #FAFAF8;

  /* Brand */
  --primary:      #16A34A;
  --primary-dark: #0F7A35;
  --primary-soft: #DCFCE7;
  --primary-ink:  #14532D;

  /* Text */
  --text:         #111827;
  --text-2:       #374151;
  --muted:        #6B7280;
  --faint:        #9CA3AF;

  /* Lines */
  --border:       #E7E9E3;
  --border-soft:  #EEF0EA;

  /* Status */
  --warning:      #F59E0B;
  --warning-soft: #FEF3C7;
  --warning-ink:  #92400E;
  --danger:       #EF4444;
  --danger-soft:  #FEE2E2;
  --danger-ink:   #991B1B;
  --info:         #2563EB;
  --info-soft:    #DBEAFE;
  --info-ink:     #1E40AF;

  /* Tinted card backgrounds */
  --tint-green:   #ECFDF3;
  --tint-amber:   #FFF7E6;
  --tint-blue:    #EFF4FE;
  --tint-rose:    #FFF1F2;
  --tint-violet:  #F3F0FE;

  /* Radius */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-pill: 999px;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04), 0 2px 6px rgba(15,23,42,0.04);
  --shadow-md: 0 6px 18px rgba(15,23,42,0.06), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 18px 40px rgba(15,23,42,0.14), 0 4px 12px rgba(15,23,42,0.08);
  --shadow-nav: 0 -8px 24px rgba(15,23,42,0.06);

  /* Layout */
  --shell-max: 480px;
  --hdr-h: 60px;
  --nav-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: "IBM Plex Sans Thai", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  letter-spacing: -0.005em;
}
input, button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.tabular, .tabular-nums { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app-shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 8px);
}
@media (min-width: 520px) {
  body { background: linear-gradient(180deg, #EEF1EA 0%, #F6F7F4 320px); }
  .app-shell {
    box-shadow: 0 24px 80px rgba(15,23,42,0.10), 0 4px 16px rgba(15,23,42,0.04);
    border-left: 1px solid var(--border-soft);
    border-right: 1px solid var(--border-soft);
  }
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(246,247,244,0.88);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  padding-top: var(--safe-top);
}
.app-header-row {
  height: var(--hdr-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px 10px;
  gap: 12px;
}
.app-header-titles { min-width: 0; }
.app-title {
  font-size: 22px; font-weight: 700; margin: 0; line-height: 1.15;
  letter-spacing: -0.02em;
}
.app-subtitle {
  font-size: 13px; color: var(--muted); margin: 2px 0 0; line-height: 1.2;
}
.header-badges { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  box-shadow: var(--shadow-xs);
}
.status-pill-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint);
  box-shadow: 0 0 0 3px rgba(156,163,175,0.18);
}
.status-pill.is-online      { color: var(--primary-ink); }
.status-pill.is-online .status-pill-dot { background: var(--primary); box-shadow: 0 0 0 3px rgba(22,163,74,0.18); }
.status-pill.is-offline     { color: var(--warning-ink); }
.status-pill.is-offline .status-pill-dot { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,0.18); }
.status-pill.is-error       { color: var(--danger-ink); }
.status-pill.is-error .status-pill-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,0.18); }

/* ---------- Main / page ---------- */
.app-main {
  padding: 12px 20px 24px;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  pointer-events: none;
  padding: 0 12px calc(var(--safe-bottom) + 10px);
  display: flex;
  justify-content: center;
}
.bottom-nav-inner {
  pointer-events: auto;
  width: 100%;
  max-width: calc(var(--shell-max) - 16px);
  height: var(--nav-h);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 28px;
  box-shadow: 0 8px 32px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.05);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
  padding: 6px;
  gap: 2px;
}
.tab {
  background: transparent; border: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--faint);
  gap: 3px;
  border-radius: 18px;
  min-height: 56px;
  position: relative;
  transition: color .18s ease, background .18s ease, transform .12s ease;
}
.tab:active { transform: scale(0.96); }
.tab-icon {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tab-icon svg { width: 22px; height: 22px; display: block; }
.tab-label { font-size: 11px; font-weight: 600; letter-spacing: 0.01em; }
.tab.is-active {
  background: var(--primary-soft);
  color: var(--primary-ink);
}
.tab.is-active .tab-icon svg { stroke-width: 2.2; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .06s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  letter-spacing: -0.005em;
}
.btn:active { transform: scale(0.98); }
.btn:hover { background: var(--surface-tint); }
.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(15,86,32,0.18), inset 0 -1px 0 rgba(0,0,0,0.10);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-soft {
  background: var(--primary-soft); color: var(--primary-ink); border-color: transparent;
}
.btn-soft:hover { background: #C7F4D5; }
.btn-warn   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; }
.btn-ghost  { background: transparent; border-color: transparent; color: var(--primary); }
.btn-block  { width: 100%; }
.btn-sm     { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-lg     { min-height: 52px; padding: 0 20px; font-size: 15px; border-radius: 16px; }
.btn-icon   { width: 44px; padding: 0; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label {
  font-size: 12px; color: var(--muted); font-weight: 600;
  letter-spacing: 0.02em; text-transform: none;
}
.input, .select, .textarea {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  font-variant-numeric: tabular-nums;
}
.textarea { padding: 12px 14px; min-height: 84px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.16);
  background: #fff;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Search field */
.search-field { position: relative; }
.search-field .input {
  padding-left: 42px; padding-right: 40px;
  background: var(--surface);
  border-radius: 14px;
}
.search-field-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--faint); display: inline-flex; pointer-events: none;
}
.search-field-icon svg { width: 18px; height: 18px; }
.input-clear-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; background: var(--bg-deep); color: var(--muted);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.input-clear-btn svg { width: 12px; height: 12px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 12px; }
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.card-sub   { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.45; }

/* ---------- Section header ---------- */
.section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 0 10px;
  gap: 12px;
}
.section-h h2 {
  font-size: 16px; font-weight: 700; margin: 0;
  letter-spacing: -0.01em;
}
.section-h .section-h-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.section-h .link {
  color: var(--primary-dark); font-size: 13px; font-weight: 600;
  background: none; border: 0; padding: 4px 0;
  display: inline-flex; align-items: center; gap: 2px;
}

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  box-shadow: var(--shadow-xs);
  min-height: 86px;
}
.stat-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.stat-card-icon {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary-dark);
}
.stat-card-icon svg { width: 16px; height: 16px; }
.stat-card-icon.is-amber  { background: var(--tint-amber); color: #B45309; }
.stat-card-icon.is-blue   { background: var(--tint-blue);  color: #1D4ED8; }
.stat-card-icon.is-rose   { background: var(--tint-rose);  color: #BE123C; }
.stat-card-icon.is-violet { background: var(--tint-violet); color: #6D28D9; }
.stat-card-num {
  font-size: 26px; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums;
  font-family: "Inter", "IBM Plex Sans Thai", sans-serif;
  letter-spacing: -0.02em;
}
.stat-card-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---------- Action chips (quick actions) ---------- */
.action-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 8px;
}
.action-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 13.5px;
  text-align: left;
  min-height: 56px;
  color: var(--text);
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  box-shadow: var(--shadow-xs);
}
.action-card:active { transform: scale(0.98); }
.action-card:hover { border-color: var(--primary-soft); background: var(--surface-tint); }
.action-card-icon {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.action-card-icon svg { width: 18px; height: 18px; }

/* ---------- Insight card (price impact callout) ---------- */
.insight-card {
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(22,163,74,0.10) 0%, rgba(22,163,74,0) 55%),
    linear-gradient(135deg, #F0FDF4 0%, #FFFFFF 60%);
  border: 1px solid #BBF7D0;
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex; gap: 14px; align-items: flex-start;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease;
}
.insight-card:active { transform: scale(0.99); }
.insight-card:hover { box-shadow: var(--shadow-md); }
.insight-card-icon {
  width: 44px; height: 44px; border-radius: 14px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(22,163,74,0.32);
}
.insight-card-icon svg { width: 22px; height: 22px; }
.insight-card-body { flex: 1; min-width: 0; }
.insight-card-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--primary-ink); letter-spacing: -0.01em; }
.insight-card-desc { margin: 0 0 10px; font-size: 13px; color: #166534; line-height: 1.45; opacity: 0.85; }
.insight-card-cta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 700; color: var(--primary-dark);
}
.insight-card-cta svg { width: 14px; height: 14px; }

/* ---------- Pinned (legacy alias for insight) ---------- */
.pinned-card { /* kept for compat */
  background: linear-gradient(135deg, #ECFDF5 0%, #FFFFFF 100%);
  border: 1px solid #BBF7D0;
  border-radius: var(--r-lg);
  padding: 14px 16px;
}

/* ---------- Banners ---------- */
.banner {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  margin-bottom: 12px;
  display: flex; align-items: flex-start; gap: 10px;
  line-height: 1.45;
}
.banner-icon {
  flex-shrink: 0; width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
}
.banner-icon svg { width: 18px; height: 18px; }
.banner-warn   { background: var(--warning-soft); color: var(--warning-ink); }
.banner-danger { background: var(--danger-soft);  color: var(--danger-ink); }
.banner-info   { background: var(--info-soft);    color: var(--info-ink); }
.banner-soft   {
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border-soft);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 600;
  background: #F1F2EE; color: var(--muted);
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-green  { background: var(--primary-soft); color: var(--primary-ink); }
.badge-yellow { background: var(--warning-soft); color: var(--warning-ink); }
.badge-red    { background: var(--danger-soft);  color: var(--danger-ink); }
.badge-muted  { background: #F1F2EE; color: var(--muted); }
.badge-info   { background: var(--info-soft);    color: var(--info-ink); }

.gp-badge.is-green  { background: var(--primary-soft); color: var(--primary-ink); }
.gp-badge.is-yellow { background: var(--warning-soft); color: var(--warning-ink); }
.gp-badge.is-red    { background: var(--danger-soft);  color: var(--danger-ink); }
.gp-badge.is-none   { background: #F1F2EE; color: var(--muted); }

/* ---------- Segmented sub-tabs ---------- */
.segment-tabs {
  display: flex;
  background: var(--bg-deep);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 14px;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.segment-tabs::-webkit-scrollbar { display: none; }
.segment-tab {
  flex: 1 1 auto;
  min-width: 72px;
  background: transparent; border: 0; border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px; font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.segment-tab.is-active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.05);
}
/* legacy alias */
.subtabs { composes: none; }
.subtabs { display: flex; background: var(--bg-deep); padding: 4px; border-radius: 14px; margin-bottom: 14px; gap: 2px; overflow-x: auto; }
.subtab { flex: 1 1 auto; min-width: 72px; background: transparent; border: 0; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.subtab.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,0.08); }

/* ---------- Chip row ---------- */
.chip-row {
  display: flex; flex-wrap: nowrap; gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -20px 12px;
  padding: 2px 20px 6px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row.is-wrap { flex-wrap: wrap; overflow: visible; margin: 0 0 12px; padding: 0; }
.chip {
  flex-shrink: 0;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
  transition: all .15s ease;
}
.chip:hover { border-color: var(--primary); }
.chip.is-active {
  background: var(--text); color: #fff; border-color: var(--text);
}

/* ---------- Skeletons ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-tint) 0%, var(--bg-deep) 50%, var(--surface-tint) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s linear infinite;
  border-radius: 12px;
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-card { height: 88px; margin-bottom: 12px; }

/* ---------- Empty state ---------- */
.empty {
  text-align: center;
  padding: 36px 16px 28px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
}
.empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--bg-deep);
  color: var(--faint);
  display: inline-flex; align-items: center; justify-content: center;
}
.empty-icon svg { width: 28px; height: 28px; }
.empty h3 { font-size: 15px; color: var(--text); margin: 0 0 4px; font-weight: 700; }
.empty p { font-size: 13px; margin: 0 0 14px; line-height: 1.5; max-width: 280px; margin-left: auto; margin-right: auto; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; top: calc(var(--safe-top) + 12px); left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 92vw; width: max-content;
}
.toast {
  background: #111827; color: #fff;
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in .22s cubic-bezier(.2,.8,.2,1);
  max-width: 92vw;
}
.toast.is-warn   { background: var(--warning-ink); }
.toast.is-danger { background: var(--danger-ink); }
.toast.is-success{ background: var(--primary-ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.toast-action { color: #FDE68A; font-weight: 700; padding: 0; background: none; border: 0; }

/* ---------- Bottom sheet ---------- */
.sheet-root { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.sheet-root.is-open { pointer-events: auto; }
.sheet-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  opacity: 0; transition: opacity .22s ease;
  backdrop-filter: blur(2px);
}
.sheet-root.is-open .sheet-backdrop { opacity: 1; }
.sheet {
  position: absolute; left: 50%; right: auto; bottom: 0;
  width: 100%;
  max-width: var(--shell-max);
  transform: translate(-50%, 100%);
  background: var(--surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  transition: transform .26s cubic-bezier(.2,.8,.2,1);
  box-shadow: var(--shadow-lg);
  padding-bottom: var(--safe-bottom);
}
.sheet-root.is-open .sheet { transform: translate(-50%, 0); }
.sheet-handle { display: flex; justify-content: center; padding: 10px 0 4px; }
.sheet-handle::after { content: ""; width: 38px; height: 4px; background: #D1D5DB; border-radius: 2px; }
.sheet-head {
  padding: 6px 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.sheet-head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.sheet-close {
  background: var(--bg-deep); border: 0;
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.sheet-close svg { width: 14px; height: 14px; }
.sheet-body { padding: 16px 18px; overflow: auto; flex: 1; }
.sheet-foot {
  position: sticky; bottom: 0;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 10px 18px calc(10px + var(--safe-bottom));
  display: flex; gap: 10px;
}
.sheet-foot .btn { flex: 1; }

/* ---------- Confirm dialog ---------- */
.confirm-root { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.confirm-root.is-open { pointer-events: auto; }
.confirm-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,0.55); opacity: 0; transition: opacity .15s ease; }
.confirm-root.is-open .confirm-backdrop { opacity: 1; }
.confirm-card {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -45%);
  width: min(420px, 92vw);
  background: var(--surface);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .15s ease, transform .15s ease;
}
.confirm-root.is-open .confirm-card { opacity: 1; transform: translate(-50%, -50%); }
.confirm-card h3 { margin: 0 0 8px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.confirm-card p  { margin: 0 0 18px; color: var(--text-2); font-size: 14px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- List cards (recipes etc.) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
}
.list-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.list-card-title {
  font-size: 15.5px; font-weight: 700; margin: 0 0 3px;
  letter-spacing: -0.01em; line-height: 1.3;
  color: var(--text);
}
.list-card-sub { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.4; }

/* Metric row inside list card */
.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.metric { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric + .metric { border-left: 1px solid var(--border-soft); padding-left: 12px; }
.metric-label { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: 0.01em; }
.metric-value {
  font-size: 14px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; letter-spacing: -0.005em;
}
.metric-value.is-big { font-size: 18px; font-weight: 800; }
.metric-value.is-warn { color: var(--warning-ink); }
.metric-value.is-danger { color: var(--danger-ink); }

/* legacy compat */
.list-card-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; margin-top: 10px; font-size: 12.5px; }
.list-card-meta dt { color: var(--muted); margin: 0; }
.list-card-meta dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.list-card-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: calc(50% - var(--shell-max)/2 + 18px);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 22px);
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--primary); color: #fff;
  border: 0; box-shadow: 0 12px 28px rgba(22,163,74,0.36), 0 4px 8px rgba(15,23,42,0.10);
  display: inline-flex; align-items: center; justify-content: center;
  z-index: 35;
  transition: transform .12s ease, box-shadow .15s ease;
}
.fab:active { transform: scale(0.94); }
.fab svg { width: 24px; height: 24px; }
@media (max-width: 519px) {
  .fab { right: 20px; }
}

/* ---------- Sticky save bar ---------- */
.sticky-action-bar {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 10px;
  display: flex; gap: 8px;
  margin-top: 16px;
  box-shadow: var(--shadow-md);
}
.sticky-save { /* legacy */
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(10px + var(--safe-bottom));
  display: flex; gap: 10px;
}

/* ---------- Calculator card grid ---------- */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.calc-tile {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 16px 14px;
  min-height: 132px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 10px;
  text-align: left;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease;
}
.calc-tile:active { transform: scale(0.98); }
.calc-tile:hover { border-color: var(--primary-soft); box-shadow: var(--shadow-sm); }
.calc-tile-icon {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
}
.calc-tile-icon svg { width: 20px; height: 20px; }
.calc-tile-icon.is-amber  { background: var(--tint-amber); color: #B45309; }
.calc-tile-icon.is-blue   { background: var(--tint-blue);  color: #1D4ED8; }
.calc-tile-icon.is-rose   { background: var(--tint-rose);  color: #BE123C; }
.calc-tile-icon.is-violet { background: var(--tint-violet); color: #6D28D9; }
.calc-tile-name { font-size: 14.5px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.calc-tile-desc { font-size: 11.5px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.calc-tile.is-featured {
  grid-column: 1 / -1;
  min-height: 90px;
  flex-direction: row; align-items: center; gap: 14px;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(22,163,74,0.12) 0%, rgba(22,163,74,0) 55%),
    linear-gradient(135deg, #F0FDF4 0%, #FFFFFF 60%);
  border-color: #BBF7D0;
}
.calc-tile.is-featured .calc-tile-icon {
  width: 44px; height: 44px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(22,163,74,0.32);
}
.calc-tile.is-featured .calc-tile-icon svg { width: 22px; height: 22px; }
.calc-tile.is-featured .calc-tile-body { flex: 1; min-width: 0; }
.calc-tile.is-featured .calc-tile-name { color: var(--primary-ink); }
.calc-tile.is-featured .calc-tile-desc { color: #166534; opacity: 0.8; }

.calc-row { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--r-md); padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow-xs); }
.calc-row-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.calc-row-name { font-weight: 700; flex: 1; }
.calc-row-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.calc-suggest {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-md);
  margin-top: 4px; max-height: 240px; overflow: auto; z-index: 10;
  display: none;
}
.calc-suggest-item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border-soft); }
.calc-suggest-item:hover { background: var(--surface-tint); }
.calc-suggest-item:last-child { border-bottom: 0; }

.compare-line {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: 12px;
  align-items: center;
}
.compare-line.is-win { background: var(--primary-soft); border-color: #BBF7D0; }
.compare-line.is-win::after { content: "ดีที่สุด"; color: var(--primary-ink); font-weight: 700; font-size: 11px; }

/* ---------- Recipe ingredient row (editor) ---------- */
.ing-row {
  display: grid;
  grid-template-columns: 1fr 86px auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.ing-row:last-child { border-bottom: 0; }
.ing-row-name { font-size: 14.5px; font-weight: 600; }
.ing-row-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ing-row .qty-input { min-height: 40px; padding: 0 10px; text-align: right; font-size: 14px; }
.ing-row-actions { display: flex; gap: 4px; align-items: center; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s ease;
}
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover { background: var(--surface-tint); }
.icon-btn.is-locked { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary-soft); }
.icon-btn.is-danger { color: var(--danger); border-color: var(--danger-soft); }
.icon-btn.is-danger:hover { background: var(--danger-soft); }

/* ---------- Live summary panel ---------- */
.summary-panel {
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--surface) 100%);
  border: 1px solid #BBF7D0;
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.summary-panel h4 { margin: 0 0 8px; font-size: 13px; color: var(--primary-ink); font-weight: 700; letter-spacing: 0.01em; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-variant-numeric: tabular-nums; }
.summary-grid .lbl { color: var(--muted); font-size: 12.5px; }
.summary-grid .val { text-align: right; font-weight: 700; font-size: 14px; }
.summary-warn { margin-top: 10px; font-size: 12px; color: var(--warning-ink); display: flex; gap: 6px; align-items: center; }

/* ---------- Steps ---------- */
.step-row {
  display: grid; grid-template-columns: 28px 1fr auto;
  gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  align-items: start;
}
.step-row:last-child { border-bottom: 0; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-ink);
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.step-text textarea { min-height: 56px; }
.step-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

/* ---------- KV detail rows ---------- */
.kv {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px; gap: 12px;
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- Form section card (settings / sheet) ---------- */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}
.form-section-head {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 14px;
}
.form-section-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.form-section-icon svg { width: 18px; height: 18px; }
.form-section-icon.is-amber { background: var(--tint-amber); color: #B45309; }
.form-section-icon.is-blue  { background: var(--tint-blue);  color: #1D4ED8; }
.form-section-icon.is-violet { background: var(--tint-violet); color: #6D28D9; }
.form-section-icon.is-rose  { background: var(--tint-rose);  color: #BE123C; }
.form-section-titles { flex: 1; min-width: 0; }
.form-section-title { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.form-section-sub { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; line-height: 1.4; }

.inline-save {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
}
.inline-save .input { flex: 1; }

/* ---------- Picker list (multi-select) ---------- */
.picker-list { max-height: 50vh; overflow: auto; padding: 6px 0; margin: 0 -18px; }
.picker-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--border-soft);
  gap: 10px; cursor: pointer; min-height: 56px;
}
.picker-item .picker-name { font-size: 14.5px; font-weight: 600; }
.picker-item .picker-meta { font-size: 12px; color: var(--muted); }
.picker-item.is-selected { background: var(--primary-soft); }
.picker-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center;
  color: transparent; font-size: 13px;
  transition: all .15s ease;
}
.picker-check svg { width: 12px; height: 12px; }
.picker-item.is-selected .picker-check { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ---------- Tag chip (read-only) ---------- */
.tag-chip {
  display: inline-flex; padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--bg-deep); color: var(--text-2); font-size: 12px;
  margin: 0 4px 4px 0;
}

/* ---------- Switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.switch .knob { width: 40px; height: 24px; background: #D1D5DB; border-radius: 999px; position: relative; transition: background .15s ease; }
.switch .knob::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s cubic-bezier(.2,.8,.2,1); }
.switch input:checked + .knob { background: var(--primary); }
.switch input:checked + .knob::after { transform: translateX(16px); }

/* ---------- Impact tree (price impact mode) ---------- */
.impact-line {
  font-size: 12.5px; padding: 5px 0;
  color: var(--muted);
  display: flex; gap: 6px; align-items: baseline;
  font-variant-numeric: tabular-nums;
}
.impact-line .ing-name { color: var(--text); font-weight: 600; }
.impact-line.is-up   { color: var(--danger-ink); }
.impact-line.is-down { color: var(--primary-ink); }
.impact-summary {
  display: grid; grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 10px; font-size: 12.5px; font-variant-numeric: tabular-nums;
  padding-top: 10px; border-top: 1px solid var(--border-soft);
}
.delta-pill {
  display: inline-flex; align-items: center; padding: 4px 10px;
  border-radius: var(--r-pill); font-size: 12px; font-weight: 700;
  background: var(--bg-deep); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.delta-pill.up   { background: var(--danger-soft); color: var(--danger-ink); }
.delta-pill.down { background: var(--primary-soft); color: var(--primary-ink); }

/* ---------- Page heading inside calculator subpages ---------- */
.page-h {
  font-size: 18px; font-weight: 700;
  margin: 0 0 12px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.page-h-icon {
  width: 32px; height: 32px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
}
.page-h-icon svg { width: 18px; height: 18px; }

/* ---------- Misc utility ---------- */
.row { display: flex; gap: 10px; align-items: center; }
.row-grow { flex: 1; }
.row-wrap { flex-wrap: wrap; }
.divider { height: 1px; background: var(--border-soft); margin: 14px 0; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-warn   { color: var(--warning-ink); }
.text-success{ color: var(--primary-dark); }

.center { text-align: center; }
.right  { text-align: right; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-4 { gap: 4px; }
.gap-6 { gap: 6px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.page-loader { padding: 4px 0; }
[hidden] { display: none !important; }

/* ---------- Pinned card legacy compat (already used by parts) ---------- */
.pinned-card h4 { margin: 0 0 4px; font-size: 15px; color: var(--primary-ink); }
.pinned-card p  { margin: 0; font-size: 13px; color: var(--primary-ink); line-height: 1.5; opacity: 0.85; }

/* ============================================================
   NEW: header back button, lock screen, dashboard hero, compact
   ingredient rows, settings list editor.
   ============================================================ */

/* Header back button */
.back-btn {
  width: 38px; height: 38px;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 12px;
  box-shadow: var(--shadow-xs);
  margin-right: 4px;
  transition: transform .08s ease, background .15s ease;
}
.back-btn:active { transform: scale(0.94); }
.back-btn:hover { background: var(--surface-tint); }
.back-btn svg { width: 18px; height: 18px; }
.back-btn[hidden] { display: none !important; }

/* Lock screen */
.lock-screen {
  position: fixed; inset: 0; z-index: 200;
  background:
    radial-gradient(140% 100% at 50% -20%, #DCFCE7 0%, rgba(220,252,231,0) 60%),
    linear-gradient(180deg, #F6F7F4 0%, #EFF1EC 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px 20px;
  transition: opacity .26s ease, transform .26s ease;
}
.lock-screen.is-leaving { opacity: 0; transform: scale(1.02); pointer-events: none; }
.lock-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 28px;
  padding: 28px 22px 22px;
  box-shadow: 0 30px 60px rgba(15,23,42,0.10), 0 4px 12px rgba(15,23,42,0.04);
  text-align: center;
}
.lock-card.is-shake { animation: shake .42s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}
.lock-logo {
  width: 60px; height: 60px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px rgba(22,163,74,0.32);
}
.lock-logo svg { width: 28px; height: 28px; }
.lock-title { font-size: 18px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.lock-sub   { font-size: 13px; color: var(--muted); margin: 0 0 22px; }
.lock-dots  { display: flex; gap: 12px; justify-content: center; margin-bottom: 12px; }
.lock-dots span {
  width: 14px; height: 14px; border-radius: 50%;
  background: transparent;
  border: 2px solid #D1D5DB;
  transition: all .15s ease;
}
.lock-dots span.is-filled { background: var(--primary); border-color: var(--primary); transform: scale(1.05); }
.lock-msg {
  min-height: 18px; font-size: 12.5px; margin-bottom: 10px;
  color: var(--muted); font-weight: 500;
}
.lock-msg.is-err { color: var(--danger-ink); }
.lock-msg.is-ok  { color: var(--primary-ink); }
.lock-pad {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-top: 4px;
}
.lock-key {
  height: 56px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 22px; font-weight: 600;
  color: var(--text);
  font-family: "Inter", "IBM Plex Sans Thai", sans-serif;
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .08s ease, background .15s ease;
}
.lock-key:active { transform: scale(0.94); background: var(--bg-deep); }
.lock-key.is-ghost { visibility: hidden; pointer-events: none; }
.lock-key.is-back { background: var(--bg-deep); border-color: transparent; color: var(--muted); }
.lock-key.is-back svg { width: 22px; height: 22px; }

/* ---------- Dashboard hero (premium) ---------- */
.dash-hero {
  position: relative;
  background:
    radial-gradient(120% 100% at 100% 0%, rgba(34,197,94,0.55) 0%, rgba(34,197,94,0) 60%),
    linear-gradient(135deg, #064E3B 0%, #0F7A35 55%, #16A34A 100%);
  border-radius: var(--r-xl);
  padding: 18px 18px 16px;
  color: #fff;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(15,86,32,0.22);
}
.dash-hero::after {
  content: ""; position: absolute; right: -40px; bottom: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
  pointer-events: none;
}
.dash-hero-eyebrow {
  font-size: 11.5px; font-weight: 600; opacity: 0.78;
  letter-spacing: 0.06em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 6px;
}
.dash-hero-title {
  font-size: 22px; font-weight: 800; line-height: 1.2;
  margin: 4px 0 14px; letter-spacing: -0.02em;
}
.dash-hero-stats {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 0;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(8px);
  border-radius: 16px;
  padding: 14px 4px;
}
.dash-hero-stat {
  padding: 0 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.dash-hero-stat + .dash-hero-stat { border-left: 1px solid rgba(255,255,255,0.18); }
.dash-hero-stat-num {
  font-size: 22px; font-weight: 800;
  font-family: "Inter", "IBM Plex Sans Thai", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.dash-hero-stat-label { font-size: 11.5px; opacity: 0.82; font-weight: 500; }
.dash-hero-stat-delta { font-size: 11px; font-weight: 600; opacity: 0.92; margin-top: 2px; }
.dash-hero-stat-delta.is-up { color: #BBF7D0; }
.dash-hero-stat-delta.is-down { color: #FECACA; }

/* Premium stat cards (dashboard tier 2) */
.stat-grid-premium {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 16px;
}
.stat-card-premium {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 92px;
  box-shadow: var(--shadow-xs);
  transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease;
  text-align: left;
}
.stat-card-premium:active { transform: scale(0.98); }
.stat-card-premium:hover { box-shadow: var(--shadow-sm); }
.stat-card-premium-icon {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
}
.stat-card-premium-icon svg { width: 16px; height: 16px; }
.stat-card-premium-icon.is-amber  { background: var(--tint-amber); color: #B45309; }
.stat-card-premium-icon.is-blue   { background: var(--tint-blue);  color: #1D4ED8; }
.stat-card-premium-icon.is-rose   { background: var(--tint-rose);  color: #BE123C; }
.stat-card-premium-icon.is-violet { background: var(--tint-violet); color: #6D28D9; }
.stat-card-premium-label { font-size: 11.5px; color: var(--muted); font-weight: 500; padding-right: 38px; }
.stat-card-premium-num {
  font-size: 28px; font-weight: 800;
  font-family: "Inter", "IBM Plex Sans Thai", sans-serif;
  font-variant-numeric: tabular-nums;
  line-height: 1.05; letter-spacing: -0.02em;
  color: var(--text);
}
.stat-card-premium-meta { font-size: 11.5px; color: var(--muted); }

/* ---------- Compact ingredient row ---------- */
.ing-cat-group { margin-bottom: 14px; }
.ing-cat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 4px 8px;
  margin-top: 6px;
}
.ing-cat-head-left {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.ing-cat-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
}
.ing-cat-count {
  font-size: 11px; color: var(--muted); font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--bg-deep); padding: 2px 8px; border-radius: var(--r-pill);
}

.ing-line-list {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.ing-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  background: transparent;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  transition: background .12s ease;
}
.ing-line:last-child { border-bottom: 0; }
.ing-line:hover { background: var(--surface-tint); }
.ing-line:active { background: var(--bg-deep); }
.ing-line.is-inactive { opacity: 0.55; }
.ing-line-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ing-line-name {
  font-size: 14.5px; font-weight: 600; color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ing-line-meta {
  font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.ing-line-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }
.ing-line-price {
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.005em;
  text-align: right;
  white-space: nowrap;
}
.ing-line-price-sub {
  font-size: 10.5px; color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}
.ing-line-chev {
  color: var(--faint); flex-shrink: 0;
  display: inline-flex; align-items: center;
}
.ing-line-chev svg { width: 14px; height: 14px; }

.ing-summary-bar {
  display: flex; gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  margin-bottom: 12px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  align-items: center;
  flex-wrap: wrap;
}
.ing-summary-bar .pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; color: var(--text-2);
}
.ing-summary-bar .pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.ing-summary-bar .pill .num {
  font-weight: 800; color: var(--text);
}

/* ---------- Settings list editor ---------- */
.settings-section-list {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.settings-row-button {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent; border: 0;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  transition: background .12s ease;
  min-height: 60px;
}
.settings-row-button:last-child { border-bottom: 0; }
.settings-row-button:hover { background: var(--surface-tint); }
.settings-row-button:active { background: var(--bg-deep); }
.settings-row-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.settings-row-icon svg { width: 18px; height: 18px; }
.settings-row-icon.is-amber  { background: var(--tint-amber); color: #B45309; }
.settings-row-icon.is-blue   { background: var(--tint-blue);  color: #1D4ED8; }
.settings-row-icon.is-rose   { background: var(--tint-rose);  color: #BE123C; }
.settings-row-icon.is-violet { background: var(--tint-violet); color: #6D28D9; }
.settings-row-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.settings-row-title { font-size: 14.5px; font-weight: 600; color: var(--text); letter-spacing: -0.005em; }
.settings-row-sub   { font-size: 12px; color: var(--muted); line-height: 1.35; }
.settings-row-trail {
  flex-shrink: 0; color: var(--faint);
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
}
.settings-row-trail svg { width: 14px; height: 14px; }

.settings-overline {
  font-size: 11.5px; color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  margin: 18px 4px 8px;
}
.settings-overline:first-child { margin-top: 6px; }

/* Re-orderable row used in category management */
.reorder-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-xs);
}
.reorder-handle {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  background: var(--bg-deep);
  color: var(--muted);
  cursor: grab;
}
.reorder-handle svg { width: 14px; height: 14px; }
.reorder-row .input { min-height: 40px; padding: 0 10px; font-size: 14px; }
.reorder-actions { display: inline-flex; gap: 4px; }
.reorder-actions .icon-btn { width: 32px; height: 32px; }
.reorder-actions .icon-btn svg { width: 14px; height: 14px; }

/* ---------- Item detail row in pickers / lists ---------- */
.detail-line {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.detail-line:last-child { border-bottom: 0; }
.detail-line-label { color: var(--muted); flex: 1; }
.detail-line-val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

