:root {
  --paper: #f7f6f1;
  --ink: #171b1f;
  --muted: #687078;
  --line: #d9d6ca;
  --panel: #ffffff;
  --teal: #146c64;
  --teal-soft: #dceee9;
  --amber: #c9902f;
  --amber-soft: #fff1d4;
  --red: #a33b2f;
  --red-soft: #f7dfda;
  --blue: #2f5f8f;
  --shadow: 0 24px 70px rgba(22, 27, 31, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 22px;
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 56px);
  background: rgba(247, 246, 241, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: white;
  background: var(--ink);
  border-radius: 6px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
}

.nav {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.nav a {
  color: var(--muted);
  padding: 9px 10px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.92rem;
}

.nav a:hover {
  color: var(--ink);
  background: rgba(23, 27, 31, 0.06);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.section-band {
  padding: clamp(52px, 8vw, 92px) clamp(18px, 4vw, 56px);
}

.section-band.alt {
  background: #ecebe3;
}

.section-band.dark {
  color: #f8f5ec;
  background: #181c1f;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: end;
  min-height: calc(100vh - 74px);
  border-bottom: 1px solid var(--line);
}

.hero-copy {
  max-width: 980px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dark .eyebrow {
  color: #8fd4c8;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 1080px;
  margin-bottom: 22px;
  font-size: clamp(2.55rem, 5.8vw, 6.6rem);
  line-height: 0.96;
  font-weight: 850;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(1.8rem, 3.2vw, 3.4rem);
  line-height: 1.05;
}

h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.lead {
  max-width: 860px;
  color: #3f464c;
  font-size: clamp(1rem, 1.6vw, 1.28rem);
}

.hero-panel,
.chart-panel,
.kpi,
.risk-detail,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 24px;
}

.risk-meter {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.risk-meter span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.risk-meter strong {
  display: block;
  margin: 6px 0 16px;
  color: var(--red);
  font-size: 2.6rem;
  line-height: 1;
}

.meter {
  height: 10px;
  overflow: hidden;
  background: #eee8dc;
  border-radius: 999px;
}

.meter i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--red));
}

.hero-stats {
  display: grid;
  gap: 16px;
  margin: 24px 0 0;
}

.hero-stats div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.hero-stats dt {
  color: var(--muted);
}

.hero-stats dd {
  margin: 0;
  font-weight: 800;
}

.toolbar {
  position: sticky;
  top: 74px;
  z-index: 9;
  display: flex;
  align-items: end;
  gap: 14px;
  padding: 14px clamp(18px, 4vw, 56px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.filter-group {
  display: grid;
  gap: 5px;
}

.filter-group label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

select,
.segmented {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
}

select {
  min-width: 220px;
  padding: 0 34px 0 12px;
}

.toggle-group {
  display: flex;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  background: #ecebe3;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented {
  min-width: 96px;
  padding: 0 14px;
  border-color: transparent;
  cursor: pointer;
}

.segmented.active {
  color: white;
  background: var(--ink);
}

.section-heading {
  max-width: 900px;
  margin-bottom: 28px;
}

.section-heading p:last-child {
  color: var(--muted);
  font-size: 1.04rem;
}

.kpi-grid,
.analytics-grid,
.risk-grid {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.kpi {
  padding: 20px;
}

.kpi span,
.kpi small {
  display: block;
  color: var(--muted);
}

.kpi strong {
  display: block;
  margin: 8px 0;
  font-size: clamp(1.35rem, 2.2vw, 2.1rem);
  line-height: 1.05;
}

.kpi.attention {
  background: var(--amber-soft);
}

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

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

.chart-panel {
  padding: 20px;
}

.technical-only {
  display: none;
}

body.tecnico .technical-only {
  display: block;
}

.assumptions {
  margin-top: 16px;
  padding: 22px;
  background: #e4eee9;
  border: 1px solid #b8d4cc;
  border-radius: 8px;
}

.assumptions p {
  max-width: 1050px;
  margin-bottom: 0;
  color: #31413e;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel-head span {
  color: var(--muted);
  font-size: 0.86rem;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.risk-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.risk-card {
  min-height: 210px;
  padding: 18px;
  text-align: left;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.risk-card.active {
  border-color: var(--red);
  box-shadow: inset 0 0 0 2px rgba(163, 59, 47, 0.15);
}

.risk-card .severity {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.risk-card h3 {
  margin: 18px 0 10px;
  font-size: 1.18rem;
}

.risk-card p {
  color: var(--muted);
  margin: 0;
}

.risk-detail {
  padding: 26px;
}

.risk-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
}

.risk-detail h3 {
  margin-bottom: 10px;
  font-size: 1.35rem;
}

.risk-detail h4 {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.risk-detail p {
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

th,
td {
  padding: 15px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

tr:last-child td {
  border-bottom: 0;
}

.final-alert {
  max-width: 980px;
}

.dark h2 {
  color: white;
}

.dark p {
  color: #d6d1c4;
  font-size: 1.1rem;
}

.action-strip {
  display: grid;
  gap: 8px;
  margin-top: 34px;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.action-strip span {
  color: #9fd7cc;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.action-strip strong {
  font-size: 1.35rem;
}

body.tecnico .executivo-only {
  display: none;
}

@media (max-width: 980px) {
  .hero,
  .analytics-grid,
  .risk-detail-grid {
    grid-template-columns: 1fr;
  }

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

  .nav {
    display: none;
  }

  .toolbar {
    position: static;
    flex-wrap: wrap;
  }

  .toggle-group {
    margin-left: 0;
  }
}

@media (max-width: 620px) {
  .topbar {
    gap: 10px;
  }

  .brand {
    min-width: 0;
  }

  .brand small {
    display: none;
  }

  .hero {
    min-height: auto;
  }

  h1 {
    font-size: 2.75rem;
  }

  .kpi-grid,
  .risk-grid {
    grid-template-columns: 1fr;
  }

  select {
    width: calc(100vw - 36px);
    min-width: 0;
  }

  .toggle-group {
    width: 100%;
  }

  .segmented {
    flex: 1;
  }
}

@media print {
  .topbar,
  .toolbar {
    display: none;
  }

  body {
    background: white;
  }

  .section-band {
    padding: 28px 0;
    break-inside: avoid;
  }

  .hero {
    min-height: auto;
  }

  .hero-panel,
  .chart-panel,
  .kpi,
  .risk-detail,
  .table-wrap {
    box-shadow: none;
  }
}
