/* Sprint 7.5 — Canonical UI primitives
   All classes reference tokens from tokens.css.
   bf-* legacy classes remain untouched until Sprint 7.18. */

/* ─── Button ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: filter 0.15s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  height: 36px; /* md default */
}

.btn-sm { height: 28px; padding: 0 10px; font-size: 0.8125rem; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 0.9375rem; }
.btn-icon { padding: 0; width: 36px; justify-content: center; }

.btn-primary {
  background: var(--accent);
  color: oklch(10% 0 0);
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-danger {
  background: rgba(var(--danger-rgb, 239 68 68) / 0.15);
  color: oklch(75% 0.18 25);
  border: 1px solid rgba(var(--danger-rgb, 239 68 68) / 0.3);
}
.btn-danger:hover {
  background: rgba(var(--danger-rgb, 239 68 68) / 0.25);
}

/* ─── Input ──────────────────────────────────────────────── */
.input {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-elev-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-dim); }

/* ─── Field ──────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hint {
  font-size: 0.6875rem;
  color: var(--text-dim);
  margin: 0;
}

/* ─── Field error ────────────────────────────────────────── */
/* Inline error message rendered below an .input by {% field %} when the
   bound form field has errors. Wired through aria-describedby so screen
   readers announce the message together with the input. */
.field-error {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--danger);
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
}

.input[aria-invalid="true"] {
  border-color: var(--danger);
}

.input[aria-invalid="true"]:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px oklch(0.55 0.18 25 / 0.18);
}

/* ─── Autocomplete dropdown (customer search) ────────────────── */
/* Popover anchored below the input: elevated surface + shadow so it floats,
   theme-aware tokens, keyboard-navigable options. The combobox wrapper (input +
   results only, NOT the helper text) is the positioned ancestor so top:100%
   drops the list directly under the input. */
.customer-combobox { position: relative; }

.customer-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  z-index: var(--z-dropdown);
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}

.customer-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
}
.customer-result:hover,
.customer-result.is-active {
  background: var(--surface-2);
}

/* Custom clear button (replaces the browser's native search ✗) */
.customer-combobox input[type="search"] { padding-right: 38px; }
.customer-combobox input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.customer-clear {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.customer-clear:hover {
  color: var(--text);
  background: var(--surface-hover);
}

/* ─── Badge ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 10px;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-default  { background: var(--surface-2); color: var(--text-muted); }
.badge-success  { background: oklch(25% 0.08 145 / 0.35); color: oklch(80% 0.16 145); }
.badge-warn     { background: oklch(28% 0.08 80  / 0.35); color: oklch(82% 0.16 80); }
.badge-danger   { background: oklch(22% 0.08 25  / 0.35); color: oklch(75% 0.18 25); }
.badge-info     { background: oklch(22% 0.06 260 / 0.35); color: oklch(78% 0.12 260); }
.badge-accent   { background: var(--accent-soft); color: var(--accent); }

/* ─── Chip ───────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 14px;
  border-radius: var(--r-pill, 9999px);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-1);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}
.chip:hover {
  background: var(--surface-2);
  color: var(--text);
}
.chip.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(var(--accent-rgb, 0 0 0) / 0.3);
}

/* ─── Avatar ─────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
  background: oklch(30% 0.12 var(--avatar-hue, 50));
  color: oklch(92% 0.04 var(--avatar-hue, 50));
  border: 1px solid oklch(45% 0.1 var(--avatar-hue, 50) / 0.4);
  width: 32px;
  height: 32px;
}

/* ─── Card ───────────────────────────────────────────────── */
.card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 1rem);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.card-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin: 2px 0 0;
}

/* ─── Section head ───────────────────────────────────────── */
/* Mid-level heading between .page-head (page) and .card-head (card): labels a
   group of cards as one section (e.g. the metrics dashboard's Frequência /
   Financeiro blocks). Larger than .card-title so section > card reads clearly. */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.section-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.section-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
}

/* ─── KPI Card ───────────────────────────────────────────── */
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 1rem);
}

.kpi-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 600;
  font-family: var(--font-display);
  line-height: 1.1;
  color: var(--text);
  margin: 0;
}

.kpi-delta {
  font-size: 0.75rem;
  font-weight: 500;
  margin: 0;
}
.kpi-delta.trend-up   { color: oklch(80% 0.16 145); }
.kpi-delta.trend-down { color: oklch(75% 0.18 25); }

.currency {
  font-size: 60%;
  font-weight: 500;
  opacity: 0.7;
  margin-right: 2px;
}

/* ─── Page container ─────────────────────────────────────── */
.page-container {
  max-width: var(--bf-page-max-width, 80rem);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

@media (max-width: 480px) {
  .page-container { padding: 0 var(--space-4); }
}

/* ─── PageHead ───────────────────────────────────────────── */
/* Back/up control, left-aligned above the page head. Backward navigation lives
   top-left (breadcrumb position); the right page-head-actions slot is reserved
   for forward/primary actions. Visual styling comes from the button system
   (.btn .btn-secondary .btn-md in markup); this class only owns the placement, so
   the control stays consistent with every other button in the design system. */
.page-back {
  margin-bottom: var(--space-4);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.page-head-left { min-width: 0; }
.page-head-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; flex-shrink: 0; }

@media (max-width: 600px) {
  .page-head { flex-direction: column; align-items: stretch; gap: var(--space-3); }
  .page-head-actions { justify-content: flex-start; flex-shrink: 1; }
}

.page-eyebrow {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 var(--space-2);
}

.page-title {
  font-size: 2rem;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
  margin: 0 0 var(--space-1);
}

.page-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ─── Grid utilities ─────────────────────────────────────── */
.grid-2, .grid-3, .grid-4, .grid-auto-280 {
  display: grid;
  gap: var(--space-4);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto-280 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media (min-width: 481px) and (max-width: 768px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Split layout ───────────────────────────────────────── */
.split-2 {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: var(--space-6);
}

@media (max-width: 900px) {
  .split-2 { grid-template-columns: 1fr; }
}

/* ─── Stack utilities ────────────────────────────────────── */
.stack-1, .stack-2, .stack-3, .stack-4, .stack-6 {
  display: flex;
  flex-direction: column;
}

.stack-1 { gap: var(--space-1); }
.stack-2 { gap: var(--space-2); }
.stack-3 { gap: var(--space-3); }
.stack-4 { gap: var(--space-4); }
.stack-6 { gap: var(--space-6); }

/* ─── Empty state ────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-10) var(--space-6);
  gap: var(--space-3);
}

.empty-state-icon {
  color: var(--text-dim);
  margin-bottom: var(--space-2);
}

.empty-title {
  font-size: 1.125rem;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text);
  margin: 0;
}

.empty-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
  max-width: 36ch;
}

.empty-action { margin-top: var(--space-2); }

/* ─── Toast ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 80px;
  right: var(--space-4);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 380px;
  width: 100%;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-lg);
  border: 1px solid transparent;
  backdrop-filter: blur(12px);
  pointer-events: all;
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.toast-icon { flex-shrink: 0; margin-top: 1px; }

.toast-body {
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: inherit;
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.toast-close:hover { opacity: 1; }

.toast-success {
  background: oklch(18% 0.06 145 / 0.9);
  border-color: var(--success);
  color: var(--success);
}

.toast-warn {
  background: oklch(18% 0.06 75 / 0.9);
  border-color: var(--warn);
  color: var(--warn);
}

.toast-danger {
  background: oklch(16% 0.06 25 / 0.9);
  border-color: var(--danger);
  color: var(--danger);
}

.toast-info {
  background: oklch(16% 0.04 230 / 0.9);
  border-color: var(--info);
  color: var(--info);
}

/* ── Charts ──────────────────────────────────────────────── */
.chart-point {
  opacity: 0;
  transition: opacity 0.2s ease;
}
svg:hover .chart-point {
  opacity: 1;
}

/* ───────────────────────────────────────────────────────────────────
   Canonical table — handoff section 3.4
   ─────────────────────────────────────────────────────────────────── */
.table-canonical {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84375rem; /* 13.5px */
}

.table-canonical thead th {
  font-size: 0.6875rem; /* 11px */
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.table-canonical tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-canonical tbody tr:hover td {
  background: var(--bg-elev-3);
}

.table-canonical tbody tr:last-child td {
  border-bottom: none;
}

.table-canonical .num,
.table-canonical th.num {
  text-align: right;
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
}

.table-canonical .actions {
  text-align: right;
  white-space: nowrap;
}

/* ─── Column chart ───────────────────────────────────────── */
/* Vertical bar chart for category totals (e.g. payments by method): each column
   is value (top) + accent bar (height ∝ total) + label + percentage (bottom).
   Bottom-aligned so bars rise from a shared baseline. Pure CSS, no chart lib. */
.column-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: var(--space-4);
}
.column-chart__col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.column-chart__value {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  color: var(--text);
  white-space: nowrap;
}
.column-chart__bar {
  width: 100%;
  max-width: 72px;
  background: var(--accent);
  border-radius: var(--r-sm, 4px) var(--r-sm, 4px) 0 0;
  min-height: 4px;
}
.column-chart__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.25;
}
.column-chart__pct {
  font-size: 0.6875rem;
  color: var(--text-dim);
}

/* ─── Focus Visible — global accessibility (Sprint 8.4 / WCAG 2.4.7) ─────────
   Propagates an accent-coloured 2px outline to every keyboard-focusable
   element across the application. Aligns with HANDOFF §7 (focus visibility
   is part of the design-system contract, not a landing-page concern). Mouse
   clicks do NOT trigger the outline — only `:focus-visible` matches, which
   browsers reserve for keyboard / programmatic focus. */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* =========================================================================
 * Platform Admin Shell — layout + nav lateral
 * ========================================================================= */
.platform-admin-shell {
  display: flex;
  min-height: calc(100vh - 64px);
}

.platform-admin-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--bg-elev-2);
  border-right: 1px solid var(--border);
  min-width: 220px;
  flex-shrink: 0;
}

.platform-admin-nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
}

.platform-admin-nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
}

.platform-admin-nav-link:hover {
  background: var(--bg-elev-3);
  color: var(--text);
}

.platform-admin-nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.platform-admin-content {
  flex: 1;
  padding: var(--space-6);
  overflow-x: auto;
}

.platform-admin-row--highlight,
.platform-admin-row--highlight td {
  background: var(--accent-soft);
}

/* =========================================================================
 * BANNER — global status banners (error / success / info / warn)
 * Shared across authenticated shell. auth.css aliases these for auth pages.
 * ========================================================================= */
.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  margin-bottom: var(--space-5);
  font-size: 0.875rem;
  line-height: 1.5;
}
.banner-icon { flex-shrink: 0; margin-top: 2px; }
.banner-body { flex: 1; }
.banner-body p { margin: 0; }
.banner-body p + p { margin-top: var(--space-1); }
.banner--error {
  background: oklch(0.35 0.12 25 / 0.18);
  border: 1px solid oklch(0.55 0.18 25 / 0.35);
  color: oklch(0.82 0.14 25);
}
.banner--success {
  background: oklch(0.32 0.10 155 / 0.18);
  border: 1px solid oklch(0.55 0.13 155 / 0.35);
  color: oklch(0.82 0.13 155);
}
.banner--info {
  background: oklch(0.30 0.08 230 / 0.18);
  border: 1px solid oklch(0.55 0.10 230 / 0.35);
  color: oklch(0.82 0.10 230);
}
.banner--warn {
  background: oklch(0.38 0.12 60 / 0.18);
  border: 1px solid oklch(0.55 0.15 60 / 0.40);
  color: oklch(0.85 0.12 60);
}

/* ─── Code block ─────────────────────────────────────────────── */
.code-block {
  display: block;
  padding: var(--space-4);
  background: var(--bg-elev-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  margin: 0;
}

/* ─── Screen-reader only ─────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* =========================================================================
 * Sprint 10.2 — platform mode banner + env badge
 * ========================================================================= */
.platform-mode-banner {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: oklch(0.38 0.12 60 / 0.18);
  border-bottom: 1px solid oklch(0.55 0.15 60 / 0.4);
  color: oklch(0.85 0.12 60);
  font-size: 0.8125rem;
  line-height: 1.4;
  font-weight: 500;
}

.platform-mode-banner svg {
  flex-shrink: 0;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--r-pill);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

.env-badge--prod {
  background: oklch(0.45 0.18 25 / 0.18);
  color: oklch(0.78 0.15 25);
  border: 1px solid oklch(0.55 0.18 25 / 0.4);
}

.env-badge--staging {
  background: oklch(0.4 0.14 60 / 0.18);
  color: oklch(0.82 0.12 60);
  border: 1px solid oklch(0.55 0.15 60 / 0.4);
}

.env-badge--dev {
  background: oklch(0.3 0.02 240 / 0.2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* =========================================================================
 * Sprint 10.3 — KPI cards, pill tabs, dashboard grids, alerts list
 * ========================================================================= */

/* Pill tabs (period selector) */
.pill-tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
}

.pill {
  padding: 6px var(--space-3);
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.pill:hover { color: var(--text); }

.pill.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* KPI card extra elements (kpi, kpi-label, kpi-value defined above) */
.kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Grid layouts */
.grid-6 {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1280px) {
  .grid-6 { grid-template-columns: repeat(6, 1fr); }
}

.split-70-30 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 1024px) {
  .split-70-30 { grid-template-columns: 70fr 30fr; }
}

/* Chart frame */
.chart-frame {
  position: relative;
}

/* Alerts list */
.alerts-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}

.alert-item:last-child { border-bottom: 0; }

.alert-item--warn svg { color: var(--warn, oklch(0.85 0.12 60)); }
.alert-item--danger svg { color: var(--danger); }
.alert-item--success svg { color: var(--success); }

.alert-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8125rem;
}

.alert-msg {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Card utilities */
.card--padded { padding: var(--space-6); }

/* Health check cards */
.health-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-raised);
}
.health-card__icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.health-card__body { flex: 1; min-width: 0; }
.health-card__name { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.health-card__msg  { font-size: 0.8125rem; color: var(--text-muted); margin-top: 2px; }
.health-card--success { border-color: var(--success); }
.health-card--success .health-card__icon { color: var(--success); }
.health-card--warn    { border-color: var(--warn); }
.health-card--warn    .health-card__icon { color: var(--warn); }
.health-card--danger  { border-color: var(--danger); }
.health-card--danger  .health-card__icon { color: var(--danger); }

.card-footer-link {
  display: block;
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: none;
}

.card-footer-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.emptystate-inline {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* User broadcast banners */
.user-broadcast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--accent-soft, oklch(55% 0.18 250 / 0.12));
  border-bottom: 1px solid var(--accent-line, oklch(55% 0.18 250 / 0.25));
  color: var(--text);
  font-size: 0.875rem;
}
.user-broadcast-body { flex: 1; }
.user-broadcast-dismiss {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  flex-shrink: 0;
}
.user-broadcast-dismiss:hover { color: var(--text); }

/* Diff viewer */
.diff-viewer { }
.diff-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 1024px) {
  .diff-grid { grid-template-columns: 1fr 1fr; }
}
.diff-side { display: flex; flex-direction: column; gap: var(--space-2); }
.diff-side h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
}
/* Convey before/after via the heading color, not a side-stripe border. */
.diff-side--before h4 { color: var(--danger); }
.diff-side--after  h4 { color: var(--success); }

/* ── Customer Metrics Dashboard ──────────────────────────────────── */
.period-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
}
.period-form-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.period-group {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.period-legend {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}
.period-inputs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.period-sep {
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.period-vs {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  padding-top: 1.75rem;
}
.period-shortcuts {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
/* Financeiro date-range filter row: date pickers + submit, with preset shortcuts. */
.period-filter-row {
  display: flex;
  gap: var(--space-3);
  align-items: end;
  flex-wrap: wrap;
}
.period-filter-row .field { flex: 0 1 180px; }
.period-filter-row .period-sep {
  align-self: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  padding-bottom: 10px;
}
.metrics-spinner {
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  color: var(--text-muted);
  font-size: 0.875rem;
}
.htmx-indicator.metrics-spinner { display: flex; }
.htmx-request .metrics-spinner { display: flex; }
.metrics-partial {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-md, 8px);
  padding: 0 var(--space-3);
  height: 2rem;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-outline:hover,
.btn-outline.active {
  border-color: var(--accent);
  color: var(--accent);
}
