/* Kaizen · Eduzz Intelligence — app shell, filtros, cards, gráficos, tabelas e calendário. */

/* ---------- Clientes e composição do faturamento ---------- */
.gross-breakdown { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 12px; padding: 18px 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.gross-breakdown div { flex: 1 1 170px; }
.gross-breakdown span, .gross-breakdown small { display: block; color: var(--muted); font-size: 12px; }
.gross-breakdown strong { display: block; margin: 4px 0; font-size: 20px; font-variant-numeric: tabular-nums; }
.gross-breakdown p { flex-basis: 100%; margin: 0; color: var(--subtle); font-size: 12px; }
.customer-intro { margin: 16px 0; color: var(--muted); }
.analytics-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-size: 15px; font-weight: 600; }
.analytics-details summary::after { content: "+"; margin-left: auto; color: var(--accent); }
.analytics-details[open] summary::after { content: "−"; }
.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 20px; }
.analytics-grid h3 { margin-bottom: 10px; }
.customer-filters .field { min-width: 0; flex: 1 1 170px; }
.customer-filters input, .customer-filters select { width: 100%; min-width: 0; min-height: 54px; padding: 23px 14px 7px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--field); }
.customer-filters .filter-row { flex-wrap: wrap; }
.customer-filters select { text-overflow: ellipsis; }
.customer-insights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.customer-note { margin: 10px 0 0; color: var(--subtle); font-size: 12px; overflow-wrap: anywhere; }
.customer-ranking { margin-top: 16px; }
.customer-ranking-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.customer-ranking-row span { min-width: 0; overflow-wrap: anywhere; }
.customer-ranking-row small { display: block; margin-top: 4px; color: var(--subtle); }
.customer-ranking-row strong { padding: 5px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-variant-numeric: tabular-nums; }
.customer-list { margin-top: 16px; }
.customer-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--border); text-decoration: none; }
.customer-row:hover .customer-open { text-decoration: underline; }
.customer-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: var(--radius-xs); }
.customer-identity { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.customer-identity > div { min-width: 0; }
.customer-identity strong, .customer-value strong { display: block; font-size: 15px; }
.customer-row small, .customer-transaction small { display: block; margin-top: 4px; color: var(--subtle); font-size: 12px; }
.customer-row div, .customer-profile p, .customer-transaction div { min-width: 0; overflow-wrap: anywhere; }
.customer-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.customer-tags span { padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 11px; }
.customer-value { text-align: right; }
.customer-open { display: block; margin-top: 10px; color: var(--accent); font-size: 12px; font-weight: 600; }
.customer-pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 16px; margin-top: 20px; color: var(--subtle); }
.customer-coverage { margin: 20px 0; }
.customer-back { margin-top: 16px; }
.customer-profile p { margin: 6px 0 0; color: var(--muted); }
.customer-lifetime { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.customer-lifetime span { display: block; color: var(--muted); font-size: 12px; }
.customer-lifetime strong { display: block; margin-top: 8px; font-size: 22px; overflow-wrap: anywhere; }
.customer-transaction { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.customer-attribution { grid-column: 1 / -1; }
@media (max-width: 800px) {
  .customer-insights { grid-template-columns: minmax(0, 1fr); }
  .analytics-grid { grid-template-columns: minmax(0, 1fr); }
  .customer-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .customer-value { text-align: left; }
  .customer-lifetime { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .customer-transaction { grid-template-columns: minmax(0, 1fr); }
  .customer-filters .button { flex: 1 1 auto; }
  .gross-breakdown { padding: 16px; }
}

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #090a0a;
  --bg-elevated: #0d100e;
  --sidebar: #0c0e0d;
  --surface: #121614;
  --surface-strong: #181d1a;
  --surface-hover: #1f2622;
  --field: #131715;
  --border: #212723;
  --border-strong: #333c36;
  --text: #f3f6f4;
  --muted: #a3ada6;
  --subtle: #7f8a83;
  --accent: #21d07a;
  --accent-hover: #3fe392;
  --accent-ink: #04130a;
  --accent-soft: rgba(33, 208, 122, .13);
  --danger: #ff6b81;
  --amber: #f5b942;
  --chart-secondary: #65a8ff;
  --chart-bars: #8b96a8;
  --scrim: rgba(0, 0, 0, .58);
  --shadow: 0 24px 64px rgba(0, 0, 0, .5);
  --card-shadow: none;
  --radius-lg: 22px;
  --radius: 18px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --sidebar-width: 256px;
  --tabbar-height: 60px;
  --gutter-left: 40px;
  --gutter-right: 40px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f6;
  --bg-elevated: #ffffff;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-strong: #f4f7f5;
  --surface-hover: #eaf0ec;
  --field: #ffffff;
  --border: #e1e7e3;
  --border-strong: #c9d2cc;
  --text: #121714;
  --muted: #56615a;
  --subtle: #69746c;
  --accent: #078f50;
  --accent-hover: #067a44;
  --accent-ink: #ffffff;
  --accent-soft: rgba(7, 143, 80, .10);
  --danger: #d42c4d;
  --amber: #a56a05;
  --chart-secondary: #2563eb;
  --chart-bars: #708090;
  --scrim: rgba(15, 23, 18, .42);
  --shadow: 0 24px 60px rgba(22, 35, 26, .16);
  --card-shadow: 0 1px 2px rgba(22, 35, 26, .04), 0 8px 24px rgba(22, 35, 26, .04);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button, a, summary, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { -webkit-user-select: none; user-select: none; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; font-weight: 750; letter-spacing: -.035em; line-height: 1.15; }
h2 { margin-bottom: 4px; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
h3 { margin-bottom: 2px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: not-allowed; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 300; padding: 12px 16px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.skip-link:focus { top: calc(16px + env(safe-area-inset-top)); }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }

/* ---------- Botões ---------- */
.button, .icon-button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; cursor: pointer; transition: transform .15s ease, background .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease; }
.button { min-height: 44px; gap: 8px; padding: 0 18px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.button svg { width: 17px; height: 17px; flex: 0 0 auto; }
.button:active, .icon-button:active { transform: scale(.97); }
.button:disabled { cursor: progress; opacity: .7; }
.button-primary { background: var(--accent); color: var(--accent-ink); }
.button-primary:hover { background: var(--accent-hover); }
.button-secondary { border-color: var(--border); background: var(--surface-strong); color: var(--text); }
.button-secondary:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.button-danger { background: var(--danger); color: #fff; }
html[data-theme="dark"] .button-danger { color: #2a060d; }
.button-small { min-height: 36px; padding: 0 14px; border-radius: var(--radius-xs); font-size: 13px; }
.icon-button { width: 44px; height: 44px; flex: 0 0 auto; border-color: var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); }
.icon-button:hover { border-color: var(--border-strong); color: var(--text); }
.icon-button:disabled { opacity: .4; }
.icon-button svg { width: 19px; height: 19px; }
.theme-icon { display: none; }
html[data-theme="dark"] .theme-icon-sun, html[data-theme="light"] .theme-icon-moon { display: block; }
#sync-button[aria-busy="true"] svg { animation: spin 1s linear infinite; }

/* ---------- Shell: sidebar (desktop) ---------- */
.app-shell { min-height: 100dvh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: var(--sidebar-width); flex-direction: column; gap: 28px; padding: 28px 16px 20px; border-right: 1px solid var(--border); background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px; }
.brand-mark { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 30%, transparent), var(--accent-soft)); color: var(--accent); }
.brand-mark svg { width: 21px; height: 21px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-size: 12px; }
.nav-list { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600; text-decoration: none; transition: background .16s ease, color .16s ease; }
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); }
.nav-item--account, .sheet-header, .sheet-backdrop, .app-reload { display: none; }

.account-panel { display: grid; gap: 14px; margin-top: auto; }
.account-summary { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.account-avatar { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 750; }
.account-copy { min-width: 0; flex: 1; }
.account-copy strong, .account-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 13px; }
.account-copy span { color: var(--subtle); font-size: 12px; }
.account-logout { min-height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; transition: border-color .15s, color .15s; }
.account-logout:hover { border-color: var(--danger); color: var(--danger); }
.connection-state { display: flex; align-items: center; gap: 12px; padding: 0 12px; }
.connection-state strong, .connection-state span { display: block; }
.connection-state strong { font-size: 12px; }
.connection-state div > span { color: var(--subtle); font-size: 12px; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--accent); animation: status-ping 2.2s ease-out infinite; }
.install-help { padding: 0 12px; color: var(--muted); font-size: 13px; }
.install-help summary { min-height: 36px; padding-block: 8px; cursor: pointer; font-weight: 600; }
.install-help ol { display: grid; gap: 6px; margin: 4px 0 10px; padding-left: 20px; }
.install-help strong { color: var(--text); }
.install-help p { margin: 0 0 6px; color: var(--subtle); font-size: 12px; line-height: 1.55; }
@media (hover: hover) and (min-width: 801px) { .install-help { display: none; } }

/* ---------- Shell: conteúdo ---------- */
.main-content { min-width: 0; margin-left: var(--sidebar-width); padding: 0 var(--gutter-right) 72px var(--gutter-left); background: radial-gradient(900px 420px at 85% -120px, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%) no-repeat; }
.main-content > * { max-width: 1240px; margin-inline: auto; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 34px 0 6px; }
.topbar-title { min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.sync-strip { display: flex; align-items: baseline; gap: 10px; margin-bottom: 28px; color: var(--muted); font-size: 13px; }
.sync-strip .status-dot { transform: translateY(-1px); }
.sync-strip > div { min-width: 0; }
.sync-strip strong { margin-right: 8px; color: var(--text); font-weight: 650; }
.sync-strip[data-state="running"] .status-dot { background: var(--amber); }
.sync-strip[data-state="error"] .status-dot { background: var(--danger); animation: none; }
.sync-strip[data-state="error"] strong { color: var(--danger); }
.data-warning { margin: -12px 0 24px; padding: 12px 16px; border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--border)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--amber) 9%, var(--surface)); font-size: 13px; }
.page-section { padding-top: 44px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.section-heading > div, .card-heading > div { min-width: 0; }
.section-heading p, .card-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.comparison-caption { margin: 0 0 14px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- Filtros ---------- */
.filter-bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 22px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.field { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 6px; }
.field-grow { flex: 1 1 280px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 600; }
.field input, .field select, .search-field input { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--border); outline: none; border-radius: var(--radius-sm); background: var(--field); color: var(--text); font-size: 14px; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus, .search-field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field--boxed > span { position: absolute; top: 9px; left: 15px; z-index: 1; color: var(--subtle); font-size: 11px; font-weight: 600; letter-spacing: .01em; pointer-events: none; }
.field--boxed select, .field--boxed .custom-select__trigger, .field--boxed .date-picker__trigger { min-height: 54px; padding: 22px 14px 7px; }
.compare-field { flex: 0 0 240px; margin-left: auto; }
.currency-field { flex: 0 0 112px; }
.date-field { flex: 0 0 190px; }
.filter-submit { min-height: 54px; }
.product-field { max-width: 520px; }
.product-filter-control { display: flex; align-items: stretch; gap: 8px; }
.product-filter-control select, .product-filter-control .custom-select { min-width: 0; flex: 1; }
.product-favorite-toggle, .product-archive-toggle { display: inline-grid; width: 54px; min-height: 54px; flex: 0 0 auto; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--field); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s, color .15s, opacity .15s; }
.product-favorite-toggle svg, .product-archive-toggle svg { width: 19px; height: 19px; }
.product-favorite-toggle:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.product-favorite-toggle.is-favorite { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); background: var(--accent-soft); color: var(--accent); }
.product-favorite-toggle.is-favorite svg { fill: currentColor; }
.product-archive-toggle:hover:not(:disabled) { border-color: var(--amber); color: var(--amber); }
.product-archive-toggle.is-archived { border-color: color-mix(in srgb, var(--amber) 55%, var(--border)); background: color-mix(in srgb, var(--amber) 12%, var(--surface)); color: var(--amber); }
.product-favorite-toggle:disabled, .product-archive-toggle:disabled { opacity: .4; }
.filter-bar.is-busy .product-favorite-toggle:disabled, .filter-bar.is-busy .product-archive-toggle:disabled { opacity: .7; }
.product-favorites-row { display: flex; min-width: 0; flex: 1 1 260px; align-items: center; gap: 10px; }
.product-favorites { display: flex; min-width: 0; flex: 1; flex-wrap: wrap; align-items: center; gap: 8px; }
.product-favorite-chip { min-height: 36px; max-width: 100%; overflow: hidden; padding: 0 14px; border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border)); border-radius: 999px; background: var(--accent-soft); color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; transition: border-color .15s, background .15s; }
.product-favorite-chip:hover { border-color: var(--accent); }
.product-favorites__empty { min-width: 0; overflow: hidden; color: var(--subtle); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.product-manager-toggle { min-height: 36px; flex: 0 0 auto; padding: 0 12px; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s, color .15s; }
.product-manager-toggle:hover { background: var(--surface-hover); color: var(--text); }
.product-manager-toggle:disabled { cursor: progress; }

/* Controle segmentado (período e métrica) */
.segmented { display: inline-flex; max-width: 100%; gap: 2px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--field); }
.segmented__option { min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: var(--radius-xs); background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.segmented__option:hover { color: var(--text); }
.segmented__option[aria-checked="true"] { border-color: color-mix(in srgb, var(--accent) 34%, transparent); background: var(--accent-soft); color: var(--accent); }
.calendar-metric-field .segmented__option { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* Select customizado */
.custom-select, .date-picker { position: relative; width: 100%; min-width: 0; }
.custom-select__native { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; opacity: 0; pointer-events: none; }
.custom-select__trigger, .date-picker__trigger { display: flex; width: 100%; min-height: 46px; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); outline: none; background: var(--field); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 600; text-align: left; transition: border-color .15s, box-shadow .15s, background .15s; }
.custom-select__trigger:hover, .date-picker__trigger:hover, .custom-select.is-open .custom-select__trigger, .date-picker.is-open .date-picker__trigger { border-color: var(--border-strong); background: var(--surface-strong); }
.custom-select__trigger:focus-visible, .date-picker__trigger:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.custom-select__trigger:disabled, .date-picker__trigger:disabled { cursor: progress; }
.custom-select__label, .date-picker__trigger > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.custom-select__icon { display: grid; flex: 0 0 auto; align-self: center; place-items: center; color: var(--subtle); transition: transform .18s ease, color .15s ease; }
.custom-select__icon svg { width: 16px; height: 16px; stroke-width: 2.2; }
.field--boxed .custom-select__icon, .field--boxed .date-picker__trigger svg { margin-top: -14px; }
.custom-select.is-open .custom-select__icon { color: var(--accent); transform: rotate(180deg); }
.custom-select__menu { position: absolute; top: calc(100% + 8px); right: 0; left: 0; z-index: 60; display: grid; max-height: 320px; gap: 2px; overflow-y: auto; overscroll-behavior: contain; padding: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-strong); box-shadow: var(--shadow); animation: pop-in .14s var(--ease-out); }
.custom-select__menu[hidden], .custom-select__menu[aria-hidden="true"], .date-picker__popover[hidden], .date-picker__popover[aria-hidden="true"] { display: none !important; }
.custom-select__option { display: flex; min-height: 40px; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; text-align: left; transition: background .12s, color .12s; }
.custom-select__option:hover, .custom-select__option:focus-visible { outline: none; background: var(--surface-hover); color: var(--text); }
.custom-select__option[aria-selected="true"] { color: var(--accent); font-weight: 650; }
.custom-select__option[aria-selected="true"]::after { content: ""; width: 6px; height: 11px; flex: 0 0 auto; margin-right: 4px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-2px); }
.custom-select__option:disabled { cursor: not-allowed; opacity: .45; }

/* Date picker */
.date-picker__trigger svg { width: 17px; height: 17px; flex: 0 0 auto; color: var(--subtle); }
.date-picker__popover { position: absolute; top: calc(100% + 8px); left: 0; z-index: 70; width: 296px; padding: 16px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-strong); box-shadow: var(--shadow); animation: pop-in .14s var(--ease-out); }
.date-picker__header, .date-picker__footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.date-picker__header { margin-bottom: 12px; }
.date-picker__header strong { display: block; font-size: 14px; }
.date-picker__navigation { display: flex; gap: 4px; }
.date-picker__nav { display: grid; width: 34px; height: 34px; place-items: center; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.date-picker__nav:hover, .date-picker__nav:focus-visible { outline: none; background: var(--accent-soft); color: var(--accent); }
.date-picker__weekdays, .date-picker__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.date-picker__weekdays { margin-bottom: 4px; color: var(--subtle); font-size: 11px; font-weight: 700; }
.date-picker__day { display: grid; width: 100%; aspect-ratio: 1; place-items: center; border: 1px solid transparent; border-radius: 50%; background: transparent; color: var(--text); cursor: pointer; font-size: 13px; font-variant-numeric: tabular-nums; }
.date-picker__day:hover, .date-picker__day:focus-visible { outline: none; background: var(--accent-soft); }
.date-picker__day.is-outside { color: var(--subtle); opacity: .5; }
.date-picker__day.is-today { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent); font-weight: 750; }
.date-picker__day.is-selected { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 750; }
.date-picker__footer { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.date-picker__footer-button { min-height: 36px; padding: 0 8px; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 600; }
.date-picker__footer-button:hover, .date-picker__footer-button:focus-visible { outline: none; color: var(--text); }
.date-picker__footer-button.is-today-action { color: var(--accent); }

/* ---------- Indicadores ---------- */
.metrics-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.metric-card { display: flex; min-width: 0; grid-column: span 3; flex-direction: column; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--card-shadow); }
.metric-card--hero { grid-column: span 6; padding: 22px; }
.metric-card--accent { border-color: color-mix(in srgb, var(--accent) 26%, var(--border)); background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 15%, var(--surface)), var(--surface) 62%); }
.calendar-summary-grid .metric-card { grid-column: span 2; }
.calendar-summary-grid .metric-card--hero { grid-column: span 6; }
.metric-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.metric-icon { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; border-radius: 9px; background: var(--surface-hover); color: var(--muted); }
.metric-icon svg { width: 16px; height: 16px; }
.metric-icon.accent-green { background: var(--accent-soft); color: var(--accent); }
.metric-icon.accent-amber { background: color-mix(in srgb, var(--amber) 13%, transparent); color: var(--amber); }
.metric-value { display: block; margin-top: 14px; font-size: 24px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.035em; line-height: 1.1; overflow-wrap: anywhere; transition: opacity .2s ease; }
.metric-card--hero .metric-value { font-size: clamp(30px, 3vw, 38px); }
.metrics-grid[aria-busy="true"] .metric-value { opacity: .45; }
.metric-card small { display: block; margin-top: 8px; color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; }
.metric-comparison { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 10px; color: var(--subtle); font-size: 12px; font-variant-numeric: tabular-nums; }
.delta-pill { display: inline-flex; min-height: 22px; align-items: center; padding: 0 8px; border-radius: 999px; background: var(--surface-hover); color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.metric-comparison[data-tone="positive"] .delta-pill { background: var(--accent-soft); color: var(--accent); }
.metric-comparison[data-tone="negative"] .delta-pill { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* ---------- Cards de gráfico ---------- */
.chart-card, .table-card, .calendar-card { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--card-shadow); }
.chart-card, .calendar-card { margin-top: 12px; padding: 22px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.chart-legend:empty { display: none; }
.legend-chip { display: inline-flex; min-height: 32px; flex: 0 0 auto; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text); cursor: pointer; font-size: 12px; font-weight: 600; white-space: nowrap; transition: border-color .15s, color .15s, background .15s; }
.legend-chip[aria-pressed="true"] { background: var(--surface-strong); }
.legend-chip:hover { border-color: var(--border-strong); }
.legend-chip__swatch { width: 10px; height: 10px; flex: 0 0 auto; border: 2px solid currentColor; border-radius: 3px; background: currentColor; }
.legend-chip__swatch.is-line { height: 0; border-width: 2px 0 0; border-radius: 0; background: none; width: 14px; }
.legend-chip__swatch.is-dashed { height: 0; border-width: 2px 0 0; border-style: dashed; border-radius: 0; background: none; width: 14px; }
.legend-chip[aria-pressed="false"] { border-style: dashed; color: var(--subtle); }
.legend-chip[aria-pressed="false"] .legend-chip__swatch { background: none; opacity: .45; }
.chart-wrap { height: 240px; margin-top: 18px; }
.chart-wrap-large { position: relative; height: 320px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.chart-wrap[aria-busy="true"] canvas { opacity: .5; transition: opacity .2s; }
.chart-empty { display: grid; height: 100%; place-items: center; color: var(--muted); font-size: 14px; text-align: center; }
.chart-data { margin-top: 16px; border-top: 1px solid var(--border); }
.chart-data summary { min-height: 44px; padding-top: 14px; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 600; }
.chart-data table { min-width: 620px; margin-top: 8px; }
.calendar-annual-chart-card .chart-data table { min-width: 980px; }
.calendar-annual-chart-card th:not(:first-child) { text-align: right; }
.monthly-average-row td { border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface-strong); color: var(--text); font-weight: 700; }

.chart-tooltip { position: absolute; z-index: 8; width: min(300px, calc(100% - 16px)); min-width: 220px; pointer-events: none; opacity: 0; transform: translateY(5px); padding: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--surface-strong) 94%, transparent); box-shadow: var(--shadow); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); transition: opacity .12s ease, transform .12s ease; }
.chart-tooltip.is-visible { opacity: 1; transform: translateY(0); }
.chart-tooltip__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.chart-tooltip__heading { min-width: 0; }
.chart-tooltip__eyebrow { display: none; }
.chart-tooltip__title { display: block; overflow: hidden; font-size: 14px; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
.chart-tooltip__count { flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.chart-tooltip__count.is-partial { border-color: color-mix(in srgb, var(--amber) 60%, var(--border)); background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--amber); }
.chart-tooltip__rows { display: grid; gap: 8px; padding-top: 11px; }
.chart-tooltip__row, .chart-tooltip__detail { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 14px; }
.chart-tooltip__row-label { display: flex; min-width: 0; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.chart-tooltip__swatch { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 3px; }
.chart-tooltip__swatch.is-line { width: 14px; height: 3px; border-radius: 999px; }
.chart-tooltip__label, .chart-tooltip__detail-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tooltip__value, .chart-tooltip__detail-value { flex: 0 0 auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-tooltip__details { display: grid; gap: 6px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--border); }
.chart-tooltip__details-title { color: var(--subtle); font-size: 10px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.chart-tooltip__detail { color: var(--subtle); font-size: 11px; }
.chart-tooltip__detail-value { color: var(--muted); font-size: 11px; }

/* ---------- Tabelas ---------- */
.table-heading { align-items: flex-end; }
.table-controls { display: flex; align-items: stretch; gap: 10px; }
.table-status { flex: 0 0 232px; }
.search-field { position: relative; display: flex; align-items: center; }
.search-field svg { position: absolute; left: 15px; width: 17px; height: 17px; color: var(--subtle); pointer-events: none; }
.search-field input { width: min(320px, 38vw); min-height: 54px; padding: 0 14px 0 42px; }
.search-field input::placeholder { color: var(--subtle); }
.table-card { overflow: hidden; }
.table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; min-width: 820px; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--subtle); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
td { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
@media (hover: hover) { tbody tr:hover { background: var(--surface-strong); } }
.align-right { text-align: right; }
.cell-primary, .cell-secondary { display: block; }
.cell-primary { color: var(--text); font-weight: 600; }
.cell-secondary { max-width: 280px; margin-top: 2px; overflow: hidden; color: var(--subtle); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.align-right .cell-secondary { max-width: none; }
.status-badge { display: inline-flex; min-height: 24px; align-items: center; gap: 6px; padding: 0 10px; border-radius: 999px; background: var(--surface-hover); color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-badge[data-status="paid"] { background: var(--accent-soft); color: var(--accent); }
.status-badge[data-status="refunded"], .status-badge[data-status="canceled"] { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.status-badge[data-status="waitingPayment"], .status-badge[data-status="waitingRefund"], .status-badge[data-status="processing"] { background: color-mix(in srgb, var(--amber) 13%, transparent); color: var(--amber); }
.table-loading, td.table-empty { min-height: 160px; padding: 56px 24px; color: var(--muted); font-size: 14px; text-align: center; }
.pagination { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pagination > div { display: flex; gap: 8px; }

/* ---------- Exportação ---------- */
.export-card { display: flex; align-items: center; gap: 18px; margin-top: 44px; padding: 24px; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border)); border-radius: var(--radius); background: linear-gradient(110deg, var(--accent-soft), var(--surface) 46%); }
.export-icon { display: grid; width: 48px; height: 48px; flex: 0 0 auto; place-items: center; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); }
.export-icon svg { width: 22px; height: 22px; }
.export-copy { min-width: 0; flex: 1; }
.export-copy h2 { margin-bottom: 4px; }
.export-copy > p:last-child { max-width: 680px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }

/* ---------- Calendário ---------- */
.calendar-year-field { flex: 0 0 128px; }
.calendar-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr); gap: 12px; align-items: start; }
.calendar-month-header { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "title today nav" "summary today nav"; align-items: center; gap: 2px 8px; }
.calendar-month-header h3 { grid-area: title; margin: 0; font-size: 20px; letter-spacing: -.02em; }
.calendar-month-header h3::first-letter, .date-picker__header strong::first-letter { text-transform: uppercase; }
.calendar-month-header p { grid-area: summary; margin: 0; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
#calendar-current-month { grid-area: today; }
.calendar-month-nav { display: flex; grid-area: nav; align-items: center; gap: 8px; }
.calendar-month-nav .icon-button { width: 36px; height: 36px; border-radius: var(--radius-xs); }
.calendar-weekdays, .calendar-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) minmax(92px, .85fr); gap: 6px; }
.calendar-weekdays { margin-top: 20px; color: var(--subtle); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-align: center; text-transform: uppercase; }
.calendar-month-grid { margin-top: 8px; }
.calendar-day, .calendar-week-summary { min-width: 0; min-height: 82px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface-strong); }
.calendar-day { --heat: 0; display: flex; flex-direction: column; gap: 3px; color: var(--text); cursor: pointer; font: inherit; text-align: left; transition: border-color .15s, transform .15s; }
.calendar-day:disabled { cursor: default; }
.calendar-day:hover:not(:disabled) { border-color: var(--border-strong); }
.calendar-day.is-outside { opacity: .28; }
.calendar-day.has-sales { border-color: color-mix(in srgb, var(--accent) 34%, var(--border)); background: color-mix(in srgb, var(--accent) 12%, var(--surface-strong)); background: color-mix(in srgb, var(--accent) calc(7% + var(--heat) * 26%), var(--surface-strong)); }
.calendar-day.is-today .calendar-day__number { display: inline-grid; min-width: 24px; height: 24px; margin: -3px 0 -3px -5px; padding: 0 5px; place-items: center; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
.calendar-day[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.calendar-day__top { display: flex; align-items: center; justify-content: space-between; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.calendar-day.has-sales .calendar-day__top { color: var(--text); }
.calendar-day__dot { display: none; }
.calendar-day__value { margin-top: auto; color: var(--accent); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calendar-day__meta { color: var(--subtle); font-size: 11px; }
.calendar-day:not(.has-sales) .calendar-day__meta { display: none; }
.calendar-week-summary { display: flex; flex-direction: column; justify-content: center; gap: 2px; border-style: dashed; background: transparent; text-align: center; }
.calendar-week-summary strong { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.calendar-week-summary span { color: var(--subtle); font-size: 11px; }
.calendar-week-summary.is-empty strong { color: var(--subtle); }
.calendar-day-detail { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-strong); color: var(--muted); font-size: 13px; }
.day-detail__date { display: block; color: var(--text); font-size: 14px; }
.day-detail__date::first-letter { text-transform: uppercase; }
.day-detail__stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.day-detail__stats span, .day-detail__stats strong { display: block; }
.day-detail__stats span { color: var(--subtle); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.day-detail__stats strong { margin-top: 2px; color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.calendar-insights-list { display: grid; margin-top: 10px; }
.calendar-insight { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.calendar-insight:last-child { padding-bottom: 0; border-bottom: 0; }
.calendar-insight__label { color: var(--subtle); font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.calendar-insight strong { font-size: 15px; font-variant-numeric: tabular-nums; }
.calendar-insight small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.calendar-legend { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.calendar-legend i { width: 10px; height: 10px; margin-left: 6px; border-radius: 3px; background: var(--surface-hover); }
.calendar-legend i.is-positive { background: var(--accent); }
.calendar-mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-top: 18px; }
.calendar-mini-card { min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-strong); }
.calendar-mini-card.is-current-month { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.calendar-mini-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.calendar-mini-header strong { font-size: 14px; }
.calendar-mini-header span { overflow: hidden; color: var(--accent); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.calendar-mini-weekdays, .calendar-mini-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; text-align: center; }
.calendar-mini-weekdays { margin-top: 12px; color: var(--subtle); font-size: 10px; font-weight: 700; }
.calendar-mini-days { margin-top: 4px; }
.calendar-mini-day { display: grid; aspect-ratio: 1; place-items: center; border-radius: 6px; color: var(--subtle); font-size: 10px; font-variant-numeric: tabular-nums; }
.calendar-mini-day.is-outside { visibility: hidden; }
.calendar-mini-day.has-sales { background: var(--accent); color: var(--accent-ink); font-weight: 750; }
.calendar-mini-day.is-today { box-shadow: 0 0 0 1.5px var(--text) inset; }
.calendar-mini-footer { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); text-align: center; }
.calendar-mini-footer strong, .calendar-mini-footer span { display: block; }
.calendar-mini-footer strong { font-size: 13px; font-variant-numeric: tabular-nums; }
.calendar-mini-footer span { color: var(--subtle); font-size: 10px; }

/* ---------- Modais, sheets e avisos ---------- */
.modal-layer { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--scrim); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-card { position: relative; z-index: 1; display: flex; width: min(580px, 100%); max-height: min(700px, calc(100dvh - 48px)); flex-direction: column; overflow: hidden; padding: 24px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-strong); box-shadow: var(--shadow); animation: pop-in .18s var(--ease-out); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal-header h2 { margin-bottom: 0; }
.modal-description { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.product-manager-list { min-width: 0; min-height: 0; margin-top: 18px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--border-strong) transparent; }
.product-manager-section + .product-manager-section { margin-top: 22px; }
.product-manager-section h3 { margin-bottom: 8px; color: var(--subtle); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; }
.product-manager-items { display: grid; width: 100%; min-width: 0; gap: 8px; }
.product-manager-item { display: flex; width: 100%; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.product-manager-item__copy { width: 0; min-width: 0; flex: 1 1 0; }
.product-manager-item__name, .product-manager-item__meta { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.product-manager-item__name { font-size: 14px; }
.product-manager-item__meta { margin-top: 2px; color: var(--subtle); font-size: 12px; }
.product-manager-item__action { min-width: 92px; min-height: 40px; flex: 0 0 auto; padding: 0 14px; border-radius: var(--radius-xs); font-size: 13px; }
.product-manager-empty { margin: 0; padding: 24px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; text-align: center; }
.modal-open { overflow: hidden; }
.logout-dialog { width: min(400px, calc(100% - 32px)); padding: 26px; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-strong); color: var(--text); box-shadow: var(--shadow); }
.logout-dialog::backdrop { background: var(--scrim); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.logout-dialog p { margin-bottom: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 120; display: grid; width: min(380px, calc(100vw - 32px)); gap: 8px; pointer-events: none; }
.toast { padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-strong); box-shadow: var(--shadow); font-size: 14px; animation: toast-in .24s var(--ease-out); pointer-events: auto; }
.toast.is-error { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.connectivity-banner { position: fixed; z-index: 110; inset: auto 16px calc(16px + env(safe-area-inset-bottom)); max-width: 560px; margin-inline: auto; padding: 14px 16px; border: 1px solid var(--amber); border-radius: var(--radius-sm); background: var(--surface-strong); box-shadow: var(--shadow); font-size: 13px; line-height: 1.5; }

/* ---------- Login e offline ---------- */
.login-page { display: grid; min-height: 100dvh; place-items: center; padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: radial-gradient(700px 420px at 50% -80px, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%) no-repeat; }
.login-card { width: min(400px, 100%); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; }
.login-brand img { border-radius: 16px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 22px; letter-spacing: -.02em; }
.login-brand span { color: var(--muted); font-size: 13px; }
.login-intro { margin: 8px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
#login-form { display: grid; gap: 18px; margin-top: 30px; }
#login-form .field > span { font-size: 13px; }
#login-form input { min-height: 54px; border-radius: var(--radius-sm); font-size: 16px; }
.password-control { position: relative; }
.password-control input { padding-right: 92px; }
.password-control button { position: absolute; top: 5px; right: 5px; min-height: 44px; padding-inline: 12px; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 650; }
.login-submit { min-height: 54px; font-size: 16px; }
.login-error { margin: 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 9%, transparent); color: var(--danger); font-size: 14px; line-height: 1.5; }
.login-session-note { margin: 0; color: var(--subtle); font-size: 13px; text-align: center; }
.offline-page { display: grid; min-height: 100dvh; place-items: center; padding: 24px; }
.offline-page main { width: min(400px, 100%); text-align: center; }
.offline-page img { margin-bottom: 24px; border-radius: 20px; }
.offline-page main > p:not(.eyebrow) { margin-block: 14px 26px; color: var(--muted); font-size: 15px; line-height: 1.6; }

/* ---------- Animações ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes status-ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* ---------- Desktop compacto ---------- */
@media (min-width: 801px) and (max-width: 1180px) {
  :root { --sidebar-width: 220px; --gutter-left: 24px; --gutter-right: 24px; }
  .metric-card { grid-column: span 6; }
  .calendar-summary-grid .metric-card { grid-column: span 4; }
  .calendar-summary-grid .metric-card--hero { grid-column: 1 / -1; }
  .calendar-layout { grid-template-columns: 1fr; }
  .compare-field { margin-left: 0; }
  .table-heading { align-items: stretch; flex-direction: column; }
  .table-controls .search-field { flex: 1; }
  .table-controls .search-field input { width: 100%; }
}

/* ---------- Celular e tablet em pé: experiência de aplicativo ---------- */
@media (max-width: 800px) {
  :root { --gutter-left: max(16px, env(safe-area-inset-left)); --gutter-right: max(16px, env(safe-area-inset-right)); font-size: 15px; }
  h1 { font-size: 30px; }
  h2 { font-size: 20px; }

  /* Barra de abas inferior */
  .sidebar { position: static; display: block; width: auto; padding: 0; border: 0; background: none; }
  .brand { display: none; }
  .nav-list { position: fixed; inset: auto 0 0 0; z-index: 40; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 0; padding: 6px max(8px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg-elevated) 80%, transparent); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px); }
  .nav-item, .nav-item--account { display: flex; min-height: 50px; flex-direction: column; justify-content: center; gap: 3px; padding: 0 4px; border-radius: 12px; color: var(--subtle); font-size: 11px; font-weight: 600; }
  .nav-item svg { width: 24px; height: 24px; }
  .nav-item:hover { background: none; }
  .nav-item.is-active, .nav-item[aria-expanded="true"] { background: none; color: var(--accent); }

  /* Sheet da conta */
  .sheet-backdrop { position: fixed; inset: 0; z-index: 60; display: block; background: var(--scrim); animation: fade-in .2s ease; }
  .account-panel { position: fixed; inset: auto 0 0 0; z-index: 70; max-height: 88dvh; gap: 16px; margin: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px max(20px, env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 26px 26px 0 0; background: var(--surface-strong); box-shadow: var(--shadow); visibility: hidden; transform: translateY(105%); transition: transform .32s var(--ease-out), visibility 0s .32s; }
  .account-panel.is-open { visibility: visible; transform: none; transition: transform .32s var(--ease-out), visibility 0s; }
  .account-panel::before, .custom-select__menu::after, .date-picker__popover::before, .modal-card::before { content: ""; width: 38px; height: 5px; flex: 0 0 auto; justify-self: center; align-self: center; margin: 0 auto 2px; border-radius: 999px; background: var(--border-strong); }
  .sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .sheet-header h2 { margin: 0; font-size: 22px; }
  .account-summary { padding: 14px; }
  .account-avatar { width: 44px; height: 44px; font-size: 17px; }
  .account-copy strong { font-size: 16px; }
  .account-copy span { font-size: 13px; }
  .account-logout { min-height: 44px; padding: 0 16px; font-size: 14px; }
  .connection-state, .install-help { padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
  .connection-state strong, .connection-state div > span { font-size: 13px; }
  .install-help { display: block; font-size: 14px; }
  .install-help summary { min-height: 24px; padding: 0; color: var(--text); }
  .install-help ol { margin-top: 12px; }
  .install-help p { font-size: 13px; }
  .app-reload { display: inline-flex; width: 100%; min-height: 50px; }

  /* Cabeçalho com título grande */
  .main-content { margin-left: 0; padding: 0 var(--gutter-right) calc(var(--tabbar-height) + 32px + env(safe-area-inset-bottom)) var(--gutter-left); background-size: 100% 420px; }
  .topbar { position: sticky; top: 0; z-index: 30; align-items: center; gap: 12px; margin: 0 calc(-1 * var(--gutter-right)) 0 calc(-1 * var(--gutter-left)); padding: calc(10px + env(safe-area-inset-top)) var(--gutter-right) 10px var(--gutter-left); background: color-mix(in srgb, var(--bg) 78%, transparent); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); }
  .topbar .eyebrow { margin-bottom: 0; font-size: 10px; }
  .topbar h1 { overflow: hidden; font-size: clamp(24px, 7.4vw, 30px); text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { gap: 8px; }
  .topbar-actions .icon-button, #sync-button, #oauth-button { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
  #sync-button span, #oauth-button span { display: none; }
  #sync-button svg, #oauth-button svg { width: 20px; height: 20px; }
  .sync-strip { margin: 4px 0 18px; font-size: 13px; }
  .sync-strip strong { display: block; margin: 0; }
  .sync-strip span:not(.status-dot) { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
  .page-section { padding-top: 36px; }
  .section-heading { align-items: stretch; flex-direction: column; gap: 14px; }

  /* Filtros: chips roláveis e seletores em sheet */
  .filter-bar { gap: 10px; margin-bottom: 18px; }
  .filter-row { gap: 10px; }
  .filter-row > .field--segmented { flex: 0 0 calc(100% + var(--gutter-left) + var(--gutter-right)); margin: 0 calc(-1 * var(--gutter-right)) 0 calc(-1 * var(--gutter-left)); }
  .filter-row .segmented { display: flex; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; padding: 2px var(--gutter-right) 2px var(--gutter-left); border: 0; border-radius: 0; background: none; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .filter-row .segmented::-webkit-scrollbar { display: none; }
  .filter-row .segmented__option { min-height: 42px; flex: 0 0 auto; padding: 0 16px; border-color: var(--border); border-radius: 999px; background: var(--field); font-size: 15px; }
  .filter-row .segmented__option[aria-checked="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
  .compare-field, .calendar-filters .currency-field, .table-status { flex: 1 1 0; margin-left: 0; }
  .currency-field { flex: 0 0 104px; }
  .calendar-filters .field-grow { order: -1; flex: 1 1 100%; }
  .calendar-year-field { flex: 1 1 0; }
  .date-field { flex: 1 1 0; }
  .filter-submit { flex: 1 1 100%; }
  .product-field { flex: 1 1 100%; max-width: none; }
  .field input, .field select, .search-field input, .custom-select__trigger, .date-picker__trigger { font-size: 16px; }
  .product-favorites-row { flex: 1 1 100%; }
  .product-favorites { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .product-favorites::-webkit-scrollbar { display: none; }
  .product-favorite-chip { min-height: 40px; flex: 0 0 auto; font-size: 14px; }
  .product-manager-toggle { min-height: 40px; padding: 0 4px 0 8px; color: var(--accent); font-size: 14px; }

  .custom-select.is-open::before, .date-picker.is-open::before { content: ""; position: fixed; inset: 0; z-index: 99; background: var(--scrim); animation: fade-in .2s ease; }
  .custom-select__menu, .date-picker__popover { position: fixed; inset: auto 0 0 0; z-index: 100; width: auto; max-height: min(72dvh, 620px); border-width: 1px 0 0; border-radius: 26px 26px 0 0; animation: sheet-in .3s var(--ease-out); }
  .custom-select__menu { gap: 2px; padding: 10px max(12px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .custom-select__menu::after { order: -2; }
  .custom-select__menu::before { content: attr(data-label); order: -1; padding: 10px 12px 8px; color: var(--text); font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
  .custom-select__option { min-height: 52px; padding: 0 12px; font-size: 16px; }
  .date-picker__popover { display: grid; overflow-y: auto; padding: 10px max(20px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  .date-picker__header { margin-top: 8px; }
  .date-picker__header strong { font-size: 18px; }
  .date-picker__nav { width: 44px; height: 44px; font-size: 26px; }
  .date-picker__weekdays { font-size: 12px; }
  .date-picker__day { max-height: 46px; justify-self: center; font-size: 16px; }
  .date-picker__footer-button { min-height: 44px; font-size: 15px; }

  /* Indicadores */
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card, .calendar-summary-grid .metric-card { grid-column: auto; padding: 16px; }
  .metric-card--hero, .calendar-summary-grid .metric-card--hero { grid-column: 1 / -1; padding: 20px; }
  .metric-card:not(.metric-card--hero) .metric-icon { display: none; }
  .metric-value { margin-top: 10px; font-size: 22px; }
  .metric-card--hero .metric-value { margin-top: 14px; font-size: clamp(30px, 9.4vw, 38px); }
  .calendar-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .calendar-summary-grid .metric-card { padding: 14px 12px; }
  .calendar-summary-grid .metric-label { font-size: 12px; }
  .calendar-summary-grid .metric-card small { font-size: 11px; }

  /* Gráficos */
  .chart-card, .calendar-card { padding: 18px 16px; }
  .card-heading { flex-wrap: wrap; }
  .chart-legend { flex-wrap: nowrap; margin-inline: -16px; overflow-x: auto; padding-inline: 16px; scrollbar-width: none; }
  .chart-legend::-webkit-scrollbar { display: none; }
  .legend-chip { min-height: 36px; font-size: 13px; }
  .chart-wrap-large { height: 260px; }
  .chart-tooltip { min-width: 190px; padding: 12px; }

  /* Vendas como lista */
  .table-controls { flex-direction: column; }
  .search-field input { width: 100%; }
  .table-status { flex: 0 0 auto; }
  #vendas .table-scroll { overflow: visible; }
  #vendas table, #sales-body { display: block; min-width: 0; }
  #vendas thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #sales-body tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; grid-template-areas: "name name name money" "product product payment money" "status email email date"; align-items: center; gap: 3px 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  #sales-body tr:last-child { border-bottom: 0; }
  #sales-body td { display: block; min-width: 0; padding: 0; border: 0; font-size: 13px; }
  /* The client cell dissolves so the name and the e-mail can sit on different lines of the row. */
  #sales-body td:nth-child(1):not([colspan]) { display: contents; }
  #sales-body td:nth-child(1) .cell-primary { grid-area: name; overflow: hidden; font-size: 16px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
  #sales-body td:nth-child(1) .cell-secondary { grid-area: email; max-width: none; margin-top: 8px; font-size: 13px; }
  #sales-body td:nth-child(2) { grid-area: product; overflow: hidden; }
  #sales-body td:nth-child(3) { grid-area: status; margin-top: 8px; }
  #sales-body td:nth-child(4) { grid-area: payment; }
  #sales-body td:nth-child(5) { grid-area: date; margin-top: 8px; text-align: right; }
  #sales-body td:nth-child(6) { grid-area: money; align-self: start; }
  #sales-body td:nth-child(6) .cell-primary { font-size: 16px; font-weight: 650; }
  #sales-body td:nth-child(6) .cell-secondary { margin-top: 3px; font-size: 13px; }
  #sales-body td:nth-child(n+2):nth-child(-n+5) .cell-primary { overflow: hidden; color: var(--muted); font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
  #sales-body td:nth-child(n+2):nth-child(-n+5) .cell-secondary { display: none; }
  #sales-body td:nth-child(4) .cell-primary::before { content: "· "; color: var(--subtle); }
  #sales-body td:nth-child(5) .cell-primary { color: var(--subtle); }
  #sales-body .status-badge { min-height: 22px; padding: 0 8px; font-size: 12px; }
  #sales-body td[colspan], #sales-body td.table-empty { grid-column: 1 / -1; padding: 40px 12px; }
  .pagination { padding: 10px 16px; font-size: 14px; }

  .export-card { align-items: flex-start; flex-direction: column; gap: 14px; margin-top: 36px; padding: 20px; }
  .export-icon { display: none; }
  .export-card .button { width: 100%; min-height: 50px; }

  /* Calendário */
  .calendar-layout { grid-template-columns: 1fr; }
  .calendar-month-header { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "title nav" "summary today"; gap: 8px; }
  .calendar-month-nav .icon-button { width: 44px; height: 44px; }
  #calendar-current-month { min-height: 40px; justify-self: end; }
  .calendar-weekdays, .calendar-month-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .calendar-weekdays { margin-top: 16px; font-size: 10px; }
  .calendar-weekdays span:last-child { display: none; }
  .calendar-day { min-height: 54px; align-items: center; justify-content: flex-start; gap: 4px; padding: 7px 2px; border-radius: 12px; text-align: center; }
  .calendar-day__top { justify-content: center; font-size: 14px; }
  .calendar-day__value, .calendar-day .calendar-day__meta { display: none; }
  .calendar-day.has-sales::after { content: attr(data-count); min-width: 20px; padding: 0 5px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); font-size: 11px; font-weight: 750; line-height: 18px; }
  .calendar-day.is-today .calendar-day__number { margin: -3px 0; }
  .calendar-week-summary { min-height: 0; grid-column: 1 / -1; flex-direction: row; align-items: baseline; justify-content: flex-end; gap: 8px; margin-bottom: 6px; padding: 2px 4px 8px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
  .calendar-week-summary::before { content: attr(data-week); margin-right: auto; color: var(--subtle); font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
  .calendar-week-summary strong { font-size: 13px; }
  .calendar-week-summary span { font-size: 12px; }
  .calendar-week-summary.is-empty strong { display: none; }
  .day-detail__stats strong { font-size: 14px; }
  .calendar-mini-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .calendar-mini-card { padding: 12px; }
  .calendar-mini-header { flex-direction: column; gap: 0; }
  .calendar-mini-day { border-radius: 5px; background: var(--surface-hover); font-size: 0; }
  .calendar-mini-day.is-today { box-shadow: 0 0 0 1.5px var(--text); }

  /* Modais viram sheets */
  .modal-layer { place-items: end stretch; padding: 0; }
  .modal-card { width: 100%; max-height: 88dvh; padding: 10px max(20px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); border-width: 1px 0 0; border-radius: 26px 26px 0 0; animation: sheet-in .3s var(--ease-out); }
  .modal-card::before { margin-bottom: 12px; }
  .product-manager-item__action { min-height: 44px; }
  .logout-dialog { margin-bottom: max(16px, env(safe-area-inset-bottom)); border-radius: 26px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { min-height: 50px; }
  .toast-region { right: 12px; bottom: calc(var(--tabbar-height) + 12px + env(safe-area-inset-bottom)); left: 12px; width: auto; }
  .connectivity-banner { bottom: calc(var(--tabbar-height) + 16px + env(safe-area-inset-bottom)); }
}

@media (max-width: 370px) {
  .calendar-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-mini-grid { grid-template-columns: 1fr; }
  .calendar-mini-day { font-size: 10px; }
  #sales-body td:nth-child(1) .cell-secondary { display: none; }
}

/* Instalado na Tela de Início: status bar translúcida exige contraste no tema claro. */
@media (display-mode: standalone) {
  html[data-theme="light"] body::before { content: ""; position: fixed; inset: 0 0 auto; z-index: 200; height: env(safe-area-inset-top); background: #0b0d0c; }
  body { overscroll-behavior-y: none; }
  .install-help { display: none !important; }
  .app-reload { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .status-dot { animation: none; }
}
