:root {
  /* Paleta CoA-Z — identidade do projeto */
  --navy: #1B2D4F;
  --navy-light: #2A3F66;
  --navy-deep: #122039;
  --caramel: #B8763E;
  --caramel-light: #D49A5F;
  --offwhite: #F5F1E8;
  --grafite: #2C2C2C;

  /* Tema dark navy — fundo escuro, texto claro */
  --bg: #1B2D4F;              /* navy CoA-Z — fundo principal */
  --panel: #243B6B;           /* cards: navy mais claro */
  --panel-hi: #2A4577;
  --panel-hover: #304F86;
  --border: #3A5587;
  --border-strong: #B8763E;   /* caramelo — destaque */
  --text: #F5F1E8;            /* off-white */
  --text-dim: #C4BFA8;        /* off-white escurecido */
  --text-xdim: #8A8470;

  /* Cores semânticas (ajustadas pra contraste em fundo navy) */
  --green: #6FCF97;
  --amber: #D49A5F;           /* caramelo claro */
  --red: #E07A7A;
  --blue: #7FB3FF;
  --accent: #D49A5F;          /* caramelo claro como accent */
  --accent-primary: #B8763E;  /* caramelo escuro */

  --radius: 8px;
  --radius-lg: 12px;

  --shadow-card: 0 2px 14px rgba(0, 0, 0, 0.18);

  --font-display: "Liberation Sans", "Calibri", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background: linear-gradient(160deg, #1F345A 0%, #1B2D4F 45%, #122039 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  min-height: 100vh;
}

/* === Header / brand CoA-Z em destaque === */
header.app-head {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  padding: 8px 0 22px;
  border-bottom: 2px solid var(--caramel);
  margin-bottom: 12px;
}

header.app-head h1.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-weight: normal;
}
header.app-head h1.brand .brand-logo {
  height: 88px;
  width: auto;
  display: block;
  background: var(--offwhite);
  padding: 12px 24px;
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.30);
}
header.app-head h1.brand .sub { display: none; }

header.app-head .meta {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Botões pequenos do header — tons CoA-Z */
header.app-head .btn.small {
  background: transparent;
  color: var(--offwhite);
  border: 1px solid var(--caramel);
  padding: 7px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}
header.app-head .btn.small:hover {
  background: var(--caramel);
  color: var(--navy);
  border-color: var(--caramel);
}

/* Left column — input panel */
.input-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  height: fit-content;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}
.input-panel h2 {
  font-size: 1.2rem;
  margin: 0 0 16px;
  color: var(--text);
  font-weight: 600;
}
.input-panel .note {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: -4px 0 18px;
  padding: 10px;
  background: var(--panel-hi);
  border-radius: 4px;
  border-left: 3px solid var(--accent);
  line-height: 1.5;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin: 0 0 16px;
  background: var(--panel-hi);
}
fieldset > legend {
  font-size: 0.78rem;
  color: var(--caramel-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 6px;
  font-weight: 700;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 90px 70px;
  gap: 6px;
  align-items: center;
  margin-bottom: 9px;
}
.field-row:last-child { margin-bottom: 0; }
.field-row label {
  font-size: 0.92rem;
  color: var(--text);
}
.field-row label .hint {
  color: var(--text-xdim);
  font-size: 0.78rem;
  margin-left: 4px;
}
.field-row .units {
  color: var(--text-xdim);
  font-size: 0.78rem;
  text-align: center;
  white-space: nowrap;
}

input[type="number"],
input[type="text"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 9px;
  font-family: inherit;
  font-size: 0.95rem;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
}
input[type="number"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--blue);
}
input[type="number"].z-score {
  background: var(--panel);
}
input[type="number"].z-score.auto-filled {
  background: rgba(91, 156, 255, 0.08);
  border-color: rgba(91, 156, 255, 0.3);
  font-style: italic;
  color: var(--blue);
}

.field-ga {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.field-ga label { font-weight: 600; font-size: 0.95rem; }
.field-ga .ga-inputs {
  display: grid;
  grid-template-columns: 60px auto 60px auto;
  gap: 6px;
  align-items: center;
}
.field-ga .ga-inputs input {
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-hi);
  color: var(--text);
  font-size: 1rem;
  text-align: center;
}
.field-ga .ga-inputs .units {
  color: var(--text-dim);
  font-size: 0.88rem;
}

.flags {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.flag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--panel);
  border-radius: 4px;
  cursor: pointer;
}
.flag-row input { margin: 0; width: 16px; height: 16px; accent-color: var(--caramel); }
.flag-row label {
  font-size: 0.92rem;
  cursor: pointer;
  flex: 1;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.btn {
  background: var(--panel-hi);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 9px 15px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.btn:hover { background: var(--panel-hover); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 5px 11px; font-size: 0.85rem; }

/* Right column — results */
.results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.risk-banner {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  box-shadow: var(--shadow-card);
}
.risk-banner.low    { border-color: rgba(48, 199, 138, 0.4); }
.risk-banner.intermediate { border-color: rgba(228, 183, 60, 0.4); }
.risk-banner.high   { border-color: rgba(230, 93, 93, 0.4); }

.risk-dot {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  flex-shrink: 0;
}
.risk-dot.low    { background: radial-gradient(circle, var(--green), rgba(48, 199, 138, 0.3)); }
.risk-dot.intermediate { background: radial-gradient(circle, var(--amber), rgba(228, 183, 60, 0.3)); }
.risk-dot.high   { background: radial-gradient(circle, var(--red), rgba(230, 93, 93, 0.3)); }
.risk-dot.empty  { background: radial-gradient(circle, var(--border-strong), rgba(90, 100, 120, 0.2)); }

.risk-text h2 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 600;
}
.risk-text .score {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-top: 5px;
}
.risk-text h2.low    { color: var(--green); }
.risk-text h2.intermediate { color: var(--amber); }
.risk-text h2.high   { color: var(--red); }

/* Panels grid */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.panel h3 {
  margin: 0 0 12px;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel h3 .count {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 400;
}

/* Z-score rows */
.zscore-row {
  display: grid;
  grid-template-columns: 1fr 60px 80px;
  gap: 8px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.zscore-row:last-child { border: 0; }
.zscore-row .label { color: var(--text); }
.zscore-row .value {
  font-family: "SF Mono", Menlo, monospace;
  text-align: right;
  font-weight: 600;
}
.zscore-row .value.normal   { color: var(--text); }
.zscore-row .value.border   { color: var(--amber); }
.zscore-row .value.severe   { color: var(--red); }
.zscore-row .bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.zscore-row .bar .marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--text);
  border-radius: 1px;
}
.zscore-row .bar .zone {
  position: absolute;
  top: 0;
  bottom: 0;
}
.zscore-row .bar .zone.normal { left: 25%; right: 25%; background: rgba(48, 199, 138, 0.25); }
.zscore-row .bar .zone.border-low  { left: 12.5%; width: 12.5%; background: rgba(228, 183, 60, 0.25); }
.zscore-row .bar .zone.border-high { right: 12.5%; width: 12.5%; background: rgba(228, 183, 60, 0.25); }
.zscore-row .bar .zone.severe-low  { left: 0; width: 12.5%; background: rgba(230, 93, 93, 0.25); }
.zscore-row .bar .zone.severe-high { right: 0; width: 12.5%; background: rgba(230, 93, 93, 0.25); }

/* Ratio rows */
.ratio-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.ratio-row:last-child { border: 0; }
.ratio-row .label { color: var(--text); }
.ratio-row .expected { color: var(--text-xdim); font-size: 0.78rem; }
.ratio-row .value {
  font-family: "SF Mono", Menlo, monospace;
  font-weight: 600;
  text-align: right;
  min-width: 60px;
}
.ratio-row.alert .value { color: var(--red); }
.ratio-row .value.ok { color: var(--green); }

/* Interpretation */
.interp {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}
.interp.low    { border-left-color: var(--green); }
.interp.intermediate { border-left-color: var(--amber); }
.interp.high   { border-left-color: var(--red); }
.interp h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 600;
}
.interp .body {
  color: var(--text);
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.6;
}
.interp .citations {
  color: var(--text-dim);
  font-size: 0.88rem;
  font-style: italic;
}

/* Active findings list */
.findings-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.findings-panel h3 {
  margin: 0 0 12px;
  font-size: 1.08rem;
  display: flex;
  justify-content: space-between;
}
.finding {
  padding: 11px 13px;
  background: var(--panel-hi);
  border-radius: 4px;
  margin-bottom: 6px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  font-size: 0.9rem;
}
.finding .key {
  color: var(--blue);
  font-family: "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
}
.finding .note {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
}
.finding .weight {
  text-align: right;
  color: var(--amber);
  font-family: "SF Mono", Menlo, monospace;
  font-weight: 600;
  font-size: 0.9rem;
}
.finding .source {
  color: var(--text-xdim);
  font-size: 0.78rem;
  margin-top: 2px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 0.95rem;
}
.empty-state h3 {
  color: var(--text);
  margin: 0 0 8px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 26px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.modal h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
}
.modal .close {
  float: right;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.modal .ref-item {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.modal .ref-item:last-child { border: 0; }
.modal .ref-item strong { display: block; margin-bottom: 2px; }
.modal .ref-item .meta { color: var(--text-dim); font-size: 0.85rem; }
.modal .ref-item a { color: var(--blue); text-decoration: none; }
.modal .ref-item a:hover { text-decoration: underline; }

@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .input-panel { position: static; max-height: none; }
  .panels { grid-template-columns: 1fr; }
  header.app-head h1.brand .brand-logo { height: 64px; padding: 10px 18px; }
}
