/* Ganhos na visão do cliente (earnings-client-v1.js). Cores pelos tokens da área do
   cliente (--af-*), que a camada da marca define para os temas claro e escuro. */

.afe-root {
  --afe-bg: var(--af-panel, #0a1630);
  --afe-raised: var(--af-raised, #0f2042);
  --afe-line: var(--af-line, #182c52);
  --afe-text: var(--af-text, #e3f0ff);
  --afe-muted: var(--af-muted, #9db3d4);
  --afe-soft: var(--af-soft, #7189ad);
  --afe-accent: var(--af-accent, #48a8ff);
  --afe-accent-bg: var(--af-accent-bg, #0c2550);
  --afe-green: var(--af-green, #34d399);
  --afe-green-bg: var(--af-green-bg, rgba(52, 211, 153, 0.12));
  --afe-amber: var(--amber, #f59e0b);
  --afe-bar: linear-gradient(180deg, #6fbaff 0%, #1a7bff 60%, #0a62f0 100%);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--afe-text);
  font-variant-numeric: tabular-nums;
}

.panel.afe-on > :not(.afe-root) {
  display: none !important;
}

.afe-root button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.afe-root button:focus-visible {
  outline: 2px solid var(--afe-accent);
  outline-offset: 2px;
}

.afe-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.afe-head h2 {
  margin: 0;
  color: var(--afe-text);
}

.afe-head p {
  margin: 2px 0 0;
  color: var(--afe-muted);
}

.afe-refresh {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 8px 13px;
  border: 1px solid var(--afe-line);
  border-radius: 10px;
  background: var(--afe-bg);
  color: var(--afe-accent) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
}

.afe-refresh svg {
  width: 15px;
  height: 15px;
}

.afe-refresh:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ── Destaque da semana ── */

.afe-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 12px;
}

.afe-hero-main {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 22px 18px;
  border-radius: 18px;
  background: radial-gradient(420px 220px at 100% 0%, rgba(72, 168, 255, 0.24), transparent 70%), linear-gradient(160deg, #0f1a30 0%, #0c0f16 60%, #080a10 100%);
  border: 1px solid rgba(72, 168, 255, 0.24);
  color: #e3f0ff;
}

.afe-eyebrow {
  color: #8cc8ff;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.afe-hero-num {
  font-size: clamp(36px, 6vw, 52px);
  line-height: 1.05;
  font-weight: 200;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.afe-delta {
  color: #9db3d4;
  font-size: 13px;
}

.afe-delta.up {
  color: #6fe0ad;
}

.afe-delta.down {
  color: #ffb4a2;
}

.afe-hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.afe-mini {
  display: flex;
  flex-direction: column;
  min-width: 92px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(3, 6, 13, 0.4);
  border: 1px solid rgba(72, 168, 255, 0.16);
}

.afe-mini strong {
  font-size: 15px;
  color: #ffffff;
}

.afe-mini span {
  font-size: 11.5px;
  color: #9db3d4;
}

.afe-hero-side {
  display: grid;
  gap: 12px;
}

.afe-side-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--afe-line);
  background: var(--afe-bg);
}

.afe-side-card span {
  color: var(--afe-muted);
  font-size: 12.5px;
}

.afe-side-card strong {
  font-size: 22px;
  color: var(--afe-text);
}

.afe-side-card small {
  color: var(--afe-soft);
  font-size: 11.5px;
}

.afe-side-card.pending strong {
  color: var(--afe-accent);
}

/* ── Abas Dia / Semana ── */

.afe-tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--afe-line);
  background: var(--afe-bg);
}

.afe-tabs button {
  border: 0;
  border-radius: 9px;
  padding: 8px 18px;
  background: transparent;
  color: var(--afe-muted) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
}

.afe-tabs button[aria-selected="true"] {
  background: linear-gradient(180deg, #4fadff 0%, #1a7bff 58%, #0a62f0 100%);
  color: #ffffff !important;
  box-shadow: inset 0 1px 0 rgba(212, 235, 255, 0.3);
}

/* ── Colunas ── */

.afe-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.afe-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.afe-card {
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--afe-line);
  background: var(--afe-bg);
}

.afe-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 12px;
}

.afe-card-head h3 {
  margin: 0;
  font-size: 15px;
  color: var(--afe-text);
}

.afe-card-head h3::first-letter {
  text-transform: uppercase;
}

.afe-card-head > span {
  color: var(--afe-soft);
  font-size: 11.5px;
}

.afe-card-total {
  font-size: 18px;
  color: var(--afe-text);
}

/* ── Gráfico diário: uma série, barras finas com topo arredondado ── */

.afe-chart {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 4px;
  height: 170px;
  padding-top: 18px;
  border-bottom: 1px solid var(--afe-line);
  background-image: linear-gradient(var(--afe-line) 1px, transparent 1px);
  background-size: 100% 50%;
  background-position: 0 18px;
  background-repeat: repeat-y;
}

.afe-bar {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  padding: 0 0 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.afe-bar:hover,
.afe-bar.is-selected {
  background: var(--afe-accent-bg);
}

.afe-bar-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.afe-bar-fill {
  display: block;
  width: min(18px, 70%);
  border-radius: 4px 4px 0 0;
  background: var(--afe-bar);
  opacity: 0.55;
  transition: opacity 0.15s ease;
}

.afe-bar.is-selected .afe-bar-fill,
.afe-bar:hover .afe-bar-fill {
  opacity: 1;
}

.afe-bar-day {
  font-size: 10.5px;
  color: var(--afe-soft);
  text-transform: uppercase;
}

.afe-bar-day.is-today {
  color: var(--afe-accent);
  font-weight: 700;
}

.afe-bar-num {
  font-size: 11px;
  color: var(--afe-muted);
}

.afe-bar.is-selected .afe-bar-num {
  color: var(--afe-text);
  font-weight: 700;
}

.afe-tip {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -100%);
  padding: 4px 8px;
  border-radius: 7px;
  background: #0b1020;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

/* ── Listas ── */

.afe-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.afe-chips span {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--afe-raised);
  color: var(--afe-muted);
  font-size: 12px;
}

.afe-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.afe-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--afe-line);
}

.afe-row:first-child {
  border-top: 0;
}

.afe-row.is-off {
  opacity: 0.55;
}

.afe-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.afe-row-main strong {
  color: var(--afe-text);
  font-size: 14px;
  overflow-wrap: break-word;
}

.afe-row-main strong::first-letter {
  text-transform: uppercase;
}

.afe-row-main span {
  color: var(--afe-muted);
  font-size: 12px;
}

.afe-row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: 0 0 auto;
}

.afe-row-side strong {
  color: var(--afe-text);
  font-size: 15px;
}

.afe-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.afe-pill.paid {
  background: var(--afe-green-bg);
  color: var(--afe-green);
}

.afe-pill.pending {
  background: var(--afe-accent-bg);
  color: var(--afe-accent);
}

.afe-pill.current {
  background: rgba(245, 158, 11, 0.14);
  color: var(--afe-amber);
}

.afe-empty {
  padding: 14px 0;
  color: var(--afe-muted);
  font-size: 13px;
}

/* ── Semanas ── */

.afe-weeks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.afe-week {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--afe-line);
  background: var(--afe-raised);
  text-align: left;
}

.afe-week.is-selected {
  border-color: var(--afe-accent);
  box-shadow: inset 0 0 0 1px var(--afe-accent);
}

.afe-week-top {
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 6px;
  color: var(--afe-muted);
  font-size: 12px;
}

.afe-week > strong {
  font-size: 20px;
  color: var(--afe-text);
}

.afe-week-meta {
  color: var(--afe-muted);
  font-size: 11.5px;
}

.afe-spark {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 3px;
  height: 30px;
  margin-top: 6px;
}

.afe-spark span {
  display: block;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--afe-accent);
  opacity: 0.75;
}

/* ── Tema claro ── */

html[data-af-theme=light] .afe-tip {
  background: #0b1020;
}

html[data-af-theme=light] .afe-pill.current {
  background: #fff4dc;
  color: #945b00;
}

/* ── Celular ── */

@media (max-width: 760px) {
  .afe-hero,
  .afe-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .afe-hero-side {
    grid-template-columns: 1fr 1fr;
  }

  .afe-hero-main {
    padding: 18px 16px 16px;
  }

  .afe-mini {
    min-width: 0;
    flex: 1 1 0;
  }

  .afe-tabs {
    align-self: stretch;
  }

  .afe-tabs button {
    flex: 1;
  }

  .afe-chart {
    height: 150px;
    gap: 2px;
  }

  .afe-weeks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .afe-head h2 {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .afe-bar-fill {
    transition: none;
  }
}
