/* Design tokens. ONE accent color (--amber) means "this matters": a
   highlighted/busiest bar, an insight marker, a primary button, a selected
   filter chip. Everything else in the UI -- links, nav, secondary buttons,
   hover states -- uses the blue/gray scale below, which is chrome, not a
   signal. Variable names (--green, --amber) are historical from an even
   earlier warm cafe palette; kept as-is rather than renamed everywhere
   they're referenced. */
:root {
  --bg: #F6F7F9;
  --text: #14161A;
  --muted: #667085;
  --green: #2F6FED;       /* blue "chrome" scale -- links, nav, secondary UI. NOT a signal color. */
  --green-light: #EAF0FE; /* blue chrome, light/hover background */
  --amber: #F59E0B;       /* the ONE accent/signal color -- "this matters" */
  --amber-light: #FEF3E2; /* signal color, light/hover background */
  --slate: #334155;       /* neutral dark marker/selection color, matches charts.js COLORS.slate -- also not a signal color */
  --card: #FFFFFF;
  --border: #E4E7EC;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.05);
  --shadow-md: 0 4px 16px rgba(20, 22, 26, 0.06);
  --shadow-card: 0 1px 3px rgba(20, 22, 26, 0.08), 0 2px 8px rgba(20, 22, 26, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Explicit type scale so hierarchy is consistent everywhere, not left to
   browser defaults: page titles (h1) > card/section titles (h2) > card
   sub-titles (h3) > body text. The dashboard's 4 headline numbers
   (.stat-value) intentionally sit ABOVE all of these -- see below. */
h1, h2, h3, h4 {
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  color: var(--text);
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }

a { color: var(--green); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--green);
  color: white;
  padding: 10px 16px;
  z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 500;
  transition: transform 0.05s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--amber); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #D97F09; }
.btn-secondary { background: var(--green-light); color: var(--green); border-color: transparent; }
.btn-secondary:hover { background: #DCE7FD; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--green-light); border-color: transparent; }
.btn-danger { background: #fff; color: #C0342A; border-color: #F3C6C0; }
.btn-danger:hover { background: #FDF1EF; }
.btn:focus-visible, a:focus-visible, [tabindex]:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

.site-header {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand-name { font-weight: 700; font-size: 1.3rem; letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.brand-name:hover { color: var(--green); }
.brand-name.active { color: var(--green); }
.private-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--green-light);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.main-nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.main-nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 999px;
  transition: background 0.12s ease, color 0.12s ease;
}
.main-nav a:hover { background: var(--green-light); color: var(--green); }
.main-nav a.active { background: var(--green); color: #fff; }

main { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }

.view[hidden] { display: none; }
[hidden] { display: none !important; }

.error-banner {
  background: #FDF1EF;
  border: 1px solid #F3C6C0;
  color: #A32E24;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.merge-banner {
  background: var(--green-light);
  border: 1px solid var(--border);
  color: var(--green);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

/* Landing page (shown before any data is uploaded) */
.landing-hero { text-align: center; max-width: 640px; margin: 28px auto 0; }
.landing-hero h1 { font-size: 2.4rem; letter-spacing: -0.02em; }
.landing-subhead { color: var(--muted); font-size: 1.05rem; }
.landing-hero-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.landing-privacy-line {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 18px;
  color: var(--green); font-size: 0.85rem; font-weight: 500;
}
.btn-lg { padding: 13px 26px; font-size: 1rem; border-radius: 12px; }

.link-button {
  display: block; margin: 14px auto 0; background: none; border: none; padding: 4px;
  color: var(--muted); font-size: 0.85rem; text-decoration: underline; text-underline-offset: 2px;
}
.link-button:hover { color: var(--green); }

.intro-points { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 14px; }
.intro-points li {
  padding-left: 20px; position: relative; color: var(--text); font-size: 0.95rem; line-height: 1.5;
}
.intro-points li::before {
  content: ""; position: absolute; left: 0; top: 8px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
}

.landing-section-title { text-align: center; font-size: 1.5rem; margin-bottom: 22px; }
.landing-features, .landing-how { max-width: 1000px; margin: 64px auto 0; }
.landing-feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.landing-feature-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-card);
}
.landing-feature-icon { font-size: 1.6rem; display: block; margin-bottom: 10px; }
.landing-feature-card h3 { font-size: 1rem; margin-bottom: 6px; }
.landing-feature-card p { color: var(--muted); font-size: 0.9rem; margin: 0; }

.landing-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.landing-step h3 { font-size: 1rem; color: var(--green); margin-bottom: 6px; }
.landing-step p { color: var(--muted); font-size: 0.9rem; margin: 0; }

.landing-upload { max-width: 640px; margin: 64px auto 0; scroll-margin-top: 90px; }

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card);
  padding: 48px 24px;
  text-align: center;
  margin: 28px auto;
  max-width: 640px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.dragover { border-color: var(--green); background: var(--green-light); box-shadow: var(--shadow-md); }
.dropzone p { margin: 10px 0; color: var(--muted); }
.upload-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 16px; }
.upload-secondary { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.upload-help { font-size: 0.85rem; color: var(--muted); text-align: center; margin-top: 8px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (max-width: 820px) {
  .landing-feature-grid, .landing-steps { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .landing-feature-grid, .landing-steps { grid-template-columns: 1fr; }
}

/* Cards -- one consistent treatment everywhere (soft shadow, no border)
   instead of a thin gray border, which read as a repeated template box. */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
/* The 4 headline-number cards get more breathing room than an ordinary
   card -- they're the most important content on the dashboard. */
.stat-card { text-align: left; min-width: 0; padding: 28px 24px; }
.stat-card .stat-label { color: var(--muted); font-size: 0.85rem; margin-bottom: 8px; }
/* The single biggest, boldest text on any page -- bigger than any heading
   (h1 tops out at 1.75rem) on purpose, so these 4 headline numbers read as
   the most important thing on the dashboard at a glance. */
.stat-card .stat-value { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text); line-height: 1.1; }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.chart-card { position: relative; min-width: 0; }
.chart-card h3 { font-size: 1.05rem; margin-bottom: 4px; }
.chart-card .chart-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 10px; }
.chart-canvas-wrap { height: 260px; position: relative; width: 100%; }
.chart-canvas-wrap.tall { height: 340px; }
.chart-canvas-wrap canvas { max-width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 0.8rem; color: var(--muted); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.heatmap-legend { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.78rem; color: var(--muted); }
.heatmap-legend-scale { display: flex; height: 12px; width: 120px; border-radius: 4px; overflow: hidden; }
.heatmap-legend-scale span { flex: 1; }
.see-details-link {
  display: inline-block; margin-top: 10px; font-size: 0.85rem; font-weight: 600;
  text-decoration: none; color: var(--green);
}
.chart-card-clickable { cursor: pointer; transition: box-shadow 0.15s ease, transform 0.15s ease; }
.chart-card-clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.chart-card-clickable:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }

.full-width { grid-column: 1 / -1; }

/* Dashboard cross-filter chips */
.filter-chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--green-light); color: var(--green);
  font-size: 0.82rem; font-weight: 600; padding: 5px 6px 5px 12px; border-radius: 999px;
}
.filter-chip button {
  background: transparent; border: none; color: var(--green); font-size: 1rem; line-height: 1;
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
}
.filter-chip button:hover { background: rgba(47, 111, 237, 0.15); }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; border-radius: 999px; }

.thin-data-banner {
  background: var(--amber-light); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 20px; color: var(--muted); font-size: 0.9rem;
}

/* Insights -- more room than an ordinary card, since this is the "most
   important secondary content" on the dashboard, right after the headline
   numbers. */
.insights-section { margin-top: 36px; padding: 28px 24px; }
.insight-card { border-bottom: 1px solid var(--border); }
.insight-card:last-child { border-bottom: none; }
.insight-toggle {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; padding: 16px;
  background: transparent; border: none; text-align: left; border-radius: 10px;
}
.insight-toggle:hover { background: var(--green-light); }
/* A calm solid dot in the one accent color, instead of a sparkle emoji --
   deliberate and consistent rather than decorative. */
.insight-icon {
  width: 10px; height: 10px; border-radius: 50%; background: var(--amber);
  flex-shrink: 0; margin-top: 7px;
}
.insight-headline-wrap { flex: 1; }
.insight-headline { font-weight: 700; margin-bottom: 4px; display: block; }
.insight-action { color: var(--muted); font-size: 0.92rem; display: block; }
.insight-caret { color: var(--muted); font-size: 0.9rem; transition: transform 0.15s ease; margin-top: 3px; }
.insight-toggle[aria-expanded="true"] .insight-caret { transform: rotate(180deg); }
.insight-detail { padding: 0 16px 18px 50px; }
.insight-detail[hidden] { display: none; }
.insight-why { color: var(--muted); font-size: 0.92rem; margin: 10px 0; }
.insights-disclaimer { font-size: 0.8rem; color: var(--muted); margin-top: 10px; font-style: italic; }

/* Grow Your Business: menu engineering matrix */
.menu-eng-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.menu-eng-quadrant { background: var(--card); border-radius: 10px; padding: 14px; border-left: 4px solid; box-shadow: var(--shadow-card); }
.menu-eng-quadrant h3 { margin: 0 0 4px 0; font-size: 1rem; }
.menu-eng-item-list { list-style: none; padding: 0; margin: 10px 0 0 0; font-size: 0.88rem; }
.menu-eng-item-list li { margin-bottom: 5px; }
.menu-eng-star { border-left-color: var(--green); }
.menu-eng-plowhorse { border-left-color: var(--amber); }
.menu-eng-puzzle { border-left-color: var(--slate); }
.menu-eng-dog { border-left-color: var(--muted); }
@media (max-width: 640px) {
  .menu-eng-grid { grid-template-columns: 1fr; }
}

/* Ask a Question */
#askHistoryList { max-height: 480px; overflow-y: auto; }
.ask-turn { margin-bottom: 16px; }
.ask-turn:last-child { margin-bottom: 0; }
.ask-question { background: var(--green-light); color: var(--text); padding: 10px 14px; border-radius: 12px 12px 12px 2px; margin-bottom: 6px; max-width: 85%; }
.ask-answer { background: var(--card); border: 1px solid var(--border); padding: 10px 14px; border-radius: 12px 12px 2px 12px; max-width: 85%; margin-left: auto; }

/* Detail pages */
.detail-header { margin-bottom: 18px; }
.detail-section { margin: 22px 0; }
.detail-section h2 { font-size: 1.15rem; }
.finding-list, .try-list { padding-left: 20px; margin: 8px 0; }
.finding-list li, .try-list li { margin-bottom: 6px; }
.toggle-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toggle-group { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.toggle-group button {
  border: none; background: var(--card); padding: 8px 16px; font-size: 0.88rem; color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease;
}
.toggle-group button:hover:not(.active) { background: var(--green-light); color: var(--green); }
.toggle-group button.active { background: var(--green); color: #fff; }

.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.92rem; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; cursor: pointer; }
.data-table th:hover { color: var(--green); }
.data-table tbody tr { transition: background 0.1s ease; }
.data-table tbody tr:hover { background: var(--green-light); }
.search-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.search-row input[type="search"], .search-row select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text);
}

/* Heatmap */
.heatmap-table { border-collapse: collapse; width: 100%; font-size: 0.72rem; }
.heatmap-table th, .heatmap-table td {
  border: 1px solid var(--border); text-align: center; padding: 4px 2px; min-width: 34px;
}
.heatmap-table th { color: var(--muted); font-weight: 500; background: var(--card); }
.heatmap-table td { cursor: pointer; transition: outline 0.1s ease; }
.heatmap-table td:hover, .heatmap-table td:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.heatmap-scroll { overflow-x: auto; }

/* Data page */
.data-stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.gap-list { padding-left: 20px; }
.data-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* Column matching */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; }
.match-field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.92rem; }
.match-field select { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
.match-note { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.match-remembered-note { background: var(--green-light); color: var(--green); padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 0.88rem; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 22, 26, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-box {
  background: var(--card); border-radius: var(--radius); padding: 24px; max-width: 440px; width: 100%;
  border: 1px solid var(--border); box-shadow: var(--shadow-md);
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.date-range-row { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.date-range-row select { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); }
.date-range-row + .chart-meta { margin-top: -12px; margin-bottom: 16px; }
.one-off-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--muted); margin-left: 8px; }
.maturity-note { font-size: 0.72rem; color: var(--muted); }

/* Items page */
.items-table tbody tr[data-item] { cursor: pointer; }
.items-table tr.variation-row td { font-size: 0.85rem; color: var(--muted); background: var(--bg); }
.items-table tr.variation-row td:first-child { padding-left: 28px; }
.est-badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 0.72rem; background: var(--amber-light); color: var(--text); cursor: help; }

.site-footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 20px; }
.footer-privacy-note {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin-bottom: 8px; color: var(--muted); font-size: 0.78rem;
}
.footer-privacy-note svg { flex-shrink: 0; opacity: 0.7; }

@media (max-width: 820px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .match-grid { grid-template-columns: 1fr; }
  .data-stat-row { grid-template-columns: 1fr; }
  .header-inner { gap: 10px; }
  .main-nav { order: 3; width: 100%; margin-left: 0; }
}

@media (max-width: 480px) {
  main { padding: 20px 14px 50px; }
  .landing-hero h1 { font-size: 1.7rem; }
  .landing-hero-actions { flex-direction: column; align-items: stretch; }
  .dropzone { padding: 30px 16px; }
}
