/* CoPos Dashboard styles -- editorial operations.
 *
 * Direction: calm, dense where it needs to be, generous around headline numbers.
 * - Newsreader serif for page headlines (Google Fonts)
 * - System sans for body and UI chrome
 * - Tabular numerals everywhere a number lives in a tile or table
 * - Green for "up" comparisons, deep violet for "down" -- intentional escape
 *   from the green/red traffic-light cliche
 */

:root {
  /* Calibrated to the rendered .topbar height (padding 0.6rem + ~1rem line). */
  --topbar-height: 2.5rem;

  --coop-green:        #2B5E3A;
  --coop-green-dark:   #1f4429;
  --coop-green-soft:   #eaf3ed;
  --down-purple:       #7c3aed;
  --down-purple-soft:  #f3eafe;

  --bg:        #f6f7f5;
  --panel:     #ffffff;
  --panel-2:   #fbfbf9;
  --ink:       #1c2421;
  --ink-muted: #6a736d;
  --ink-faint: #9aa29c;
  --border:    #dce0d9;
  --border-strong: #b9bfb6;

  --error-bg:     #fdecec;
  --error-fg:     #8a1f1f;
  --error-border: #f0c2c2;
  --flash-bg:     #eaf3ed;
  --flash-fg:     #1f4429;

  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
          Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--coop-green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ----------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  background: var(--coop-green);
  color: #fff;
  padding: 0.6rem 1.25rem;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand { font-weight: 600; font-size: 1rem; letter-spacing: 0.01em; color: inherit; text-decoration: none; }
.brand:hover { text-decoration: underline; }

.primary-nav {
  display: flex;
  gap: 0.15rem;
  flex: 1 1 auto;
  overflow: visible;
}
.primary-nav a {
  color: rgba(255, 255, 255, 0.92);
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.92rem;
  white-space: nowrap;
  transition: background 0.12s ease;
}
.primary-nav a:hover { background: rgba(255, 255, 255, 0.12); text-decoration: none; }
.primary-nav a.active { background: rgba(255, 255, 255, 0.18); font-weight: 500; }
.primary-nav a.disabled { color: rgba(255, 255, 255, 0.55); cursor: not-allowed; }
.primary-nav a.disabled:hover { background: transparent; }

.userbar { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.username {
  opacity: 0.85;
  color: #fff;
  text-decoration: none;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  transition: background 0.12s ease;
}
a.username:hover { background: rgba(255,255,255,0.12); text-decoration: none; opacity: 1; }
.logout-form { margin: 0; }
.logout-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s ease;
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.22); }

/* ---------- Layout ------------------------------------------------------ */

.content { max-width: 1180px; margin: 1.5rem auto; padding: 0 1.25rem; }
.subtle  { color: var(--ink-muted); }
.dot     { color: var(--ink-faint); margin: 0 0.5em; }

.back-link { margin: 0 0 0.65rem 0; font-size: 0.85rem; }
.back-link a { color: var(--ink-muted); text-decoration: none; }
.back-link a:hover { text-decoration: underline; color: var(--ink); }

/* Sortable tables — JS adds .th-sortable to any column that opted in.
   Sticky thead clears the global topbar; z-index below the topbar's 100. */
.sortable-table thead th {
  position: sticky;
  top: var(--topbar-height);
  background: #fafafa;
  z-index: 5;
}
.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { background: #f0f0e8; }
.sort-arrow { font-size: 0.75em; color: var(--ink-muted); }

.data-sync-footer {
  max-width: 1180px;
  margin: 2.5rem auto 1.25rem auto;
  padding: 0 1.25rem;
  color: var(--ink-faint);
  font-size: 0.75rem;
  text-align: center;
}

.settings-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
  max-width: 760px;
  margin-top: 0.5rem;
}
.settings-tile {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.settings-tile:hover { border-color: var(--ink-muted); background: var(--surface-hover, #fafafa); }
.settings-tile h3 { margin: 0 0 0.2rem 0; font-size: 1rem; font-weight: 600; }
.settings-tile p  { margin: 0; font-size: 0.85rem; }

.notif-form .panel { margin-bottom: 1rem; }
.notif-table { width: 100%; border-collapse: collapse; }
.notif-table th, .notif-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  text-align: left;
}
.notif-table th { font-weight: 600; font-size: 0.85rem; color: var(--ink-muted); }
.notif-table tr:last-child td { border-bottom: none; }
.notif-toggle-cell { width: 4.5rem; text-align: center !important; }
.notif-name { font-weight: 500; }
.notif-desc { font-size: 0.82rem; margin-top: 0.15rem; }
.notif-table input[type="checkbox"]:disabled { opacity: 0.4; cursor: not-allowed; }

/* /returns "Items returned" cell — one stacked line per return_line row. */
.returns-items-cell { font-size: 0.88rem; max-width: 32rem; }
.return-item-line { line-height: 1.35; padding: 0.05rem 0; }
.return-item-qty  { font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.return-item-name { font-weight: 500; }

/* ---------- Recap header ------------------------------------------------ */

.recap-header { margin: 0.5rem 0 1.25rem 0; }
.recap-header h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 0.35rem 0;
  color: var(--ink);
}
.recap-header .recap-day {
  color: var(--coop-green-dark);
  font-style: italic;
  font-weight: 500;
}
.recap-subtitle { margin: 0; color: var(--ink-muted); font-size: 0.95rem; }

/* ---------- Date picker (Daily page) ----------------------------------- */

.date-picker-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1rem 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  width: fit-content;
}
.date-picker-form label { color: var(--ink-muted); }
.date-picker-form input[type="date"] {
  font: inherit;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.date-picker-form button {
  font: inherit;
  background: var(--coop-green);
  color: #fff;
  border: none;
  padding: 0.3rem 0.85rem;
  border-radius: 4px;
  cursor: pointer;
}
.date-picker-form button:hover { background: var(--coop-green-dark); }

/* Daily-page navigation row: prev arrow | date picker | next arrow */
.daily-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1rem 0;
}
.daily-nav .date-picker-form { margin: 0; }
.daily-nav .trend-nav-btn { margin-top: 0; }

/* Inline pill shown beside the recap subtitle to clarify which day is shown */
.label-pill {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--coop-green-soft);
  color: var(--coop-green-dark);
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: 0.1em;
}
.label-pill-muted {
  background: #eef0ed;
  color: var(--ink-muted);
}

/* Holiday pills appear next to dates in trend tables and the daily
   header. Color-coded by category to match the chart annotation
   plugin in trend-charts.js (federal=green, retail=purple, eve=gray,
   custom=amber). Smaller and softer than the primary label-pill since
   it's metadata, not a state indicator. */
.holiday-pill {
  display: inline-block;
  margin-left: 0.35em;
  padding: 0.02rem 0.45rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  vertical-align: 0.08em;
  white-space: nowrap;
  font-family: var(--sans);
  text-transform: none;
  background: #eef0ed;
  color: var(--ink-muted);
  border: 1px solid transparent;
}
.holiday-federal { background: var(--coop-green-soft);  color: var(--coop-green-dark); }
.holiday-retail  { background: var(--down-purple-soft); color: var(--down-purple);    }
.holiday-eve     { background: #f4f3ee;                  color: #8a7a4a;               }
.holiday-custom  { background: #fef3c7;                  color: #b45309;               }

/* ---------- Holidays admin page ---------------------------------------- */

.holiday-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  font-size: 0.9rem;
}
.holiday-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.holiday-form label.grow { flex: 1 1 180px; }
.holiday-form label > span { font-size: 0.78rem; color: var(--ink-muted); }
.holiday-form input[type="date"],
.holiday-form input[type="text"],
.holiday-form select {
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.holiday-form input:focus,
.holiday-form select:focus {
  outline: 2px solid var(--coop-green);
  outline-offset: -1px;
  border-color: var(--coop-green);
}
.holiday-form button {
  font: inherit;
  background: var(--coop-green);
  color: #fff;
  border: none;
  padding: 0.5rem 0.95rem;
  border-radius: 4px;
  cursor: pointer;
}
.holiday-form button:hover { background: var(--coop-green-dark); }

.holidays-table td { vertical-align: middle; }
.holidays-table .actions-cell { white-space: nowrap; }
.holidays-table input[type="date"],
.holidays-table input[type="text"],
.holidays-table select {
  font: inherit;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
  width: 100%;
  box-sizing: border-box;
}
.row-editing { background: var(--coop-green-soft); }

.inline-form { display: inline; margin: 0; }
.btn-link, .btn-link-cancel {
  background: transparent;
  border: 0;
  color: var(--coop-green);
  padding: 0.25rem 0.45rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: none;
}
.btn-link:hover, .btn-link-cancel:hover { text-decoration: underline; }
.btn-link-danger {
  background: transparent;
  border: 0;
  color: var(--down-purple);
  padding: 0.25rem 0.45rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-link-danger:hover { text-decoration: underline; }
.btn-primary {
  background: var(--coop-green);
  color: #fff;
  border: 0;
  padding: 0.3rem 0.7rem;
  border-radius: 3px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn-primary:hover { background: var(--coop-green-dark); }

/* ---------- Comparison toggle ------------------------------------------ */

.compare-toggle {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin: 0 0 0.6rem 0;
  gap: 2px;
}
.compare-pill {
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  color: var(--ink-muted);
  white-space: nowrap;
}
.compare-pill:hover { color: var(--ink); text-decoration: none; }
.compare-pill.active {
  background: var(--coop-green);
  color: #fff;
  font-weight: 500;
}
.compare-pill.active:hover { color: #fff; }
.compare-target-line {
  font-size: 0.85rem;
  color: var(--ink-muted);
  margin: 0 0 1.25rem 0;
}
.compare-target-line strong { color: var(--ink); font-weight: 500; }

/* Secondary toggle row (chart-only controls, e.g. align by weekday) sits
   under the comparison-target line. Slightly de-emphasized to keep the
   primary comparison choice dominant. */
.compare-toggle-sub { margin-top: 0; }
.compare-toggle-sub .compare-pill { font-size: 0.78rem; }

/* ---------- Metric tile grid ------------------------------------------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 2rem 0;
}

.metric {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.15rem 1.05rem 1.15rem;
  color: inherit;
  transition: border-color 0.12s ease, transform 0.12s ease,
              box-shadow 0.12s ease;
}
.metric:hover {
  border-color: var(--border-strong);
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02), 0 4px 12px rgba(0, 0, 0, 0.04);
}

.metric-label {
  color: var(--ink-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.metric-value {
  font-family: var(--sans);
  font-size: 1.85rem;
  font-weight: 600;
  margin-top: 0.35rem;
  color: var(--coop-green-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}
.metric-delta {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
}
.metric-delta .arrow { font-size: 0.7em; }
.delta-up   { background: var(--coop-green-soft); color: var(--coop-green-dark); }
.delta-down { background: var(--down-purple-soft); color: var(--down-purple); }
.delta-flat { background: #eef0ed; color: var(--ink-muted); }
.delta-none { background: transparent; color: var(--ink-faint); padding-left: 0; }

/* Comparison value + date shown under the delta. Smaller and dimmer than
   the % chip so the delta stays the dominant secondary signal. */
.metric-compare {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.metric-compare-date {
  opacity: 0.85;
  white-space: nowrap;
}

/* ---------- Breakdown panels ------------------------------------------- */

.breakdowns {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.15rem 1.25rem;
}
.panel h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.1rem;
  margin: 0 0 0.85rem 0;
  letter-spacing: -0.005em;
  color: var(--ink);
}

/* Department table */
.dept-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.dept-table thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  font-weight: 500;
  padding: 0.35rem 0.5rem 0.45rem 0;
  border-bottom: 1px solid var(--border);
  /* Stick the header to the top of the nearest scrolling ancestor.
     For long item lists that's the viewport; inside .day-scroll or
     the modal it sticks to the inner scroll container instead. The
     solid background is needed so body rows don't show through. */
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.dept-table thead th.num { text-align: right; padding-right: 0; }
.dept-table thead th.cell-center,
.dept-table td.cell-center { text-align: center; }
.dept-table tbody td {
  padding: 0.45rem 0.5rem 0.45rem 0;
  border-bottom: 1px solid #eef0ec;
  font-variant-numeric: tabular-nums;
}
.dept-table tbody tr:last-child td { border-bottom: none; }
.dept-table td.num { text-align: right; padding-right: 0; }
/* A .num cell hugs its right edge (padding-right:0); the next column
   defaults to padding-left:0. When a numeric column is followed by a
   non-numeric column mid-table (e.g. activity page "Active days" →
   "Last seen"), the two cells visually collide. Restore the gap. */
.dept-table thead th.num + th,
.dept-table tbody td.num + td { padding-left: 0.5rem; }

/* ---------- Secondary metric tiles ------------------------------------- */

/* Sits directly below the headline grid, visually de-emphasized so the
   primary tiles stay dominant. Non-clickable (no destination route). */
.metric-grid-secondary {
  margin-top: -0.6rem;        /* pull closer to the headline row above */
  margin-bottom: 1.5rem;
}
.metric-grid-secondary .metric {
  padding: 0.8rem 1rem 0.85rem 1rem;
  background: var(--panel-2);
}
.metric-grid-secondary .metric-value { font-size: 1.35rem; }
.metric-static { cursor: default; }
.metric-static:hover { border-color: var(--border); }

/* ---------- Money-flow waterfall --------------------------------------- */

.money-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin: 0 0 1rem 0;
}
.flow-step {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  min-width: 90px;
}
.flow-step.flow-op-minus { background: var(--down-purple-soft); }
.flow-step.flow-op-plus  { background: var(--coop-green-soft); }
.flow-step.flow-op-eq    { background: transparent; }
.flow-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.flow-amount {
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.flow-op-minus .flow-amount { color: var(--down-purple); }
.flow-op-plus  .flow-amount { color: var(--coop-green-dark); }
.flow-arrow {
  color: var(--ink-faint);
  font-size: 1.1rem;
}

/* ---------- Tender mix bar ---------------------------------------------- */

.share-bar-wrap {
  position: relative;
  display: inline-block;
  min-width: 90px;
  width: 100%;
  background: #eef0ec;
  border-radius: 3px;
  height: 1.05rem;
  overflow: hidden;
}
.share-bar {
  background: var(--coop-green);
  height: 100%;
  border-radius: 3px;
  opacity: 0.78;
}
.share-bar-label {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  mix-blend-mode: multiply;
}
.tender-table td.num { vertical-align: middle; }
/* Breathing room between the right-aligned dollar amount and the start of
   the share bar in the next column, so the two readings don't visually
   collide. */
.tender-table td:nth-child(2) { padding-right: 0.9rem; }

/* ---------- Store credit & loyalty (kv list) ---------------------------- */

.kv-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  margin: 0;
  font-size: 0.92rem;
}
.kv-grid dt {
  color: var(--ink-muted);
}
.kv-grid dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.kv-grid .kv-divider { border-top: 1px solid var(--border); padding-top: 0.5rem; }
.kv-grid .kv-divider + dd.kv-divider { border-top: 1px solid var(--border); padding-top: 0.5rem; }
.kv-hint {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  margin-left: 0.3rem;
}
.kv-grid dd.delta-up   { color: var(--coop-green-dark); }
.kv-grid dd.delta-down { color: var(--down-purple); }

/* Hourly chart sits inside a fixed-height wrapper so Chart.js can be
   responsive without growing without bound. Tall enough that axis tick
   labels don't get vertically crushed when Chart.js auto-fits. */
.panel canvas { display: block; width: 100% !important; height: 280px !important; }

/* ---------- Empty state ------------------------------------------------ */

.empty-state {
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 2rem 1.5rem;
  text-align: center;
}
.empty-state p { margin: 0 0 0.5rem 0; }

/* ---------- Login ------------------------------------------------------ */

.login-card {
  max-width: 380px;
  margin: 4rem auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2rem 1.75rem;
}
.login-card h1 {
  font-family: var(--serif);
  font-weight: 500;
  margin: 0 0 0.25rem 0;
  font-size: 1.6rem;
}
.login-card .subtitle { color: var(--ink-muted); margin: 0 0 1.5rem 0; }
.login-form { display: flex; flex-direction: column; gap: 0.9rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.25rem; }
.login-form label > span { font-size: 0.85rem; color: var(--ink-muted); }
.login-form input {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.login-form input:focus {
  outline: 2px solid var(--coop-green);
  outline-offset: -1px;
  border-color: var(--coop-green);
}
.login-form button {
  background: var(--coop-green);
  color: #fff;
  border: none;
  padding: 0.65rem;
  border-radius: 4px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}
.login-form button:hover { background: var(--coop-green-dark); }

/* ---------- Misc ------------------------------------------------------- */

.error {
  background: var(--error-bg); color: var(--error-fg);
  border: 1px solid var(--error-border);
  border-radius: 4px;
  padding: 0.55rem 0.75rem;
  margin: 0.5rem 0 1rem 0;
  font-size: 0.9rem;
}
.flashes { margin-bottom: 1rem; }
.flash {
  background: var(--flash-bg); color: var(--flash-fg);
  border: 1px solid var(--coop-green);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}
code {
  background: #eef0ed;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.9em;
}

/* ---------- Mobile ----------------------------------------------------- */

@media (max-width: 800px) {
  .breakdowns { grid-template-columns: 1fr; }
  .metric-value { font-size: 1.55rem; }
}
@media (max-width: 700px) {
  .recap-header h1 { font-size: 1.7rem; }
}

/* ---------- Hamburger toggle (visible only on mobile) ------------------ */

/* Hidden input drives the drawer state via :checked sibling combinator —
   no JS needed for the open/close toggle. */
.nav-toggle-input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.nav-hamburger {
  display: none;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.92);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  border-radius: 4px;
  margin-left: auto;
  user-select: none;
}
.nav-hamburger:hover { background: rgba(255, 255, 255, 0.12); }
.nav-toggle-input:focus-visible + .nav-hamburger {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}
/* Visual feedback: highlight the hamburger when the drawer is open */
.nav-toggle-input:checked ~ .nav-hamburger {
  background: rgba(255, 255, 255, 0.25);
}


/* ---------- Upload page ------------------------------------------------ */

.upload-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  max-width: 720px;
}

.upload-banner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--coop-green);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  max-width: 720px;
}
.upload-banner-warning {
  border-left-color: var(--down-purple);
  background: var(--down-purple-soft);
  color: var(--ink);
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 2.5rem 1rem;
  border: 2px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  text-align: center;
}
.drop-zone:hover,
.drop-zone-hover {
  background: var(--coop-green-soft);
  border-color: var(--coop-green);
}
.drop-zone-icon {
  font-size: 2.4rem;
  line-height: 1;
  color: var(--coop-green);
  margin-bottom: 0.25rem;
}
.drop-zone-primary {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--ink);
}
.drop-zone-secondary {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.file-summary {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

#submit-btn {
  margin-top: 1rem;
  width: 100%;
  background: var(--coop-green);
  color: #fff;
  border: none;
  padding: 0.75rem;
  border-radius: 4px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease;
}
#submit-btn:hover:not(:disabled) { background: var(--coop-green-dark); }
#submit-btn:disabled {
  background: #cdd2cc;
  color: #fff;
  cursor: not-allowed;
}

#progress-area {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  font-variant-numeric: tabular-nums;
}
.progress-track {
  height: 8px;
  background: #eef0ed;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--coop-green);
  width: 0%;
  transition: width 0.15s ease;
}
.progress-bar-indeterminate {
  width: 100% !important;
  background: linear-gradient(90deg,
    var(--coop-green-soft) 0%,
    var(--coop-green) 40%,
    var(--coop-green) 60%,
    var(--coop-green-soft) 100%);
  background-size: 200% 100%;
  animation: progress-slide 1.4s linear infinite;
}
@keyframes progress-slide {
  from { background-position: 100% 0; }
  to   { background-position: -100% 0; }
}
#progress-elapsed {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.result-banner {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 4px;
  font-size: 0.92rem;
}
.result-success {
  background: var(--coop-green-soft);
  border: 1px solid var(--coop-green);
  color: var(--coop-green-dark);
}
.result-error {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: var(--error-fg);
}
.result-banner .btn-link {
  display: inline-block;
  margin-left: 0.6rem;
  padding: 0.2rem 0.6rem;
  background: var(--coop-green);
  color: #fff;
  border-radius: 3px;
  text-decoration: none;
}
.result-banner .btn-link:hover { background: var(--coop-green-dark); text-decoration: none; }

.log-details { margin-top: 0.6rem; }
.log-details summary { cursor: pointer; font-size: 0.85rem; color: var(--ink-muted); }
.log-tail {
  margin-top: 0.5rem;
  background: #1c2421;
  color: #e8ebe6;
  padding: 0.7rem 0.85rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.78rem;
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 280px;
  overflow-y: auto;
}

.upload-tips {
  margin-top: 1.5rem;
  max-width: 720px;
  font-size: 0.9rem;
  color: var(--ink-muted);
}
.upload-tips h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.05rem;
  margin: 0 0 0.5rem 0;
  color: var(--ink);
}
.upload-tips ul { margin: 0; padding-left: 1.25rem; }
.upload-tips li { margin: 0.25rem 0; }

/* ---------- Trend pages (Weekly / Monthly / Annual) -------------------- */

.trend-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0.5rem 0 1.25rem 0;
}
.trend-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.01em;
  flex: 1;
}
.trend-subtitle {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 400;
  color: var(--ink-muted);
  margin-left: 0.5rem;
}
.trend-nav-arrow {
  font-size: 1.3rem;
  color: var(--coop-green);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}
.trend-nav-arrow:hover { background: var(--coop-green-soft); text-decoration: none; }
.trend-nav-arrow.disabled { color: var(--ink-faint); pointer-events: none; }

/* Wide panel that spans the full breakdowns grid */
.panel-wide {
  grid-column: 1 / -1;
}
.panel canvas {
  display: block;
  width: 100% !important;
  height: 300px !important;
}
.panel-wide canvas {
  height: 340px !important;
}

/* Year jump strip on /annual */
.year-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 1rem 0;
}

/* Legend dots next to chart titles */
.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 4px 0 10px;
  vertical-align: middle;
}

/* Inline legend used in chart panel titles. Replaces Chart.js's own
   legend (which collided with rotated holiday-marker labels above the
   plot area). Each .legend-tag is a series name preceded by a small
   colored swatch keyed to the same colors used by the chart's
   datasets. */
.legend-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink);
  white-space: nowrap;
  margin: 0 0.15rem;
}
.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.swatch-current { background: var(--coop-green); }
.swatch-prior   { background: var(--down-purple-soft); border: 1px solid var(--down-purple); }
.swatch-net     { background: var(--coop-green); }
.swatch-avg {
  background: transparent;
  border: 0;
  width: 18px;
  height: 2px;
  border-top: 2px dashed var(--down-purple);
  border-radius: 0;
}

/* Table row states */
.row-no-data td { color: var(--ink-faint); }
.row-total td { border-top: 2px solid var(--border); padding-top: 0.5rem; }

/* Scrollable day-by-day table on monthly page */
.day-scroll { max-height: 420px; overflow-y: auto; }
.day-scroll .dept-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

@media (max-width: 800px) {
  .trend-title { font-size: 1.5rem; }
  .year-jump { gap: 3px; }
}

/* ---------- Trend pages (weekly / monthly / annual) -------------------- */

.trend-nav {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.25rem;
}
.trend-nav h1 { margin: 0; }
.trend-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-top: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
  font-size: 1rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.trend-nav-btn:hover { background: var(--coop-green-soft); border-color: var(--coop-green); text-decoration: none; }
.trend-nav-disabled { color: var(--ink-faint); pointer-events: none; }
.trend-nav-disabled:hover { background: var(--panel); border-color: var(--border); }

.panel-wide {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.15rem 1.25rem;
  margin: 0 0 1rem 0;
}
.panel-wide h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.1rem;
  margin: 0 0 0.85rem 0;
  color: var(--ink);
}
.panel-wide canvas { display: block; width: 100% !important; }

.totals-row td { border-top: 2px solid var(--border) !important; padding-top: 0.55rem; }

/* ---------- Clickable item rows ---------------------------------------- */

[data-clickable-rows] tbody tr {
  cursor: pointer;
  transition: background-color 0.1s ease;
}
[data-clickable-rows] tbody tr:hover,
[data-clickable-rows] tbody tr:focus {
  background-color: var(--coop-green-soft);
  outline: none;
}

/* ---------- Modal dialog (item detail) --------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 28, 24, 0.55);
}
.modal-panel {
  position: relative;
  z-index: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-width: 720px;
  width: calc(100% - 2rem);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal-body { padding: 1.5rem 1.75rem 1.75rem; }
.modal-close {
  position: absolute;
  top: 0.55rem;
  right: 0.85rem;
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.modal-close:hover { color: var(--ink); }
.modal-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.45rem;
  margin: 0 2.2rem 0.2rem 0;
  color: var(--ink);
}
.modal-subtitle { margin: 0 0 1.2rem 0; font-size: 0.85rem; }
.modal-section-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 1.5rem 0 0.6rem 0;
}
.modal-grid {
  display: grid;
  grid-template-columns: max-content 1fr max-content 1fr;
  column-gap: 1.2rem;
  row-gap: 0.45rem;
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
}
.modal-grid dt {
  color: var(--ink-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  align-self: center;
}
.modal-grid dd { margin: 0; align-self: center; }
.modal-trend-table { width: 100%; font-size: 0.85rem; }
.modal-trend-table th { font-size: 0.72rem; }

/* ---------- Sparklines ------------------------------------------------- */
.spark {
  display: inline-block;
  vertical-align: middle;
  color: var(--coop-green);
}
.spark-line {
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  fill: none;
}
.spark-dot { fill: currentColor; stroke: none; }
.spark-line-partial {
  stroke-dasharray: 3 2.5;
  opacity: 0.45;
}
.spark-dot-partial {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  opacity: 0.55;
}
.spark-baseline {
  stroke: var(--ink-faint);
  stroke-width: 1;
  stroke-dasharray: 2 2;
}
.spark-empty {
  color: var(--ink-faint);
  font-size: 0.85rem;
  font-style: italic;
}

/* Sparkline inside a table cell column */
.spark-col { width: 96px; }
.dept-table thead th.spark-col { text-align: center; }
.spark-cell {
  text-align: center;
  line-height: 0;
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
  color: var(--coop-green);
}

/* Big sparkline above the modal trend tables — stretches to container */
.modal-spark {
  margin: 0.3rem 0 0.6rem 0;
  line-height: 0;
  color: var(--coop-green);
}
.modal-spark .spark { width: 100%; height: 36px; display: block; }

/* Sparkline inside a metric tile (weekly top) */
.metric-spark {
  margin-top: 0.55rem;
  line-height: 0;
  color: var(--coop-green);
}
.metric-spark .spark { display: block; }

body.modal-open { overflow: hidden; }

@media (max-width: 700px) {
  .modal-grid { grid-template-columns: max-content 1fr; }
  .modal-body { padding: 1.2rem 1.1rem 1.4rem; }
  .modal-title { font-size: 1.2rem; }
}
.row-closed td { color: var(--ink-faint); font-style: italic; }

.year-jump {
  margin-top: 1rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.year-jump a {
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.year-jump a:hover { background: var(--coop-green-soft); border-color: var(--coop-green); text-decoration: none; }
.year-active {
  padding: 0.2rem 0.55rem;
  background: var(--coop-green);
  color: #fff;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Mobile nav (max-width: 768px) ------------------------------ */
/* Switch to a hamburger drawer below 768px. Bumped from 600px because
   between 600-768 the inline desktop nav overflowed the topbar width and
   pushed Tools/Roadmap off-screen on phones held in portrait. */

@media (max-width: 768px) {

  .topbar {
    padding: 0.5rem 1rem;
    flex-wrap: nowrap;
    position: relative;  /* anchor for absolute drawer */
  }
  .brand {
    font-size: 0.9rem;
    flex: 1 1 auto;
  }

  .nav-hamburger { display: inline-block; }
  .username { display: none; }

  .primary-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--coop-green-dark);
    border-bottom: 2px solid rgba(0, 0, 0, 0.2);
    padding: 0.4rem 0;
    z-index: 200;
    overflow: visible;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }
  .nav-toggle-input:checked ~ .primary-nav,
  body.nav-open .primary-nav {
    display: flex;
  }

  .primary-nav > a {
    padding: 0.7rem 1.25rem;
    border-radius: 0;
  }

  .primary-nav > .nav-group { width: 100%; }
  .nav-group-toggle {
    width: 100%;
    justify-content: flex-start;
    padding: 0.5rem 1.25rem 0.3rem;
    border-radius: 0;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    cursor: default;
  }
  .nav-group-toggle:hover { background: transparent; }
  .nav-group-toggle.active { background: transparent; }
  .nav-chevron { display: none; }

  .nav-group-menu {
    display: block !important;
    position: static;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    min-width: 0;
    width: 100%;
  }
  .nav-group-menu a {
    display: block;
    color: rgba(255, 255, 255, 0.92);
    padding: 0.6rem 1.25rem 0.6rem 2.25rem;
    border-radius: 0;
    font-size: 0.95rem;
  }
  .nav-group-menu a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }
  .nav-group-menu a.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
  }
}

/* ---------- Mobile scorecard layout (max-width: 600px) ----------------- */
/* Layout-only adjustments below this breakpoint: tile grid, hide
   secondary panels. Nav handling lives in the 768px block above.         */

@media (max-width: 600px) {

  /* Tighter content padding */
  .content { padding: 0 0.75rem; margin-top: 0.75rem; }

  /* Compact recap header */
  .recap-header { margin-bottom: 0.75rem; }
  .recap-header h1 { font-size: 1.5rem; }
  .recap-subtitle { font-size: 0.85rem; }

  /* Hide comparison target line -- not needed for a quick glance */
  .compare-target-line { display: none; }
  /* Same reasoning: hide per-tile comparison details on mobile */
  .metric-compare { display: none; }

  /* 2-column tile grid, big numbers */
  .metric-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin: 0.6rem 0 1rem 0;
  }

  /* Hide average basket tile (5th tile, least useful at a glance) */
  .metric:nth-child(5) { display: none; }

  .metric { padding: 0.75rem 0.85rem; }
  .metric-value { font-size: 1.45rem; letter-spacing: -0.02em; }
  .metric-label { font-size: 0.7rem; }
  .metric-delta { font-size: 0.75rem; padding: 0.15rem 0.45rem; margin-top: 0.35rem; }

  /* On /daily only: hide the tender mix + store credit row (low value at a
     glance, full info on tap-through). Tagged in recap.html as
     .breakdowns-secondary so .breakdowns on /weekly+/monthly keep showing. */
  .breakdowns-secondary { display: none; }

  .trend-nav h1 { font-size: 1.4rem; }
}

/* ---------- Items page ------------------------------------------------- */

.items-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 0 0 1rem 0;
  font-size: 0.88rem;
}
.items-search-input {
  font: inherit;
  padding: 0.4rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 220px;
}
.items-search-input:focus {
  outline: 2px solid var(--coop-green);
  border-color: var(--coop-green);
}
.items-controls button {
  font: inherit;
  background: var(--coop-green);
  color: #fff;
  border: none;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  cursor: pointer;
}
.clear-search { color: var(--ink-muted); font-size: 0.85rem; }
.sort-label { color: var(--ink-muted); margin-left: 0.5rem; }
.sort-pill {
  padding: 0.25rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-muted);
  font-size: 0.82rem;
}
.sort-pill:hover { border-color: var(--coop-green); text-decoration: none; }
.sort-pill.active { background: var(--coop-green); color: #fff; border-color: var(--coop-green); }

.items-table .item-desc { max-width: 320px; }

/* Subtle tag shown when an item-search row matched only via brand name —
   helps the user understand why an item with no name match showed up. */
.search-match-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-style: italic;
  margin-left: 0.4em;
  vertical-align: baseline;
  opacity: 0.75;
}

.margin-low  { color: var(--down-purple); }
.margin-ok   { color: var(--ink-muted); }
.margin-high { color: var(--coop-green-dark); font-weight: 500; }

.cat-flag {
  display: inline-block;
  font-size: 0.7rem;
  background: var(--coop-green-soft);
  color: var(--coop-green-dark);
  border-radius: 3px;
  padding: 0.05em 0.4em;
  margin-left: 0.4em;
  vertical-align: middle;
  font-weight: 500;
}

/* On the /items page (8 cols): hide Dept, Category, Unit cost, Margin */
@media (max-width: 600px) {
  .items-table-list th:nth-child(2),
  .items-table-list td:nth-child(2),
  .items-table-list th:nth-child(3),
  .items-table-list td:nth-child(3),
  .items-table-list th:nth-child(5),
  .items-table-list td:nth-child(5),
  .items-table-list th:nth-child(8),
  .items-table-list td:nth-child(8) { display: none; }

  /* On /categories/<id> (7 cols, no Category column): hide Dept, Unit cost, Margin */
  .items-table-cat th:nth-child(2),
  .items-table-cat td:nth-child(2),
  .items-table-cat th:nth-child(4),
  .items-table-cat td:nth-child(4),
  .items-table-cat th:nth-child(7),
  .items-table-cat td:nth-child(7) { display: none; }
}


/* ---------- Sortable column headers ------------------------------------ */

.sort-th { padding: 0; }
.sort-th a {
  display: block;
  padding: 0.55rem 0.75rem;
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.sort-th a:hover {
  background: var(--coop-green-soft);
  text-decoration: none;
}
.sort-th.sort-active a {
  color: var(--coop-green-dark);
  font-weight: 600;
}
.sort-arrow {
  display: inline-block;
  font-size: 0.75em;
  margin-left: 0.25em;
  color: var(--coop-green);
}


/* ---------- Inactive items --------------------------------------------- */

.item-inactive { opacity: 0.55; }
.item-inactive .item-desc::after {
  content: " · inactive";
  font-size: 0.85em;
  color: var(--ink-muted);
  font-weight: normal;
  font-style: italic;
}

.inactive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 1rem;
  font-size: 0.9rem;
  color: var(--ink-muted);
  cursor: pointer;
  user-select: none;
}
.inactive-toggle input { margin: 0; cursor: pointer; }


/* ---------- Category link inside item rows ----------------------------- */

.cat-link { color: var(--coop-green); }
.cat-link:hover { text-decoration: underline; }

/* ---------- Nav dropdowns ----------------------------------------------
   Desktop-only styling for the Sales / Products / Tools group dropdowns.
   Wrapped in min-width: 769px so the mobile drawer rules at <=768px aren't
   overridden by these (CSS source-order specificity was beating them and
   the dropdowns were rendering as absolute-positioned overlays on phones,
   stacking on top of each other and hiding Weekly/Monthly/Annual etc).  */

.nav-group { position: relative; }

@media (min-width: 769px) {

  .nav-group-toggle {
    background: transparent;
    border: 0;
    color: rgba(255, 255, 255, 0.92);
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    font-size: 0.92rem;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: background 0.12s ease;
  }
  .nav-group-toggle:hover { background: rgba(255, 255, 255, 0.12); }
  .nav-group-toggle.active { background: rgba(255, 255, 255, 0.18); font-weight: 500; }

  .nav-chevron {
    font-size: 0.7rem;
    line-height: 1;
    transition: transform 0.15s ease;
  }

  .nav-group-menu {
    display: none;
    position: absolute;
    /* No gap between trigger and menu — a transparent gap breaks the
       :hover state on `.nav-group` as the cursor crosses it, which is why
       the dropdown used to close before the user could reach an item.
       The menu's own padding provides the visual breathing room instead. */
    top: 100%;
    left: 0;
    min-width: 150px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 0.45rem 0.3rem 0.3rem;
    z-index: 100;
  }
  .nav-group-menu a {
    display: block;
    color: var(--ink);
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    font-size: 0.92rem;
    white-space: nowrap;
  }
  .nav-group-menu a:hover {
    background: var(--coop-green-soft);
    text-decoration: none;
  }
  .nav-group-menu a.active {
    background: var(--coop-green-soft);
    color: var(--coop-green-dark);
    font-weight: 500;
  }

  /* Open on hover (only on devices that actually hover -- skips touch) */
  @media (hover: hover) {
    .nav-group:hover .nav-group-menu { display: block; }
    .nav-group:hover .nav-chevron { transform: rotate(180deg); }
  }

  /* Open on keyboard focus (works everywhere) */
  .nav-group:focus-within .nav-group-menu { display: block; }
  .nav-group:focus-within .nav-chevron { transform: rotate(180deg); }

  /* Open via JS click toggle (touch + any modality) */
  .nav-group.open .nav-group-menu { display: block; }
  .nav-group.open .nav-chevron { transform: rotate(180deg); }
}


/* ---------- Roadmap page ----------------------------------------------- */

.roadmap-section { margin: 1.75rem 0; max-width: 820px; }
.roadmap-section h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.45rem;
  color: var(--coop-green-dark);
  margin: 0 0 0.6rem 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}
.roadmap-list { list-style: disc; padding-left: 1.4rem; margin: 0.5rem 0 0 0; }
.roadmap-list li { margin-bottom: 0.7rem; line-height: 1.55; color: var(--ink); }
.roadmap-list li strong { color: var(--coop-green-dark); font-weight: 600; }

@media (max-width: 600px) {
  .roadmap-section h2 { font-size: 1.2rem; }
}

/* ---------- Departments page ------------------------------------------ */

/* YoY delta cell on the leaderboard. Inline text-only (no pill) so it
   reads as a compact column. Matches the green/violet palette used by
   .metric-delta but without the rounded background. */
.yoy-cell { font-variant-numeric: tabular-nums; }
.yoy-up   { color: var(--coop-green-dark); }
.yoy-down { color: var(--down-purple); }
.yoy-flat { color: var(--ink-muted); }

/* Per-department margin small-multiples grid. Auto-fits to viewport width;
   each card is its own micro chart with a header and a fixed-height canvas. */
.dept-margin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.75rem;
}
.dept-margin-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.7rem 0.4rem 0.7rem;
}
.dept-margin-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.dept-margin-title {
  font-size: 0.85rem;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.dept-margin-badge {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--coop-green-dark);
  background: var(--coop-green-soft);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}
.dept-margin-badge-missing {
  color: var(--ink-faint);
  background: transparent;
  font-weight: 400;
  font-style: italic;
  padding: 0;
}
.dept-margin-canvas {
  display: block;
  width: 100% !important;
  height: 90px !important;
}

@media (max-width: 600px) {
  .dept-margin-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .dept-margin-card { padding: 0.4rem 0.5rem 0.3rem 0.5rem; }
  .dept-margin-title { font-size: 0.78rem; }
  .dept-margin-badge { font-size: 0.7rem; padding: 0.05rem 0.35rem; }
}


/* ---------- Mobile audit pass (2026-05-14) -----------------------------
   Restores content that earlier mobile rules hid wholesale (.panel-wide
   and .breakdowns were both display:none under 600px, which scorched
   charts and day-by-day tables on /weekly /monthly /annual /members
   and the entire admin pages). Adds touch-target sizing, scroll
   wrappers, and column hides instead of hiding whole panels.            */

/* Drawer-only nav links (Account, etc): hidden on desktop, surfaced
   inside the mobile drawer. */
.primary-nav .drawer-only { display: none; }

@media (max-width: 768px) {
  .primary-nav .drawer-only { display: block; }
  .primary-nav .drawer-only { padding: 0.7rem 1.25rem; border-radius: 0; }
}

@media (max-width: 600px) {

  /* --- Wide panels: bring back charts + tables on phones, with phone-
     appropriate padding and chart heights ----------------------------- */
  .panel,
  .panel-wide { padding: 0.85rem 0.85rem; }
  .panel h2,
  .panel-wide h2 { font-size: 1rem; margin-bottom: 0.6rem; }
  .panel canvas,
  .panel-wide canvas { height: 220px !important; }

  /* Members chart was 320px tall; equity chart 220px; tighten both. */
  #members-chart { height: 240px !important; }

  /* Tables wider than the panel scroll horizontally instead of forcing
     the whole page to scroll. Keeps panel padding clean.
     `display: block` on a table makes it scrollable but kills its own
     min-width — wrap in a scroll shell instead via a parent rule.       */
  .panel > .dept-table,
  .panel-wide > .dept-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* --- Tap-target bumps. iOS HIG and Android M3 both call ~44px / 48px
     minimum tappable area; current sort headers + pills are well under. */
  .sort-th a { padding: 0.75rem 0.6rem; }
  .compare-pill { padding: 0.55rem 0.95rem; font-size: 0.88rem; }
  .compare-toggle { flex-wrap: wrap; }
  .btn-link, .btn-link-cancel, .btn-link-danger,
  .btn-primary { padding: 0.5rem 0.7rem; font-size: 0.88rem; }

  /* --- Trend / daily nav bars: don't overflow on narrow phones */
  .trend-nav { gap: 0.5rem; flex-wrap: wrap; }
  .trend-nav h1 { font-size: 1.35rem; }
  .trend-nav-btn { width: 2.4rem; height: 2.4rem; font-size: 1.1rem; }
  .daily-nav { flex-wrap: nowrap; gap: 0.4rem; }
  .daily-nav .date-picker-form {
    flex: 1 1 auto;
    padding: 0.35rem 0.5rem;
    gap: 0.35rem;
  }
  .daily-nav .date-picker-form label { display: none; }

  /* --- Money-flow waterfall: tighten so it fits */
  .money-flow { padding: 0.6rem 0.7rem; gap: 0.2rem 0.35rem; }
  .flow-step { min-width: 70px; padding: 0.2rem 0.45rem; }
  .flow-amount { font-size: 0.85rem; }
  .flow-label { font-size: 0.62rem; }

  /* --- Items search input: full width on phone (was a fixed 220px) */
  .items-search-input { width: 100%; flex: 1 1 100%; }

  /* --- Members participation table: drop the Member sales column */
  .members-table th:nth-child(3),
  .members-table td:nth-child(3) { display: none; }

  /* --- Holidays admin: hide Notes col (often empty, eats width) and
     stack the Edit/Delete buttons so they don't overflow. */
  .holidays-table th:nth-child(4),
  .holidays-table td:nth-child(4) { display: none; }
  .holidays-table .actions-cell,
  .users-table .actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    justify-content: flex-end;
  }

  /* --- Users admin: hide Created + Last login (audit, not glance) */
  .users-table th:nth-child(5),
  .users-table td:nth-child(5),
  .users-table th:nth-child(6),
  .users-table td:nth-child(6) { display: none; }

  /* The admin form rows already wrap thanks to flex-wrap, but inputs
     can shrink past their content; give them sensible min widths. */
  .holiday-form label,
  .user-form label { flex: 1 1 calc(50% - 0.4rem); min-width: 0; }
  .holiday-form input,
  .holiday-form select,
  .user-form input,
  .user-form select { width: 100%; }

  /* --- Modal trend table: smaller font + drop Member % col (4th) so
     the 4-column monthly table fits without horizontal scroll. */
  .modal-trend-table { font-size: 0.78rem; }
  .modal-trend-table th:nth-child(4),
  .modal-trend-table td:nth-child(4) { display: none; }

  /* --- Compare-target line is hidden up the file via display:none on
     .compare-target-line; nothing to do here.                          */
}

/* ============================================================
   Real Deals — promo pills + home page + prep summary
   ============================================================ */

/* Promo pill badges (inline next to items, in tables, etc.) */
.promo-pill {
  display: inline-block;
  padding: 0.1em 0.55em;
  margin-left: 0.4em;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 999px;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
  text-transform: uppercase;
}
.promo-pill-active   { background: #c0392b; color: #fff; }     /* red — on sale now */
.promo-pill-soon     { background: #e67e22; color: #fff; }     /* amber — starts in <=7d */
.promo-pill-upcoming { background: #2980b9; color: #fff; }     /* blue — future cycle */
.promo-pill-past     { background: #95a5a6; color: #fff; }     /* gray — past order Mon */

/* ---------- /home KPI tiles ---------- */
.home-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin: 1rem 0 1.5rem;
}
.home-kpi-tile {
  display: block;
  background: #fff;
  border: 1px solid #e3e3e0;
  border-radius: 10px;
  padding: 0.9rem 1rem 1rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 120ms, transform 120ms;
}
.home-kpi-tile:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
.home-kpi-tile .kpi-label   { font-size: 0.85rem; color: #666; letter-spacing: 0.01em; }
.home-kpi-tile .kpi-value   { font-size: 1.65rem; font-weight: 600; margin-top: 0.2rem; }
.home-kpi-tile .kpi-value-sm { font-size: 1.15rem; font-weight: 600; margin-top: 0.15rem; }
.home-kpi-tile .kpi-sub     { font-size: 0.9rem; color: #444; margin-top: 0.15rem; }
.home-kpi-tile .kpi-compare { font-size: 0.78rem; margin-top: 0.35rem; }
.kpi-delta            { font-weight: 600; margin-left: 0.4em; }
.kpi-delta.pos        { color: #27ae60; }
.kpi-delta.neg        { color: #c0392b; }
.kpi-value-sm         { font-size: 1.1rem; font-weight: 600; }

/* Home section headings (Real Deals, Top movers, Quick links) */
.home-section { margin: 1.75rem 0; }
.home-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.home-section-more {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--coop-green, #1a6b3a);
  text-decoration: none;
}
.home-section-more:hover { text-decoration: underline; }

/* Home promo summary strip (4 stat blocks above the cycle table) */
.home-promo-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.6rem;
  background: #fbfaf6;
  border: 1px solid #e6e3da;
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
}
.home-promo-stat .kpi-label { font-size: 0.78rem; color: #666; }

/* Home top movers grid: gainers + losers side by side */
.home-movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 760px) {
  .home-movers-grid { grid-template-columns: 1fr; }
}

/* Home quick links: pill row */
.home-quicklinks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.home-quicklink {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #fff;
  border: 1px solid #d8d4cb;
  border-radius: 999px;
  color: inherit;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 120ms, border-color 120ms;
}
.home-quicklink:hover {
  background: var(--coop-green, #1a6b3a);
  color: #fff;
  border-color: var(--coop-green, #1a6b3a);
}

/* /promos buyer-prep summary block */
.prep-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem 1.25rem;
  padding: 0.75rem 0.9rem;
}
.prep-summary > div .kpi-label { font-size: 0.8rem; color: #666; margin-bottom: 0.15rem; }
.prep-summary .promo-pill { margin-left: 0; margin-right: 0.35em; }

/* /registers — side-by-side register cards + hour-of-day heat-strip */
.reg-card-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 720px) {
  .reg-card-pair { grid-template-columns: 1fr; }
}
.reg-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.1rem 1.1rem;
}
.reg-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 0.9rem;
}
.reg-card-num {
  font-family: var(--serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--coop-green);
}
.reg-card-status {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}
.reg-card-status-idle {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}
.reg-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.7rem 1rem;
}
@media (max-width: 480px) {
  .reg-card-grid { grid-template-columns: 1fr 1fr; }
}
.reg-card-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-bottom: 0.15rem;
}
.reg-card-stat-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  color: var(--ink);
}

/* Heat-strip: one cell per hour, intensity-shaded by net sales */
.heatstrip-row {
  display: grid;
  grid-template-columns: 4rem 1fr;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.7rem;
}
.heatstrip-row-label {
  display: flex;
  align-items: center;
  font-family: var(--serif);
  font-weight: 600;
  color: var(--coop-green);
}
.heatstrip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.heatstrip-cell {
  position: relative;
  background-color: var(--panel-2);
  text-align: center;
  padding: 0.4rem 0.15rem 0.35rem;
  min-height: 3.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: default;
}
.heatstrip-label {
  font-size: 0.65rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.heatstrip-value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
/* When intensity is high, the green tint background gets dark; pull text
   toward white to keep contrast readable. Threshold tuned to ~0.4 alpha. */
.heatstrip-cell[style*="rgba(43, 94, 58, 0.4"],
.heatstrip-cell[style*="rgba(43, 94, 58, 0.5"],
.heatstrip-cell[style*="rgba(43, 94, 58, 0.6"],
.heatstrip-cell[style*="rgba(43, 94, 58, 0.7"],
.heatstrip-cell[style*="rgba(43, 94, 58, 0.8"],
.heatstrip-cell[style*="rgba(43, 94, 58, 0.9"],
.heatstrip-cell[style*="rgba(43, 94, 58, 1."] {
  color: #fff;
}
.heatstrip-cell[style*="rgba(43, 94, 58, 0.4"] .heatstrip-label,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.5"] .heatstrip-label,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.6"] .heatstrip-label,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.7"] .heatstrip-label,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.8"] .heatstrip-label,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.9"] .heatstrip-label,
.heatstrip-cell[style*="rgba(43, 94, 58, 1."] .heatstrip-label,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.4"] .heatstrip-value,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.5"] .heatstrip-value,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.6"] .heatstrip-value,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.7"] .heatstrip-value,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.8"] .heatstrip-value,
.heatstrip-cell[style*="rgba(43, 94, 58, 0.9"] .heatstrip-value,
.heatstrip-cell[style*="rgba(43, 94, 58, 1."] .heatstrip-value {
  color: #fff;
}
.anomaly-panel {
  border-left: 4px solid var(--down-purple);
}
