:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --mist: #eef5f4;
  --text: #172126;
  --muted: #657277;
  --border: #d7e1de;
  --green-bg: #e8f5ec;
  --green: #24733d;
  --red-bg: #fff0ef;
  --red: #b42318;
  --blue-bg: #e7f5f8;
  --blue: #0b6f86;
  --yellow-bg: #fff7e7;
  --yellow: #b7791f;
  --gray-bg: #edf2f1;
  --shadow-soft: 0 14px 38px rgba(23, 33, 38, 0.05);
  --shadow-hover: 0 10px 24px rgba(11, 111, 134, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1160px;
  background:
    linear-gradient(180deg, rgba(11, 111, 134, 0.08), rgba(244, 247, 246, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

.app-shell {
  width: min(1480px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.filters,
.metric-grid,
.split-grid {
  margin-bottom: 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.source-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.status-pill.ok {
  background: var(--green-bg);
  color: var(--green);
  border-color: #b7dfbf;
}

.status-pill.warn {
  background: var(--yellow-bg);
  color: var(--yellow);
  border-color: #ebd382;
}

.status-pill.error {
  background: var(--red-bg);
  color: var(--red);
  border-color: #f2b8b5;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  box-shadow: 0 1px 2px rgba(23, 33, 38, 0.025);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metric,
.panel-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.metric {
  padding: 16px;
  box-shadow: 0 8px 20px rgba(23, 33, 38, 0.035);
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.15;
}

.metric.negative strong {
  color: var(--red);
}

.metric.positive strong {
  color: var(--green);
}

.panel-section {
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(238, 245, 244, 0.7);
}

.section-title.compact {
  min-height: 72px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.ok {
  background: var(--green);
}

.dot.danger {
  background: var(--red);
}

.dot.info {
  background: var(--blue);
}

.dot.neutral {
  background: #8e8e93;
}

.weekly-wrap,
.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.weekly-table {
  min-width: 1140px;
  table-layout: fixed;
}

.weekly-tables {
  display: grid;
  gap: 24px;
  padding: 16px;
}

.week-block {
  min-width: 1140px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.week-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 0;
  background: #f7faf9;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.week-toggle:hover {
  background: var(--mist);
}

.week-toggle-left,
.week-toggle-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.week-toggle-right {
  color: var(--muted);
  font-size: 12px;
}

.week-toggle-status {
  min-width: 68px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--blue);
  text-align: center;
  box-shadow: 0 2px 8px rgba(23, 33, 38, 0.035);
}

.week-toggle-icon {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--blue);
  border-bottom: 2px solid var(--blue);
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.week-toggle[aria-expanded="false"] .week-toggle-icon {
  transform: rotate(-45deg);
}

.week-body {
  display: block;
}

.week-block.is-collapsed .week-body {
  display: none;
}

th,
td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

th:last-child,
td:last-child {
  border-right: 0;
}

.weekly-table th {
  height: 48px;
  background: var(--mist);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.weekly-table th.day-header.is-today {
  color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(11, 111, 134, 0.32);
}

.weekly-table th:first-child,
.weekly-table td:first-child {
  width: 160px;
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
}

.weekly-table th:first-child {
  background: var(--mist);
}

.team-cell {
  padding: 12px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.day-cell {
  height: 96px;
  padding: 8px;
  text-align: center;
  vertical-align: middle;
}

.day-card {
  position: relative;
  display: grid;
  width: 100%;
  gap: 3px;
  height: 100%;
  align-content: center;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px;
  appearance: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1.18;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.day-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: var(--blue);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.day-card:hover {
  transform: translateY(-2px);
  border-color: rgba(11, 111, 134, 0.68);
  box-shadow: var(--shadow-hover);
}

.day-card:hover::before,
.day-card:focus-visible::before,
.day-card.is-today::before {
  opacity: 1;
  transform: translateY(0);
}

.day-card:focus-visible {
  outline: 3px solid rgba(11, 111, 134, 0.26);
  outline-offset: 2px;
}

.day-card strong {
  font-size: 12px;
}

.day-card.verde {
  background: var(--green-bg);
  border-color: #b7dcc2;
  color: var(--green);
}

.day-card.vermelho {
  background: var(--red-bg);
  border-color: #f1c3bf;
  color: var(--red);
}

.day-card.azul {
  background: var(--blue-bg);
  border-color: #badce4;
  color: var(--blue);
}

.day-card.amarelo {
  background: var(--yellow-bg);
  border-color: #ead5aa;
  color: var(--yellow);
}

.day-card.cinza {
  background: var(--gray-bg);
  border-color: var(--border);
  color: var(--muted);
}

.day-card.is-today {
  border-color: rgba(11, 111, 134, 0.76);
  box-shadow: inset 0 0 0 1px rgba(11, 111, 134, 0.18);
}

.money-line {
  color: var(--text);
  font-weight: 700;
}

.muted-line {
  color: var(--muted);
}

.reason-line {
  color: var(--blue);
  font-weight: 700;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  gap: 16px;
  padding: 16px;
}

.plan-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-2);
  box-shadow: 0 8px 20px rgba(23, 33, 38, 0.035);
}

.plan-card header.plan-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.plan-card h3 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.plan-pending-badge {
  min-width: 112px;
  padding: 10px 12px;
  border: 1px solid #f5c9c5;
  border-radius: 8px;
  background: var(--surface);
  text-align: right;
  box-shadow: 0 4px 12px rgba(161, 40, 36, 0.08);
}

.plan-pending-badge span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.plan-pending-badge strong {
  color: var(--red);
  font-size: 22px;
}

.plan-stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 18px;
}

.plan-stat {
  min-height: 84px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(23, 33, 38, 0.035);
}

.plan-stat span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.plan-stat strong {
  font-size: 26px;
  line-height: 1;
}

.plan-stat.executed strong {
  color: var(--green);
}

.plan-stat.programmed strong {
  color: var(--blue);
}

.plan-stat.reprogrammed strong {
  color: var(--yellow);
}

.plan-stat.pending strong {
  color: var(--red);
}

.plan-progress {
  margin-top: 18px;
}

.plan-progress-bar {
  display: flex;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--red-bg);
}

.plan-progress-bar i {
  display: block;
  height: 100%;
}

.plan-progress-bar .executed,
.plan-progress-legend .executed {
  background: var(--green);
}

.plan-progress-bar .programmed,
.plan-progress-legend .programmed {
  background: var(--blue);
}

.plan-progress-bar .reprogrammed,
.plan-progress-legend .reprogrammed {
  background: #bd7d1c;
}

.plan-progress-bar .pending,
.plan-progress-legend .pending {
  background: #bd241f;
}

.plan-progress-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.plan-progress-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.plan-progress-legend i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.plan-reason-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 800;
}

.reason-list {
  display: grid;
  gap: 8px;
}

.reason-row {
  display: grid;
  grid-template-columns: 1fr 72px 70px;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
}

.reason-row strong,
.reason-row span {
  overflow-wrap: anywhere;
}

.reason-row .numeric {
  text-align: right;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(560px, 1.1fr);
  gap: 18px;
  margin-top: 18px;
}

.action-list {
  display: grid;
  gap: 0;
}

.alert-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.alert-card {
  display: grid;
  min-height: 118px;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.alert-card.ALTO {
  background: var(--red-bg);
  border-color: #f2b8b5;
}

.alert-card.MEDIO {
  background: var(--yellow-bg);
  border-color: #ebd382;
}

.alert-card.BAIXO {
  background: var(--green-bg);
  border-color: #b7dfbf;
}

.alert-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.alert-card h3 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
}

.alert-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.alert-value strong {
  font-size: 28px;
  line-height: 1;
}

.alert-value span,
.alert-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.alert-card p {
  margin: 0;
}

.alert-action {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.action-item {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.action-item:last-child {
  border-bottom: 0;
}

.risk {
  align-self: start;
  justify-self: start;
  min-width: 64px;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.risk.ALTO {
  background: var(--red-bg);
  color: var(--red);
}

.risk.MEDIO {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.risk.BAIXO {
  background: var(--green-bg);
  color: var(--green);
}

.action-body strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.action-body p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.dense-table th,
.dense-table td {
  padding: 10px 12px;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

.dense-table th {
  background: #f0f0f4;
  color: var(--muted);
  font-size: 12px;
}

.dense-table td.numeric {
  text-align: right;
  white-space: nowrap;
}

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

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(29, 29, 31, 0.24);
}

.detail-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 21;
  display: grid;
  grid-template-rows: auto auto 1fr;
  width: min(720px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 70px rgba(29, 29, 31, 0.18);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.detail-drawer[aria-hidden="false"] {
  transform: translateX(0);
}

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

.detail-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-close {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 22px;
  line-height: 1;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.detail-summary div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
}

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

.detail-summary span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-summary strong {
  overflow-wrap: anywhere;
  font-size: 16px;
}

.detail-content {
  overflow: auto;
  padding: 16px 20px 28px;
}

.service-summary {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.service-summary-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.service-summary-title h3 {
  margin: 0;
  font-size: 14px;
}

.service-summary-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.service-summary-list {
  display: grid;
}

.service-summary-item {
  display: grid;
  grid-template-columns: 1fr 120px 82px;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.service-summary-item:last-child {
  border-bottom: 0;
}

.service-summary-item strong {
  overflow-wrap: anywhere;
}

.service-summary-item span,
.service-summary-item small {
  text-align: right;
  white-space: nowrap;
}

.service-summary-item span {
  color: var(--text);
  font-weight: 800;
}

.service-summary-item small {
  color: var(--muted);
  font-weight: 700;
}

.detail-record {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.detail-record + .detail-record {
  margin-top: 10px;
}

.detail-record-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-record p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.detail-record dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
}

.detail-record dl div {
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-2);
}

.detail-record dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-record dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 800;
}

.detail-action {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

@media print {
  body {
    min-width: 0;
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .filters,
  .split-grid {
    display: none;
  }

  .metric-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .weekly-wrap {
    overflow: visible;
  }

  .weekly-table {
    min-width: 0;
  }
}
