:root {
  /* fixa os controles nativos no claro, mesmo com o sistema em modo escuro */
  color-scheme: light;
  --font-inter: 'Inter', sans-serif;

  --background: 0 0% 100%;
  --foreground: 224 71% 4%;
  --card: 0 0% 100%;
  --card-foreground: 224 71% 4%;
  --popover: 0 0% 100%;
  --popover-foreground: 224 71% 4%;
  /* ciano da marca: #01D9E6, extraído da logo Cia do Médico */
  --primary: 183 99% 45%;
  /* texto escuro sobre o ciano: branco sobre ele daria só 1,5:1 */
  --primary-foreground: 200 60% 8%;
  /* ciano escurecido, para quando o ciano precisa virar texto/ícone no claro */
  --primary-strong: 187 95% 26%;
  --secondary: 185 25% 96%;
  --secondary-foreground: 190 30% 15%;
  --muted: 185 25% 96%;
  --muted-foreground: 200 9% 46%;
  --accent: 185 75% 94%;
  --accent-foreground: 187 95% 24%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 100%;
  --border: 190 16% 90%;
  --input: 190 16% 90%;
  --ring: 183 99% 45%;
  --chart-1: 187 86% 35%;
  --chart-2: 160 60% 45%;
  --chart-3: 30 80% 55%;
  --chart-4: 196 80% 40%;
  --chart-5: 340 75% 55%;

  /* status colors — not part of the source system; derived from the chart-2 / chart-3 / destructive hues so they stay in-family */
  --success: 160 60% 32%;
  --success-bg: 160 55% 95%;
  --warning: 30 75% 38%;
  --warning-bg: 30 80% 95%;
  --destructive-bg: 0 84% 96%;

  --gold: 40 92% 46%;        /* ouro do card de meta */
  --gold-ink: 32 78% 30%;    /* dourado escuro, legível como texto */
  --radius: 0.625rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-inter);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar:horizontal { height: 0; display: none; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.4); }
::-webkit-scrollbar-corner { background: transparent; }

.page {
  width: 100%;
  margin: 0;
  padding: 28px 32px 64px;
}

/* ---------- Icons ---------- */

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: hsl(var(--muted-foreground));
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -3px;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: 26px;
  font-weight: 300;
  margin: 0;
  letter-spacing: -0.02em;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.brand-logo {
  height: 38px;
  width: auto;
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.refresh-note {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 300;
  display: flex;
  align-items: center;
  gap: 6px;
}
.refresh-note .icon { width: 13px; height: 13px; color: hsl(var(--success)); }

.btn-link {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.7);
  color: hsl(var(--foreground));
  font-weight: 400;
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-link:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-link .icon { width: 14px; height: 14px; color: inherit; }

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border: none;
  height: 42px; /* matches the filter pills it sits beside */
  padding: 0 20px;
  border-radius: var(--radius);
  font-weight: 400;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.01em;
  transition: background 0.15s;
}
.btn-primary:hover { background: hsl(var(--primary) / 0.9); }
.btn-primary.small { height: 34px; padding: 0 11px; }
.btn-primary .icon { width: 14px; height: 14px; color: inherit; }

/* ---------- Tabs (segmented control) ---------- */

/* navigation + filters live in one panel */
.controls {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: 12px;
  margin-bottom: 18px;
  overflow: hidden;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  flex-wrap: wrap;
}

.controls-row-nav {
  position: relative;
  justify-content: center;
  border-bottom: 1px solid hsl(var(--border) / 0.7);
  background: hsl(var(--secondary) / 0.35);
}

.tabs {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border) / 0.7);
  background: hsl(var(--card));
  padding: 3px;
  gap: 3px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  height: 38px;
  border: 1px solid transparent;
  background: transparent;
  color: hsl(var(--muted-foreground));
  font-weight: 400;
  font-family: inherit;
  padding: 0 22px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover { color: hsl(var(--foreground)); }

.tab-btn.active {
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  border-color: hsl(var(--border) / 0.6);
  box-shadow: 0 1px 2px rgba(16, 20, 24, 0.05);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Cards ---------- */

.card {
  display: flex;
  flex-direction: column;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: none;
  margin-bottom: 16px;
}

.card h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  gap: 8px;
}
/* badge dentro do título não herda o caixa-alta espaçado */
.card h3 .badge { text-transform: none; letter-spacing: normal; }

.info {
  display: inline-flex;
  align-items: center;
  cursor: help;
  margin-left: auto;
  text-transform: none;
  letter-spacing: normal;
}
.icon-info {
  width: 13px;
  height: 13px;
  stroke-width: 1.6;
  color: hsl(var(--muted-foreground) / 0.7);
  transition: color 0.15s;
}
.info:hover .icon-info { color: hsl(var(--primary-strong)); }

.hint {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 300;
  margin: 6px 0 14px;
  line-height: 1.5;
}

/* subtítulo dentro de um card, separando blocos de assunto diferente */
.section-label {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid hsl(var(--border) / 0.7);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: hsl(var(--foreground));
}
.section-label + .hint { margin-top: 4px; }

/* ---------- Filters ---------- */

/* the pills share the row evenly; the button stays at its natural width */
.controls-row-filters .btn-primary { flex: none; }

.filter-field {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.6);
  border-radius: calc(var(--radius) - 2px);
  padding: 5px 12px;
  min-height: 42px;
  transition: border-color 0.15s;
}
/* only the top bar's fields share the width evenly */
.controls-row-filters .filter-field { flex: 1; min-width: 0; }
.filter-field:hover { border-color: hsl(var(--border)); }
.filter-field:focus-within {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

.filter-field label {
  font-size: 9px;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground) / 0.8);
  font-weight: 500;
  letter-spacing: 0.12em;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-field select,
.filter-field input {
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 400;
  width: 100%;
  min-width: 0;
  color: hsl(var(--foreground));
  font-family: inherit;
  height: 18px;
}
/* the CMA field sits inside a card, not the filter bar — keep it compact */
.filter-field select:focus,
.filter-field input:focus {
  outline: none;
  box-shadow: none;
}
/* o select é transparente para casar com a pílula, mas a lista nativa herda
   isso e abre sem fundo — as opções precisam de cor própria */
.filter-field select option,
.meta-horizonte select option {
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
}

/* taken out of the flow so it never pulls the tabs off centre */
.status-note {
  position: absolute;
  right: 14px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 300;
}

/* ---------- Grid ---------- */

.grid {
  display: grid;
  gap: 16px;
}
/* grid items default to min-width:auto, which lets a wide canvas push the
   layout past the viewport — this keeps charts shrinkable */
.grid > * { min-width: 0; }

.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-main { grid-template-columns: 1.7fr 1fr; }

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* o gap da pilha já separa os cards — a margem própria dobraria o espaço.
   A margem vai para a pilha, para o box bater com o dos cards soltos ao lado. */
.stack > .card { margin-bottom: 0; }
.grid > .stack { margin-bottom: 16px; }

/* ---------- Meta card ---------- */

/* Meta comercial ao lado da coorte: a tabela precisa de mais largura */
/* stretch: os dois cards terminam na mesma linha mesmo se a coorte crescer */
.grid-meta-coorte { grid-template-columns: 1.7fr 1fr; align-items: stretch; }
.grid-meta-coorte .meta-card { order: 2; display: flex; flex-direction: column; }
.grid-meta-coorte .meta-grid {
  grid-template-columns: 1fr;
  flex: 1;
  grid-auto-rows: 1fr;   /* as caixas dividem a altura sobrando */
}
@media (max-width: 1100px) { .grid-meta-coorte { grid-template-columns: 1fr; } }

/* Aura dourada: este é o card do tesouro, o número que o time persegue */
.meta-card {
  padding-bottom: 16px;
  position: relative;
  border-color: hsl(var(--gold) / 0.55);
  background:
    linear-gradient(180deg, hsl(var(--gold) / 0.10), hsl(var(--gold) / 0) 190px),
    hsl(var(--card));
  box-shadow:
    0 0 0 1px hsl(var(--gold) / 0.22),
    0 10px 34px -14px hsl(var(--gold) / 0.55);
}
/* fio dourado no topo, como a borda de uma moeda */
.meta-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg,
    hsl(var(--gold) / 0.25), hsl(var(--gold)), hsl(45 95% 72%), hsl(var(--gold)), hsl(var(--gold) / 0.25));
}
.meta-card .meta-header h2 { color: hsl(var(--gold-ink)); }
/* a linha do período é legenda, não título: menor e mais discreta */
.meta-card .meta-periodo {
  font-size: 10px;
  letter-spacing: 0.01em;
  margin: 0 0 16px;
}

.meta-card .meta-box.is-principal {
  border-color: hsl(var(--gold) / 0.75);
  background: hsl(var(--gold) / 0.09);
  box-shadow: inset 0 0 0 1px hsl(var(--gold) / 0.3);
}

.meta-card .tag-principal {
  background: hsl(var(--gold) / 0.18);
  color: hsl(var(--gold-ink));
}

/* título e controles na mesma linha; o período desce para a linha de baixo,
   senão a legenda longa empurra o botão para fora do card estreito */
.meta-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: nowrap;
  gap: 12px;
}

.meta-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--foreground));
  display: flex;
  align-items: center;
  gap: 8px;
}

.muted { color: hsl(var(--muted-foreground)); font-size: 13px; font-weight: 300; margin: 4px 0 0; }

.meta-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.meta-box {
  display: flex;
  flex-direction: column;
  /* spreads the lines through the box instead of pooling the slack in one gap */
  justify-content: space-between;
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: calc(var(--radius) - 2px);
  padding: 12px 14px;
  background: hsl(var(--card));
}
.meta-box .label {
  font-size: 11px;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground) / 0.8);
  font-weight: 500;
  letter-spacing: 0.14em;
}
.meta-box .value {
  font-size: 22px;
  font-weight: 300;
  margin: 3px 0 2px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.meta-box .sub { font-size: 12px; font-weight: 300; color: hsl(var(--muted-foreground)); }
/* respiro entre as linhas de referência (piso / meta projetada) */
.meta-box .sub:not(.forte) + .sub { margin-top: 4px; }
/* marca do esperado até hoje, dentro da própria barra */
.meta-box .sub strong { font-weight: 500; color: hsl(var(--foreground)); }
/* last line of the box, so the four statuses read across on one line */
.meta-box .status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 10px;
}
/* a bolinha herda o tom do semáforo do .status (tom-green/amber/red/blue) */
.meta-box .status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 4px;
}
.status-green { color: hsl(var(--success)); }
.status-green .dot { background: hsl(var(--success)); }
.status-red { color: hsl(var(--destructive)); }
.status-red .dot { background: hsl(var(--destructive)); }
.status-neutral { color: hsl(var(--muted-foreground)); }
.status-neutral .dot { background: hsl(var(--muted-foreground)); }

/* ---------- Numbers & KV lists ---------- */

.big-number {
  font-size: 36px;
  font-weight: 600;
  margin: 8px 0 14px;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

#dadosContratosList dd,
#caixaValue,
#mrrFinalValue {
  font-weight: 600;
}

#dadosContratosList > div:nth-child(2) dd {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: hsl(var(--foreground));
}

#dadosContratosList > div:nth-child(2) dt {
  align-self: center;
}

.kv-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.kv-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  padding: 9px 0;
  border-top: 1px solid hsl(var(--border) / 0.7);
}
.kv-list > div:first-child { border-top: none; }
.kv-list dt { color: hsl(var(--muted-foreground)); font-weight: 300; margin: 0; }
.kv-list dd { margin: 0; font-weight: 400; font-variant-numeric: tabular-nums; color: hsl(var(--foreground)); }
.kv-list dd.positive { color: hsl(var(--success)); }
.kv-list dd.negative { color: hsl(var(--destructive)); }

/* the swatch beside a label carries the series identity (never the text color) */
.kv-list dt .swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: 1px;
}
/* keeps labels aligned whether or not the row carries a swatch */
.kv-list dt .swatch-spacer { display: inline-block; width: 16px; }

.kv-list.compact > div { font-size: 12px; padding: 6px 0; }

/* value carried inside a pill, for the anchor rows of a composition */
.kv-list .value-pill {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-weight: 500;
  line-height: 1.5;
}
.kv-list .value-pill.tone-neutral {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}
.kv-list .value-pill.tone-good {
  background: hsl(var(--success-bg));
  color: hsl(var(--success));
}
.kv-list .value-pill.tone-bad {
  background: hsl(var(--destructive-bg));
  color: hsl(var(--destructive));
}
.kv-list .value-pill.tone-warn {
  background: hsl(var(--warning-bg));
  color: hsl(var(--warning));
}
/* variante sólida: fundo cheio e texto branco */
.kv-list .value-pill.solid.tone-bad {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.kv-list .value-pill.solid.tone-good {
  background: hsl(var(--success));
  color: #fff;
}
.kv-list .value-pill.solid.tone-warn {
  background: hsl(var(--warning));
  color: #fff;
}

/* legenda abaixo do valor, dentro da mesma linha */
.kv-list dd.dd-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}
.kv-list .dd-caption {
  font-size: 11px;
  font-weight: 300;
  color: hsl(var(--muted-foreground));
}
.kv-list .dd-caption.negative { color: hsl(var(--destructive)); }
/* legenda em balão: texto branco, então o fundo vai sólido (o tom claro
   do .tone-bad não daria contraste com branco no tema claro) */
.kv-list .dd-caption.value-pill {
  padding: 2px 9px;
  font-weight: 400;
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

/* seta fora da cápsula */
.kv-list dd.dd-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.kv-list .arrow-out { font-size: 11px; line-height: 1; }
.kv-list .arrow-out.tone-good { color: hsl(var(--success)); }
.kv-list .arrow-out.tone-bad { color: hsl(var(--destructive)); }
.kv-list .arrow-out.tone-warn { color: hsl(var(--warning)); }

/* closing row of a composition (the sum of the rows above it) */
.kv-list > div.total { border-top-color: hsl(var(--border)); }
.kv-list > div.total dd { font-weight: 600; }

.pill {
  margin-top: 12px;
  font-weight: 400;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: calc(var(--radius) - 2px);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* ---------- Growth blocks ---------- */

/* The last list in a card fills the leftover height, and its rows share that
   space equally — so the card reads as a full table instead of tight rows with
   a pool of empty space (or one visible gap) somewhere in the card. */
/* o card do Caixa absorve a sobra da coluna; o de baixo fica no seu tamanho */
.stack > #cardCaixa { flex: 1; }

.card > .kv-list:last-child,
.kv-list:has(+ .metric-blocks),
.kv-list:has(+ .growth-blocks) {
  flex: 1;
}
.card > .kv-list:last-child > div,
.kv-list:has(+ .metric-blocks) > div,
.kv-list:has(+ .growth-blocks) > div {
  flex: 1;
  align-items: center;
}

.metric-blocks,
.growth-blocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
/* card de largura cheia: os pares ficam lado a lado e quebram em telas menores */
.metric-blocks-wide {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
/* três blocos em coluna estreita: cabem lado a lado e quebram se apertar */
.metric-blocks-3 {
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
}

/* duas colunas de três: o fluxo por coluna mantém as médias de um lado
   e o mês corrente do outro, na mesma ordem em que são gerados */
.metric-blocks-2col {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(3, auto);
  grid-auto-flow: column;
}
@media (max-width: 1150px) {
  .metric-blocks-2col { grid-auto-flow: row; grid-template-rows: none; }
}

/* same box as a growth block, but neutral — these values carry no direction */
.metric-block {
  border-radius: calc(var(--radius) - 2px);
  padding: 10px 12px;
  background: hsl(var(--secondary));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-block .label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: hsl(var(--muted-foreground));
  display: flex;
  align-items: center;
  gap: 5px;
}
.metric-block .label .info { margin-left: 0; }
.metric-block .value {
  font-size: 17px;
  font-weight: 400;
  color: hsl(var(--foreground));
  font-variant-numeric: tabular-nums;
}
.metric-block .sub {
  font-size: 11px;
  font-weight: 300;
  line-height: 1.35;
  color: hsl(var(--muted-foreground));
}

/* a coroa acompanha a linha do nome, não o centro do bloco de duas linhas */
.metric-block .best-seller-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
}

.metric-block .best-seller-crown {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  text-align: center;
  flex: none;
  flex-shrink: 0;
  order: 2;
  /* centra a coroa (30px) na linha do nome (16px × 1,3 = 20,8px), em vez de
     no meio do bloco de duas linhas */
  margin: -4.6px 0 0;
}

.metric-block .best-seller-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  order: 1;
}

.metric-block .best-seller-name {
  display: block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  color: hsl(var(--foreground));
}

.metric-block .best-seller-meta {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  color: hsl(var(--muted-foreground));
}

/* selo de meta dentro do bloco */
.metric-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
}
.metric-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: currentColor;
}
.metric-status.tone-good { color: hsl(var(--success)); }
.metric-status.tone-bad { color: hsl(var(--destructive)); }
.metric-status.tone-warn { color: hsl(var(--warning)); }

.growth-block {
  border-radius: calc(var(--radius) - 2px);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.growth-block .label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: hsl(var(--muted-foreground));
}
.growth-block .value {
  font-size: 17px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.growth-block .value .arrow { font-size: 0.85rem; line-height: 1; }
.growth-block .caption {
  font-size: 11px;
  font-weight: 300;
  line-height: 1.35;
  color: hsl(var(--muted-foreground));
}
.growth-block.positive { background: hsl(var(--success-bg)); }
.growth-block.positive .value { color: hsl(var(--success)); }
.growth-block.negative { background: hsl(var(--destructive-bg)); }
.growth-block.negative .value { color: hsl(var(--destructive)); }
/* cresceu, mas não bateu a meta */
.growth-block.warning { background: hsl(var(--warning-bg)); }
.growth-block.warning .value { color: hsl(var(--warning)); }

/* ---------- Donut (Situação das mensalidades) ---------- */

.donut-wrap {
  position: relative;
  width: 156px;
  height: 156px;
  flex: none;
  margin: 2px auto 14px;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}
.donut-center .value {
  font-size: 26px;
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.donut-center .label {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: hsl(var(--muted-foreground) / 0.8);
  margin-top: 3px;
}

/* ---------- Charts ---------- */

.chart-wrap {
  height: 250px;
  position: relative;
}
.chart-wrap.tall { height: 300px; }
.chart-wrap.compact { height: 108px; }
/* o card é flex column: o gráfico combinado absorve a altura que sobrar,
   em vez de deixar um vazio quando a coluna vizinha estica a linha */
.chart-wrap.chart-combo {
  height: auto;
  flex: 1;
  min-height: 360px;
}

/* period picker on a chart card */
.period-select { position: relative; }

.badge-btn {
  border: 1px solid transparent;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s;
}
.badge-btn:hover { border-color: hsl(var(--primary) / 0.4); }

.period-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  min-width: 118px;
  background: hsl(var(--popover));
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 20, 24, 0.10);
}
.period-select:hover .period-menu,
.period-select:focus-within .period-menu { display: flex; }

.period-menu button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  color: hsl(var(--foreground));
  text-align: left;
  padding: 7px 10px;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
}
.period-menu button:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.period-menu button.active {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.chart-subtitle {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: hsl(var(--muted-foreground) / 0.8);
  margin: 16px 0 6px;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
}
.card-header-row h3, .card-header-row h4 { margin: 0; }

.rank-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.rank-split-card {
  margin-bottom: 0;
}
.compact-rank {
  height: 280px;
}

.daily-sales-card {
  margin-top: 2px;
  margin-bottom: 16px;
}

.daily-sales-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 10px;
  color: hsl(var(--foreground));
}

.daily-sales-head strong {
  font-size: clamp(1.5rem, 1.2rem + 0.8vw, 2rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: hsl(var(--foreground));
}

.daily-sales-label {
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}

.daily-chart {
  height: 320px;
}

.badge-date {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border) / 0.8);
}

.badge {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
  font-size: 11px;
  font-weight: 500;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Coorte heatmap ---------- */

/* a tabela estica para ocupar a altura toda do card */
#cardCoorte { display: flex; flex-direction: column; }
.coorte-scroll { overflow-x: auto; flex: 1; }
.coorte-scroll > .coorte-table { height: 100%; }

.coorte-table {
  border-collapse: separate;
  border-spacing: 3px;
  width: 100%;
  font-size: 12px;
}
.coorte-table th, .coorte-table td {
  padding: 3px 7px;
  text-align: center;
  white-space: nowrap;
}
.coorte-table th {
  color: hsl(var(--muted-foreground));
  font-weight: 400;
  font-size: 11px;
}
/* nomeia os eixos: sem isso os números 1..12 parecem meses do calendário */
.coorte-table th.axis-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  /* o letter-spacing sobra depois da última letra e desloca o centro visual */
  text-indent: 0.08em;
  color: hsl(var(--muted-foreground) / 0.75);
  padding-bottom: 2px;
}
.coorte-table th.axis-label[rowspan] { vertical-align: bottom; }
/* width:1% + nowrap encolhe a coluna ao conteúdo; sem isso ela absorve toda a
   sobra da tabela (100% de largura) e o mês fica longe das células */
.coorte-table td.row-label,
.coorte-table th.axis-label[rowspan] {
  width: 1%;
  white-space: nowrap;
  text-align: center;
  padding-left: 2px;
  padding-right: 8px;
}
.coorte-table td.row-label {
  font-weight: 400;
  color: hsl(var(--foreground));
}
.coorte-table td.cell {
  border-radius: 5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.coorte-table td.empty { background: transparent; }

.coorte-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 300;
  color: hsl(var(--muted-foreground));
}
/* legenda em faixas nomeadas, não rampa contínua */
.coorte-legend .ramp {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
}
.coorte-legend .ramp .faixa {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 400;
  color: hsl(var(--foreground));
  white-space: nowrap;
}
.coorte-legend .ramp .faixa i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}

/* ---------- Center / stat tiles ---------- */

.center-card { text-align: center; }
.center-card h3 { justify-content: center; }
.center-card .big-number { font-size: 26px; }

.total-dia { font-size: 13px; font-weight: 300; color: hsl(var(--muted-foreground)); margin: 0 0 8px; }
.total-dia strong { color: hsl(var(--foreground)); font-size: 17px; font-weight: 400; }

/* ---------- Vendedor list ---------- */

/* ---------- Busca + paginação da lista ---------- */

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 320px;
  height: 38px;
  padding: 0 12px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.search-field:hover { border-color: hsl(var(--border)); }
.search-field:focus-within {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}
.search-field .icon { width: 15px; height: 15px; color: hsl(var(--muted-foreground)); }
.search-field input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  color: hsl(var(--foreground));
}
.search-field input::-webkit-search-cancel-button { cursor: pointer; }

.list-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 300;
  color: hsl(var(--muted-foreground));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty-state {
  margin: 0;
  padding: 28px 0;
  text-align: center;
  font-size: 13px;
  font-weight: 300;
  color: hsl(var(--muted-foreground));
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pagination:empty { display: none; }

.page-nums { display: flex; gap: 4px; flex-wrap: wrap; }

.pagination button {
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  border: 1px solid hsl(var(--border) / 0.7);
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, border-color 0.15s;
}
.pagination button:hover:not(:disabled) {
  background: hsl(var(--accent));
  border-color: hsl(var(--primary) / 0.4);
}
.pagination button:disabled {
  opacity: 0.45;
  cursor: default;
}
.pagination .page-num.active {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  font-weight: 500;
}

.vendedores-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vendedor-row {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: calc(var(--radius) - 2px);
  padding: 11px 15px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: hsl(var(--card));
}
.vendedor-row:hover { border-color: hsl(var(--border)); }
.vendedor-row.active { border-color: hsl(var(--primary) / 0.5); background: hsl(var(--accent)); }

/* posição, etiqueta de categoria e total ficam na mesma linha do nome, em vez
   de centrados na altura da linha inteira */
.rank-pos {
  width: 26px;
  flex: none;
  align-self: flex-start;
  text-align: right;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: hsl(var(--muted-foreground) / 0.75);
}
/* pódio destacado com o ciano da marca */
.vendedor-row.is-top .rank-pos { color: hsl(var(--primary-strong)); font-weight: 600; }
.vendedor-row.is-top .avatar { background: hsl(var(--primary) / 0.22); }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.14);
  color: hsl(var(--primary-strong));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.vendedor-info { flex: 1; min-width: 0; }
.name-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.name-wrap {
  min-width: 0;
  flex: 1;
}
.vendedor-info .name {
  font-weight: 400;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vendedor-summary {
  margin-top: 3px;
  color: hsl(var(--foreground));
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.vendedor-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.vendedor-tag.commercial {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary-strong));
}
.vendedor-tag.reception {
  background: hsl(var(--warning) / 0.12);
  color: hsl(var(--warning));
}
.vendedor-info .days { font-size: 12px; font-weight: 300; color: hsl(var(--muted-foreground)); margin: 2px 0 7px; }

.progress-track {
  height: 4px;
  background: hsl(var(--secondary));
  border-radius: 4px;
  overflow: hidden;
}
.progress-track > span {
  display: block;
  height: 100%;
  background: hsl(var(--primary));
  border-radius: 4px;
}

/* categoria + total formam uma coluna só, centrada na altura da linha */
.vendedor-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  flex-shrink: 0;
  align-self: center;
}
.vendedor-total .num { font-size: 18px; font-weight: 400; color: hsl(var(--foreground)); font-variant-numeric: tabular-nums; }
.vendedor-total .lbl { font-size: 10px; color: hsl(var(--muted-foreground) / 0.8); text-transform: uppercase; font-weight: 500; letter-spacing: 0.1em; }

.drilldown {
  margin-top: 18px;
  border-top: 1px solid hsl(var(--border) / 0.7);
  padding-top: 16px;
}

/* aberto dentro da lista: vira um painel preso à linha do vendedor */
.vendedores-list .drilldown {
  margin-top: -4px;
  padding: 14px 16px 16px;
  border: 1px solid hsl(var(--primary) / 0.35);
  border-top: none;
  border-radius: 0 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px);
  background: hsl(var(--accent) / 0.5);
}
/* a linha ativa encosta no painel */
.vendedor-row.active {
  border-bottom-color: transparent;
  border-radius: calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0 0;
}

.tiny-note { font-size: 11px; font-weight: 300; color: hsl(var(--muted-foreground)); }

/* ---------- Campo CMA (simulador do card CSV) ---------- */

.cma-field { margin-bottom: 16px; }

.cma-field > label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: hsl(var(--muted-foreground) / 0.8);
  margin-bottom: 6px;
  cursor: pointer;
}

/* a moldura é do grupo inteiro, então o botão fica embutido no campo */
.cma-input {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 4px 0 12px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.cma-input:hover { border-color: hsl(var(--border)); }
.cma-input:focus-within {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}

.cma-input .prefix {
  font-size: 13px;
  font-weight: 300;
  color: hsl(var(--muted-foreground));
}

.cma-input input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  color: hsl(var(--foreground));
  font-variant-numeric: tabular-nums;
}

.cma-input .btn-primary {
  height: 34px;
  padding: 0 14px;
  font-size: 12px;
  flex: none;
}

.cma-field .tiny-note { margin: 6px 0 0; }

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

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: hsl(224 40% 6% / 0.55);
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(16, 20, 24, 0.22);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid hsl(var(--border) / 0.7);
}
.modal-header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 300;
  letter-spacing: -0.01em;
}
.modal-header .btn-link { padding: 6px 8px; flex: none; }

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-field { display: flex; flex-direction: column; gap: 6px; }
/* a classe acima ganha do [hidden] do navegador; sem isto o campo oculto continua visível */
.modal-field[hidden] { display: none; }
/* label direto ou dentro do .field-head: mesmo estilo nos dois casos */
.modal-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: hsl(var(--muted-foreground) / 0.8);
}
.modal-field > .tiny-note { margin: 0; }
.modal-field input,
.modal-field select {
  height: 40px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: hsl(var(--foreground));
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border) / 0.7);
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}
.modal-field input:focus,
.modal-field select:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 1px hsl(var(--ring));
}
.modal-field select {
  appearance: none;
  cursor: pointer;
  font-variant-numeric: normal;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  padding-right: 32px;
}
.modal-field select option { color: hsl(var(--foreground)); background: hsl(var(--card)); }

/* período da meta: início — até — fim */
.modal-range { display: flex; align-items: center; gap: 10px; }
.modal-range input { flex: 1; min-width: 0; }
.modal-range .range-sep {
  flex: none;
  font-size: 12px;
  font-weight: 400;
  color: hsl(var(--muted-foreground));
}
@media (max-width: 480px) {
  .modal-range { flex-direction: column; align-items: stretch; }
  .modal-range .range-sep { text-align: center; }
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid hsl(var(--border) / 0.7);
}

.error-banner {
  background: hsl(var(--destructive-bg));
  color: hsl(var(--destructive));
  border-radius: calc(var(--radius) - 2px);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 400;
}

/* Tema claro é o padrão, independente da preferência do sistema.
   Para voltar ao escuro, use <html data-theme="dark">. */
:root[data-theme="dark"] {
  --gold: 42 88% 58%;
  --gold-ink: 44 90% 72%;
    /* makes native widgets (select popups, scrollbars) render dark too */
    color-scheme: dark;
    --background: 224 71% 4%;
    --foreground: 220 14% 96%;
    --card: 224 50% 7%;
    --card-foreground: 220 14% 96%;
    --popover: 224 50% 7%;
    --popover-foreground: 220 14% 96%;
    --primary: 183 90% 48%;
    --primary-foreground: 200 60% 8%;
    --primary-strong: 183 85% 62%;
    --secondary: 195 30% 12%;
    --secondary-foreground: 185 25% 96%;
    --muted: 195 30% 12%;
    --muted-foreground: 200 9% 58%;
    --accent: 187 70% 15%;
    --accent-foreground: 183 85% 68%;
    --destructive: 0 62% 30%;
    --destructive-foreground: 0 0% 98%;
    --border: 195 25% 16%;
    --input: 195 25% 16%;
    --ring: 183 90% 48%;

    --success: 160 55% 55%;
    --success-bg: 160 40% 14%;
    --warning: 30 75% 60%;
    --warning-bg: 30 50% 14%;
    --destructive-bg: 0 45% 16%;
}

/* etiqueta da caixa escolhida como alvo principal do período */
.meta-box .tag-principal {
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.14);
  color: hsl(var(--primary-strong));
  font-size: 9px;
  letter-spacing: 0.06em;
}
.meta-box.is-principal { border-color: hsl(var(--primary) / 0.45); }

/* Horizonte ao lado do "Definir meta": filtra só este card, aplica na hora */
.meta-header-acoes { display: flex; align-items: center; gap: 10px; }
.meta-horizonte { display: flex; align-items: center; gap: 7px; }
.meta-horizonte label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  color: hsl(var(--gold-ink) / 0.75);
}
.meta-horizonte select {
  appearance: none;
  height: 34px;
  padding: 0 28px 0 10px;
  font-family: inherit;
  font-size: 13px;
  color: hsl(var(--foreground));
  background-color: hsl(var(--card));
  border: 1px solid hsl(var(--gold) / 0.45);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23885011' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
}
.meta-horizonte select:focus {
  outline: none;
  border-color: hsl(var(--gold));
  box-shadow: 0 0 0 1px hsl(var(--gold));
}
.meta-horizonte select option { color: hsl(var(--foreground)); background: hsl(var(--card)); }

/* label + "Usar atual" na mesma linha do campo */
.modal-field .field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.btn-usar-atual {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: hsl(var(--primary-strong));
}
.btn-usar-atual:hover { text-decoration: underline; }

/* ===== Placar de ritmo comercial ===== */

.meta-vazio {
  font-size: 13px;
  font-weight: 300;
  line-height: 1.55;
  color: hsl(var(--muted-foreground));
  padding: 8px 0;
}

/* tons do semáforo, usados em texto e em barra */
.tom-green { color: hsl(var(--success)); }
.tom-amber { color: hsl(var(--warning)); }
.tom-red { color: hsl(var(--destructive)); }
.tom-neutral { color: hsl(var(--muted-foreground)); }
.tom-blue { color: hsl(var(--primary-strong)); }

/* diagnóstico: a primeira coisa que se lê no card */

/* barra = realizado sobre a meta total; a marca vertical é o esperado hoje */

/* histórico → meta → realizado, lado a lado */
/* mesmas caixas douradas do design anterior do card */
/* o realizado carrega o tom do semáforo, que precisa vencer o dourado */


/* premissas da projeção: contexto do motor, não meta do time */
.meta-premissas {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
  padding: 7px 10px;
  border-radius: calc(var(--radius) - 2px);
  background: hsl(var(--gold) / 0.09);
  border: 1px solid hsl(var(--gold) / 0.25);
  font-size: 12px;
  font-weight: 400;
  color: hsl(var(--gold-ink));
}
.meta-premissas .info { margin-left: 0; }
.meta-premissas .icon-info { color: hsl(var(--gold-ink) / 0.8); }

/* o percentual da meta é a leitura principal abaixo da barra */
.meta-box .sub.forte {
  font-size: 12.5px;
  font-weight: 500;
  color: hsl(var(--foreground));
  /* respiro entre o percentual da meta e a linha de referência abaixo */
  margin-bottom: 6px;
  margin-top: 1px;
}

/* barra em blocos: 24 segmentos, preenchidos na cor do status */
.meta-box .bar-segmentos {
  display: flex;
  gap: 3px;
  margin: 8px 0 7px;
}
.meta-box .bar-segmentos i {
  flex: 1;
  height: 9px;
  border-radius: 2px;
  min-width: 0;
}

/* churn e tíquete dividem a última linha do placar */
.meta-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.meta-pair > .meta-box { margin: 0; }
@media (max-width: 560px) {
  .meta-pair { grid-template-columns: 1fr; }
}


/* ===== Responsivo: tablet e celular ===== */

/* o canvas mede a caixa absoluta, então o gráfico segue o tamanho do
   .chart-wrap no desktop e pode ficar mais largo que ele no celular */
.chart-swipe .chart-scroll { position: absolute; inset: 0; }

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

@media (max-width: 640px) {
  .page { padding: 14px 12px 40px; }

  .topbar { margin-bottom: 14px; gap: 10px; }
  .brand-logo { height: 30px; }
  .refresh-note { font-size: 12px; white-space: nowrap; }
  /* celular não tem a API de tela cheia (iPhone) ou ela pouco ajuda */
  #fullscreenBtn { display: none; }

  /* o status sai da posição absoluta: em tela estreita ele cobriria as abas */
  .controls-row-nav { flex-direction: column; gap: 6px; }
  .status-note { position: static; }
  .tabs { width: 100%; }
  /* com 3 abas o texto quebra em 2 linhas em vez de empurrar a última para fora da tela */
  .tab-btn { flex: 1 1 0; min-width: 0; justify-content: center; text-align: center; padding: 4px 8px;
             height: auto; min-height: 38px; white-space: normal; line-height: 1.2; }

  .controls-row-filters { display: grid; grid-template-columns: 1fr 1fr; }
  .controls-row-filters .btn-primary { justify-content: center; }

  .card { padding: 16px 14px; }
  .card h3 { font-size: 13px; letter-spacing: 0.04em; }
  .big-number { font-size: 30px; }

  .card-header-row { flex-wrap: wrap; }
  .kv-list > div { gap: 12px; }
  .kv-list dt { flex: 1; min-width: 0; }
  .kv-list dd { text-align: right; white-space: nowrap; }
  .kv-list dd.dd-stack { flex: 0 1 auto; max-width: 62%; }
  .kv-list .dd-caption { white-space: normal; }

  /* gráficos de barra por mês/dia: altura fixa e largura mínima, com rolagem
     lateral dentro do card para os rótulos não se atropelarem */
  .chart-wrap.chart-combo { flex: none; min-height: 0; height: 320px; }
  .chart-swipe { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
  .chart-swipe .chart-scroll { right: auto; width: max(100%, 640px); }
  .daily-chart .chart-scroll { width: max(100%, 760px); }
  .daily-chart { height: 280px; }

  .meta-header { flex-wrap: wrap; }
  .meta-header-acoes { width: 100%; justify-content: space-between; }

  .list-toolbar { flex-wrap: wrap; }
  .search-field { max-width: none; flex-basis: 100%; }
  .list-count { margin-left: 0; }
  .vendedor-row { gap: 10px; padding: 10px 12px; }
  .rank-pos { width: 18px; }
  .avatar { width: 30px; height: 30px; font-size: 11px; }

  .modal-backdrop { padding: 10px; }
  .modal { max-height: 94vh; }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
}

/* blocos em par só cabem lado a lado acima de ~480px: valores como
   "R$ 14.563.889,42" estouram a coluna */
@media (max-width: 480px) {
  .metric-blocks, .growth-blocks, .metric-blocks-2col { grid-template-columns: 1fr; }
  .refresh-note { display: none; }
}

/* ---------- Ranking de clínicas ---------- */
#tab-ranking .card + .card { margin-top: 16px; }
#tab-ranking .metric-blocks { margin-bottom: 14px; }
.rank-table-scroll { overflow-x: auto; }
.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.rank-table th {
  color: hsl(var(--muted-foreground));
  font-weight: 400;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.rank-table th.left { text-align: left; }
.rank-table td {
  padding: 10px;
  border-bottom: 1px solid hsl(var(--border) / 0.7);
  vertical-align: middle;
}
.rank-table tbody tr:hover { background: hsl(var(--muted) / 0.6); }
.rank-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-table td.strong { font-weight: 600; color: hsl(var(--foreground)); }
.rank-table .rank-name { font-weight: 500; min-width: 160px; }
.rank-table .rank-sub {
  display: block;
  font-size: 11px;
  font-weight: 300;
  color: hsl(var(--muted-foreground));
}
.rank-table td.rank-empty {
  text-align: center;
  color: hsl(var(--muted-foreground));
  padding: 24px 10px;
}
.rank-pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
}
.rank-pos-badge.is-top {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}
