:root {
  color-scheme: light;

  --background: #f7f5f1;
  --foreground: #211b1d;

  --card: #ffffff;
  --card-foreground: #211b1d;

  --popover: #ffffff;
  --popover-foreground: #211b1d;

  --primary: #7a1726;
  --primary-foreground: #ffffff;
  --primary-2: #a52a3c;

  --secondary: #f2ede9;
  --secondary-foreground: #352d2f;

  --accent: #c29b2f;
  --accent-foreground: #211b1d;

  --muted: #f1ede8;
  --muted-foreground: #766d70;

  --border: #e6dfda;
  --input: #e6dfda;
  --ring: rgba(122, 23, 38, 0.24);

  --destructive: #a62532;

  --radius: 14px;

  --shadow-sm:
    0 1px 2px rgba(24, 18, 20, 0.03), 0 4px 14px rgba(24, 18, 20, 0.025);

  --shadow-md:
    0 1px 2px rgba(24, 18, 20, 0.04), 0 12px 34px rgba(24, 18, 20, 0.055);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --background: #111113;
  --foreground: #f3eeee;

  --card: #171719;
  --card-foreground: #f3eeee;

  --popover: #1b1b1e;
  --popover-foreground: #f3eeee;

  --primary: #b84b5e;
  --primary-foreground: #ffffff;
  --primary-2: #8d2538;

  --secondary: #232326;
  --secondary-foreground: #f0e9e9;

  --accent: #d1ad42;
  --accent-foreground: #171719;

  --muted: #222225;
  --muted-foreground: #aaa0a3;

  --border: #2e2e33;
  --input: #333338;
  --ring: rgba(184, 75, 94, 0.28);

  --destructive: #d1505b;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);

  --shadow-md: 0 16px 42px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(
      circle at 86% -10%,
      color-mix(in srgb, var(--primary) 7%, transparent),
      transparent 28%
    ),
    var(--background);

  color: var(--foreground);

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 42px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;

  margin-bottom: 20px;
}

.page-header h1 {
  margin: 5px 0 4px;

  font-size: clamp(28px, 2.1vw, 38px);
  line-height: 1.05;

  font-weight: 760;
  letter-spacing: -0.04em;
}

.page-header p {
  margin: 0;

  color: var(--muted-foreground);

  font-size: 13px;
}

.eyebrow {
  color: var(--accent);

  font-size: 10px;
  font-weight: 800;

  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.header-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  min-width: 40px;
  height: 40px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  padding: 0 11px;

  border: 1px solid var(--border);
  border-radius: 10px;

  background: var(--card);
  color: var(--foreground);

  cursor: pointer;
  text-decoration: none;

  box-shadow: var(--shadow-sm);
}

.icon-button:hover {
  background: var(--secondary);
}

.icon-button-label {
  min-width: auto;

  color: var(--primary);

  font-size: 12px;
  font-weight: 700;
}

.update-meta {
  padding-left: 12px;

  border-left: 1px solid var(--border);
}

.update-meta span {
  display: block;

  margin-bottom: 2px;

  color: var(--muted-foreground);

  font-size: 9px;
  font-weight: 800;

  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.update-meta strong {
  display: block;

  font-size: 11px;
  font-weight: 650;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);

  background: var(--card);
  color: var(--card-foreground);

  box-shadow: var(--shadow-sm);
}

.filter-card {
  margin-bottom: 16px;
  padding: 14px;
}

.filter-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;

  margin-bottom: 12px;
}

.filter-card-top h2 {
  margin: 0;

  font-size: 13px;
}

.filter-card-top p {
  margin: 2px 0 0;

  color: var(--muted-foreground);

  font-size: 10px;
}

.filters-grid {
  display: grid;
  gap: 9px;
}

.first-page-filters {
  grid-template-columns: repeat(6, minmax(145px, 1fr));
}

.details-filters {
  grid-template-columns: repeat(5, minmax(145px, 1fr));
}

.filter-field {
  min-width: 0;
}

.filter-field > span {
  display: block;

  margin: 0 0 5px 2px;

  color: var(--muted-foreground);

  font-size: 9px;
  font-weight: 750;
}

.filter-field select {
  width: 100%;
  min-height: 40px;

  padding: 0 11px;

  border: 1px solid var(--input);
  border-radius: 9px;

  background: var(--background);
  color: var(--foreground);
}

.button {
  min-height: 36px;

  padding: 0 13px;

  border: 1px solid transparent;
  border-radius: 9px;

  cursor: pointer;

  font-size: 11px;
  font-weight: 700;
}

.button-ghost-danger {
  border-color: color-mix(in srgb, var(--destructive) 22%, var(--border));

  background: color-mix(in srgb, var(--destructive) 8%, var(--card));

  color: var(--destructive);
}

.button-ghost-danger:hover {
  background: var(--destructive);
  color: #fff;
}

/* Choices.js */
.choices {
  margin: 0 !important;
}

.choices__inner {
  min-height: 40px !important;

  display: flex;
  align-items: center;

  padding: 6px 32px 6px 10px !important;

  border: 1px solid var(--input) !important;
  border-radius: 9px !important;

  background: var(--background) !important;
  color: var(--foreground) !important;

  font-size: 12px !important;
}

.is-focused .choices__inner,
.is-open .choices__inner {
  border-color: var(--primary) !important;

  box-shadow: 0 0 0 3px var(--ring) !important;
}

.choices__list--single {
  padding: 0 !important;
}

.choices__list--dropdown,
.choices__list[aria-expanded] {
  z-index: 60 !important;

  margin-top: 6px !important;

  border: 1px solid var(--border) !important;
  border-radius: 10px !important;

  background: var(--popover) !important;
  color: var(--popover-foreground) !important;

  box-shadow: var(--shadow-md) !important;
}

.choices__input {
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;

  background: var(--background) !important;
  color: var(--foreground) !important;
}

.choices__item--selectable.is-highlighted {
  background: var(--secondary) !important;
  color: var(--foreground) !important;
}

/* Alert */
.alert {
  margin-bottom: 14px;
  padding: 11px 13px;

  border-radius: 10px;

  font-size: 11px;
}

.alert-error {
  border: 1px solid color-mix(in srgb, var(--destructive) 34%, var(--border));

  background: color-mix(in srgb, var(--destructive) 9%, var(--card));

  color: var(--destructive);
}

/* First page grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));

  gap: 12px;
}

.metric-card {
  min-width: 0;

  padding: 13px;

  border: 1px solid var(--border);
  border-radius: var(--radius);

  background: var(--card);

  box-shadow: var(--shadow-sm);
}

.metric-card-wide {
  grid-column: span 2;
}

.metric-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding-bottom: 9px;
  margin-bottom: 3px;

  border-bottom: 1px solid var(--border);
}

.metric-card-header h2 {
  margin: 0;

  color: var(--primary);

  font-size: 13px;
}

.metric-card-header p {
  margin: 2px 0 0;

  color: var(--muted-foreground);

  font-size: 9px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mini-button,
.details-button {
  height: 28px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 8px;

  border: 1px solid var(--border);
  border-radius: 8px;

  background: var(--background);
  color: var(--muted-foreground);

  cursor: pointer;
  text-decoration: none;

  font-size: 9px;
  font-weight: 700;
}

.details-button:hover,
.mini-button:hover {
  background: var(--secondary);
  color: var(--primary);
}

.metric-table-wrapper {
  width: 100%;
  overflow-x: auto;

  scrollbar-width: thin;
}

.metric-table {
  width: 100%;
  min-width: 410px;

  border-collapse: separate;
  border-spacing: 0;

  font-size: 10px;
}

.metric-table th,
.metric-table td {
  padding: 5px 7px;

  border-bottom: 1px solid var(--border);

  text-align: right;
  white-space: nowrap;

  font-variant-numeric: tabular-nums;
}

.metric-table thead th {
  background: var(--card);
  color: var(--primary);

  font-size: 9px;
}

.metric-table .month-cell {
  text-align: left;

  color: var(--muted-foreground);
}

.metric-table tbody tr:hover {
  background: var(--secondary);
}

.metric-table .total-row {
  background: var(--secondary);

  font-weight: 800;
}

.metric-table .total-row .month-cell {
  color: var(--primary);
}

.metric-value-link {
  display: block;

  margin: -5px -7px;
  padding: 5px 7px;

  color: inherit;
  text-decoration: none;

  border-radius: 5px;
}

.metric-value-link:hover {
  background: color-mix(in srgb, var(--primary) 8%, transparent);

  color: var(--primary);
}

.table-sort-button {
  width: 100%;

  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;

  padding: 0;

  border: 0;

  background: transparent;
  color: inherit;

  cursor: pointer;

  font: inherit;
  font-weight: inherit;
}

.table-sort-button-month {
  justify-content: flex-start;
}

.sort-icon {
  color: var(--muted-foreground);

  font-size: 8px;
}

.skeleton {
  height: 330px;

  border: 1px solid var(--border);
  border-radius: var(--radius);

  background: linear-gradient(
    90deg,
    var(--card) 0%,
    var(--secondary) 45%,
    var(--card) 100%
  );

  background-size: 220% 100%;

  animation: skeleton 1.2s ease infinite;
}

@keyframes skeleton {
  to {
    background-position: -120% 0;
  }
}

/* Details */
.back-link {
  display: inline-block;

  margin-bottom: 9px;

  color: var(--primary);

  text-decoration: none;

  font-size: 10px;
  font-weight: 700;
}

.details-top-grid {
  display: grid;
  grid-template-columns:
    minmax(190px, 0.62fr)
    minmax(0, 1.5fr)
    minmax(0, 1.5fr);

  gap: 12px;

  margin-bottom: 12px;
}

.metric-summary-card,
.chart-card {
  padding: 15px;
}

.card-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-heading-row h2 {
  margin: 2px 0 0;

  font-size: 14px;
}

.card-heading-row p {
  margin: 3px 0 0;

  color: var(--muted-foreground);

  font-size: 10px;
}

.card-kicker {
  color: var(--muted-foreground);

  font-size: 9px;
  font-weight: 800;

  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.metric-summary-value {
  margin-top: 38px;

  font-size: clamp(38px, 4vw, 58px);
  font-weight: 760;

  letter-spacing: -0.055em;
}

.metric-summary-caption {
  margin-top: 6px;

  color: var(--muted-foreground);

  font-size: 10px;
}

.mini-link {
  color: var(--primary);

  font-size: 9px;
  font-weight: 700;

  text-decoration: none;
}

.chart {
  width: 100%;
}

.chart-ranking {
  height: 360px;
}

.chart-evolution {
  height: 390px;
}

.evolution-card {
  padding: 15px;
}

.updating-pill {
  position: fixed;
  right: 18px;
  bottom: 18px;

  z-index: 1000;

  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 9px 12px;

  border: 1px solid var(--border);
  border-radius: 999px;

  background: var(--popover);
  color: var(--popover-foreground);

  box-shadow: var(--shadow-md);

  font-size: 10px;
  font-weight: 700;
}

.spinner {
  width: 12px;
  height: 12px;

  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;

  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Dialog */
.dialog-layer {
  position: fixed;
  inset: 0;

  z-index: 9999;

  display: grid;
  place-items: center;

  padding: 18px;
}

.dialog-backdrop {
  position: absolute;
  inset: 0;

  background: rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(4px);
}

.dialog-card {
  position: relative;
  z-index: 1;

  width: min(620px, 100%);
  max-height: 90vh;

  overflow-y: auto;

  padding: 18px;

  border: 1px solid var(--border);
  border-radius: 16px;

  background: var(--popover);
  color: var(--popover-foreground);

  box-shadow: var(--shadow-md);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;

  margin-bottom: 16px;
}

.dialog-header h2 {
  margin: 3px 0 0;
}

.info-block {
  margin-bottom: 14px;
}

.info-block > span {
  display: block;

  margin-bottom: 5px;

  color: var(--muted-foreground);

  font-size: 9px;
  font-weight: 800;

  text-transform: uppercase;
}

.info-block p {
  margin: 0;

  font-size: 12px;
  line-height: 1.55;
}

.code-inline {
  padding: 10px;

  border: 1px solid var(--border);
  border-radius: 9px;

  background: var(--background);

  font-family: Consolas, monospace;
  font-size: 11px;
}

.notice {
  margin: 12px 0;
  padding: 10px;

  border: 1px solid var(--border);
  border-radius: 9px;

  background: color-mix(in srgb, var(--accent) 10%, var(--card));

  font-size: 11px;
}

.notice p {
  margin: 4px 0 0;
}

.code-details summary {
  cursor: pointer;

  color: var(--primary);

  font-size: 10px;
  font-weight: 700;
}

.code-details pre {
  overflow-x: auto;

  padding: 12px;

  border-radius: 10px;

  background: #0d0d0f;
  color: #f4efef;

  font-size: 10px;
}

/* Formulas page compatibility */
.formula-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));

  gap: 12px;
}

.formula-card {
  padding: 15px;

  border: 1px solid var(--border);
  border-radius: var(--radius);

  background: var(--card);

  box-shadow: var(--shadow-sm);
}

.formula-title h2 {
  margin: 0;

  color: var(--primary);
}

.formula-title span {
  color: var(--muted-foreground);

  font-size: 9px;
}

.formula-section {
  margin-top: 13px;
}

.formula-section strong {
  display: block;

  margin-bottom: 5px;

  color: var(--muted-foreground);

  font-size: 9px;

  text-transform: uppercase;
}

.formula-section p {
  margin: 0;

  font-size: 11px;
}

/* Responsive */
@media (max-width: 1300px) {
  .first-page-filters {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }

  .details-filters {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
  }

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

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

  .metric-summary-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 18px, 1760px);
    padding-top: 16px;
  }

  .page-header {
    flex-direction: column;
    gap: 12px;
  }

  .header-toolbar {
    width: 100%;
  }

  .update-meta {
    margin-left: auto;
  }

  .filter-card-top p {
    display: none;
  }

  .first-page-filters,
  .details-filters,
  .dashboard-grid,
  .details-top-grid,
  .formula-grid {
    grid-template-columns: 1fr;
  }

  .metric-card-wide {
    grid-column: span 1;
  }

  .chart-ranking {
    height: 330px;
  }

  .chart-evolution {
    height: 350px;
  }

  .metric-summary-card {
    grid-column: auto;
  }
}

/* ============================================================
   V5.1 - LEGIBILIDADE E FILTROS NATIVOS ESTÁVEIS
   ============================================================ */

body {
  font-size: 15px;
}

.page-header h1 {
  font-size: clamp(34px, 2.45vw, 44px);
}

.page-header p {
  font-size: 15px;
}

.eyebrow {
  font-size: 12px;
}

.update-meta span {
  font-size: 10px;
}

.update-meta strong {
  font-size: 13px;
}

.icon-button-label {
  font-size: 13px;
}

.filter-card-top h2 {
  font-size: 15px;
}

.filter-card-top p {
  font-size: 12px;
}

.filter-field > span {
  margin-bottom: 6px;
  font-size: 11px;
}

.filter-field select {
  min-height: 44px;
  padding: 0 38px 0 12px;

  border: 1px solid var(--input);
  border-radius: 10px;

  background-color: var(--background);
  color: var(--foreground);

  font-size: 14px;

  cursor: pointer;

  outline: none;

  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
}

.filter-field select:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}

.filter-field select:focus {
  border-color: var(--primary);

  box-shadow: 0 0 0 3px var(--ring);
}

.button {
  font-size: 12px;
}

.metric-card-header h2 {
  font-size: 15px;
}

.metric-card-header p {
  font-size: 11px;
}

.mini-button,
.details-button {
  height: 30px;
  font-size: 10px;
}

.metric-table {
  min-width: 430px;
  font-size: 11.5px;
}

.metric-table thead th {
  font-size: 10.5px;
}

.metric-table th,
.metric-table td {
  padding: 6px 8px;
}

.card-heading-row h2 {
  font-size: 16px;
}

.card-heading-row p,
.metric-summary-caption {
  font-size: 11px;
}

.card-kicker {
  font-size: 10px;
}

.back-link {
  font-size: 11px;
}

.formula-title h2 {
  font-size: 17px;
}

.formula-section strong {
  font-size: 10px;
}

.formula-section p {
  font-size: 12px;
}

/* A V5.1 não depende mais de Choices.js.
   Mantemos esse fallback para evitar qualquer resíduo visual
   caso o navegador ainda tenha o CSS antigo em cache. */
.choices {
  display: none !important;
}

.filter-field select {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  position: relative !important;
  z-index: 2;
}

@media (max-width: 780px) {
  .page-header h1 {
    font-size: 30px;
  }

  .filter-field select {
    min-height: 46px;
    font-size: 15px;
  }

  .metric-table {
    font-size: 12px;
  }
}

/* ============================================================
   V5.2 - GEIST + +1 ponto de legibilidade
   ============================================================ */

body {
  font-family:
    "Geist Variable",
    "Geist",
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;

  font-size: 16px;
}

.page-header h1 {
  font-size: clamp(35px, 2.5vw, 45px);
}

.page-header p {
  font-size: 16px;
}

.eyebrow {
  font-size: 13px;
}

.update-meta span {
  font-size: 11px;
}

.update-meta strong,
.icon-button-label {
  font-size: 14px;
}

.filter-card-top h2 {
  font-size: 16px;
}

.filter-card-top p {
  font-size: 13px;
}

.filter-field > span {
  font-size: 12px;
}

.filter-field select {
  min-height: 46px;
  font-size: 15px;
}

.button {
  font-size: 13px;
}

.metric-card-header h2 {
  font-size: 16px;
}

.metric-card-header p {
  font-size: 12px;
}

.mini-button,
.details-button {
  font-size: 11px;
}

.metric-table {
  font-size: 12.5px;
}

.metric-table thead th {
  font-size: 11.5px;
}

.card-heading-row h2 {
  font-size: 17px;
}

.card-heading-row p,
.metric-summary-caption {
  font-size: 12px;
}

.card-kicker,
.back-link {
  font-size: 11px;
}

.details-filters-with-indicator {
  grid-template-columns: repeat(6, minmax(140px, 1fr));
}

/* Primeira tela passa a ter 7 filtros: 3 + 4 em telas intermediárias. */
.first-page-filters {
  grid-template-columns: repeat(7, minmax(130px, 1fr));
}

@media (max-width: 1500px) {
  .first-page-filters {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
  }

  .details-filters-with-indicator {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
  }
}

@media (max-width: 780px) {
  .page-header h1 {
    font-size: 31px;
  }

  .first-page-filters,
  .details-filters-with-indicator {
    grid-template-columns: 1fr;
  }

  .filter-field select {
    font-size: 16px;
  }

  .metric-table {
    font-size: 13px;
  }
}

/* ============================================================
   V6 STATIC / MOBILE
   ============================================================ */

.static-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted-foreground);
}

@media (max-width: 640px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  .page-header {
    gap: 18px;
  }

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

  .filter-card {
    padding: 14px;
  }

  .metric-card {
    min-width: 0;
  }

  .metric-card-header {
    align-items: flex-start;
    gap: 12px;
  }

  .metric-table-wrapper {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .metric-value-link {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }

  .chart {
    min-height: 330px;
  }

  .chart-ranking {
    min-height: 420px;
  }

  .chart-evolution {
    min-height: 360px;
  }
}

/* ============================================================
   V7.2 - PERÍODO + CHECKBOX MULTISELECT
   ============================================================ */

.date-range-toolbar {
  width: min(560px, 100%);
  margin: -10px 0 12px auto;
  padding: 10px 12px;

  display: grid;
  grid-template-columns:
    auto minmax(130px, 1fr)
    auto minmax(130px, 1fr)
    32px;
  align-items: end;
  gap: 8px;

  border: 1px solid var(--border);
  border-radius: 12px;

  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.date-range-title {
  align-self: center;
  display: flex;
  flex-direction: column;
  padding-right: 4px;
}

.date-range-title span,
.date-range-field span {
  font-size: 10px;
  font-weight: 750;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.date-range-title strong {
  font-size: 12px;
  white-space: nowrap;
}

.date-range-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.date-range-field input {
  width: 100%;
  min-height: 36px;
  padding: 0 9px;

  border: 1px solid var(--input);
  border-radius: 9px;

  color: var(--foreground);
  background: var(--background);

  font: inherit;
  font-size: 12px;
  outline: none;
}

.date-range-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.date-range-between {
  align-self: end;
  padding-bottom: 9px;
  font-size: 11px;
  color: var(--muted-foreground);
}

.date-range-clear {
  width: 32px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  border: 1px solid var(--border);
  border-radius: 9px;

  background: transparent;
  color: var(--muted-foreground);

  cursor: pointer;
  font-size: 18px;
}

.date-range-clear:hover {
  color: var(--foreground);
  background: var(--muted);
}

.checkbox-multiselect {
  position: relative;
  width: 100%;
}

.checkbox-multiselect-trigger {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  border: 1px solid var(--input);
  border-radius: 9px;

  background: var(--background);
  color: var(--foreground);

  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  outline: none;
}

.checkbox-multiselect-trigger:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}

.checkbox-multiselect.open .checkbox-multiselect-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.checkbox-multiselect-trigger.has-selection .checkbox-multiselect-label {
  font-weight: 700;
}

.checkbox-multiselect-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checkbox-multiselect-chevron {
  flex: 0 0 auto;
  transition: transform 0.16s ease;
}

.checkbox-multiselect.open .checkbox-multiselect-chevron {
  transform: rotate(180deg);
}

.checkbox-multiselect-panel {
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 0;

  width: max(100%, 260px);
  max-width: 380px;
  display: none;

  border: 1px solid var(--border);
  border-radius: 12px;

  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: var(--shadow-md);

  overflow: hidden;
}

.checkbox-multiselect.open .checkbox-multiselect-panel {
  display: block;
}

.checkbox-multiselect-search-wrap {
  padding: 9px;
  border-bottom: 1px solid var(--border);
}

.checkbox-multiselect-search {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;

  border: 1px solid var(--input);
  border-radius: 8px;

  background: var(--background);
  color: var(--foreground);

  font: inherit;
  font-size: 12px;
  outline: none;
}

.checkbox-multiselect-search:focus {
  border-color: var(--primary);
}

.checkbox-multiselect-list {
  max-height: 290px;
  overflow-y: auto;
  padding: 6px;
}

.checkbox-option {
  min-height: 36px;
  padding: 6px 8px;

  display: flex;
  align-items: center;
  gap: 9px;

  border-radius: 8px;

  cursor: pointer;
  user-select: none;
  font-size: 12px;
}

.checkbox-option:hover {
  background: var(--muted);
}

.checkbox-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

.checkbox-option-all {
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  font-weight: 700;
}

.formula-fx {
  font-size: 10px;
  font-weight: 850;
  letter-spacing: -0.02em;
}

@media (max-width: 860px) {
  .date-range-toolbar {
    width: 100%;
    margin-top: 0;
    grid-template-columns:
      minmax(0, 1fr)
      minmax(0, 1fr)
      32px;
  }

  .date-range-title {
    grid-column: 1 / -1;
  }

  .date-range-between {
    display: none;
  }

  .checkbox-multiselect-panel {
    width: 100%;
    max-width: none;
  }
}

/* ============================================================
   V7.3 - ANO/MÊS CHECKBOX NAS DUAS TELAS
   ============================================================ */

.first-page-filters {
  grid-template-columns: repeat(9, minmax(118px, 1fr));
}

.checkbox-multiselect-panel {
  min-width: 220px;
}

.checkbox-option {
  min-height: 34px;
  padding: 7px 9px;
  border-radius: 0;
}

.checkbox-option-all {
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}

.checkbox-option input {
  flex: 0 0 auto;
}

@media (max-width: 1500px) {
  .first-page-filters {
    grid-template-columns: repeat(5, minmax(145px, 1fr));
  }
}

@media (max-width: 980px) {
  .first-page-filters {
    grid-template-columns: repeat(3, minmax(145px, 1fr));
  }
}

@media (max-width: 640px) {
  .first-page-filters {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   V7.4 - ANO/MÊS PRIMEIROS + FILTRO EFETIVO
   ============================================================ */

.first-page-filters {
  grid-template-columns: repeat(9, minmax(118px, 1fr));
}

@media (max-width: 1500px) {
  .first-page-filters {
    grid-template-columns: repeat(5, minmax(145px, 1fr));
  }
}

@media (max-width: 980px) {
  .first-page-filters {
    grid-template-columns: repeat(3, minmax(145px, 1fr));
  }
}

@media (max-width: 640px) {
  .first-page-filters {
    grid-template-columns: 1fr;
  }
}

/* Allow grid/flex children to shrink to the viewport. */
.app-shell,
.filters-grid > *,
.details-top-grid > *,
.dashboard-grid > *,
.formula-grid > *,
.page-header > *,
.card-heading-row > *,
.filter-card-top > *,
.chart-card,
.chart-ranking,
.chart-evolution,
.metric-summary-card {
  min-width: 0;
}

.chart {
  width: 100%;
  max-width: 100%;
}

.page-header h1,
.card-heading-row h2,
.metric-summary-value,
.checkbox-option span {
  overflow-wrap: anywhere;
}

.checkbox-multiselect-panel {
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.checkbox-multiselect-label {
  min-width: 0;
}

@media (max-width: 780px) {
  .filter-card-top,
  .metric-card-header {
    flex-wrap: wrap;
  }

  .metric-summary-value {
    font-size: clamp(30px, 9vw, 48px);
  }
}

/* ==========================================================
   V7.6 - NAVEGAÇÃO LATERAL GRANA BRASÍLIA
   ========================================================== */

:root {
  --brand-sidebar: #521019;
  --brand-sidebar-hover: #641522;
  --brand-sidebar-active: #6f1b28;
  --brand-sidebar-gold: #c69b19;
}

.side-nav-root {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1400;
  pointer-events: none;
}

.side-nav-rail {
  position: fixed;
  left: 0;
  top: 18px;
  width: 48px;
  min-height: 92px;
  padding: 10px 7px;
  border: 0;
  border-radius: 0 12px 12px 0;
  background: var(--brand-sidebar);
  box-shadow: 0 10px 28px rgb(0 0 0 / 22%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  pointer-events: auto;
  transition:
    transform 0.18s ease,
    background 0.18s ease;
}

.side-nav-rail:hover {
  background: var(--brand-sidebar-hover);
  transform: translateX(2px);
}

.side-nav-mark {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.side-nav-hamburger {
  width: 21px;
  display: grid;
  gap: 4px;
}

.side-nav-hamburger i {
  height: 2px;
  width: 100%;
  display: block;
  background: currentColor;
  border-radius: 999px;
}

.side-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgb(8 13 22 / 45%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

.side-nav-panel {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(270px, calc(100vw - 40px));
  padding: 18px 14px 22px;
  background: linear-gradient(180deg, #521019 0%, #451019 100%);
  color: #fff;
  box-shadow: 18px 0 48px rgb(0 0 0 / 30%);
  transform: translateX(-102%);
  pointer-events: auto;
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}

.side-nav-root.open .side-nav-panel {
  transform: translateX(0);
}
.side-nav-root.open .side-nav-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.side-nav-root.open .side-nav-rail {
  visibility: hidden;
}

.side-nav-brand {
  padding: 2px 4px 0;
}

.side-nav-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.side-nav-logo {
  width: 185px;
  max-width: calc(100% - 42px);
  height: auto;
  object-fit: contain;
}

.side-nav-close {
  width: 32px;
  height: 32px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 8px;
  background: transparent;
  color: rgb(255 255 255 / 84%);
  font: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.side-nav-close:hover {
  background: rgb(255 255 255 / 8%);
}

.side-nav-section-title {
  margin-top: 10px;
  padding: 0 2px 7px;
  color: var(--brand-sidebar-gold);
  border-bottom: 1px solid rgb(198 155 25 / 30%);
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  width: 100%;
  display: block; /* ou block, se já não for */
}

.side-nav-links {
  display: grid;
  gap: 3px;
  padding: 4px 4px 0;
}

.side-nav-link {
  min-height: 36px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  border-left: 3px solid transparent;
  border-radius: 3px;
  color: rgb(255 255 255 / 76%);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.side-nav-link:hover {
  color: #fff;
  background: rgb(255 255 255 / 5%);
}

.side-nav-link.active {
  color: #fff;
  background: var(--brand-sidebar-active);
  border-left-color: var(--brand-sidebar-gold);
  font-weight: 700;
}

body.side-nav-open {
  overflow: hidden;
}

/* Lotes em criação */
.lotes-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 18px 0;
}

.lotes-kpi {
  min-width: 0;
  padding: 18px;
}

.lotes-kpi .card-heading-row {
  align-items: flex-start;
}

.lotes-kpi-label {
  color: var(--muted-foreground);
  font-size: 0.84rem;
  font-weight: 650;
}

.lotes-kpi-value {
  margin-top: 10px;
  font-size: clamp(1.45rem, 2.6vw, 2.15rem);
  line-height: 1;
  font-weight: 760;
  letter-spacing: -0.04em;
}

.lotes-kpi-caption {
  margin-top: 8px;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.formula-mini-button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--secondary);
  color: var(--foreground);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.lotes-table-card {
  overflow: hidden;
}

.lotes-table-wrap {
  overflow: auto;
  max-height: 62vh;
}

.lotes-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1100px;
}

.lotes-table th,
.lotes-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 0.83rem;
}

.lotes-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card);
  color: var(--muted-foreground);
  font-weight: 680;
}

.lotes-table tbody tr:hover td {
  background: var(--secondary);
}

.lotes-age-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--secondary);
  font-weight: 650;
}

.formula-page-section + .formula-page-section {
  margin-top: 34px;
}

.formula-section-header {
  margin-bottom: 14px;
}

.formula-section-header h2 {
  margin: 0 0 4px;
}

.formula-section-header p {
  margin: 0;
  color: var(--muted-foreground);
}

@media (max-width: 1300px) {
  .lotes-kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .side-nav-rail {
    top: 12px;
    bottom: auto;
    min-height: 84px;
  }

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

@media (max-width: 520px) {
  .lotes-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================
   V7.11 - LOTES EM CRIAÇÃO / referência operacional
   ========================================================== */
.lotes-reference-page {
}
.lotes-shell {
  width: min(1880px, calc(100% - 28px));
  padding-top: 14px;
}
.lotes-compact-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}
.lotes-compact-header h1 {
  margin: 4px 0 0;
  font-size: clamp(26px, 2.2vw, 36px);
  line-height: 1;
  letter-spacing: -0.04em;
}
.lotes-period-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.lotes-period-badge strong {
  display: grid;
  place-items: center;
  min-width: 29px;
  height: 29px;
  padding: 0 7px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
}
.lotes-history-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}
.lotes-history-link:hover,
.lotes-history-link:focus-visible { background: color-mix(in srgb, var(--primary) 10%, transparent); }
.lotes-history-link strong {
  display: inline-grid;
  place-items: center;
  min-width: 29px;
  height: 29px;
  margin-left: 7px;
  padding: 0 7px;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
}
.history-current-label { color: var(--primary); font-size: 11px; font-weight: 800; white-space: nowrap; }
.history-shell { width: min(1880px, calc(100% - 28px)); padding-top: 14px; }
.history-filter-card { margin-bottom: 14px; }
.history-filters { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; }
.history-filter-field { display: grid; gap: 4px; min-width: 0; }
.history-filter-field span { color: var(--muted-foreground); font-size: 10px; font-weight: 720; }
.history-multi-select { position: relative; min-width: 0; }
.history-multi-select summary { display: flex; align-items: center; justify-content: space-between; min-height: 40px; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--card); color: var(--foreground); font-size: 12px; cursor: pointer; list-style: none; }
.history-multi-select summary::-webkit-details-marker { display: none; }
.history-multi-select summary::after { content: "⌄"; color: var(--muted-foreground); font-size: 12px; }
.history-multi-select[open] summary { border-color: var(--primary); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.history-multi-menu { position: absolute; z-index: 8; top: 100%; left: 0; right: 0; max-height: 250px; overflow: auto; padding: 6px; border: 1px solid var(--primary); border-top: 0; border-radius: 0 0 5px 5px; background: var(--card); box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.history-multi-menu label { display: flex; align-items: center; gap: 7px; min-height: 28px; padding: 3px 5px; color: var(--foreground); font-size: 11px; cursor: pointer; }
.history-multi-menu label:hover { background: color-mix(in srgb, var(--primary) 8%, var(--card)); }
.history-multi-menu input { accent-color: var(--primary); }
.history-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.history-kpi { padding: 14px 16px; border-top: 2px solid var(--primary); }
.history-kpi span { color: var(--muted-foreground); font-size: 11px; }
.history-kpi strong { display: block; margin-top: 5px; color: var(--foreground); font-size: 22px; font-variant-numeric: tabular-nums; }
.history-table-card { overflow: hidden; }
.history-table-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 15px 16px; border-bottom: 1px solid var(--border); }
.history-table-heading h2 { margin: 0; font-size: 15px; }
.history-table-heading p { margin: 4px 0 0; color: var(--muted-foreground); font-size: 12px; }
.history-year-filter { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.history-year-button { min-width: 52px; min-height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: 5px; background: var(--card); color: var(--muted-foreground); font: inherit; font-size: 11px; font-weight: 750; cursor: pointer; }
.history-year-button:hover, .history-year-button:focus-visible { border-color: var(--primary); color: var(--primary); }
.history-year-button.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.history-source { color: var(--primary); font-size: 11px; font-weight: 750; }
.history-table-wrap { max-width: 100%; overflow: auto; }
.history-table { width: 100%; min-width: 2100px; border-collapse: collapse; font-size: 12px; }
.history-table th, .history-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.history-table thead th { position: sticky; top: 0; z-index: 1; background: var(--card); color: var(--muted-foreground); font-size: 11px; font-weight: 700; }
.history-table th.num, .history-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.history-table tbody tr:hover td { background: color-mix(in srgb, var(--primary) 5%, var(--card)); }
.history-table tfoot th { background: var(--card); font-weight: 800; }
.history-sort { min-height: 28px; padding: 3px 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: inherit; cursor: pointer; }
.history-sort span { color: var(--muted-foreground); margin-left: 4px; }
.history-sort.active { color: var(--primary); }
.history-expand { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0; border: 0; background: transparent; color: var(--foreground); font: inherit; text-align: left; cursor: pointer; }
.history-expand span:first-child { display: inline-grid; place-items: center; width: 17px; height: 17px; border: 1px solid var(--border); border-radius: 3px; color: var(--primary); font-weight: 800; }
.history-level-0 td { background: color-mix(in srgb, var(--primary) 7%, var(--card)); font-weight: 800; }
.history-level-1 td { background: color-mix(in srgb, var(--primary) 3%, var(--card)); font-weight: 650; }
.history-level-1 td:first-child { padding-left: 34px; }
.history-level-2 td:first-child { padding-left: 58px; }
.history-level-3 td:first-child { padding-left: 84px; color: var(--muted-foreground); }
.history-empty { padding: 32px !important; color: var(--muted-foreground); text-align: center !important; }
@media (max-width: 980px) { .history-filters { grid-template-columns: repeat(3, minmax(120px, 1fr)); } .history-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .history-filters { grid-template-columns: 1fr; } .history-kpis { grid-template-columns: 1fr 1fr; gap: 8px; } .history-kpi { padding: 11px; } .history-kpi strong { font-size: 18px; } .history-header .card-actions { gap: 4px; } .history-table-heading { align-items: flex-start; flex-direction: column; } .history-year-filter { width: 100%; } .history-year-button { flex: 1; } }
.lotes-filter-strip {
  padding: 10px 12px;
  border-radius: 8px;
}
.lotes-filter-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(132px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}
.lotes-select-field {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.lotes-select-field > span {
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 720;
}
.lotes-select-field select {
  width: 100%;
  height: 34px;
  padding: 0 34px 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--card);
  color: var(--foreground);
  font-size: 12px;
  outline: none;
}
.lotes-select-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}
.lotes-clear-button {
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 5px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 760;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.lotes-clear-button:hover {
  background: var(--primary-2);
}
.lotes-reference-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.lotes-reference-kpi {
  position: relative;
  min-height: 92px;
  padding: 14px 15px;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  border-radius: 8px;
}
.lotes-kpi-topline {
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--accent);
}
.lotes-reference-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
}
.lotes-reference-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lotes-reference-label {
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 690;
}
.lotes-reference-value {
  margin-top: 4px;
  font-size: clamp(21px, 2vw, 27px);
  line-height: 1;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.lotes-charts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.lotes-chart-card {
  padding: 12px 14px 8px;
  border-radius: 8px;
  overflow: hidden;
}
.lotes-chart-card header {
  min-height: 38px;
}
.lotes-chart-card h2 {
  margin: 0;
  color: var(--primary);
  font-size: 13px;
  font-weight: 760;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted-foreground);
  font-size: 10px;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
}
.dot-primary {
  background: var(--primary);
}
.dot-accent {
  background: var(--accent);
}
.lotes-chart {
  height: 285px;
  width: 100%;
}
.lotes-reference-table-card {
  padding: 10px 12px 0;
  border-radius: 8px;
  overflow: hidden;
}
.lotes-reference-table-wrap {
  max-height: 285px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.lotes-reference-table {
  min-width: 980px;
}
.lotes-reference-table th,
.lotes-reference-table td {
  padding: 7px 9px;
  font-size: 10.5px;
}
.lotes-reference-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
  color: var(--foreground);
  font-weight: 760;
}
.lotes-reference-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
}
.lotes-reference-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lotes-reference-table tfoot th {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 7px 9px;
  background: var(--card);
  border-top: 2px solid var(--border);
  font-size: 10.5px;
  font-weight: 800;
}
@media (max-width: 1450px) {
  .lotes-filter-row {
    grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
  }
  .lotes-clear-button {
    grid-column: auto;
  }
  .lotes-charts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lotes-chart-card:last-child {
    grid-column: 1/-1;
  }
  .lotes-reference-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .lotes-filter-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lotes-clear-button {
    grid-column: 1/-1;
  }
  .lotes-reference-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lotes-charts-grid {
    grid-template-columns: 1fr;
  }
  .lotes-chart-card:last-child {
    grid-column: auto;
  }
  .lotes-chart {
    height: 270px;
  }
}
@media (max-width: 560px) {
  .lotes-shell {
    width: min(100% - 18px, 1880px);
    padding-top: 12px;
  }
  .lotes-compact-header {
    align-items: flex-start;
  }
  .lotes-period-badge span {
    display: none;
  }
  .lotes-filter-row {
    grid-template-columns: 1fr;
  }
  .lotes-reference-kpis {
    grid-template-columns: 1fr;
  }
  .lotes-reference-kpi {
    min-height: 82px;
  }
  .lotes-chart {
    height: 250px;
  }
}

/* ============================================================
   V7.12 - FILTROS LOTES NO MESMO PADRAO DO DESEMPENHO
   ============================================================ */
.lotes-filter-card {
  margin-top: 14px;
}

.lotes-page-filters {
  grid-template-columns: repeat(7, minmax(140px, 1fr));
}

.lotes-page-filters .checkbox-multiselect-trigger {
  min-height: 40px;
}

/* Aviso temporário de indisponibilidade na origem Agrosys. */
.filter-field-tecnico .agrosys-status-note {
  display: flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 5px 2px;
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
  color: color-mix(in srgb, var(--foreground) 82%, var(--accent));
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
}

.filter-field-tecnico .agrosys-status-note-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-foreground);
  font-size: 9px;
  font-weight: 850;
}

@media (max-width: 780px) {
  .filter-field-tecnico .agrosys-status-note {
    width: 100%;
    border-radius: 9px;
    font-size: 11px;
    white-space: normal;
  }
}

@media (max-width: 1300px) {
  .lotes-page-filters {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
}

@media (max-width: 780px) {
  .lotes-page-filters {
    grid-template-columns: 1fr;
  }
}

/* V7.13 - subtítulo informativo dos gráficos de lotes */
.lotes-chart-card header > div:first-child {
  min-width: 0;
}
.lotes-chart-card .chart-subtitle {
  margin: 3px 0 0;
  color: var(--muted-foreground);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 500;
}

/* ============================================================
   V7.14 - nitidez dos graficos, menu circular e tabela ordenavel
   ============================================================ */
.side-nav-rail {
  top: 14px;
  left: 14px;
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  border-radius: 50%;
  gap: 0;
}
.side-nav-rail:hover {
  transform: translateY(-1px);
}
.side-nav-hamburger {
  width: 20px;
  gap: 4px;
}
.side-nav-hamburger i {
  height: 2px;
}

/* Reserva espaco somente no cabecalho: o botao nao acompanha os graficos/tabelas. */
.side-nav-root {
  position: absolute;
  inset: 0 auto auto 0;
  height: 0;
}
.side-nav-rail {
  position: absolute;
}
.side-nav-overlay,
.side-nav-panel {
  position: fixed;
}
.has-side-nav .app-shell > header:first-child,
.has-side-nav .app-shell > .page-header:first-child {
  padding-left: 58px;
}

.lotes-sort-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.lotes-sort-button.num {
  justify-content: flex-end;
}
.lotes-sort-button .sort-icon {
  opacity: 0.48;
  font-size: 10px;
}
.lotes-sort-button:hover .sort-icon,
.lotes-sort-button.active .sort-icon {
  opacity: 1;
  color: var(--primary);
}

/* Os SVGs do ECharts permanecem vetoriais em zoom e telas de alta densidade. */
.lotes-chart > div,
.lotes-chart svg {
  width: 100% !important;
  max-width: 100%;
}
.lotes-chart svg {
  overflow: visible;
}

@media (max-width: 780px) {
  .side-nav-rail {
    top: 10px;
    left: 10px;
    width: 42px;
    height: 42px;
    min-height: 42px;
  }
  .has-side-nav .app-shell > header:first-child,
  .has-side-nav .app-shell > .page-header:first-child {
    padding-left: 50px;
  }
  .lotes-chart-card {
    padding-left: 10px;
    padding-right: 10px;
  }
  .lotes-chart {
    height: 270px;
  }
}

@media (max-width: 420px) {
  .lotes-reference-table th,
  .lotes-reference-table td {
    font-size: 10px;
  }
}

/* Fórmulas legíveis no desktop e no telefone. */
.dashboard-grid > .metric-card-wide { grid-column: 1 / -1; }
.formula-disclosure { min-width: 0; padding: 0; align-self: start; scroll-margin-top: 20px; }
.formula-disclosure > summary { padding: 14px 16px; min-height: 48px; cursor: pointer; color: var(--primary); font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.formula-content { padding: 0 16px 16px; min-width: 0; }
.formula-content p, .formula-explanation { font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.formula-explanation h3 { font-size: 13px; margin: 14px 0 6px; }
.formula-explanation ol { padding-left: 22px; margin: 6px 0; }
.formula-explanation li + li { margin-top: 6px; }
.formula-columns { display: flex; flex-wrap: wrap; gap: 6px; }
.formula-columns code { padding: 3px 6px; border-radius: 5px; background: var(--muted); max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
.formula-content .code-inline, .dialog-body .code-inline { white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; font-size: 13px; line-height: 1.6; }
.formula-content pre, .dialog-body pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.lotes-formula-section { margin-top: 16px; }
.lotes-formula-section h2 { font-size: 18px; color: var(--primary); }
.lotes-formula-section > p { font-size: 14px; color: var(--muted-foreground); }
.lotes-reference-kpi { position: relative; padding-right: 48px; }
.lotes-reference-kpi .formula-mini-button { position: absolute; top: 6px; right: 6px; min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.lotes-chart-card .formula-chart-link { display: inline-flex; align-items: center; min-height: 36px; margin-top: 4px; }
#formulaIndicador { margin-top: 14px; }
@media (max-width: 780px) {
  .formula-grid { grid-template-columns: minmax(0, 1fr); }
  .formula-disclosure > summary { min-height: 48px; }
  .lotes-reference-kpi .formula-mini-button { min-width: 44px; min-height: 44px; }
  .lotes-reference-kpi { padding-right: 56px; }
  .formula-chart-link { min-height: 44px !important; }
  .dialog-card { width: min(100%, 680px); max-width: 100%; }
}

/* Fórmulas de Lotes: os mesmos botões e painel do index. */
.lotes-reference-kpi .lotes-formula-button { position: absolute; top: 6px; right: 6px; }
.lotes-chart-card > header { position: relative; padding-right: 42px; }
.lotes-chart-card > header .lotes-formula-button { position: absolute; top: 0; right: 0; }
@media (max-width: 780px) {
  .lotes-formula-button, #formulaFecharLotes { min-width: 44px; min-height: 44px; }
  .lotes-chart-card > header { padding-right: 52px; min-height: 44px; }
}

/* ============================================================
   V7.24 - DIFERENÇA DE AVES ABATIDAS / protótipo visual
   ============================================================ */
.abate-page {
}

.abate-page-filters {
  grid-template-columns: repeat(7, minmax(135px, 1fr));
}

.abate-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.abate-kpi-card {
  position: relative;
  min-height: 112px;
  padding: 16px;
  overflow: hidden;
}

.abate-kpi-accent {
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--accent);
}

.abate-kpi-label {
  color: var(--muted-foreground);
  font-size: 10px;
  font-weight: 760;
}

.abate-kpi-value {
  display: block;
  margin-top: 8px;
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1;
  font-weight: 760;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.abate-kpi-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted-foreground);
  font-size: 9px;
}

.abate-kpi-diff.is-negative .abate-kpi-accent {
  background: var(--destructive);
}

.abate-kpi-diff.is-negative .abate-kpi-value {
  color: var(--destructive);
}

.abate-kpi-diff.is-positive .abate-kpi-accent {
  background: var(--accent);
}

.abate-kpi-diff.is-positive .abate-kpi-value {
  color: var(--accent);
}

.abate-kpi-diff.is-zero .abate-kpi-value {
  color: var(--muted-foreground);
}

.abate-table-card {
  padding: 15px;
  overflow: hidden;
}

.abate-section-heading {
  margin-bottom: 12px;
}

.abate-section-heading strong {
  color: var(--primary);
}

.abate-table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  scrollbar-width: thin;
}

.abate-table {
  width: 100%;
  min-width: 880px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 10.5px;
}

.abate-table th,
.abate-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.abate-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
  color: var(--foreground);
  font-size: 9.5px;
  font-weight: 780;
}

.abate-table .num {
  text-align: right;
}

.abate-table .action {
  width: 1%;
  text-align: center;
}

.abate-table tbody tr:hover td {
  background: var(--secondary);
}

.abate-table tfoot th {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--card);
  border-top: 2px solid var(--border);
  border-bottom: 0;
  font-weight: 800;
}

.abate-diff-heading {
  color: var(--primary) !important;
}

.abate-diff-pill {
  display: inline-flex;
  min-width: 68px;
  justify-content: flex-end;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--secondary);
  font-weight: 800;
}

.abate-diff-pill.is-negative,
.abate-summary-diff.is-negative {
  color: var(--destructive);
}

.abate-diff-pill.is-negative {
  border-color: color-mix(in srgb, var(--destructive) 28%, var(--border));
  background: color-mix(in srgb, var(--destructive) 8%, var(--card));
}

.abate-diff-pill.is-positive,
.abate-summary-diff.is-positive {
  color: var(--accent);
}

.abate-diff-pill.is-positive {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: color-mix(in srgb, var(--accent) 9%, var(--card));
}

.abate-diff-pill.is-zero,
.abate-summary-diff.is-zero {
  color: var(--muted-foreground);
}

.abate-table:not(.abate-detail-table) .abate-row.is-negative td:first-child {
  box-shadow: inset 2px 0 0 var(--destructive);
}

.abate-table:not(.abate-detail-table) .abate-row.is-positive td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}

.abate-empty {
  padding: 34px !important;
  color: var(--muted-foreground);
  text-align: center !important;
}

.abate-dialog-card {
  width: min(1180px, 100%);
}

.abate-dialog-subtitle {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 10px;
}

.abate-modal-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.abate-modal-summary > div {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--background);
}

.abate-modal-summary span,
.abate-modal-summary strong {
  display: block;
}

.abate-modal-summary span {
  color: var(--muted-foreground);
  font-size: 9px;
  font-weight: 750;
}

.abate-modal-summary strong {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.abate-modal-table-wrap {
  max-height: 54vh;
}

.abate-detail-table {
  min-width: 1040px;
}

@media (max-width: 1400px) {
  .abate-page-filters {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
  }
}

@media (max-width: 1050px) {
  .abate-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .abate-page-filters {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }
}

@media (max-width: 780px) {
  .abate-page-filters,
  .abate-kpis,
  .abate-modal-summary {
    grid-template-columns: 1fr;
  }

  .abate-table-card {
    padding: 11px;
  }

  .abate-kpi-card {
    min-height: 98px;
  }
}

/* RxP: leitura e controles no padrão dos demais indicadores. */
.abate-kpi-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.abate-kpi-label .mini-button { flex: 0 0 auto; }
.abate-kpi-card small { font-size: 13px; line-height: 1.5; }
.abate-page .filter-card-top p,
.abate-page .abate-section-heading p,
.abate-page .abate-dialog-subtitle { font-size: 14px; line-height: 1.5; }
.abate-page .abate-table { font-size: 14px; }
.abate-page .abate-table thead th { font-size: 13px; }
.abate-page .abate-table .mini-button { font-size: 14px; padding: 8px 12px; }
.abate-sort-button { font: inherit; color: inherit; background: transparent; border: 0; padding: 4px 0; cursor: pointer; text-align: inherit; }
.abate-sort-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

.abate-filter-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 14px; margin-left: auto; }
#periodoRxp { font-size: 14px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

/* Portal: header controls and touch targets. */
.page-header, .lotes-compact-header { position: relative; padding-right: 52px; }
.page-header [data-theme-toggle], .lotes-compact-header [data-theme-toggle] { position: absolute; top: 0; right: 0; min-width: 40px; min-height: 40px; }
button, .mini-button, .icon-button, .details-button, .checkbox-option, .checkbox-multiselect-trigger, .filter-field select { min-height: 40px; }
.mini-button, .icon-button { min-width: 40px; }

.metric-table-wrapper { max-width: 100%; max-height: 620px; overflow: auto; --month-width: 9ch; }
.metric-table .month-cell { box-sizing: border-box; width: var(--month-width); min-width: var(--month-width); max-width: var(--month-width); padding: 4px; position: sticky; left: 0; z-index: 2; background: var(--card); box-shadow: 2px 0 3px var(--border); }
.metric-table thead th { position: sticky; top: 0; z-index: 3; background: var(--card); }
.metric-table thead .month-cell { z-index: 4; }
@media (max-width: 768px) {
  .metric-table-desktop { display: table; min-width: 480px; }
}

#modalAbate .abate-modal-table-wrap { overflow-x: hidden; }
#modalAbate .abate-detail-table { width: 100%; min-width: 0; table-layout: fixed; }
#modalAbate .abate-detail-table th, #modalAbate .abate-detail-table td { white-space: normal; overflow-wrap: anywhere; padding: 5px 3px; font-size: 11px; }
#modalAbate .abate-detail-table .abate-sort-button { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
@media (max-width: 768px) {
  #modalAbate .abate-detail-table, #modalAbate .abate-detail-table tbody { display: block; }
  #modalAbate .abate-detail-table thead { display: none; }
  #modalAbate .abate-detail-table tr { display: block; padding: 8px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 8px; }
  #modalAbate .abate-detail-table td { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px; width: auto; text-align: right; padding: 5px 0; font-size: 12px; }
  #modalAbate .abate-detail-table td::before { content: attr(data-label); font-weight: 600; text-align: left; }
  #modalAbate .abate-detail-table td > * { min-width: 0; overflow-wrap: anywhere; }
}

/* Histórico: alternância entre Mortalidade e Peso */
.history-table-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.history-view-filter { display: inline-flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 7px; background: color-mix(in srgb, var(--muted) 55%, transparent); }
.history-view-button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 5px; background: transparent; color: var(--muted-foreground); font: inherit; font-size: 11px; font-weight: 750; cursor: pointer; }
.history-view-button:hover, .history-view-button:focus-visible { color: var(--primary); }
.history-view-button.active { background: var(--card); color: var(--primary); box-shadow: 0 1px 3px color-mix(in srgb, var(--foreground) 12%, transparent); }
.history-table[data-view="mortality"] { min-width: 2320px; }
.history-table[data-view="weight"] { min-width: 1460px; }
@media (max-width: 640px) {
  .history-table-heading-actions { width: 100%; justify-content: stretch; }
  .history-view-filter { width: 100%; }
  .history-view-button { flex: 1; }
}


/* Histórico de lotes — ajustes visuais v4 */
.history-page {
  --history-combined-col-bg: color-mix(in srgb, var(--primary) 8%, var(--card));
  --history-combined-col-hover-bg: color-mix(in srgb, var(--primary) 12%, var(--card));
  --history-row-odd-bg: color-mix(in srgb, var(--primary) 1.5%, var(--card));
  --history-row-even-bg: color-mix(in srgb, var(--secondary) 6%, var(--card));
}
[data-theme="dark"] .history-page {
  --history-combined-col-bg: color-mix(in srgb, var(--primary) 18%, var(--card));
  --history-combined-col-hover-bg: color-mix(in srgb, var(--primary) 24%, var(--card));
  --history-row-odd-bg: color-mix(in srgb, var(--foreground) 3%, var(--card));
  --history-row-even-bg: color-mix(in srgb, var(--foreground) 6%, var(--card));
}
.history-shell { width: min(100%, calc(100% - 28px)); max-width: 100%; }
.history-table-card { overflow: hidden; }
.history-table-wrap { max-width: 100%; overflow-x: clip; overflow-y: auto; }
.history-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  font-size: 11px;
}
.history-table th,
.history-table td {
  padding: 9px 8px;
  white-space: nowrap;
}
.history-table thead th {
  font-size: 10px;
  line-height: 1.2;
}
.history-table th:nth-child(1),
.history-table td:nth-child(1) { width: 18%; }
.history-table th:nth-child(2),
.history-table td:nth-child(2) { width: 7%; }
.history-table th:nth-child(3),
.history-table td:nth-child(3) { width: 8%; }
.history-table th:nth-child(n + 4),
.history-table td:nth-child(n + 4) { width: 4.45%; }
.history-table tbody tr:nth-child(odd) td { background: var(--history-row-odd-bg); }
.history-table tbody tr:nth-child(even) td { background: var(--history-row-even-bg); }
.history-table tbody tr.history-level-0 td { background: color-mix(in srgb, var(--primary) 8%, var(--history-row-odd-bg)); font-weight: 800; }
.history-table tbody tr.history-level-1 td { background: color-mix(in srgb, var(--primary) 5%, var(--history-row-even-bg)); font-weight: 700; }
.history-table tbody tr.history-level-2 td { background: color-mix(in srgb, var(--primary) 3%, var(--history-row-odd-bg)); }
.history-table tbody tr.history-level-3 td { background: var(--history-row-even-bg); }
.history-table .history-col-combined { background: var(--history-combined-col-bg) !important; }
.history-table tbody tr:hover td { background: color-mix(in srgb, var(--primary) 6%, var(--card)); }
.history-table tbody tr:hover td.history-col-combined { background: var(--history-combined-col-hover-bg) !important; }
.history-table tfoot th { background: color-mix(in srgb, var(--primary) 4%, var(--card)); }
.history-table tfoot .history-col-combined { background: var(--history-combined-col-bg); }
.history-expand { gap: 6px; width: 100%; }
.history-expand span:last-child { overflow: hidden; text-overflow: ellipsis; }
.history-level-1 td:first-child { padding-left: 24px; }
.history-level-2 td:first-child { padding-left: 40px; }
.history-level-3 td:first-child { padding-left: 54px; }
@media (max-width: 1380px) {
  .history-table { font-size: 10px; }
  .history-table th,
  .history-table td { padding: 8px 6px; }
}
@media (max-width: 980px) {
  .history-table-wrap { overflow-x: auto; }
  .history-table { min-width: 980px; table-layout: auto; }
}

/* Histórico: identificação fixa e rolagem restrita à tabela. */
.history-table-wrap { overflow: auto; max-height: 70vh; isolation: isolate; }
.history-table[data-view="mortality"],
.history-table[data-view="weight"] { min-width: 1480px; table-layout: auto; font-size: 12px; border-collapse: separate; border-spacing: 0; }
.history-table[data-view="weight"] { min-width: 1120px; }
.history-table th, .history-table td { padding: 10px 12px; line-height: 1.45; }
.history-table th:first-child, .history-table td:first-child { width: 220px; min-width: 220px; max-width: 220px; position: sticky; left: 0; z-index: 2; box-shadow: 3px 0 5px -3px var(--muted-foreground); }
.history-table thead th { top: 0; z-index: 3; font-size: 12px; color: var(--foreground); border-bottom: 2px solid var(--border); }
.history-table thead th:first-child { z-index: 4; }
.history-table tfoot th { border-top: 2px solid var(--border); }
.history-table .history-sort, .history-table .history-expand { min-height: 40px; }
.history-table .history-expand { white-space: normal; overflow-wrap: anywhere; }
.history-table .history-expand span:first-child { flex: 0 0 22px; height: 22px; border-radius: 6px; background: var(--card); }
.history-table .history-expand span:last-child { overflow: visible; }
.history-table .history-expand[aria-expanded="true"] { font-weight: 800; }
.history-table .history-expand:focus-visible, .history-table .history-sort:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.history-table tbody tr.history-level-0 td { border-top: 2px solid var(--border); }
.history-table[data-view="mortality"] th:nth-child(3n + 4), .history-table[data-view="mortality"] td:nth-child(3n + 4) { border-left: 1px solid var(--border); }
@media (max-width: 768px) {
  .history-table th:first-child, .history-table td:first-child { width: 160px; min-width: 160px; max-width: 160px; }
  .history-table th, .history-table td { padding-top: 8px; padding-bottom: 8px; }
  .history-table .history-level-1 td:first-child { padding-left: 18px; }
  .history-table .history-level-2 td:first-child { padding-left: 28px; }
  .history-table .history-level-3 td:first-child { padding-left: 38px; }
}


/* Histórico de lotes — refinamento visual v5 */
.history-page {
  --history-row-odd-bg: color-mix(in srgb, var(--card) 90%, var(--muted) 10%);
  --history-row-even-bg: color-mix(in srgb, var(--card) 84%, var(--muted) 16%);
  --history-combined-col-odd-bg: color-mix(in srgb, var(--primary) 9%, var(--history-row-odd-bg));
  --history-combined-col-even-bg: color-mix(in srgb, var(--primary) 13%, var(--history-row-even-bg));
  --history-combined-col-head-bg: color-mix(in srgb, var(--primary) 11%, var(--card));
  --history-combined-col-hover-bg: color-mix(in srgb, var(--primary) 16%, var(--card));
}
[data-theme="dark"] .history-page {
  --history-row-odd-bg: color-mix(in srgb, var(--card) 92%, var(--foreground) 8%);
  --history-row-even-bg: color-mix(in srgb, var(--card) 86%, var(--foreground) 14%);
  --history-combined-col-odd-bg: color-mix(in srgb, var(--primary) 20%, var(--history-row-odd-bg));
  --history-combined-col-even-bg: color-mix(in srgb, var(--primary) 24%, var(--history-row-even-bg));
  --history-combined-col-head-bg: color-mix(in srgb, var(--primary) 22%, var(--card));
  --history-combined-col-hover-bg: color-mix(in srgb, var(--primary) 28%, var(--card));
}
.history-table tbody tr:nth-child(odd) td { background: var(--history-row-odd-bg); }
.history-table tbody tr:nth-child(even) td { background: var(--history-row-even-bg); }
.history-table thead th.history-col-combined,
.history-table tfoot .history-col-combined {
  background: var(--history-combined-col-head-bg);
  color: var(--primary);
}
.history-table tbody tr:nth-child(odd) td.history-col-combined {
  background: var(--history-combined-col-odd-bg) !important;
  color: var(--primary);
  font-weight: 700;
}
.history-table tbody tr:nth-child(even) td.history-col-combined {
  background: var(--history-combined-col-even-bg) !important;
  color: var(--primary);
  font-weight: 700;
}
.history-table tbody tr:hover td.history-col-combined {
  background: var(--history-combined-col-hover-bg) !important;
}
.history-table tbody tr.history-level-0 td.history-col-combined {
  background: color-mix(in srgb, var(--primary) 18%, var(--history-row-odd-bg)) !important;
}
.history-table tbody tr.history-level-1 td.history-col-combined {
  background: color-mix(in srgb, var(--primary) 15%, var(--history-row-even-bg)) !important;
}

/* Tabelas do Histórico e Lotes: padrão visual compacto do portal. */
.history-page .history-table-wrap { margin: 0 12px 12px; border: 1px solid var(--border); border-radius: 8px; }
.history-page .history-table { font-size: 13px; }
.history-page .history-table thead th { background: color-mix(in srgb, var(--accent) 8%, var(--card)); font-size: 13px; border-bottom: 1px solid var(--border); }
.history-page .history-table tbody tr td { background: var(--card); border-top: 0; }
.history-page .history-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--secondary) 35%, var(--card)); }
.history-page .history-table tbody tr:hover td { background: color-mix(in srgb, var(--primary) 5%, var(--card)); }
.history-page .history-table th, .history-page .history-table td { padding-top: 7px; padding-bottom: 7px; border-left: 0; }
.history-page .history-table :is(thead, tbody, tfoot) tr :is(th, td).history-col-combined { background: color-mix(in srgb, var(--primary) 5%, var(--card)) !important; color: var(--primary); font-weight: 700; }
.history-page .history-table tfoot th { background: var(--card); }
.history-page .history-table .history-expand span:first-child { border: 0; background: transparent; border-radius: 0; }
.lotes-reference-table th, .lotes-reference-table td, .lotes-reference-table tfoot th { font-size: 13px; padding: 10px 11px; }

.history-page .history-table :is(tbody, tfoot) tr :is(td, th).num { font-weight: 400; }

/* Lotes em Criação — visão Produtores/Galpões v7.52 */
.lotes-analysis-head { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; padding:12px 14px 0; border-bottom:1px solid var(--border); }
.lotes-view-tabs { display:flex; align-items:flex-end; gap:4px; }
.lotes-view-tab { appearance:none; border:0; border-bottom:3px solid transparent; background:transparent; color:var(--muted-foreground); font:inherit; font-weight:700; padding:11px 18px 10px; cursor:pointer; }
.lotes-view-tab:hover { color:var(--foreground); }
.lotes-view-tab.active { color:var(--primary); border-bottom-color:var(--primary); }

.lotes-galpao-controls { display:flex; align-items:flex-end; gap:10px; padding-bottom:8px; }
.lotes-galpao-controls label { display:grid; gap:4px; color:var(--muted-foreground); font-size:11px; font-weight:700; }
.lotes-galpao-controls select { min-height:36px; border:1px solid var(--border); border-radius:8px; background:var(--card); color:var(--foreground); padding:0 30px 0 10px; font:inherit; font-size:13px; font-weight:650; }
.lotes-galpao-fixed-indicator { display:grid; gap:4px; }
.lotes-galpao-fixed-indicator > span { color:var(--muted-foreground); font-size:11px; font-weight:700; }
.lotes-galpao-fixed-indicator > strong { min-height:36px; display:flex; align-items:center; padding:0 11px; border:1px solid var(--border); border-radius:8px; background:color-mix(in srgb, var(--primary) 5%, var(--card)); color:var(--primary); font-size:13px; }

/* A aba Produtores mantém até aproximadamente 15 linhas visíveis e rola internamente. */
#produtoresView .lotes-reference-table-wrap { max-height:665px; overflow:auto; overscroll-behavior:contain; }
#produtoresView .lotes-reference-table thead th { position:sticky; top:0; z-index:3; }
#produtoresView .lotes-reference-table tfoot th { position:sticky; bottom:0; z-index:3; background:var(--card); box-shadow:0 -1px 0 var(--border); }
.lotes-expand-producer { display:inline-flex; align-items:center; gap:8px; border:0; background:transparent; color:inherit; font:inherit; padding:0; cursor:pointer; text-align:left; }
.lotes-expand-producer > span { display:inline-grid; place-items:center; width:22px; height:22px; border:1px solid var(--border); border-radius:6px; color:var(--primary); background:var(--card); font-size:16px; line-height:1; font-weight:800; flex:0 0 auto; }
.lotes-producer-row:hover td { background:color-mix(in srgb, var(--primary) 5%, var(--card)); }
.lotes-galpao-child td { background:color-mix(in srgb, var(--secondary) 42%, var(--card)) !important; color:var(--muted-foreground); }
.lotes-galpao-child-name { padding-left:30px; color:var(--foreground); font-weight:700; }

/* Gráfico e ranking ocupam exatamente metade da largura e a mesma altura. */
.lotes-galpao-dashboard { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:stretch; gap:14px; padding:14px; }
.lotes-galpao-chart-card,.lotes-galpao-list-card { min-width:0; height:520px; display:flex; flex-direction:column; border:1px solid var(--border); border-radius:10px; background:var(--card); overflow:hidden; }
.lotes-galpao-section-head { flex:0 0 auto; display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:14px 16px 9px; border-bottom:1px solid color-mix(in srgb, var(--border) 75%, transparent); }
.lotes-galpao-section-head h3 { margin:0 0 3px; color:var(--primary); font-size:15px; }
.lotes-galpao-section-head p { margin:0; color:var(--muted-foreground); font-size:12px; }
.lotes-galpao-ranking-chart { flex:1 1 auto; min-height:0; width:100%; height:auto; }
.lotes-galpao-ranking-list { flex:1 1 auto; min-height:0; overflow-y:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch; padding:0 10px 10px; scrollbar-gutter:stable; }
.lotes-galpao-ranking-list::-webkit-scrollbar { width:8px; }
.lotes-galpao-ranking-list::-webkit-scrollbar-thumb { background:color-mix(in srgb, var(--muted-foreground) 34%, transparent); border-radius:99px; }

.lotes-galpao-rank-row { width:100%; display:grid; grid-template-columns:36px minmax(150px,1.35fr) 82px 96px 96px minmax(132px,.75fr); align-items:center; gap:8px; border:0; border-bottom:1px solid var(--border); background:var(--card); color:var(--foreground); padding:10px 8px; text-align:left; cursor:pointer; font:inherit; touch-action:manipulation; }
.lotes-galpao-rank-row:hover,.lotes-galpao-rank-row:focus-visible { background:color-mix(in srgb, var(--primary) 5%, var(--card)); outline:none; }
.lotes-galpao-rank-row strong { display:block; font-size:13px; }
.lotes-galpao-rank-row small { display:block; margin-top:2px; color:var(--muted-foreground); font-size:10px; line-height:1.2; }
.lotes-galpao-rank-pos { display:grid; place-items:center; width:30px; height:30px; border-radius:7px; background:color-mix(in srgb, var(--accent) 12%, var(--card)); font-weight:800; }
.lotes-galpao-rank-name { min-width:0; }
.lotes-galpao-rank-name strong { font-size:14px; }
.lotes-galpao-rank-name small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.lotes-galpao-rank-metric { text-align:right; }
.lotes-galpao-rank-highlight { text-align:right; border-radius:7px; padding:6px 7px; background:color-mix(in srgb, var(--primary) 8%, var(--card)); color:var(--primary); }
.lotes-galpao-rank-highlight small { color:var(--primary); opacity:.78; }
.lotes-galpao-detail-cta { justify-self:stretch; min-height:38px; display:grid; grid-template-columns:1fr auto; grid-template-rows:auto auto; align-items:center; column-gap:6px; padding:5px 8px; border:1px solid color-mix(in srgb, var(--primary) 25%, var(--border)); border-radius:8px; background:color-mix(in srgb, var(--primary) 5%, var(--card)); color:var(--primary); text-align:center; transition:background .18s ease,border-color .18s ease,transform .18s ease; }
.lotes-galpao-detail-cta > span { grid-column:1; grid-row:1; font-size:11px; font-weight:800; line-height:1.1; }
.lotes-galpao-detail-cta small { grid-column:1; grid-row:2; margin:1px 0 0; color:var(--muted-foreground); font-size:8px; font-weight:650; line-height:1.1; }
.lotes-galpao-detail-cta b { grid-column:2; grid-row:1 / span 2; font-size:18px; line-height:1; }
.lotes-galpao-rank-row:hover .lotes-galpao-detail-cta,.lotes-galpao-rank-row:focus-visible .lotes-galpao-detail-cta { background:color-mix(in srgb, var(--primary) 10%, var(--card)); border-color:color-mix(in srgb, var(--primary) 45%, var(--border)); transform:translateX(1px); }
.lotes-galpao-empty { padding:30px 16px; color:var(--muted-foreground); text-align:center; }

body.lotes-drawer-open { overflow:hidden; }
.lotes-galpao-drawer { position:fixed; inset:0; z-index:1200; display:block; }
.lotes-galpao-drawer-backdrop { position:absolute; inset:0; background:color-mix(in srgb, var(--foreground) 28%, transparent); }
.lotes-galpao-drawer-panel { position:absolute; top:0; right:0; width:min(620px,92vw); height:100%; display:flex; flex-direction:column; background:var(--background); border-left:1px solid var(--border); box-shadow:-14px 0 40px color-mix(in srgb, var(--foreground) 16%, transparent); }
.lotes-galpao-drawer-handle { display:none; }
.lotes-galpao-drawer-header { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; padding:20px 20px 14px; border-bottom:1px solid var(--border); background:var(--card); }
.lotes-galpao-drawer-header h2 { margin:3px 0 2px; color:var(--primary); font-size:24px; }
.lotes-galpao-drawer-header p { margin:0; color:var(--muted-foreground); }
.lotes-galpao-drawer-body { overflow:auto; overscroll-behavior:contain; padding:16px 18px 24px; }
.lotes-galpao-summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(118px,1fr)); gap:10px; margin-bottom:14px; }
.lotes-galpao-summary > div { border:1px solid var(--border); border-radius:9px; background:var(--card); padding:12px; }
.lotes-galpao-summary small { display:block; color:var(--muted-foreground); font-size:11px; margin-bottom:4px; }
.lotes-galpao-summary strong { display:block; font-size:14px; }
.lotes-galpao-detail-section { margin-top:14px; border:1px solid var(--border); border-radius:10px; background:var(--card); overflow:hidden; }
.lotes-galpao-detail-section h3 { margin:0; padding:12px 14px; color:var(--primary); font-size:14px; border-bottom:1px solid var(--border); }
.lotes-galpao-detail-table-wrap { overflow-x:hidden; }
.lotes-galpao-detail-table { width:100%; border-collapse:collapse; table-layout:fixed; font-size:12px; }
.lotes-galpao-detail-table th,.lotes-galpao-detail-table td { padding:9px 10px; border-bottom:1px solid var(--border); white-space:nowrap; }
.lotes-galpao-detail-table th { background:color-mix(in srgb, var(--accent) 8%, var(--card)); text-align:left; }
.lotes-galpao-detail-table .num { text-align:right; }
.lotes-mortality-cell { color:var(--primary); font-weight:800; background:color-mix(in srgb, var(--primary) 7%, var(--card)); }
.lotes-galpao-detail-chart { width:100%; height:300px; }

@media (max-width: 1100px) {
  .lotes-galpao-rank-row { grid-template-columns:34px minmax(120px,1.2fr) 76px 88px 88px 112px; gap:6px; }
  .lotes-galpao-detail-cta small { font-size:8px; }
}

@media (max-width: 980px) {
  .lotes-galpao-dashboard { grid-template-columns:1fr; }
  .lotes-galpao-chart-card,.lotes-galpao-list-card { height:440px; }
}

@media (max-width: 768px) {
  .lotes-analysis-head { align-items:stretch; flex-direction:column; gap:8px; padding:8px 10px 0; }
  .lotes-view-tabs { width:100%; }
  .lotes-view-tab { flex:1; min-height:44px; padding:10px 8px; }
  .lotes-galpao-controls { width:100%; justify-content:space-between; align-items:end; padding:0 0 9px; }
  .lotes-galpao-fixed-indicator { flex:1; }
  .lotes-galpao-fixed-indicator > strong { min-height:42px; }
  .lotes-galpao-controls label { flex:1; }
  .lotes-galpao-controls select { width:100%; min-height:42px; }
  .lotes-galpao-dashboard { padding:10px; gap:10px; }
  .lotes-galpao-chart-card,.lotes-galpao-list-card { height:410px; }
  .lotes-galpao-ranking-list { padding:0 7px 8px; scrollbar-gutter:auto; }
  .lotes-galpao-rank-row { grid-template-columns:32px minmax(0,1fr) auto; grid-template-areas:"pos name mortality" "pos aves peso" "pos cta cta"; gap:6px 8px; padding:10px 5px; }
  .lotes-galpao-rank-pos { grid-area:pos; align-self:start; margin-top:2px; }
  .lotes-galpao-rank-name { grid-area:name; }
  .lotes-galpao-rank-highlight { grid-area:mortality; min-width:74px; }
  .lotes-galpao-rank-metric:nth-of-type(3) { grid-area:aves; text-align:left; }
  .lotes-galpao-rank-metric:nth-of-type(4) { grid-area:peso; text-align:right; }
  .lotes-galpao-detail-cta { grid-area:cta; min-height:32px; justify-self:stretch; }
  .lotes-galpao-detail-cta > span { font-size:11px; }
  .lotes-galpao-detail-cta small { font-size:8px; }
  .lotes-galpao-section-head { padding:12px 12px 8px; }
  .lotes-galpao-section-head p { font-size:11px; }

  .lotes-galpao-drawer-panel { top:auto; bottom:0; width:100%; height:min(92vh,900px); border-left:0; border-top:1px solid var(--border); border-radius:18px 18px 0 0; }
  .lotes-galpao-drawer-handle { display:block; width:42px; height:4px; border-radius:99px; background:var(--border); margin:8px auto 0; }
  .lotes-galpao-drawer-header { padding:10px 14px 12px; }
  .lotes-galpao-drawer-header h2 { font-size:20px; }
  .lotes-galpao-drawer-body { padding:12px 10px 18px; }
  .lotes-galpao-summary { grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  .lotes-galpao-summary > div { padding:9px 8px; min-width:0; }
  .lotes-galpao-summary strong { font-size:12px; overflow-wrap:anywhere; }
  .lotes-galpao-detail-table { font-size:11px; }
  .lotes-galpao-detail-table th,.lotes-galpao-detail-table td { padding:8px 6px; }
  .lotes-galpao-detail-chart { height:245px; }
  .lotes-galpao-child-name { padding-left:14px; }

  #produtoresView .lotes-reference-table-wrap { max-height:620px; }
}

@media (max-width: 430px) {
  .lotes-galpao-controls { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
  .lotes-galpao-chart-card,.lotes-galpao-list-card { height:390px; }
  .lotes-galpao-section-head h3 { font-size:14px; }
  .lotes-galpao-rank-row { grid-template-columns:30px minmax(0,1fr) auto; }
  .lotes-galpao-rank-row strong { font-size:12px; }
  .lotes-galpao-rank-name strong { font-size:13px; }
  .lotes-galpao-rank-highlight { min-width:70px; padding:5px 6px; }
  .lotes-galpao-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .lotes-galpao-detail-chart { height:225px; }
}
