:root {
  --bg: #0f1115;
  --fg: #e8e9ee;
  --muted: #8a8f9a;
  --card: #1a1d24;
  --accent: #4ea3ff;
  --good: #4ec38a;
  --bad: #ee6c6c;
  --border: #262a33;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); }
.app { max-width: 1200px; margin: 0 auto; padding: 24px; }
.muted { color: var(--muted); }

header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
header h1 { margin: 0 12px; font-size: 24px; font-weight: 500; }

/* Both period arrows sit together on the left of the title so they keep a fixed
   position when the title text changes width from one period to the next. */
.period-nav { display: flex; gap: 6px; }
.period-nav button { font-size: 28px; line-height: 1; padding: 2px 12px; }

/* Pin the week/period header at top so the current week stays visible while
   scrolling through long sections. Scoped to the top-level header so drawer
   headers stay in their natural flow. */
.app > header {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: 12px 0;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

button {
  background: var(--card); color: var(--fg); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  transition: background 120ms ease, transform 80ms ease;
  font-size: 14px;
}
button:hover { background: #232733; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: progress; }

button.primary {
  background: var(--accent); border-color: var(--accent); color: #04111f;
  font-weight: 600;
}
button.primary:hover { background: #5fb1ff; }

/* Right-anchored Update column: the button on top, the last-computed
   timestamp ("Mon May 11, 11:43 (Paris)") on a muted sub-line below. */
.update-wrap {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.update-ts {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Split button: Update + a caret opening the secondary update actions. */
.update-split { position: relative; display: flex; }
.update-split > button:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.update-caret {
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  border-left: 1px solid rgba(4, 17, 31, 0.25);
  padding: 8px 10px; font-size: 12px; line-height: 1;
}
.update-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  min-width: 260px; padding: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.update-menu button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; background: transparent; border: none;
  padding: 8px 10px; border-radius: 8px; font-size: 13px;
}
.update-menu button:hover:not(:disabled) { background: #232733; }
.update-menu-hint { color: var(--muted); font-size: 11px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px;
  cursor: pointer; transition: transform 120ms ease, border-color 120ms ease;
}
.kpi:hover { transform: translateY(-1px); border-color: #3a4050; }
.kpi-title { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 28px; font-weight: 600; margin-top: 6px; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px; }

.delta { font-size: 13px; margin-left: 8px; font-weight: 500; }
.delta.good { color: var(--good); }
.delta.bad  { color: var(--bad); }
.delta.muted{ color: var(--muted); }

/* Absolute-diff inline element. Sits on its own line under the metric
   (kpi-diff for the KPI cards, .muted-small div for table cells). */
.diff { font-weight: 400; font-size: 10px; opacity: 0.85; }
.diff.good { color: var(--good); }
.diff.bad  { color: var(--bad); }
.diff.muted{ color: var(--muted); }
.kpi-diff { font-size: 12px; margin-top: 4px; min-height: 14px; }

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; justify-content: flex-end; z-index: 100;
  animation: fade 160ms ease;
}
.drawer {
  width: min(720px, 90vw); height: 100%; background: var(--card);
  border-left: 1px solid var(--border); padding: 24px;
  box-shadow: -8px 0 24px rgba(0,0,0,0.4);
  animation: slide 200ms ease;
  overflow-y: auto;
}
.drawer header { display: flex; justify-content: space-between; align-items: center;
                 margin-bottom: 16px; }
.drawer header h3 { margin: 0; font-size: 18px; font-weight: 500; }
.drawer header button { font-size: 22px; line-height: 1; padding: 4px 10px; }

.years-selector { display: flex; gap: 6px; margin-bottom: 16px; }
.years-selector button { padding: 4px 10px; font-size: 13px; }
.years-selector button.active { background: var(--accent); border-color: var(--accent); color: #04111f; }

.chart { width: 100%; height: auto; display: block; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.tab-bar {
  display: flex; gap: 4px; margin-bottom: 24px; align-items: center;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.tab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 10px 16px; color: var(--muted); font-weight: 500;
}
.tab:hover { color: var(--fg); background: transparent; }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }

.tab-bar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 6px;
}

.access-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  cursor: pointer; user-select: none;
}
.access-toggle:hover { color: var(--fg); }
.access-toggle input { display: none; }
.access-toggle-track {
  position: relative;
  width: 32px; height: 18px;
  background: #2a2f3a;
  border-radius: 10px;
  transition: background 120ms ease;
}
.access-toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: var(--fg);
  border-radius: 50%;
  transition: left 120ms ease;
}
.access-toggle input:checked ~ .access-toggle-track { background: var(--accent); }
.access-toggle input:checked ~ .access-toggle-track .access-toggle-thumb { left: 16px; }

.breakdown { margin-top: 32px; }
.breakdown h2 { font-size: 15px; color: var(--muted); text-transform: uppercase;
                letter-spacing: 0.04em; margin: 24px 0 8px; }
.breakdown table { width: 100%; border-collapse: collapse; background: var(--card);
                   border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.breakdown td { padding: 10px 14px; border-top: 1px solid var(--border); }
.breakdown tbody tr:first-child td { border-top: none; }
.breakdown td.num { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown td:first-child { color: var(--muted); }

.manual-entry { margin-top: 32px; }
.manual-entry h2 { font-size: 15px; color: var(--muted); text-transform: uppercase;
                   letter-spacing: 0.04em; margin: 24px 0 12px; }
.manual-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
               gap: 12px; }
.manual-cell { display: flex; flex-direction: column; gap: 4px; background: var(--card);
               border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.manual-label { color: var(--muted); font-size: 12px; text-transform: uppercase;
                letter-spacing: 0.04em; }
.manual-input-wrap { display: flex; align-items: center; gap: 6px; }
.manual-input-wrap .prefix { color: var(--muted); font-weight: 500; }
.manual-input-wrap input {
  flex: 1; min-width: 0; background: transparent; color: var(--fg);
  border: none; padding: 4px 0; font-size: 16px; font-variant-numeric: tabular-nums;
  outline: none;
}
.manual-input-wrap input:focus { border-bottom: 1px solid var(--accent); }
.manual-status { font-size: 11px; }
.manual-status.busy { color: var(--muted); }
.manual-status.ok { color: var(--good); font-weight: 700; }

/* Wholesale top-customers sub-rows */
.breakdown tr.sub td.indent {
  padding-left: 32px;
  color: var(--fg);
  font-size: 13px;
}
.breakdown tr.sub td {
  font-size: 13px;
  border-top: 1px dashed var(--border);
}
.breakdown td.muted-small {
  color: var(--muted);
  font-size: 12px;
}

/* Labor: QBO total override input (above the table) */
.labor-override { margin: 8px 0 16px; max-width: 320px; }

/* ─── Square daily breakdown (expanded panel under the Square channel row) ─── */
/* Parent row tint when open, anchors the panel visually */
.breakdown tr.square-open td { background: #1a1f28; }
/* Daily rows sit on a slightly darker band than the card */
.breakdown tr.square-day td {
  background: #11151c;
  border-top: 1px dashed transparent;
}
/* Vertical rail on the left column to tie the 7 days to their Square parent */
.breakdown tr.square-day td.square-day-left {
  border-left: 1px solid var(--border);
  padding-left: 32px;
}
.breakdown tr.square-day td.indent { padding-left: 32px; }
/* Two-column inline layout: day label + weather */
.square-day-left {
  display: flex; align-items: center; gap: 20px;
}
.square-day-name { min-width: 56px; font-size: 13px; }
.square-day-name .muted-small { display: block; font-size: 11px; margin-top: 1px; }
.square-day-weather {
  display: inline-flex; align-items: center; gap: 14px;
  font-size: 13px; color: var(--fg);
}
.square-day-weather .temp { font-variant-numeric: tabular-nums; }
.square-day-weather .precip {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.square-day-weather .precip.wet { color: #4ea3ff; }
.square-day-weather .precip svg { vertical-align: middle; }
/* Revenue cell — slightly heavier than regular text but not as bold as the parent row */
.breakdown tr.square-day td.square-day-rev { font-weight: 500; font-size: 14px; }
/* Footer (AVG / DAY) — dashed top divider to separate from the 7-day list */
.breakdown tr.square-day.square-day-footer td { border-top: 1px dashed var(--border); }
.square-avg-label { text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }

/* Labor table cells: put the diff badge and the cc/cash breakdown on their
   own line below the main value, right-aligned (inherits td.num text-align). */
.labor-costs td .diff        { display: block; margin-top: 2px; font-size: 11px; }
.labor-costs td .muted-small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

/* Labor by location wide table */
.labor-costs thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.labor-costs thead th.num { text-align: right; }
.labor-costs tr.total td { border-top: 2px solid var(--border); }

/* Zero values render as a faint dash for visual quietness */
.breakdown .zero {
  color: var(--muted);
  opacity: 0.5;
}

/* Expandable channel row (wholesale top customers) */
.breakdown tr.expandable { cursor: pointer; }
.breakdown tr.expandable:hover { background: #1f232c; }
.breakdown .caret {
  display: inline-block;
  width: 14px;
  color: var(--muted);
  font-size: 10px;
  margin-right: 4px;
}

/* Hover popover used by Other costs $$$ cells (payee tooltip) */
.hover-host { position: relative; cursor: help; }
.hover-host .hover-popover {
  /* Fixed positioning so the popover escapes any ancestor's overflow:hidden
     (notably the rounded-corner table) and we can flip up/down based on
     available viewport space. JS sets `top` and `left` on mouseenter. */
  position: fixed;
  top: 0;
  left: 0;
  min-width: 280px;
  max-width: 480px;
  background: #1a1d24;
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.6);
  display: none;
  z-index: 50;
  font-size: 13px;
  text-align: left;
  white-space: normal;
  overflow: hidden;
}
.hover-host:hover .hover-popover { display: block; }
.hover-popover strong {
  display: block;
  background: rgba(78,163,255,0.18);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 700;
  padding: 8px 12px;
  border-bottom: 1px solid var(--accent);
}
.hover-popover table { width: 100%; border-collapse: collapse; }
.hover-popover table td { padding: 6px 12px; border-top: 1px solid var(--border); color: var(--fg); }
.hover-popover table tr:first-child td { border-top: none; }
.hover-popover table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Clickable wholesale customer subrows */
.breakdown tr.sub.clickable { cursor: pointer; }
.breakdown tr.sub.clickable:hover { background: #1f232c; }

/* Section split: table-left + chart-right */
.section-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
}
.section-row > .table-side { flex: 1 1 60%; min-width: 0; }
.section-row > .table-side.wide { flex: 1 1 70%; }
.section-row > .pie-side { flex: 0 0 auto; width: 280px; }

/* Revenue by channel / store: narrower tables. Originally 40% width;
   widened by ~35% (→ 54%) so longer channel labels + amounts fit on one line. */
.section-row.narrow > .table-side { flex: 0 1 54%; }
.section-row.narrow > .pie-side { flex: 1 1 auto; width: auto; max-width: 420px; }

.pie-chart, .bar-chart {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: center;
}
.pie-chart svg, .bar-chart svg { width: 100%; height: auto; max-height: 240px; }

@media (max-width: 900px) {
  .section-row, .section-row.narrow { flex-direction: column; }
  .section-row > .pie-side { width: 100%; max-width: none; align-self: stretch; }
}

/* Pinned tooltip stays open after click */
.hover-host { cursor: pointer; }
.hover-host.pinned .hover-popover { display: block; }

/* QBO line descriptions inline under each payee row */
.payee-descs td { background: rgba(78,163,255,0.04); padding: 4px 12px 6px 18px !important; }
.payee-descs .desc {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  padding: 2px 0;
  line-height: 1.4;
}
.payee-descs .desc > :first-child {
  /* Allow long descriptions to wrap onto multiple lines instead of pushing
     the amount column off the popover. Covers both the plain <span> and the
     QuickBooks deep-link <a>. */
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
}
.payee-descs .desc .num { flex-shrink: 0; white-space: nowrap; }
/* Description that deep-links to the QBO transaction. */
.payee-descs .desc a.desc-qbo { color: var(--accent); text-decoration: none; }
.payee-descs .desc a.desc-qbo:hover { text-decoration: underline; }

/* Section title with an inline action next to it (e.g. Other costs → Refresh).
   Baseline-aligned so the small button sits on the h2's text line. */
.section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.section-refresh { padding: 3px 10px; font-size: 12px; }
.section-refresh-status { font-size: 11px; }
.section-refresh-status.ok  { color: var(--good); font-weight: 700; }
.section-refresh-status.err { color: var(--bad); }

/* Other costs: globally-excluded account rows (persisted). Dimmed, with the
   row toggle (reused from the P&L table) flipped to the "add back" accent. */
.other-costs .pl-row-toggle { margin-right: 6px; vertical-align: baseline; }
.other-costs tr.oc-excluded td { color: var(--muted); }
.other-costs tr.oc-excluded .pl-row-toggle { color: var(--accent); border-color: var(--accent); }
.other-costs tr.oc-excluded .hover-host { opacity: 0.6; }

/* Stores Details table: 9 columns, full width, two-line cells where a single
   metric has a primary + secondary value (e.g. Tips $ on row 1, "% / N #" on
   row 2). */
.stores-details {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
}
.stores-details thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.stores-details thead th.num { text-align: right; }
.stores-details tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.stores-details tbody tr:first-child td { border-top: none; }
.stores-details td.num { text-align: right; font-variant-numeric: tabular-nums; }
.stores-details td:first-child { color: var(--fg); font-weight: 500; }
.stores-details td .muted-small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
/* Faint dash for $0 / null values — keeps the cell visually quiet so the eye
   tracks toward non-zero metrics. */
.stores-details td .zero,
.stores-details td.num > .zero {
  color: var(--muted);
  opacity: 0.5;
}

/* Caret on the right of the channel name (wholesale expandable row). */
.breakdown .caret.caret-right {
  margin-right: 0;
  margin-left: 6px;
}

/* Employee Feedback table — same chrome as Stores Details. Per-rating columns
   get a subtle tinted header so the eye can group counts at a glance. */
.feedback-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
}
.feedback-table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.feedback-table thead th.num { text-align: right; }
.feedback-table thead th.feedback-happy   { color: var(--good); }
.feedback-table thead th.feedback-neutral { color: var(--muted); }
.feedback-table thead th.feedback-sad     { color: var(--bad); }
.feedback-table tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.feedback-table tbody tr:first-child td { border-top: none; }
.feedback-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.feedback-table td:first-child { color: var(--fg); font-weight: 500; }
.feedback-table td .muted-small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
  white-space: normal;
  word-break: break-word;
  max-width: 260px;   /* prevent very long name lists from stretching the column */
  margin-left: auto;
}
.feedback-table td .zero { color: var(--muted); opacity: 0.5; }

/* NYC paper bags — same chrome as Stores Details, but only four narrow columns,
   so it is capped rather than stretched across the full width. */
.bag-fees {
  width: 100%;
  max-width: 520px;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
}
.bag-fees thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.bag-fees thead th.num { text-align: right; }
.bag-fees tbody td { padding: 10px 12px; border-top: 1px solid var(--border); }
.bag-fees tbody tr:first-child td { border-top: none; }
.bag-fees td.num { text-align: right; font-variant-numeric: tabular-nums; }
.bag-fees td:first-child { color: var(--fg); font-weight: 500; }
.bag-fees tr.total-row td { border-top: 1px solid var(--border); background: rgba(255,255,255,0.02); }
.bag-fees td .zero { color: var(--muted); opacity: 0.5; }
/* A zero here is not a quiet empty cell: the bag fee is mandatory, so a store
   that charged none means the register isn't ringing it. Loud on purpose. */
.bag-fees td .bag-zero { color: var(--bad); font-weight: 600; }
.bag-fee-note { color: var(--muted); font-size: 11px; margin: 6px 0 0; }

/* Store losses — what the evening count says the shelves lost (evening counts
   + unexplained material gaps, sourced from the inventory app). Same chrome as
   Stores Details; three columns only, so it is capped rather than stretched.
   Rows nest three deep: store → category → product. */
/* Category columns make this table as wide as the shelf is varied (up to 8
   when the same-day filter is off), so it scrolls inside its own box rather
   than pushing the page sideways. */
.store-losses-scroll { overflow-x: auto; }
.store-losses {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
}
.store-losses thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.store-losses thead th.num { text-align: right; }
.store-losses tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.store-losses td.num { text-align: right; font-variant-numeric: tabular-nums; }
.store-losses tr.loss-store td:first-child { color: var(--fg); font-weight: 600; }
/* The Lost column measures something else than the category columns next to
   it — a rule keeps the eye from adding them up. */
.store-losses th.lost-col, .store-losses td.lost-col { border-left: 1px solid var(--border); }
.store-losses tbody td:first-child { white-space: nowrap; }
.store-losses td .muted-small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.store-losses td .zero { color: var(--muted); opacity: 0.5; }
/* Product level sits one indent deeper than the category (the .indent used by
   the wholesale sub-rows), so the three levels stay readable at a glance. */
.breakdown tr.sub td.indent2 {
  padding-left: 52px;
  color: var(--fg);
  font-size: 13px;
}
/* "keeps" = shelf life over a day: counted at close, then back on the shelf.
   Quiet by design — it qualifies the number, it is not a warning. Shared with
   the product-watch candidate cards (category / store pills). */
.store-losses .loss-tag,
.watch-candidate .loss-tag {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
/* The dollar cost rides beside the count, quieter than it: the unit is the
   measurement, the money is the argument for acting on it. */
.store-losses .loss-usd { color: var(--muted); font-size: 11px; margin-left: 4px; }
/* Second line of a cell: the share of the shelf on the left, the diff against
   the previous period on the right — two different comparisons, so they do not
   sit flush against each other. */
.store-losses .loss-sub { display: flex; justify-content: flex-end; gap: 8px; }
.store-losses .loss-pct { color: var(--muted); }
.store-losses-note { color: var(--muted); font-size: 11px; margin: 6px 0 0; max-width: 720px; }
/* Losses the same-day filter is hiding — stated, never silently dropped. */
.store-losses-note .loss-hidden-note { display: block; margin-top: 3px; color: var(--fg); opacity: 0.75; }
/* The section's own switch sits on the h2's baseline (same chrome as the
   header's Full Access toggle, reused wholesale). */
.store-losses-head .access-toggle { font-size: 12px; }

/* Specials & product watch — same chrome as Store losses on purpose: it
   answers the next question (we lost that much — what do we DO about the
   product?). Rates only; no Per-day toggle, per day by construction. */
.product-watch { min-width: 640px; }
.watch-subhead {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 500;
  margin: 16px 0 0;
}
.watch-new { color: var(--muted); font-size: 11px; font-style: italic; }
/* "None" is a result, not an absence — the operator must see the bar was
   cleared, not wonder whether the section broke. */
.watch-none { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
/* One candidate = one card. The scope badge says where; "all stores" is the
   loud one — a product failing everywhere is a menu decision, not a store
   quirk. */
.watch-candidate {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 8px;
}
.watch-candidate-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.watch-scope {
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}
.watch-scope.all { background: rgba(255,107,107,0.15); color: var(--bad); }
.watch-candidate-line { color: var(--muted); font-size: 12px; margin-top: 4px; }
.watch-candidate-line .watch-strong { color: var(--fg); }
.watch-candidate-line .watch-elsewhere { color: var(--muted); }

/* Prorated rows (Rent & Lease cross-month proration) get a subtle accent
   tint and a small badge so the user knows the displayed amount isn't the
   raw weekly QBO snapshot but a monthly amount × (days-in-week / days-in-month). */
.other-costs tr.prorated td { background: rgba(78,163,255,0.07); }
.other-costs .prorate-badge {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent);
  font-size: 11px;
  cursor: help;
}

/* ─── P&L / Balance Sheet tab ─────────────────────────────────────── */
.pl-tab { margin-top: 24px; }
.pl-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pl-controls select {
  background: var(--card); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px;
}
.pl-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pl-switch button { border: none; border-radius: 0; padding: 6px 14px; font-size: 13px; background: var(--card); color: var(--muted); }
.pl-switch button.active { background: var(--accent); color: #04111f; font-weight: 600; }
.pl-meta { color: var(--muted); font-size: 12px; }
.pl-source-failed { color: var(--bad); font-weight: 600; margin-left: 8px; }

.pl-chart { margin-top: 20px; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px 6px; }
.pl-chart h2 { font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; margin: 0 0 10px; }
/* Cap the chart height so the table below gets usable room (and its sticky
   header is reachable without burying it under a tall chart). */
.pl-chart .chart { max-height: 240px; display: block; margin: 0 auto; }

/* Bounded viewport so the rows scroll inside the table (not the page),
   keeping the sticky column header (thead, position:sticky top:0) and the
   sticky Total/category columns visible while scrolling down a long P&L. */
.pl-scroll { overflow: auto; max-height: calc(100vh - 300px); min-height: 240px;
  margin-top: 16px; border: 1px solid var(--border); border-radius: 10px; }
/* separate (not collapse) so position:sticky works on the thead cells —
   Chrome ignores sticky table headers under border-collapse. */
.pl-table { border-collapse: separate; border-spacing: 0; background: var(--card); font-size: 13px; width: 100%; }
.pl-table th, .pl-table td { padding: 7px 12px; border-top: 1px solid var(--border); white-space: nowrap; }
.pl-table thead th { border-top: none; color: var(--muted); font-weight: 500; font-size: 12px;
  position: sticky; top: 0; background: var(--card); z-index: 2; }
.pl-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pl-table .num.neg { color: var(--bad); }
.pl-table .num.good { color: var(--good); }
.pl-table td:first-child, .pl-table th:first-child {
  position: sticky; left: 0; background: var(--card); z-index: 1;
  width: 280px; min-width: 280px; max-width: 280px;
  overflow: hidden; text-overflow: ellipsis; }
.pl-table thead th:first-child { z-index: 3; }
/* The Total column sticks right after the fixed-width category column, so
   both stay pinned while week columns scroll under them. Backgrounds on
   sticky cells must be OPAQUE — translucent ones let scrolled content bleed
   through. */
.pl-table .total { font-weight: 600; border-right: 1px solid var(--border);
  position: sticky; left: 280px; background: var(--card); z-index: 1; }
.pl-table thead th.total { z-index: 3; }
.pl-table tr.pl-group td { color: var(--muted); text-transform: uppercase; font-size: 11px;
  letter-spacing: 0.05em; padding-top: 12px; }
.pl-table tr.pl-item td:first-child { padding-left: 24px; color: var(--fg); }
.pl-table tr.pl-computed td { font-weight: 700; background: #1e222b; }
.pl-zero { color: var(--border); }

/* Client-side line toggles: drop a COGS/Expense line from the totals + chart
   for an operational view (no persistence). Excluded rows stay visible but
   muted + struck through; the toggle stays bright so it can be clicked back. */
.pl-row-toggle { display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0; margin-right: 8px; vertical-align: middle;
  border: 1px solid var(--border); border-radius: 50%; background: transparent;
  color: var(--muted); font-size: 12px; line-height: 1; cursor: pointer; }
.pl-row-toggle:hover { border-color: var(--accent); color: var(--accent); }
.pl-table tr.pl-excluded td:first-child { color: var(--muted); }
.pl-table tr.pl-excluded td.num { color: var(--muted); }
.pl-table tr.pl-excluded td:not(:first-child) { text-decoration: line-through; }
.pl-table tr.pl-excluded .pl-row-toggle { color: var(--accent); border-color: var(--accent); }

.bs-table { margin-top: 16px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; max-width: 720px; }
.pl-asof { margin-top: 16px; }
.pl-section-title { margin: 32px 0 0; font-size: 15px; font-weight: 600; border-top: 1px solid var(--border); padding-top: 20px; }
.pl-section-title + .pl-asof { margin-top: 6px; }

.pl-unmapped { margin-top: 24px; border: 1px solid var(--bad); border-radius: 10px; padding: 14px 16px; }
.pl-unmapped h2 { font-size: 14px; color: var(--bad); margin: 0 0 4px; }
.pl-unmapped p { font-size: 12px; margin: 0 0 8px; }
.pl-unmapped table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pl-unmapped td { padding: 6px 10px; border-top: 1px solid var(--border); }
.pl-unmapped td.num { text-align: right; font-variant-numeric: tabular-nums; }
.pl-realms { color: var(--muted); font-size: 11px; margin-left: 8px; }
.pl-mapfix { display: inline-flex; gap: 6px; align-items: center; }
.pl-mapfix input {
  background: transparent; border: none; border-bottom: 1px dashed var(--border);
  color: var(--fg); font-size: 12px; padding: 3px 4px; min-width: 240px;
}
.pl-mapfix input:focus { border-bottom: 1px solid var(--accent); outline: none; }
.pl-mapfix button { font-size: 12px; padding: 3px 10px; }

/* Drill-down (transaction detail) */
.pl-table td.clickable, .pl-unmapped td.clickable {
  cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: var(--muted); }
.pl-table td.clickable:hover, .pl-unmapped td.clickable:hover { color: var(--accent); }
/* Week-select: clicking a cell's background highlights its week (no scroll). */
.pl-table td.pl-pick, .pl-table th.pl-pick { cursor: pointer; }
/* The amount inside a cell still drills down (its own click stops propagation). */
.pl-table .pl-cell-amt {
  cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: var(--muted); }
.pl-table .pl-cell-amt:hover { color: var(--accent); }
.pl-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.pl-modal { background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  max-width: min(1680px, 95vw); width: 100%; max-height: 82vh; display: flex; flex-direction: column;
  box-shadow: 0 18px 50px rgba(0,0,0,0.5); }
.pl-modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 8px; }
.pl-modal header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.pl-modal header button { font-size: 20px; line-height: 1; padding: 2px 10px; }
.pl-modal-sub { padding: 0 16px 10px; color: var(--muted); font-size: 12px; }
.pl-modal-error { color: var(--bad); padding: 0 16px 14px; }
.pl-modal-scroll { overflow: auto; padding: 0 16px 16px; }
.pl-modal table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pl-modal th, .pl-modal td { padding: 6px 8px; border-top: 1px solid var(--border);
  text-align: left; white-space: nowrap; }
.pl-modal thead th { position: sticky; top: 0; background: var(--card);
  color: var(--muted); font-weight: 500; border-top: none; z-index: 1; }
.pl-modal td.memo { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.pl-modal .num { text-align: right; font-variant-numeric: tabular-nums; }
.pl-modal .num.neg { color: var(--bad); }
.pl-modal .num.good { color: var(--good); }

/* Internal transfers: ⚠ marks a leg with no same-day counterpart. */
.tr-warn { color: var(--bad); font-weight: 700; margin-right: 4px; }
.tr-ok { color: var(--muted); font-size: 11px; }
.pl-modal tr.tr-unpaired td { background: rgba(238,108,108,0.08); }
.pl-modal tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.pl-modal tr.beginning td { color: var(--muted); font-style: italic; }
.pl-source-skipped { color: var(--muted); margin-left: 8px; }
.pl-error { color: var(--bad); background: rgba(238,108,108,0.08); border: 1px solid var(--bad);
  border-radius: 8px; padding: 8px 12px; margin: 12px 0 0; font-size: 13px; }
.pl-mapfix-err { color: var(--bad); font-weight: 700; margin-left: 4px; }
.pl-att-wrap { width: 210px; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.pl-att-item { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.pl-att-item a { color: var(--accent); text-decoration: none; }
.pl-att-item a:hover { text-decoration: underline; }
.pl-att-dl { font-size: 11px; opacity: 0.8; }
/* Selected week column highlight (synced with the chart bar). Body cells use
   a translucent tint; the sticky header must stay OPAQUE (card+accent blend)
   or scrolling rows show through it. */
.pl-table td.sel { background: rgba(78,163,255,0.12); }
.pl-table tr.pl-computed td.sel { background: rgba(78,163,255,0.18); }
.pl-table thead th.sel { background: #202d3e; color: var(--fg); box-shadow: inset 0 -2px 0 0 var(--accent); }
.pl-modal .pl-amt-link { color: inherit; text-decoration: underline;
  text-decoration-color: rgba(255,255,255,0.28); text-underline-offset: 2px; }
.pl-modal .pl-amt-link:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* Drill-down: header search box + sortable columns */
.pl-modal-hdr-right { display: flex; align-items: center; gap: 10px; }
.pl-modal-search { background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; width: 280px; outline: none; }
.pl-modal-search:focus { border-color: var(--accent); }
.pl-modal th.pl-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.pl-modal th.pl-sortable:hover { color: var(--fg); }
.pl-modal th.pl-sortable.active { color: var(--fg); }
.pl-sort-arrow { font-size: 9px; opacity: 0.5; margin-left: 2px; }
.pl-modal th.pl-sortable.active .pl-sort-arrow { opacity: 1; color: var(--accent); }
