/* ==========================================================================
   Controle DISPA — Painel de Saldo de Empenho
   Dashboard escuro com sotaque vermelho/branco: KPIs, evolução mensal (SVG),
   donut de % utilizado e um comparativo (ranking) por contrato/empresa —
   tudo escopável por um filtro de contrato no topo.
   ========================================================================== */

.sep-body {
  background: radial-gradient(1100px 620px at 50% -10%, rgba(179, 18, 26, 0.12), transparent 60%),
    linear-gradient(180deg, #08080a 0%, #0b0b0e 45%, #060607 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

.sep-page {
  max-width: var(--cosae-content-max-width);
  margin: 0 auto;
  padding: 26px clamp(16px, 4vw, 44px) 90px;
  color: var(--cosae-text-inverse);
}

.sep-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--cosae-text-inverse-muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--cosae-fast) var(--cosae-ease);
}
.sep-back:hover { color: #fff; }

/* --- Cabeçalho ------------------------------------------------------- */

.sep-head { margin: 20px 0 26px; }

.sep-head__eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--cosae-red-light);
  margin-bottom: 8px;
}

.sep-head__title {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.sep-head__subtitle {
  margin: 0;
  font-size: 0.92rem;
  color: var(--cosae-text-inverse-muted);
  max-width: 620px;
  line-height: 1.6;
}

/* --- Toolbar: filtro de contrato --------------------------------------- */

.sep-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.sep-filter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
}

.sep-filter__label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--cosae-text-inverse-muted);
}

.sep-filter__control {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.sep-filter__select {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 10px 36px 10px 14px;
  width: 100%;
  max-width: 340px;
  min-width: 0;
  cursor: pointer;
  transition: border-color var(--cosae-fast) var(--cosae-ease), background var(--cosae-fast) var(--cosae-ease);
}

.sep-filter__select:hover,
.sep-filter__select:focus-visible {
  border-color: var(--cosae-red-light);
  background: rgba(255, 255, 255, 0.09);
  outline: none;
}

.sep-filter__chevron {
  position: absolute;
  right: 12px;
  color: var(--cosae-text-inverse-muted);
  pointer-events: none;
}

.sep-toolbar__meta {
  font-size: 0.76rem;
  color: var(--cosae-text-inverse-muted);
}

/* --- KPIs ---------------------------------------------------------------- */

.sep-kpis {
  display: grid;
  grid-template-columns: 1.6fr repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.sep-kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 18px 20px;
  overflow: hidden;
  min-width: 0;
}

.sep-kpi--hero {
  background: linear-gradient(155deg, rgba(179, 18, 26, 0.28), rgba(179, 18, 26, 0.06) 60%), rgba(255, 255, 255, 0.04);
  border-color: rgba(224, 85, 95, 0.35);
  box-shadow: 0 20px 44px rgba(179, 18, 26, 0.18);
}

.sep-kpi__glow {
  position: absolute;
  z-index: 0;
  width: 260px;
  height: 260px;
  top: -140px;
  right: -100px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.16), transparent 70%);
  filter: blur(6px);
  animation: sep-glow-pulse 7s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sep-glow-pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.12); }
}

.sep-kpi__label {
  position: relative;
  z-index: 1;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--cosae-text-inverse-muted);
}

.sep-kpi__value {
  position: relative;
  z-index: 1;
  font-size: 1.36rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.sep-kpi__value--hero {
  font-size: clamp(1.9rem, 3vw, 2.5rem);
  text-shadow: 0 0 34px rgba(255, 255, 255, 0.3);
}

.sep-kpi__bar {
  position: relative;
  z-index: 1;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.sep-kpi__bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cosae-red-light), var(--cosae-red));
  transition: width 900ms var(--cosae-ease);
}

/* --- Linha: Evolução + Donut --------------------------------------------- */

.sep-row {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

.sep-card {
  min-width: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 22px;
  padding: 22px clamp(16px, 3vw, 26px) 24px;
}

.sep-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

.sep-card__title {
  margin: 0 0 4px;
  font-size: 1.04rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.2px;
}

.sep-card__subtitle {
  margin: 0;
  font-size: 0.8rem;
  color: var(--cosae-text-inverse-muted);
  max-width: 420px;
  line-height: 1.5;
}

.sep-card__head-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.sep-empty {
  margin: 0;
  padding: 40px 0;
  text-align: center;
  color: var(--cosae-text-inverse-muted);
  font-size: 0.86rem;
}

/* --- Evolução (barras SVG) ------------------------------------------------ */

.sep-evo__legend {
  display: flex;
  gap: 14px;
}

.sep-evo__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--cosae-text-inverse-muted);
}

.sep-evo__dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: linear-gradient(180deg, #ffffff, #c7c7cd);
}

.sep-evo {
  position: relative;
}

.sep-evo__scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.sep-evo__svg {
  display: block;
  max-width: 100%;
  height: auto;
  overflow: visible;
}

.sep-evo__gridline {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.sep-evo__tick {
  fill: var(--cosae-text-inverse-muted);
  font-size: 10.5px;
  font-family: 'Montserrat', sans-serif;
}

.sep-evo__bar {
  cursor: pointer;
  fill: url(#sep-bar-gradient);
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.12));
  transition: filter 160ms var(--cosae-ease);
}

.sep-evo__bar:hover,
.sep-evo__bar.is-active {
  filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.32)) brightness(1.1);
}

.sep-evo__hit {
  fill: transparent;
  cursor: pointer;
}

.sep-evo__month-label {
  fill: var(--cosae-text-inverse-muted);
  font-size: 11px;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
  text-anchor: middle;
}

.sep-evo__month-label.is-active { fill: #fff; }

.sep-evo__value-label {
  fill: #fff;
  font-size: 11px;
  font-weight: 800;
  font-family: 'Montserrat', sans-serif;
  text-anchor: middle;
  opacity: 0;
  transition: opacity 160ms var(--cosae-ease);
}

.sep-evo__value-label.is-visible { opacity: 1; }

@media (max-width: 640px) {
  .sep-evo__svg { max-width: none; width: auto; }
}

/* --- Donut ----------------------------------------------------------------- */

.sep-donut {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto 18px;
  width: min(270px, 100%);
}

.sep-donut__svg {
  width: 100%;
  height: auto;
  transform: rotate(-90deg);
}

.sep-donut__track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 16;
}

.sep-donut__progress {
  fill: none;
  stroke: url(#sep-donut-gradient);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 452.4;
  stroke-dashoffset: 452.4;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.28));
  transition: stroke-dashoffset 900ms var(--cosae-ease);
}

.sep-donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 32px;
}

.sep-donut__pct {
  max-width: 100%;
  font-size: 1.65rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
  white-space: normal;
  text-align: center;
  line-height: 1.15;
}

.sep-donut__pct-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--cosae-text-inverse-muted);
}

.sep-donut__pct-badge {
  flex-shrink: 0;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--cosae-red-light);
  background: rgba(179, 18, 26, 0.14);
  border: 1px solid rgba(224, 85, 95, 0.3);
  border-radius: 999px;
  padding: 5px 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sep-donut__legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sep-donut__legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.sep-donut__legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.sep-donut__legend-swatch--utilizado { background: linear-gradient(180deg, #ffffff, #c7c7cd); }
.sep-donut__legend-swatch--disponivel { background: rgba(255, 255, 255, 0.14); }

.sep-donut__legend-text {
  flex: 1;
  color: var(--cosae-text-inverse-muted);
  font-weight: 600;
}

.sep-donut__legend-value {
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* --- Comparativo (ranking) ------------------------------------------------- */

.sep-viewswitch {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

.sep-viewswitch__btn {
  border: none;
  background: none;
  color: var(--cosae-text-inverse-muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: color var(--cosae-fast) var(--cosae-ease), background var(--cosae-fast) var(--cosae-ease);
}
.sep-viewswitch__btn:hover { color: #fff; }
.sep-viewswitch__btn.is-active {
  color: #0a0a0a;
  background: linear-gradient(180deg, #ffffff, #d8d8db);
  box-shadow: 0 4px 14px rgba(255, 255, 255, 0.25);
}

.sep-table-toggle {
  background: none;
  border: none;
  color: var(--cosae-red-light);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 8px 4px;
}
.sep-table-toggle:hover { text-decoration: underline; }

.sep-rank {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sep-rank-row {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color var(--cosae-fast) var(--cosae-ease), background var(--cosae-fast) var(--cosae-ease), transform var(--cosae-fast) var(--cosae-ease);
}

.sep-rank-row:hover {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.sep-rank-row.is-selected {
  border-color: var(--cosae-red-light);
  background: rgba(179, 18, 26, 0.1);
  box-shadow: 0 0 0 1px rgba(224, 85, 95, 0.25) inset;
}

.sep-rank-row__pos {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--cosae-text-inverse-muted);
  font-variant-numeric: tabular-nums;
}

.sep-rank-row__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sep-rank-row__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sep-rank-row__title {
  font-size: 0.86rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sep-rank-row__value {
  flex-shrink: 0;
  font-size: 0.86rem;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.sep-rank-row__bar-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.sep-rank-row__bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d9d9dd, #ffffff);
  transition: width 700ms var(--cosae-ease);
}

.sep-rank-row.is-selected .sep-rank-row__bar-fill {
  background: linear-gradient(90deg, var(--cosae-red-light), var(--cosae-red));
}

.sep-rank-row__sub {
  font-size: 0.72rem;
  color: var(--cosae-text-inverse-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sep-rank-row__go {
  flex-shrink: 0;
  color: var(--cosae-text-inverse-muted);
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity var(--cosae-fast) var(--cosae-ease), transform var(--cosae-fast) var(--cosae-ease);
}
.sep-rank-row:hover .sep-rank-row__go,
.sep-rank-row.is-selected .sep-rank-row__go {
  opacity: 1;
  transform: translateX(0);
}

/* --- Tooltip de hover (vidro escuro) -------------------------------- */

.sep-tooltip {
  position: absolute;
  z-index: 8;
  min-width: 190px;
  background: rgba(12, 12, 14, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 12px 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translate(-50%, -100%);
  pointer-events: none;
  transition: opacity var(--cosae-fast) var(--cosae-ease);
}

.sep-tooltip[data-open="true"] { opacity: 1; }

.sep-tooltip__title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--cosae-text-inverse-muted);
  margin-bottom: 4px;
  overflow-wrap: anywhere;
}

.sep-tooltip__value {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 3px;
}

.sep-tooltip__meta {
  font-size: 0.74rem;
  color: var(--cosae-text-inverse-muted);
}

/* --- Tabela (fallback / acessível) ------------------------------------ */

.sep-table-wrap { margin-top: 16px; overflow-x: auto; }

.sep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.sep-table th,
.sep-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sep-table thead th {
  color: var(--cosae-text-inverse-muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sep-table td.num,
.sep-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.sep-table tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }

/* --- Responsivo ------------------------------------------------------------ */

@media (max-width: 980px) {
  .sep-kpis { grid-template-columns: 1fr 1fr; }
  .sep-kpi--hero { grid-column: 1 / -1; }
  .sep-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sep-toolbar { flex-direction: column; align-items: stretch; }
  .sep-filter { flex-direction: column; align-items: flex-start; gap: 6px; width: 100%; }
  .sep-filter__control { width: 100%; }
  .sep-filter__select { max-width: none; }
  .sep-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .sep-kpi { padding: 14px 16px; }
  .sep-kpi__value--hero { font-size: 1.8rem; }
  .sep-card { padding: 18px 16px 20px; border-radius: 18px; }
  .sep-rank-row { grid-template-columns: 20px minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; }
  .sep-rank-row__go { display: none; }
}
