/* Dashboard widgets (Sales, Invoices, Inventory, Labour). Kept apart from styles.css so the
   dashboard can change without touching the shared stylesheet. */
/* Rows stretch, so the two widgets side by side are always the same height; the body grows to fill and the
   footer note sits at the bottom */
.widgets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xl); margin: 0 0 var(--space-2xl); align-items: stretch; }
.widget { display: flex; flex-direction: column; min-width: 0; border-top: 6px solid var(--range); }
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); padding: 12px var(--space-xl) 8px; }
.widget-head h2 { font-size: 20px; font-weight: 800; margin: 0; display: flex; align-items: center; gap: 10px; }
.w-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-control); background: var(--lime-soft); color: var(--range); flex: none; }
.w-open { font-size: var(--text-sm); white-space: nowrap; }
.widget-body { padding: 0 var(--space-xl) var(--space-lg); flex: 1; }
.w-empty { color: var(--muted); font-size: var(--text-sm); line-height: 1.55; padding: 0 var(--space-xl) var(--space-xl); }
.widget-body .w-empty { padding: var(--space-md) 0 0; }
.w-note { padding: 8px var(--space-xl); border-top: 1px dashed var(--crust); color: var(--warn); font-weight: 600; }

.w-figures { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); padding-bottom: var(--space-md); border-bottom: 1px dashed var(--crust); }
.w-figures .label { display: block; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.w-figures b { display: block; font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; margin: 1px 0 2px; }
.w-figures > div > .tiny { display: block; }
.w-sub { margin: var(--space-lg) 0 var(--space-sm); padding-top: var(--space-md); border-top: 1px solid var(--line); font-family: var(--font-heading); font-size: 15px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: var(--space-md); }
.w-figures + .w-sub { border-top: 0; padding-top: 0; }
.w-sub .tiny { font-family: var(--font-body); font-weight: 400; }
.widget .pill-count { font-family: var(--font-body); background: var(--stone); border-radius: 999px; padding: 0 9px; font-size: var(--text-xs); color: var(--stone-ink); font-weight: 700; line-height: 20px; }
.widget .pill-count.warn { background: var(--saffron-soft); color: var(--saffron-dark); }
.w-none { font-size: var(--text-sm); color: var(--muted); }

/* Sales by category: one series, one hue, sorted largest first */
.cat-bars { list-style: none; margin: 0 -6px; padding: 0; display: grid; gap: 2px; }
.cat-bars li { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: var(--space-lg); font-size: var(--text-sm); padding: 2px 6px; border-radius: 6px; }
.cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-track { height: var(--bar-h); background: var(--chart-track); border-radius: 4px; overflow: hidden; }
.cat-bar { display: block; height: 100%; background: var(--chart-1); border-radius: 0 4px 4px 0; }
.cat-val { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; white-space: nowrap; min-width: 108px; }

/* Net sales by day: a column per day of the period, empty days shown as a stub */
.day-cols { position: relative; height: var(--col-h); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; align-items: end; border-bottom: 1px solid var(--chart-zero); }
.day-col { position: relative; height: 100%; display: flex; align-items: flex-end; }
.day-bar { position: relative; display: block; width: 100%; background: var(--chart-1); border-radius: 4px 4px 0 0; }

/* Same day last period, faint, behind this period's bar */
.day-ghost { position: absolute; left: 0; right: 0; bottom: 0; background: var(--crumb); border-radius: 4px 4px 0 0; }

/* Today: a lime slot, the design system's "where you are" */
.day-col.is-today { background: var(--lime-soft); border-radius: 4px 4px 0 0; box-shadow: inset 0 -3px 0 var(--lime-edge); }
.day-col.is-today .day-ghost { background: #D3E6A3; }
.day-today-key { display: inline-flex; align-items: center; gap: 6px; }
.day-today-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--lime); box-shadow: inset 0 -2px 0 var(--lime-edge); }
/* Pace for the period */
.w-pace { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px var(--space-lg); margin-top: var(--space-md); padding: 8px 12px; background: var(--bg); border-radius: var(--radius-control); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.w-pace b { color: var(--ink); }
.day-col.none::after { content: ''; position: relative; display: block; width: 100%; height: 2px; background: var(--crust); }
.day-avg { position: absolute; left: 0; right: 0; border-top: var(--ref-line); pointer-events: none; }
.day-axis { display: flex; justify-content: space-between; margin-top: 4px; }

/* Lists of items (new items, price rises) and grouped costing issues */
.w-list, .w-issues { list-style: none; margin: 0; padding: 0; }
.w-list li { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-lg); padding: 4px 0; border-bottom: 1px solid var(--stone); font-size: var(--text-sm); }
.w-list li > a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.w-list li > .tiny { white-space: nowrap; }
.w-list li.muted, .w-issues li.muted { border: 0; font-size: var(--text-xs); }
.w-issues { margin-top: var(--space-lg); }
.w-issues li { display: flex; align-items: center; gap: var(--space-md); padding: 5px 0; border-bottom: 1px solid var(--stone); font-size: var(--text-sm); }
.w-issue-name { flex: 1; min-width: 0; }
.widget .dash-clear { padding: var(--space-lg) 0 0; }

@media (max-width: 1000px) { .widgets { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .w-figures b { font-size: var(--text-lg); }
  .cat-val { min-width: 0; }
  .cat-bars li { grid-template-columns: minmax(70px, 30%) 1fr auto; gap: var(--space-md); }
  /* New items and price rises: the name on its own line above the supplier, so it isn't cut to "PR…" */
  .w-list li { flex-direction: column; align-items: stretch; gap: 0; }
  .w-list li > .tiny { white-space: normal; }
}

/* Inventory: count status line and the link beside a sub-heading */
.w-sub-link { margin-left: auto; font-family: var(--font-body); font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.w-status { display: flex; align-items: baseline; gap: var(--space-md); font-size: var(--text-sm); color: var(--muted); padding-bottom: var(--space-sm); }
.w-status .badge { flex: none; }
.w-issues:first-child, .w-status + .w-issues { margin-top: var(--space-sm); }

/* COGS %: the 4-period bars with a target marker */
.w-var { font-size: var(--text-sm); }
.w-var > b { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.cost-chart { display: grid; gap: 2px; margin: 0 -6px; }
.cost-row, .cost-axis { display: grid; grid-template-columns: 112px 1fr 120px; align-items: center; gap: var(--space-lg); font-size: var(--text-sm); padding: 2px 6px; border-radius: 6px; }
.cost-label { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cost-track { position: relative; height: var(--bar-h); background: var(--chart-track); border-radius: 4px; }
.cost-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--plate); }
.cost-bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--chart-1); border-radius: 0 4px 4px 0; }
.cost-target { position: absolute; top: -4px; bottom: -4px; width: 0; border-left: var(--ref-line); }
.cost-val { text-align: right; font-size: var(--text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cost-axis { font-size: var(--text-xs); color: var(--muted); }
.cost-axis-track { position: relative; height: 14px; }
.cost-axis-track span { position: absolute; transform: translateX(-50%); font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .cost-row, .cost-axis { grid-template-columns: 92px 1fr 96px; gap: var(--space-md); } }
/* Phone: the period label goes on its own line above its bar, so long dates never run under the bar */
@media (max-width: 480px) { .cost-row, .cost-axis { grid-template-columns: 1fr 96px; row-gap: 2px; } .cost-label { grid-column: 1 / -1; } .cost-axis > span:first-child { display: none; } }
.cost-val b { font-size: var(--text-sm); }

/* Sales: change vs last period, and average net sales by day of week */
.w-vs { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.w-vs.good { color: var(--mint-text); }
.w-vs.bad { color: var(--coral-text); }
.w-vs.flat { color: var(--ink); }
.wk-cols { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.wk-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; padding: 4px 2px; border-radius: 6px; }
.wk-val { font-size: var(--text-xs); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wk-ph { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); font-weight: 600; }
.wk-track { width: 100%; height: var(--col-h); display: flex; align-items: flex-end; border-bottom: 1px solid var(--chart-zero); }
.wk-bar { display: block; width: 100%; background: var(--chart-1); border-radius: 4px 4px 0 0; }


/* Page head: the period picker sits under the title in place of a description */
.dash-period { margin-top: var(--space-md); }

/* Labour: the note about wages under the widget */
.w-foot { padding: 6px var(--space-xl); border-top: 1px dashed var(--crust); }

/* Settings → Notifications (kept here with the dashboard's styles so styles.css stays untouched) */
.notify-lead { margin: 0; padding: 0 var(--space-xl) var(--space-lg); }
.notify-table td { vertical-align: top; }
.notify-table tr.inactive td:not(:first-child) { opacity: .55; }
.notify-person { display: flex; flex-direction: row; align-items: center; gap: 6px; padding: 2px 0; margin: 0; white-space: nowrap; font-weight: 400; }
.notify-table th:last-child { width: 240px; }
.notify-th { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; margin-top: 6px; }
.notify-th input { width: 64px; }
.mail-meta { margin-bottom: 4px; }
.mail-subject { font-weight: 700; margin-bottom: 10px; }
.mail-body { white-space: pre-wrap; font: inherit; font-size: var(--text-sm); line-height: 1.55; background: #F7F9FA; border: 1px solid var(--stone); border-radius: 8px; padding: 14px 16px; margin: 0; max-height: 60vh; overflow: auto; }
.notify-freq-h { width: 170px; }
.notify-day { margin-top: 6px; }
.notify-table select { max-width: 100%; }


/* Sales: over/short line on the daily rec and in the journal entry */
.os-row td { color: var(--bad); font-weight: 600; }
.os-row td .tiny { font-weight: 400; }

/* Invoice review: what to do about an invoice billed to another restaurant */
.billto-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* Settings → Export */
.export-panel { max-width: 760px; }
.export-form { display: grid; gap: var(--space-xl); }
.export-form > label { max-width: 520px; }
.export-desc, .export-form .tiny { display: block; font-weight: 400; margin-top: 4px; }
.export-dates { display: flex; flex-direction: row; align-items: center; gap: 8px; margin-top: 6px; font-weight: 400; }
.export-asof .label { display: block; font-weight: 600; font-size: var(--text-sm); margin-bottom: 4px; }
.export-fmt { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.export-fmt legend { font-weight: 600; font-size: var(--text-sm); margin-bottom: 6px; padding: 0; }
.export-radio { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.export-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-lg); padding: 12px var(--space-xl); border-top: 1px solid var(--stone); }
.export-go { display: flex; gap: 8px; align-items: center; }

/* Export: PDF preview window */
.modal.pdf-dialog { width: min(1100px, 94vw); max-width: none; }
.pdf-preview { height: min(72vh, 820px); border: 1px solid var(--stone); border-radius: 8px; overflow: hidden; background: #525659; }
.pdf-preview iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.pdf-preview-note { margin: 8px 0 0; }

/* ---- Inventory → Variance -------------------------------------------------------------------- */
.vr-panel { margin-bottom: var(--space-xl); }
.vr-panel .up, .vr-table b.up { color: var(--coral-text); }
.vr-panel .down, .vr-table b.down { color: var(--mint-text); }
.vr-none { color: var(--muted); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-md); }
/* Summary tickets: the variance ticket leads, with a coloured band and a bigger figure */
.vr-stats { grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); }
.vr-key-stat .value { font-size: 30px; line-height: 1.15; white-space: nowrap; }
.vr-key-stat.is-over .value { color: var(--coral-text); }
.vr-key-stat.is-under .value { color: var(--mint-text); }
.vr-key-stat .hint { color: var(--ink); }
.vr-pct { font-size: var(--text-sm); font-weight: 700; vertical-align: middle; }
/* Chart beside the action list */
.vr-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: var(--space-xl); align-items: start; }
.vr-grid .vr-panel { margin-bottom: var(--space-xl); }
.vr-chart { display: grid; gap: 10px; }
.vr-row { display: grid; grid-template-columns: minmax(0, 170px) minmax(0, 1fr) 104px; gap: var(--space-lg); align-items: center; font-size: var(--text-sm); }
.vr-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.vr-track { position: relative; height: 14px; background: var(--chart-track); border-radius: 4px; }
.vr-bar { position: absolute; top: 0; bottom: 0; }
.vr-bar.over { background: var(--chart-1); border-radius: 0 4px 4px 0; }
.vr-bar.under { background: var(--chart-zero); border-radius: 4px 0 0 4px; }
.vr-zero { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--chart-zero); border-radius: 2px; }
.vr-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vr-key { margin-top: 2px; }
.vr-key-labels { display: flex; justify-content: space-between; font-size: var(--text-xs); color: var(--muted); }
.vr-acts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-md); }
.vr-act { border: 1px solid var(--line); border-left: 4px solid var(--coral-bar); border-radius: var(--radius-control); padding: 10px 12px; }
.vr-act.under { border-left-color: var(--mint-bar); }
.vr-act-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-md); }
.vr-act-head a { min-width: 0; overflow-wrap: anywhere; }
.vr-act-fig { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vr-act-cause { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.vr-act p { margin: 6px 0 0; color: var(--ink); line-height: 1.5; text-wrap: pretty; }
/* Last 4 periods */
.vr-trend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.vr-tp { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: var(--space-lg); min-width: 0; border-right: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.vr-tp:last-child { border-right: 0; }
.vr-tp.is-now { background: var(--lime-soft); }
.vr-tp-label { font-size: var(--text-xs); font-weight: 700; color: var(--muted); }
.vr-tp.is-now .vr-tp-label { color: var(--ink); }
.vr-tp-col { display: flex; align-items: flex-end; height: 64px; width: 100%; border-bottom: 2px solid var(--chart-zero); }
.vr-tp-bar { display: block; width: 28px; border-radius: 4px 4px 0 0; }
.vr-tp-bar.over { background: var(--chart-1); }
.vr-tp-bar.under { background: var(--chart-zero); }
.vr-tp b { font-size: var(--text-md); }
.vr-move { font-weight: 700; font-variant-numeric: tabular-nums; }
.vr-col { min-width: 0; }
/* Every item */
.vr-chip-n { font-variant-numeric: tabular-nums; opacity: .7; margin-left: 2px; }
.vr-table .vr-q { color: var(--muted); }
.vr-table tr.vr-tr-ok td { color: var(--muted); }
.vr-table tr.vr-tr-ok td a { color: var(--ink); }
.vr-missing { margin: var(--space-lg) var(--space-xl); background: var(--butter-wash); border-left: 4px solid var(--butter-bar); border-radius: var(--radius-control); padding: 10px 14px; font-size: var(--text-sm); }
.vr-more > summary { padding: 14px var(--space-xl); cursor: pointer; font-weight: 700; }
.vr-more[open] > summary { border-bottom: 1px solid var(--line); }
@media (max-width: 1100px) { .vr-grid { grid-template-columns: minmax(0, 1fr); gap: 0; } }
@media (max-width: 760px) {
  .vr-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vr-key-stat, .vr-stats > .stat:last-child { grid-column: 1 / -1; }
  .vr-row { grid-template-columns: minmax(0, 1fr) 96px; row-gap: 4px; }
  .vr-name { grid-column: 1 / -1; }
  .vr-key > span:first-child { display: none; }
  .vr-trend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vr-tp:nth-child(2) { border-right: 0; }
  .vr-tp:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .vr-tp { padding: var(--space-lg); }
}

/* ---- Dashboard header: period progress ------------------------------------- */
.dash-period { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-lg) var(--space-xl); }
.dash-progress { display: inline-flex; align-items: center; gap: var(--space-md); font-size: var(--text-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.dash-progress b { color: var(--ink); }
.dash-progress-track { width: 120px; height: 6px; background: var(--chart-track); border-radius: 4px; overflow: hidden; }
.dash-progress-track span { display: block; height: 100%; background: var(--range); border-radius: 4px; }
@media (max-width: 760px) {
  .dash-progress-track { width: 80px; }
}

/* ---- One chart family for the whole Dashboard ------------------------------------------------------
   Bars: 10px horizontal tracks, 64px columns, 4px rounded data ends on the baseline, 2px gaps.
   Reference lines (daily average, COGS target): 2px dashed. Hover: the row or column gets a light wash and
   the shared dark tooltip; marks themselves don't change colour. */
.widgets { --bar-h: 10px; --col-h: 64px; --ref-line: 2px dashed var(--chart-2); }
.cat-bars li:hover, .cost-row:hover, .wk-col:hover { background: var(--bg); }
.day-col:hover:not(.is-today) { background: var(--bg); border-radius: 4px 4px 0 0; }
.day-col:hover .day-bar { filter: brightness(1.35); }
.chart-tip { position: fixed; left: 0; top: 0; z-index: var(--z-toast); max-width: 280px; padding: 6px 10px; background: var(--range); color: #fff; font-size: var(--text-xs); line-height: 1.45; border-radius: var(--radius-control); box-shadow: var(--shadow-overlay); pointer-events: none; font-variant-numeric: tabular-nums; }
.chart-tip[hidden] { display: none; }
@media (max-width: 1000px) { .widgets { grid-template-columns: minmax(0, 1fr); } }

/* Rows a fitting list has hidden (display rules on the rows would otherwise override [hidden]) */
.widget li[hidden] { display: none; }
.w-more a { font-weight: 600; }

/* Inventory widget: one line per type of issue */
.w-types li { padding: 5px 0; }
.w-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Inventory → Checks ------------------------------------------------------------------------ */
.ck-bar { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-md) var(--space-xl); margin-bottom: var(--space-xl); }
.ck-filter { font-size: var(--text-sm); display: inline-flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; }
.ck-h { display: flex; align-items: baseline; gap: var(--space-md); flex-wrap: wrap; font-size: 18px; margin: var(--space-xl) 0 var(--space-md); }
.ck-status { margin-bottom: var(--space-md); }
.ck-group { margin-bottom: var(--space-lg); scroll-margin-top: 76px; }
.ck-group .panel-head { padding: 10px var(--space-xl); }
.ck-group .ck-gh { display: flex; align-items: center; gap: var(--space-md); margin: 0; font-size: 15px; }
.ck-list { list-style: none; margin: 0; padding: 0; }
.ck-list li { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px var(--space-lg); padding: 8px var(--space-xl); border-top: 1px solid var(--stone); font-size: var(--text-sm); }
.ck-list li:first-child { border-top: 0; }
.ck-list li a { min-width: 0; overflow-wrap: anywhere; }
.ck-why { color: var(--muted); flex: 1; min-width: 200px; }
.ck-clear { display: flex; align-items: center; gap: var(--space-md); padding: 12px var(--space-xl); font-size: var(--text-sm); color: var(--muted); }
@media (max-width: 760px) { .ck-list li { flex-direction: column; gap: 2px; } .ck-why { min-width: 0; } }

/* Checks popup */
.ck-pop .ck-bar { margin-bottom: var(--space-md); }
.ck-pop .ck-h:first-of-type { margin-top: var(--space-md); }
.ck-pop .ck-group { box-shadow: none; }

/* Labour: hours and sales per labour hour, under labour cost and labour % */
.w-hours { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px var(--space-lg); margin-top: var(--space-md); padding: 8px 12px; background: var(--bg); border-radius: var(--radius-control); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.w-hours > span { display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }

/* Variance colours follow the Dashboard (2026-11-28): ink bars for used more, grey for used less; red and
   green only in the signed ▲/▼ figures and the 4px card bands, so the page isn't a wall of red and green */
