:root {
  --bg: #111214;
  --panel: #1b1c1f;
  --panel-2: #242528;
  --panel-border: rgba(255, 255, 255, 0.075);
  --yellow: #ffcf24;
  --yellow-soft: #ffdc4f;
  --cyan: #35e0c9;
  --text: #f3f3f4;
  --text-dim: #a1a2a6;
  --pink: #f0444f;
  --green: #18c66a;
  --radius: 16px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
  /* Esconde a barra de rolagem em tudo (visual limpo na TV) — a rolagem continua funcionando */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Rubik", "Poppins", sans-serif;
  display: flex;
  justify-content: center;
  padding: 16px;
}

body:has(.login-screen:not(.is-hidden)) {
  padding: 0;
}

.dashboard.is-locked {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 24px;
  background-color: #121212;
  background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0, rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 12px);
  z-index: 200;
}

.login-screen.is-hidden {
  display: none;
}

.login-card {
  position: relative;
  width: min(100%, 420px);
  padding: 36px 36px 32px;
  background: #ffffff;
  border: none;
  border-top: 6px solid #f5c518;
  border-radius: 6px;
  box-shadow: 18px 20px 0 rgba(245, 197, 24, 0.14), 0 28px 70px rgba(0, 0, 0, 0.5);
  text-align: center;
  z-index: 1;
}

.login-logo {
  display: block;
  width: auto;
  height: 62px;
  max-width: 100%;
  margin: 0 auto;
  object-fit: contain;
}

.login-logo-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  margin-bottom: 16px;
  border-radius: 4px;
  background: #111111;
}

.login-kicker {
  display: block;
  color: #d18d00;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1.8px;
  margin-bottom: 10px;
}

.login-card h1 {
  margin: 0;
  color: #151515;
  font-family: "Poppins", sans-serif;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  line-height: 1.2;
}

.login-description {
  margin: 10px 0 26px;
  color: #716d66;
  font-size: 0.85rem;
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  text-align: left;
  gap: 7px;
}

.login-form label {
  color: #716d66;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  margin-top: 6px;
}

.login-form input {
  width: 100%;
  border: 1px solid #d9d1c5;
  border-radius: 9px;
  background: #ffffff;
  color: #151515;
  font: inherit;
  font-size: 0.88rem;
  outline: none;
  padding: 12px 13px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.login-form input:focus {
  background: #ffffff;
  border-color: #111111;
}

.login-form input::placeholder {
  color: #8e887f;
}

.login-error {
  min-height: 17px;
  margin: 3px 0 0;
  color: #bd2d43;
  font-size: 0.75rem;
}

.login-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 9px;
  background: #111111;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-top: 4px;
  padding: 13px;
  transition: filter 0.15s ease, transform 0.15s ease;
}

.login-submit:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.login-submit span {
  font-size: 1.15rem;
  line-height: 0.7;
}

.login-footer {
  display: block;
  color: #9a948b;
  font-size: 0.68rem;
  margin-top: 26px;
}

.login-decoration {
  position: absolute;
  border: 1px solid rgba(245, 197, 24, 0.12);
  border-radius: 26px;
  transform: rotate(-18deg);
}

.login-decoration-top {
  width: 360px;
  height: 170px;
  top: -75px;
  right: -100px;
}

.login-decoration-bottom {
  width: 430px;
  height: 200px;
  bottom: -110px;
  left: -130px;
  border-color: rgba(255, 255, 255, 0.08);
}

/* ---------- SPLASH / REFRESH SCREEN (logo piscando) ---------- */
.splash-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #121212;
  background-image: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0, rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 12px);
  z-index: 300;
  opacity: 1;
  transition: opacity 0.45s ease;
}

.splash-screen.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-logo {
  height: 110px;
  max-height: 28vh;
  max-width: 70vw;
  width: auto;
  object-fit: contain;
  animation: splash-blink 1.4s ease-in-out infinite;
  filter: drop-shadow(0 0 26px rgba(245, 197, 24, 0.35));
}

@keyframes splash-blink {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.15;
    transform: scale(0.96);
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 34px 24px 26px;
  }
  .login-logo {
    height: 52px;
  }

  .login-logo-panel {
    height: 84px;
  }
}

.dashboard {
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- HEADER ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(120deg, #f3ab05 0%, #f7bd2e 100%);
  border: 1px solid rgba(243, 171, 5, 0.45);
  border-radius: 8px;
  padding: 10px 22px;
  box-shadow: 0 6px 18px rgba(243, 171, 5, 0.22);
}

/* ---------- STICKY HEADER (barra amarela + KPIs fixos ao rolar) ---------- */
.sticky-head {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #1a1300;
  min-width: 150px;
  height: 56px;
}

.brand-logo {
  display: block;
  height: 56px;
  width: auto;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.25));
}

.accounts-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(0, 0, 0, 0.12);
  color: #1a1300;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.title {
  margin: 0;
  font-family: "Rubik", sans-serif;
  font-weight: 600;
  letter-spacing: 0;
  font-size: clamp(16px, 2.2vw, 28px);
  color: #1a1300;
  text-align: center;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.data-status {
  color: rgba(26, 19, 0, 0.68);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.35px;
  white-space: nowrap;
}

.data-status.loading {
  color: #805e00;
}

.data-status.error {
  color: #b42318;
}

.period-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 7px;
  padding: 4px;
  gap: 2px;
}

.period-wrap {
  position: relative;
}

.range-popover {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: min(350px, calc(100vw - 24px));
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 9px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  z-index: 30;
}

.range-popover.open {
  display: flex;
}

.range-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  right: 74px;
  transform: rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--panel-2);
  border-left: 1px solid var(--panel-border);
  border-top: 1px solid var(--panel-border);
}

.range-presets {
  display: flex;
  gap: 5px;
}

.range-presets button {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  padding: 7px 4px;
  background: #303033;
  color: var(--text);
  font: inherit;
  font-size: 0.68rem;
  cursor: pointer;
}

.range-presets button:hover {
  border-color: var(--yellow);
  color: var(--yellow-soft);
}

.range-selection {
  min-height: 18px;
  color: var(--text-dim);
  font-size: 0.7rem;
  text-align: center;
}

.calendar-header {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  text-align: center;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
}

.calendar-header button {
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.calendar-header button:disabled {
  opacity: 0.3;
  cursor: default;
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.calendar-weekdays span {
  padding: 4px 0;
  color: var(--text-dim);
  font-size: 0.62rem;
  text-align: center;
}

.calendar-day,
.calendar-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-width: 0;
}

.calendar-day {
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.7rem;
  cursor: pointer;
}

.calendar-day:hover:not(:disabled) {
  background: #414145;
}

.calendar-day.in-range {
  background: rgba(255, 207, 36, 0.2);
  border-radius: 0;
}

.calendar-day.range-start,
.calendar-day.range-end {
  border-radius: 6px;
  background: var(--yellow);
  color: #17130a;
  font-weight: 600;
}

.calendar-day:disabled {
  color: #626267;
  cursor: default;
}

.range-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--panel-border);
  padding-top: 8px;
}

.range-comparison-note {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.62rem;
  line-height: 1.35;
}

.range-apply {
  flex: 0 0 auto;
  border: none;
  background: #3b3b3e;
  color: #f3f3f3;
  font-weight: 500;
  font-size: 0.72rem;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.range-apply:hover {
  filter: brightness(1.08);
}

/* Native date inputs are retained as values for the API, not shown. */
.range-popover input[type="hidden"] {
  display: none;
}

.period-btn {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 5px;
  font-weight: 400;
  font-size: 0.8rem;
  color: rgba(26, 19, 0, 0.68);
  cursor: pointer;
  transition: all 0.2s ease;
}

.period-btn.active {
  background: #171719;
  color: var(--yellow-soft);
  box-shadow: none;
}

.icon-btn {
  border: none;
  background: rgba(0, 0, 0, 0.12);
  color: #1a1300;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.icon-btn:hover {
  background: rgba(0, 0, 0, 0.2);
}

.logout-btn:hover {
  background: rgba(220, 60, 60, 0.3);
}

.period-btn,
.icon-btn {
  user-select: none;
}

/* ---------- MENU DROPDOWN ---------- */
.menu-wrap {
  position: relative;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 190px;
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.4);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 20;
}

.menu-dropdown.open {
  display: flex;
}

.menu-dropdown button {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.menu-dropdown button:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* ---------- KPI CARDS ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.kpi-card {
  position: relative;
  background: #1d1e21;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: none;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-yellow::before {
  background: linear-gradient(90deg, var(--yellow), var(--yellow-soft));
}

.kpi-green::before {
  background: linear-gradient(90deg, #18c66a, #42df88);
}

.kpi-cyan::before {
  background: linear-gradient(90deg, #35c8c8, #68e0df);
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.7px;
  color: var(--text-dim);
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.kpi-value {
  font-family: "Rubik", sans-serif;
  font-size: clamp(22px, 2.4vw, 30px);
  font-weight: 600;
  color: #ffca19;
}

.kpi-value.accent {
  color: #2be080;
}

.kpi-value.cost-value {
  color: #2be080;
}

.kpi-yellow .kpi-value,
.kpi-pink .kpi-value {
  color: #ffca19;
}

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

.badge {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
}

.badge-up {
  color: #16dc7a;
  background: rgba(24, 198, 106, 0.22);
}

.badge-down {
  color: #ff5864;
  background: rgba(240, 68, 79, 0.22);
}

/* ---------- TABLE ---------- */
.table-card {
  background: #1b1b1d;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  /* Sem padding vertical: cabeçalho e resumo sticky grudam rente às bordas
     e não sobra faixa onde as linhas aparecem ao rolar a tabela */
  padding: 0 3px;
  box-shadow: none;
  overflow-x: auto;
  /* A tabela rola dentro do próprio card — altura maior para mostrar mais linhas */
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.perf-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.perf-table thead th {
  text-align: left;
  font-size: 0.76rem;
  letter-spacing: 0.25px;
  color: #a5a6aa;
  font-weight: 500;
  text-transform: uppercase;
  padding: 10px 14px;
  background: #101113;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
  /* Cabeçalho congelado no topo do card ao rolar as linhas */
  position: sticky;
  top: 0;
  z-index: 15;
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.25);
}

.perf-table .sort {
  color: var(--text-dim);
  font-size: 0.7rem;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

th.sortable:hover {
  color: var(--yellow-soft);
}

th.sortable:hover .sort {
  color: var(--yellow-soft);
}

.hide-toggle {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  transition: background 0.15s ease, color 0.15s ease;
}

.hide-toggle:hover {
  background: rgba(255, 197, 24, 0.18);
  color: var(--yellow-soft);
}

.hide-toggle.active {
  background: rgba(255, 93, 143, 0.18);
  color: #ff8fb0;
}

.perf-table td.col-hidden {
  visibility: hidden;
  position: relative;
}

.perf-table td.col-hidden::before {
  content: "••••••";
  visibility: visible;
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  letter-spacing: 2px;
}

.perf-table tbody td {
  padding: 9px 14px;
  font-size: 0.94rem;
  font-weight: 400;
  color: var(--text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  white-space: nowrap;
}

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

.perf-table tbody tr:nth-child(odd) {
  background: #1b1c1f;
}

.perf-table tbody tr:nth-child(even) {
  background: #242528;
}

.perf-table tbody tr:hover {
  background: #303135;
}

/* Valor gasto em amarelo (tom do cabeçalho); Mensagens em branco —
   só os comparativos (+1/-1) seguem verde/vermelho via em.up/em.down */
.perf-table tbody td:nth-child(2) {
  color: #ffca19;
  font-weight: 500;
}

.perf-table tbody td:nth-child(3) {
  color: var(--text);
}

/* ---------- BARRA FIXA NA BASE (legenda sempre visível) ---------- */
.sticky-foot {
  position: fixed; 
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: var(--bg);
  border-top: 1px solid var(--panel-border);
  padding: 8px 16px;
  box-shadow: 0 -6px 14px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

/* Legenda pequena das faixas de custo por mensagem */
.cost-legend {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.7rem;
  font-weight: 500;
  color: #8a8b90;
  letter-spacing: 0.2px;
  opacity: 1;
}

.cost-legend .legend-title {
  color: #8a8b90;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.cost-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.cost-legend .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.cost-legend .dot-green { background: #18c66a; }
.cost-legend .dot-yellow { background: #e9ad0a; }
.cost-legend .dot-orange { background: #f47717; }
.cost-legend .dot-red { background: #f0444f; }

.col-name {
  font-weight: 400;
  color: #eeeeef;
}

.perf-table tbody .col-name {
  cursor: pointer;
  transition: color 0.15s ease;
}

.perf-table tbody .col-name:hover {
  color: var(--cyan);
  text-decoration: underline;
}

em {
  font-style: normal;
  font-size: 0.75rem;
  margin-left: 4px;
}

em.up {
  color: #19d978;
}

em.down {
  color: #ff5260;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
}

.pill-red {
  background: #f0444f;
  color: #ffffff;
}

.pill-green {
  background: #18c66a;
  color: #ffffff;
}

.pill-yellow {
  background: #e9ad0a;
  color: #ffffff;
}

.pill-orange {
  background: #f47717;
  color: #ffffff;
}

.pill-neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

.pill small {
  font-weight: 600;
  font-size: 0.7rem;
  opacity: 0.85;
}

.pill small.up {
  color: #b9ffda;
}

.pill small.down {
  color: #ffd0d3;
}

/* ---------- FOOTER ---------- */
.footer-brand {
  font-weight: 400;
  color: var(--text-dim);
  font-size: 0.72rem;
  white-space: nowrap;
}

.empty-state {
  padding: 30px 18px !important;
  color: var(--text-dim) !important;
  text-align: center;
}

@media (min-width: 861px) {
  body {
    padding: 15px;
    /* Trava a página na altura da tela — a página não rola, só a tabela rola */
    height: 100vh;
    overflow: hidden;
  }

  .dashboard {
    width: 100%;
    height: 100%;
  }

  /* A tabela ocupa todo o espaço livre e rola dentro do próprio card */
  .table-card {
    flex: 1;
    min-height: 0;
    max-height: none;
  }

  /* Rodapé entra no fluxo, logo abaixo da tabela — sem faixa preta no meio */
  .sticky-foot {
    position: static;
  }
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 860px) {
  body {
    padding: 10px;
  }

  .dashboard {
    gap: 12px;
    /* No mobile a legenda quebra em mais linhas, então o respiro é maior */
    padding-bottom: 58px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 6px 12px;
  }

  .brand {
    min-width: 0;
    height: 48px;
  }

  .brand-logo {
    height: 44px;
    max-width: 150px;
  }

  .accounts-pill {
    font-size: 0.62rem;
    padding: 4px 10px;
  }

  .title {
    order: 3;
    width: 100%;
    text-align: left;
    flex-basis: 100%;
  }

  .controls {
    min-width: 0;
    gap: 6px;
  }

  .data-status {
    flex-basis: 100%;
    text-align: right;
  }

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

  /* No mobile o bloco ocuparia a tela inteira, então o sticky é desativado */
  .sticky-head {
    position: static;
  }

  .table-card {
    margin: 0 -2px;
    padding: 0 4px 4px;
    border-radius: 10px;
    -webkit-overflow-scrolling: touch;
    max-height: none; /* no mobile a página rola normal */
    overflow-y: visible;
  }

  .perf-table {
    min-width: 880px;
  }

  .perf-table thead th,
  .perf-table tbody td {
    padding: 9px 10px;
  }
}

@media (max-width: 560px) {
  body {
    padding: 8px;
  }

  .topbar {
    border-radius: 10px;
  }

  .title {
    font-size: 17px;
  }

  .controls {
    width: 100%;
    justify-content: space-between;
  }

  .period-toggle {
    max-width: calc(100vw - 110px);
    overflow-x: auto;
    border-radius: 10px;
  }

  .period-btn {
    padding: 7px 9px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .data-status {
    font-size: 0.58rem;
  }

  .table-card {
    width: calc(100vw - 16px);
  }
}

/* ---------- LIGHT THEME ---------- */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --panel-border: rgba(20, 25, 50, 0.08);
  --text: #1c2340;
  --text-dim: #6b7290;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at 15% -10%, rgba(53, 224, 201, 0.12), transparent 40%),
    radial-gradient(circle at 90% 0%, rgba(245, 197, 24, 0.14), transparent 45%),
    var(--bg);
}

:root[data-theme="light"] .kpi-card,
:root[data-theme="light"] .table-card,
:root[data-theme="light"] .menu-dropdown {
  box-shadow: 0 10px 25px rgba(20, 25, 50, 0.08);
}

:root[data-theme="light"] .perf-table tbody tr:hover {
  background: rgba(20, 25, 50, 0.03);
}

:root[data-theme="light"] .modal-box {
  background: #ffffff;
}

:root[data-theme="light"] .modal-info-card,
:root[data-theme="light"] .summary-card {
  background: rgba(20, 25, 50, 0.04);
}

:root[data-theme="light"] .range-field input[type="date"] {
  color-scheme: light;
}

:root[data-theme="light"] .chart-select {
  color-scheme: light;
}

:root[data-theme="light"] .export-range-select {
  color-scheme: light;
}

/* ---------- CLIENT MODAL ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 20, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  background: #202022;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 26px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--panel-border);
}

.modal-eyebrow {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.modal-title {
  margin: 4px 0 0;
  font-family: "Rubik", sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--yellow-soft);
  line-height: 1.25;
  word-break: break-word;
}

.modal-close {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
}

.modal-close:hover {
  background: rgba(255, 93, 143, 0.2);
  color: #ff8fb0;
}

.modal-section-title {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin: 0 0 10px;
}

.modal-info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.modal-info-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 14px;
}

.modal-info-card .info-label {
  margin-bottom: 0;
  white-space: nowrap;
}

.modal-info-card .info-value {
  text-align: right;
  overflow-wrap: anywhere;
}

.info-label {
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.info-value {
  font-size: 0.86rem;
  font-weight: 400;
  color: var(--text);
}

.modal-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  min-height: 76px;
}

.summary-card .info-label {
  margin-bottom: 0;
}

.summary-value {
  font-family: "Rubik", sans-serif;
  font-size: clamp(0.85rem, 2.4vw, 1.05rem);
  font-weight: 600;
  color: var(--yellow);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.modal-subtitle {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 10px;
}

.modal-daily {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
}

.daily-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.daily-table th {
  text-align: left;
  font-size: 0.68rem;
  letter-spacing: 0.5px;
  color: var(--yellow);
  text-transform: uppercase;
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}

.daily-table td {
  padding: 9px 10px;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.daily-table tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

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

/* ---------- GRÁFICO DE GASTOS ---------- */
.modal-chart-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 4px;
  margin-top: 18px;
  overflow: hidden;
}

.chart-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 12px 14px;
  cursor: pointer;
}

.chart-toggle-arrow {
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.chart-toggle.open .chart-toggle-arrow {
  transform: rotate(180deg);
}

.chart-body {
  display: none;
  padding: 4px 14px 16px;
}

.chart-body.open {
  display: block;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chart-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  color-scheme: dark;
}

.client-chart {
  width: 100%;
  height: 220px;
  display: block;
}

.modal-action-btn {
  border: none;
  background: linear-gradient(120deg, var(--yellow), var(--yellow-soft));
  color: #1a1300;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s ease;
}

.modal-action-btn:hover {
  filter: brightness(1.08);
}

/* ---------- AÇÕES E EXPORTAÇÃO ---------- */
.modal-actions-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.export-wrap {
  position: relative;
}

.export-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.4);
  z-index: 20;
}

.export-popover.open {
  display: flex;
}

.export-popover button {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
}

.export-popover button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.export-field-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 8px 10px 4px;
}

.export-range-select {
  width: calc(100% - 20px);
  margin: 0 10px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.8rem;
  color-scheme: dark;
}

.export-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--panel-border);
  margin-bottom: 4px;
  cursor: pointer;
}

.export-checkbox input {
  accent-color: var(--yellow);
  cursor: pointer;
}

/* ---------- ANOTAÇÕES (COMENTÁRIOS) ---------- */
.modal-notes {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  max-height: 220px;
  overflow-y: auto;
}

.comment-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
}

.comment-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-author {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--yellow-soft);
}

.comment-date {
  font-size: 0.68rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.comment-text {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-empty {
  font-size: 0.8rem;
  color: var(--text-dim);
  padding: 6px 2px;
}

.comment-form {
  border-top: 1px solid var(--panel-border);
  padding-top: 14px;
}

.notes-author-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 9px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.notes-textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
}

.notes-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.notes-status {
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 600;
}

@media (max-width: 560px) {
  .modal-info-grid {
    grid-template-columns: 1fr;
  }
  .modal-box {
    padding: 20px 18px;
  }
}
