/* Command Center Reports — Unleashed Brands style (Guidelines v1.1): Roboto; Lemon Launch #E0E621 + black #231F20;
   secondary magenta #E50695 / cyan #0CCBFB / purple #822CBF; surface #F8F8F8. Roboto is self-hosted (CSP font-src 'self'). */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/roboto-var.woff2") format("woff2");
}

:root {
  --ub-yellow: #e0e621;
  --ub-yellow-ink: #cdd31a;
  --ub-black: #231f20;
  --ub-magenta: #e50695;
  --ub-cyan: #0ccbfb;
  --ub-purple: #822cbf;
  --surface: #f8f8f8;
  --card: #ffffff;
  --ink: #231f20;
  --muted: #6b6668;
  --line: #e6e4e5;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* robust: a class selector (e.g. .view / .topbar-user) must not override the hidden attribute */

body {
  margin: 0;
  font-family: "Roboto", Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- top bar: brand black with the signature yellow accent ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--ub-black);
  color: #fff;
  border-bottom: 3px solid var(--ub-yellow);
}
.topbar-title { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 14px; }
#user-email { color: #fff; opacity: 0.92; }

#main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 56px; }
body.wide #main { max-width: none; }   /* full-window width toggle */

.view { display: block; }

/* ---- portal toolbar: collapse nav / full width ---- */
.portal-toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.tool-btn:hover { background: #f1f0f0; }
.tool-btn.active { background: var(--ub-black); color: #fff; border-color: var(--ub-black); }
.tool-btn:focus-visible { outline: 2px solid var(--ub-magenta); outline-offset: 2px; }
.tool-ico { font-size: 14px; line-height: 1; }
.portal.nav-collapsed .sidebar { display: none; }   /* nav collapse; the toolbar "Reports" button brings it back */

/* ---- portal: left report list + content ---- */
.portal { display: flex; gap: 20px; align-items: flex-start; }
.sidebar {
  flex: 0 0 240px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 20px;
}
.sidebar-title { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.report-nav { display: flex; flex-direction: column; gap: 4px; }
.report-link {
  text-align: left;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.report-link:hover { background: #f1f0f0; }
.report-link.active { background: var(--ub-black); color: #fff; }
.sidebar-empty { margin: 4px 0 0; }
.content { flex: 1 1 auto; min-width: 0; }
.report-view { display: block; }
.placeholder {
  display: flex; align-items: center; justify-content: center;
  min-height: 260px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fcfcfc;
}
.pad { padding: 8px 2px; }

@media (max-width: 820px) {
  /* Stacked layout: stretch items to the viewport width so a wide results table scrolls inside
     .table-wrap instead of stretching .content (and the filter card) to match it (mobile width bug). */
  .portal { flex-direction: column; align-items: stretch; }
  .sidebar { position: static; width: 100%; flex: none; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(35, 31, 32, 0.05);
}
.card.narrow { max-width: 460px; margin: 56px auto 20px; }

h2 { margin: 0 0 14px; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; color: var(--ub-magenta); }
.report-title { margin-bottom: 18px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---- controls ---- */
.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field.actions { flex-direction: row; gap: 10px; align-items: flex-end; }
.radio-row { display: inline-flex; gap: 16px; align-items: center; min-height: 40px; }
.radio { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; white-space: nowrap; }
.radio input { margin: 0; accent-color: var(--ub-purple); cursor: pointer; }
.offscreen { position: fixed; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }
.input {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  min-width: 170px;
}
.input:focus-visible, .btn:focus-visible { outline: 2px solid var(--ub-magenta); outline-offset: 2px; }

.btn {
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: #f1f0f0; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--ub-yellow); color: var(--ub-black); border-color: var(--ub-yellow); font-weight: 700; }
.btn-primary:hover { background: var(--ub-yellow-ink); border-color: var(--ub-yellow-ink); }
.btn-link { background: none; border: none; color: #fff; text-decoration: underline; padding: 4px; font-weight: 600; }
.btn-link:hover { background: none; color: var(--ub-yellow); }

.range-note { margin: 12px 0 0; }

/* ---- results ---- */
.results-summary { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.total { font-size: 16px; font-weight: 800; color: var(--ub-purple); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.data-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.data-table th, .data-table td { padding: 8px 11px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: left; }
.data-table thead th {
  position: sticky; top: 0;
  background: var(--ub-black);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}
.data-table thead th.num, .data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:nth-child(even) { background: #faf9f9; }
.data-table tbody tr:hover { background: #fdf6fb; }
.data-table th.sort-asc::after { content: " \25B2"; font-size: 10px; }
.data-table th.sort-desc::after { content: " \25BC"; font-size: 10px; }

/* ---- wide-table horizontal scroll: arrows above-right + edge fade shadows (reusable on any .table-wrap) ---- */
/* Sticky so the arrows stay reachable while scrolled down a tall table (the topbar isn't fixed; no overflow ancestor). */
.table-scroll-controls { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 6px; position: sticky; top: 8px; z-index: 2; }
.scroll-btn {
  width: 32px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  color: var(--ink); font-size: 12px; line-height: 1; cursor: pointer;
}
.scroll-btn:hover:not([aria-disabled="true"]) { background: var(--ub-black); color: #fff; border-color: var(--ub-black); }
.scroll-btn[aria-disabled="true"] { opacity: 0.35; cursor: default; }
.scroll-btn:focus-visible { outline: 2px solid var(--ub-magenta); outline-offset: 2px; }
.table-scroll { position: relative; isolation: isolate; }   /* own stacking context so the edge shadows can't cover the toast */
.table-scroll::before, .table-scroll::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 26px;
  pointer-events: none; opacity: 0; transition: opacity 0.15s ease; z-index: 1;
}
.table-scroll::before { left: 0; border-radius: 8px 0 0 8px; background: linear-gradient(to right, rgba(35, 31, 32, 0.16), rgba(35, 31, 32, 0)); }
.table-scroll::after { right: 0; border-radius: 0 8px 8px 0; background: linear-gradient(to left, rgba(35, 31, 32, 0.16), rgba(35, 31, 32, 0)); }
.table-scroll.can-left::before { opacity: 1; }
.table-scroll.can-right::after { opacity: 1; }
.table-note { margin: 10px 0 0; }

/* ---- status toast ---- */
.status {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ub-black);
  color: #fff;
  padding: 11px 18px;
  border-radius: 8px;
  font-size: 14px;
  max-width: 90vw;
  box-shadow: 0 4px 14px rgba(35, 31, 32, 0.25);
}
.status.error { background: var(--ub-magenta); }
.status.success { background: var(--ub-purple); }
.status.busy::after {
  content: "";
  display: inline-block;
  width: 12px; height: 12px;
  margin-left: 10px;
  vertical-align: -1px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ccr-spin 0.7s linear infinite;
}
@keyframes ccr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .status.busy::after { animation: none; }
}

@media (max-width: 640px) {
  .input { min-width: 0; width: 100%; }
  .field { width: 100%; }
  #main { padding: 16px; }
}

/* ---- filter card head + collapse ---- */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head .report-title { margin: 0; }
.collapse-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  cursor: pointer;
}
.collapse-btn:hover { background: #f1f0f0; }
.collapse-btn:focus-visible { outline: 2px solid var(--ub-magenta); outline-offset: 2px; }
.chevron { display: inline-block; font-size: 11px; transition: transform 0.15s ease; }
.filter-collapsed .filter-body { display: none; }   /* class-based: used by both the Revenue Summary and Revenue Totals filter cards */
.filter-collapsed .chevron { transform: rotate(-90deg); }
.filter-summary { margin: 10px 0 0; font-size: 13px; }
.filter-body { margin-top: 16px; }

/* ---- inline hint / tooltip (used where there is no scroll clipping, e.g. the filter form) ---- */
.field-label { display: inline-flex; align-items: center; gap: 6px; }
.hint { position: relative; display: inline-flex; }
.hint-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: #fff; color: var(--muted);
  font-size: 11px; font-weight: 700; font-style: italic; line-height: 1; cursor: help;
}
.hint-ico:hover { background: var(--ub-black); color: #fff; border-color: var(--ub-black); }
.hint-ico:focus-visible { outline: 2px solid var(--ub-magenta); outline-offset: 2px; }
.hint-body {
  position: absolute; top: 100%; left: 0; z-index: 30;
  margin-top: 8px;
  display: none;
  width: 280px; max-width: 72vw;
  padding: 11px 13px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(35, 31, 32, 0.18);
  font-size: 12.5px; font-weight: 400; line-height: 1.45; text-transform: none; letter-spacing: 0;
}
.hint-body::before { content: ""; position: absolute; top: -8px; left: 0; right: 0; height: 8px; }  /* keeps :hover across the gap */
.hint:hover .hint-body, .hint:focus-within .hint-body { display: block; }
/* Tablet band: the icon sits far to the left, so anchoring the tooltip to it runs off-screen. Anchor to
   the whole form and drop the tooltip below it, left-aligned, where 280px / 72vw always fits. The phone
   block below re-anchors to .field (a nearer positioned ancestor) for full-width-field layout. */
@media (max-width: 900px) {
  .controls { position: relative; }
  .hint { position: static; }
  .hint-body { left: 0; right: auto; }
}

/* ---- column guide (definitions for the current view) ---- */
.results-right { display: flex; align-items: center; gap: 14px; }
.col-guide {
  margin-bottom: 14px; padding: 14px 16px;
  background: #fcfcfc; border: 1px solid var(--line); border-radius: 8px;
}
.col-guide dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; align-items: baseline; }
.col-guide dt { font-weight: 700; font-size: 13px; white-space: nowrap; }
.col-guide dd { margin: 0; font-size: 13px; color: var(--muted); }

@media (max-width: 640px) {
  .col-guide dl { grid-template-columns: 1fr; gap: 2px 0; }
  .col-guide dd { margin-bottom: 8px; }
  .results-summary { flex-direction: column; align-items: flex-start; }
  .results-right { flex-wrap: wrap; }   /* content column is now true viewport width — let the header buttons wrap */

  /* Tooltip: anchor to the full-width field (not the tiny icon or the form) so it spans the content
     width and can't run off either edge of a phone screen. The descendant selectors (.field ...)
     outrank the max-width:900px .hint-body rule above regardless of source order. */
  .field { position: relative; }
  .field .hint { position: static; }
  .field .hint-body { left: 0; right: 0; width: auto; max-width: none; }
}

/* ---- Revenue Totals: KPI dashboard ---- */
.kpi-groups { display: flex; flex-direction: column; gap: 22px; }
.kpi-group { display: flex; flex-direction: column; gap: 14px; }
.kpi-group-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.kpi {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; background: #fff;
}
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.kpi-value { margin-top: 6px; font-size: 23px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi-desc { margin-top: 6px; font-size: 12px; line-height: 1.35; color: var(--muted); }
/* Headline (Total Revenue): a full-width emphasized block above the grid. */
.kpi.headline { border-color: var(--ub-purple); background: #fcf7fd; }
.kpi.headline .kpi-label { color: var(--ub-purple); }
.kpi.headline .kpi-value { font-size: 34px; color: var(--ub-purple); }
