/* 4Real Design System — base components
   Load after 4real-tokens.css. Plain CSS, no framework. */

body {
  margin:0; background:var(--bg); color:var(--text);
  font-family:var(--font-body); font-size:15px; line-height:1.6;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4 { font-family:var(--font-display); margin:0; letter-spacing:-.02em; }
h1 { font-size:38px; font-weight:700; line-height:1.15; }
h2 { font-size:26px; font-weight:700; line-height:1.25; }
h3 { font-size:20px; font-weight:600; line-height:1.35; letter-spacing:0; }
a { color:var(--color-green-700); text-decoration:none; }
a:hover { color:var(--color-green-800); text-decoration:underline; }
code, .mono, .num { font-family:var(--font-mono); }

/* buttons — min height 44px on touch */
.btn {
  display:inline-flex; align-items:center; gap:9px; cursor:pointer;
  font-family:inherit; font-weight:700; font-size:15px;
  padding:12px 20px; border-radius:var(--radius-md); border:0;
  background:var(--action); color:var(--on-action);
  transition:background .12s ease;
}
.btn:hover { background:var(--action-hover); }
.btn:focus-visible { outline:0; box-shadow:var(--focus-ring); }
.btn-ink { background:var(--color-n-900); color:#fff; }
.btn-ink:hover { background:var(--color-n-800); }
.btn-secondary { background:var(--surface); color:var(--text); border:1.5px solid var(--color-n-300); }
.btn-secondary:hover { background:var(--surface); border-color:var(--action); color:var(--color-green-700); }
.btn-ghost { background:transparent; color:var(--color-green-700); padding:12px; }
.btn-ghost:hover { background:var(--color-green-50); }
.btn-danger { background:var(--color-error); color:#fff; }
.btn-whatsapp { background:#25D366; color:var(--color-n-900); }
.btn[disabled], .btn:disabled { background:var(--color-n-100); color:var(--color-n-400); cursor:default; }
.btn-sm { font-size:13px; padding:8px 14px; border-radius:var(--radius-sm); }
.btn-lg { font-size:17px; padding:16px 28px; border-radius:12px; }

/* card */
.card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:14px; padding:var(--space-6);
}
.card-ink { background:var(--color-n-900); color:#fff; border:0; }

/* form */
.field { display:flex; flex-direction:column; gap:7px; margin-bottom:var(--space-5,20px); }
.field > label { font-size:13px; font-weight:600; color:var(--color-n-700); }
.input, .form-control, select, textarea {
  font-family:inherit; font-size:15px; color:var(--text);
  background:var(--surface); border:1.5px solid var(--color-n-300);
  border-radius:var(--radius-md); padding:12px 14px; width:100%;
}
.input:focus, .form-control:focus, select:focus, textarea:focus {
  outline:0; border-color:var(--action); box-shadow:var(--focus-ring);
}
.input.is-invalid, .input-validation-error { border-color:var(--color-error); }
.hint { font-size:12px; color:var(--text-muted); }
.error, .field-validation-error { font-size:12px; font-weight:600; color:#C13A3F; }

/* badges */
/* v2: 11px, 4×9, square corners — chosen 2026-09-30 (smaller, no rounding). Integer px on purpose (see .kpi-sm). */
.badge { display:inline-block; font-size:11px; font-weight:700; padding:4px 9px; border-radius:0; }
.badge-success { background:var(--color-green-100); color:var(--color-green-800); }
.badge-neutral { background:var(--color-n-100); color:var(--color-n-600); }
.badge-warning { background:#FEF3D6; color:#8A5B00; }
.badge-error   { background:#FDE7E8; color:#9B1E22; }
.badge-plan    { background:var(--color-accent-100); color:#3E2A9E; }
.badge-live    { background:var(--color-n-900); color:var(--color-lime-500); }

/* KPI */
.kpi { display:flex; flex-direction:column; gap:8px; }
.kpi-label { font-size:12px; font-weight:600; color:var(--text-muted); letter-spacing:.04em; text-transform:uppercase; }
.kpi-value { font-family:var(--font-display); font-size:30px; font-weight:700; letter-spacing:-.02em; }
.kpi-delta { font-size:13px; font-weight:600; }
.kpi-delta.up { color:var(--color-success); }
.kpi-delta.down { color:#C13A3F; }

/* Compact KPI card — the card chrome a grid of small stat cards needs
   (mini chart under the number, several side by side), distinct from
   .card because it runs tighter: 16px padding, not 24px, and stretches
   as a flex column so siblings in a row share the tallest one's height.
   ← portal .pc-kpi-card / .dash-kpi (painel-fidelidade.css:167-171,
   dashboard-mobile-redesign.css:182-188). */
.kpi-card {
  min-width:0; padding:16px; border:1px solid var(--border);
  border-radius:14px; background:var(--surface); box-shadow:none;
  display:flex; flex-direction:column;
}
.kpi-card > .kpi-body { flex:1 1 auto; min-height:0; }

/* Compact value size for dense KPI grids (dashboards, drill-down rows)
   where several .kpi live side by side and the full 30px .kpi-value
   would crowd them.
   Size: fixed 24px (integer px), as in portal painel-fidelidade.css
   .pc-metric-value / .cg-summary-value (commit 4827af0d). Do NOT use a
   vw-based clamp here: on a 2x display it can resolve to a fractional px
   (e.g. 22.05px at 1470px) that rasterises at a subpixel position and
   visibly vibrates on repaint next to animated elements. */
.kpi-sm .kpi-value { font-size:24px; line-height:1.15; }

/* tables — numbers use body font with tabular figures, not mono */
table.four-real { width:100%; border-collapse:collapse; background:var(--surface); }
table.four-real thead th {
  background:var(--color-n-50); border-bottom:1px solid var(--border);
  padding:14px 22px; text-align:left;
  font-size:11px; font-weight:700; color:var(--text-muted);
  letter-spacing:.08em; text-transform:uppercase;
}
table.four-real tbody td { padding:16px 22px; border-bottom:1px solid var(--color-n-100); font-size:14px; }
table.four-real td.num { font-family:var(--font-body); font-variant-numeric:tabular-nums; }
table.four-real td.num-strong { font-weight:700; font-variant-numeric:tabular-nums; }

/* Zebra striping — dense matrices (a store x metric grid, a long ledger)
   read faster with a row band than with border-only separation.
   ← portal .balanco-grid-table tbody tr:nth-child (painel-fidelidade.css
   ~L2061-2075), tokenized: the portal still hardcodes #fff/#f8fafc/blue-
   tinted hovers there, replaced here with the neutral ramp. */
table.four-real.four-real--striped tbody tr:nth-child(even) { background:var(--color-n-50); }
table.four-real.four-real--striped tbody tr:hover { background:var(--color-n-100); }

/* Total / summary row — closes the table on the same green as an
   action-head variant instead of a leftover accent colour.
   ← portal tr.balanco-total-row (painel-fidelidade.css ~L2118-2132). */
table.four-real tr.total td {
  background:var(--color-n-100); font-weight:700;
  border-top:2px solid var(--action);
  padding-top:14px; padding-bottom:14px;
}
table.four-real tr.total td:first-child { background:var(--color-n-200); }

/* toasts */
.toast { border-radius:11px; padding:14px 16px; display:flex; align-items:center; gap:12px; font-size:14px; font-weight:600; }
.toast-success { background:var(--color-n-900); color:#fff; box-shadow:var(--shadow-md); }
.toast-error { background:#FDE7E8; border:1px solid #F6C2C4; color:#9B1E22; }
.toast-warning { background:#FEF3D6; border:1px solid #F5DFA6; color:#8A5B00; }

/* pixel motif — max one or two per screen, never on buttons/inputs/cards */
.pixel-divider {
  height:8px;
  background:repeating-linear-gradient(90deg, var(--action) 0 8px, transparent 8px 16px);
}
.pixel-bubble {
  width:96px; height:72px; background:var(--action);
  clip-path:polygon(0 8px,8px 8px,8px 0,88px 0,88px 8px,96px 8px,96px 48px,88px 48px,88px 56px,36px 56px,36px 64px,28px 64px,28px 72px,20px 72px,20px 56px,8px 56px,8px 48px,0 48px);
}
.pixel-seal {
  width:64px; height:64px; display:flex; align-items:center; justify-content:center;
  background:var(--color-n-900); color:var(--color-lime-500);
  font-family:var(--font-display); font-weight:800; font-size:22px;
  clip-path:polygon(0 8px,8px 8px,8px 0,56px 0,56px 8px,64px 8px,64px 56px,56px 56px,56px 64px,8px 64px,8px 56px,0 56px);
}
.segmented { display:flex; gap:4px; }
.segmented > span { flex:1; height:14px; background:var(--border); }
.segmented > span.on { background:var(--action); }

/* Interactive segmented toggle — a small pill-track switch for view state
   (table/cards, group-by), NOT the decorative .segmented above.
   ← portal .fid-group-toggle / .fid-pill (painel-fidelidade.css
   ~L438-457). Text colour on the active state is --color-green-700, the
   DS's "green for text on a light surface" — --action itself (#8CC63F)
   is too pale to read as text (same reason .btn-ghost uses green-700). */
.segmented-pill {
  display:flex; background:var(--color-n-100);
  border-radius:var(--radius-sm); padding:3px; gap:2px;
}
.segmented-pill button {
  border:none; background:transparent; font-family:inherit; cursor:pointer;
  padding:5px 12px; font-size:12px; font-weight:600; color:var(--text-muted);
  border-radius:var(--radius-sm); transition:background .2s ease, color .2s ease;
}
.segmented-pill button:hover { color:var(--text); }
.segmented-pill button.active { background:var(--surface); color:var(--color-green-700); box-shadow:var(--shadow-sm); }
/* dark: the n-100 track doesn't remap (ramps are theme-invariant), so it
   stayed near-white; sit the track on --bg so the active --surface chip
   still reads as raised. */
[data-theme="dark"] .segmented-pill, .dark-mode .segmented-pill { background:var(--bg); }

/* HTML tooltip — consumes the --tooltip-* tokens (4real-tokens.css) so
   every balloon in the product (icon hints, table cells, Chart.js/
   ApexCharts) shares one appearance. Modelled on the portal's already-
   tokenized balloon, .pnc-apex-tooltip (painel-negocio-campanha.css
   ~L4397-4407) — NOT .fid-estab-tooltip (painel-fidelidade.css ~L388),
   which predates the tokens and still hardcodes #fff/#e2e8f0/#4a5568; that
   one is legacy and should migrate to this class rather than be copied. */
.tooltip {
  max-width:250px;
  padding:var(--tooltip-pad-y) var(--tooltip-pad-x);
  border-radius:var(--tooltip-radius);
  background:var(--tooltip-bg);
  box-shadow:var(--tooltip-shadow);
  color:var(--tooltip-fg);
  font-size:var(--tooltip-font-size);
  font-weight:var(--tooltip-weight);
  line-height:var(--tooltip-line);
  text-align:left;
  word-wrap:break-word;
}

/* Skeleton loading primitive — one shimmer keyframe, three shapes (a text
   line, a block for a chart/canvas area, a table row). Both shapes and
   the keyframe are the exact values the portal already uses for KPI
   cards, chart placeholders and table rows, unified into one primitive.
   ← portal @keyframes panelSkeleton + its consumers (painel-fidelidade.css
   ~L4532-4611 for the shimmer itself and the KPI/chart placeholders,
   ~L4672-4712 for .fid-skeleton-row / .fid-skeleton-head). */
@keyframes skeleton-shimmer {
  from { background-position:180% 0; }
  to   { background-position:-80% 0; }
}
.skeleton-line, .skeleton-block, .skeleton-row {
  position:relative; overflow:hidden;
  background:var(--color-n-100); border-radius:var(--radius-sm);
}
.skeleton-line::after, .skeleton-block::after, .skeleton-row::after {
  content:''; position:absolute; inset:0;
  background:linear-gradient(105deg,
    transparent 18%, rgba(255,255,255,.55) 42%, rgba(227,226,225,.40) 50%,
    rgba(255,255,255,.55) 58%, transparent 82%);
  background-size:220% 100%;
  animation:skeleton-shimmer 1.8s linear infinite;
}
.skeleton-line { height:14px; }
.skeleton-block { height:100%; min-height:80px; }
.skeleton-row { display:block; height:38px; }
.skeleton-row.skeleton-head { height:30px; }
[data-theme="dark"] .skeleton-line, .dark-mode .skeleton-line,
[data-theme="dark"] .skeleton-block, .dark-mode .skeleton-block,
[data-theme="dark"] .skeleton-row, .dark-mode .skeleton-row {
  background:var(--color-n-700);
}
[data-theme="dark"] .skeleton-line::after, .dark-mode .skeleton-line::after,
[data-theme="dark"] .skeleton-block::after, .dark-mode .skeleton-block::after,
[data-theme="dark"] .skeleton-row::after, .dark-mode .skeleton-row::after {
  background:linear-gradient(105deg,
    transparent 18%, rgba(60,57,58,.55) 42%, rgba(58,54,55,.40) 50%,
    rgba(60,57,58,.55) 58%, transparent 82%);
}
@media (prefers-reduced-motion: reduce) {
  .skeleton-line::after, .skeleton-block::after, .skeleton-row::after { animation:none; }
}

/* Empty state — a neutral circle + small glyph, centred, for an empty
   chart card or an empty modal list. Deliberately small and quiet: it
   should read as "nothing here yet", not compete with real content.
   ← portal .fid-empty (painel-fidelidade.css ~L4747-4779); the portal's
   modal-scoped twin .fid-modal-empty is the same anatomy at a different
   padding and is folded into this one primitive here. */
.empty-state {
  width:100%; text-align:center;
  flex:1 1 auto; display:flex; flex-direction:column;
  align-items:center; justify-content:center; gap:12px;
  padding:32px 16px;
}
.empty-state-icon {
  display:inline-flex; align-items:center; justify-content:center;
  width:40px; height:40px; border-radius:50%;
  background:var(--color-n-50); border:1px solid var(--border);
  color:var(--color-n-400); font-size:15px;
}
.empty-state-text { margin:0; font-family:var(--font-body); font-size:13px; color:var(--text-muted); }

/* Drill-down filter pill ("Filtrado por: …") — same chip anatomy as the
   portal's, with the hardcoded indigo swapped for the DS's reserved
   secondary accent (ultra violet), since this chip is informational, not
   a primary action.
   ← portal .fid-filter-badge (painel-fidelidade.css ~L789-804), which
   hardcodes rgba(102,126,234,*) / #667eea. */
.filter-pill {
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 10px; border-radius:var(--radius-full);
  background:var(--color-accent-100); border:1px solid var(--color-accent-300);
  font-size:11px; font-weight:500; color:var(--color-accent-700);
}
.filter-pill i { font-size:10px; }

/* ── Modal ────────────────────────────────────────────────────────────
   Detail/data modal: identity + a stat pill in the header, an optional
   search, a scrollable body, a loading skeleton, an empty state, a
   footer. Extracted from the two operator/detail modals that already
   carry this full anatomy.
   ← portal .op-modal-* (Fidelidade.cshtml ~L412-436 markup,
   painel-fidelidade.css ~L1458-1571 CSS) for the header/identity/stat/
   close pattern, and .fid-modal-* (Cashback.cshtml ~L317-372 markup,
   painel-fidelidade.css ~L2422-2630 CSS) for the wide content variant,
   search and footer. Both were largely pre-DS (hardcoded #f7fafc,
   #2d3748, #718096, #e2e8f0, focus ring in indigo #667eea) — tokenized
   here rather than copied literally. The backdrop/open-close mechanics
   are left to the host app (the portal's own .pc-modal owns those); this
   is the content chrome. */
.modal-backdrop {
  position:fixed; inset:0; background:rgba(35,31,32,.5);
  display:flex; align-items:center; justify-content:center;
  padding:16px; z-index:1000;
}
.modal {
  display:flex; flex-direction:column;
  max-height:calc(100vh - 32px); width:min(720px, 95vw);
  background:var(--surface); border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg); overflow:hidden;
}
.modal-wide { width:min(900px, 95vw); }

.modal-header {
  flex:0 0 auto; display:flex; align-items:center; justify-content:space-between;
  gap:16px; padding:16px 20px; background:var(--surface); border-bottom:1px solid var(--border);
}
.modal-identity { display:flex; align-items:center; gap:12px; min-width:0; }
.modal-avatar {
  width:38px; height:38px; flex-shrink:0; border-radius:50%;
  background:var(--color-green-50); color:var(--color-green-700);
  display:flex; align-items:center; justify-content:center;
  font-size:14px; font-weight:700;
}
.modal-title {
  margin:0; font-family:var(--font-display); font-size:16px; font-weight:700;
  letter-spacing:-.01em; color:var(--text); line-height:1.25;
}
.modal-subtitle { font-size:12px; color:var(--text-muted); }

/* Single stat pill in the header (e.g. "Pontos gerados: 1.240") */
.modal-stat {
  display:flex; flex-direction:column; align-items:flex-end; gap:2px;
  padding:8px 16px; border:1px solid var(--color-green-200);
  border-radius:12px; background:var(--color-green-50); line-height:1.1;
}
.modal-stat-label {
  font-family:var(--font-body); font-size:11px; font-weight:600;
  letter-spacing:.04em; text-transform:uppercase; color:var(--color-green-700);
  white-space:nowrap;
}
.modal-stat-value {
  font-family:var(--font-display); font-size:22px; font-weight:700;
  letter-spacing:-.02em; color:var(--color-green-900); font-variant-numeric:tabular-nums;
}

/* Multi-stat summary bar in the body (e.g. "Total / Valor" above a list) —
   a different pattern from .modal-stat above, used when there is a list
   to summarise rather than one identity to badge.
   ← portal .fid-modal-stats / .fid-stat-* (painel-fidelidade.css
   ~L2559-2585), which hardcode #f7fafc/#2d3748/#718096. */
.modal-stats { display:flex; gap:24px; margin-bottom:20px; padding:16px; background:var(--bg); border-radius:var(--radius-md); }
.stat-item { display:flex; flex-direction:column; align-items:center; }
.stat-value { font-family:var(--font-display); font-size:24px; font-weight:700; color:var(--text); font-variant-numeric:tabular-nums; }
.stat-label { font-size:11px; font-weight:600; color:var(--text-muted); text-transform:uppercase; letter-spacing:.04em; }

.modal-close {
  position:static; width:32px; height:32px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  border:1px solid var(--border); border-radius:var(--radius-sm);
  background:var(--surface); color:var(--text-muted); font-size:13px; cursor:pointer;
  transition:background .15s ease, color .15s ease;
}
.modal-close:hover { background:var(--color-n-100); color:var(--text); }

.modal-search { position:relative; width:min(420px, 55vw); }
.modal-search i { position:absolute; left:14px; top:50%; transform:translateY(-50%); color:var(--text-muted); }
.modal-search input {
  width:100%; padding:12px 14px 12px 40px; font-family:inherit; font-size:14px;
  color:var(--text); background:var(--surface); border:1.5px solid var(--color-n-300);
  border-radius:var(--radius-md);
}
.modal-search input:focus { outline:0; border-color:var(--action); box-shadow:var(--focus-ring); }

.modal-body { flex:1 1 auto; min-height:0; overflow-y:auto; padding:24px; background:var(--surface); }
.modal-footer { flex:0 0 auto; display:flex; justify-content:flex-end; gap:12px; padding:16px 20px; border-top:1px solid var(--border); background:var(--surface); }
