:root {
  --bg: #103936;
  --panel: rgba(9, 30, 28, 0.82);
  --panel-border: rgba(241, 211, 196, 0.18);
  --text: #f1dfd0;
  --muted: #c3d0cb;
  --accent: #58d97a;
  --accent-deep: #2d8f56;
  --card: rgba(255, 255, 255, 0.045);
  --danger: #ffb2a3;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.26);
  --good: #8af2a4;
  --good-soft: rgba(88, 217, 122, 0.16);
  --warn: #f3cd7a;
  --warn-soft: rgba(240, 190, 90, 0.15);
  --bad: #ff9f8f;
  --bad-soft: rgba(255, 120, 100, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(88, 217, 122, 0.12), transparent 26%),
    linear-gradient(135deg, #0d302d 0%, #113d39 45%, #0d3431 100%);
  color: var(--text);
  font-family: 'Manrope', sans-serif;
  overflow-x: hidden;
}

.page-shell {
  padding: 32px;
}

.hero-layout {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(300px, 442px) minmax(320px, 1fr);
  gap: 64px;
  align-items: start;
}

.hero-panel {
  position: sticky;
  top: 24px;
  align-self: start;
}

.hero-panel::after {
  content: '';
  position: absolute;
  inset: 20px -18px -20px 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  z-index: -1;
}

.hero-image {
  display: block;
  width: 100%;
  height: auto;
  box-shadow: var(--shadow);
}

.content-panel {
  max-width: 680px;
  width: 100%;
}

.brand-mark,
.eyebrow,
.upload-card h2,
.report-card h2,
.detail-block h3 {
  margin: 0;
}

.brand-mark {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(4.5rem, 8vw, 7rem);
  line-height: 0.92;
  font-weight: 500;
  letter-spacing: -0.05em;
  color: var(--text);
}

.brand-mark span {
  color: var(--accent);
}

.eyebrow {
  margin-top: 44px;
  max-width: none;
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.85rem, 2.6vw, 2.8rem);
  line-height: 1.08;
}

.hero-points {
  margin-top: 34px;
}

.upload-card,
.report-card {
  margin-top: 36px;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.card-heading,
.report-head,
.button-row {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-start;
}

.report-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.section-label {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.upload-card h2,
.report-card h2 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 2rem;
}

.microcopy,
.safety-note,
.report-footer,
.selected-file,
.status-card,
.metric-grid span,
.detail-block li {
  color: var(--muted);
}

.microcopy,
.safety-note {
  max-width: 25ch;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
}

.hero-point {
  margin: 0;
  width: 100%;
  max-width: none;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: nowrap;
}

.hero-point + .hero-point {
  margin-top: 10px;
}

.hero-disclaimer {
  color: rgba(255, 255, 255, 0.75);
}

.upload-form {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
}

.context-field {
  margin-top: 24px;
  width: 100%;
}

.context-label {
  display: block;
  margin-bottom: 10px;
  color: var(--text);
  font-weight: 600;
}

.context-field textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  border: 1px solid rgba(88, 217, 122, 0.24);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.context-field textarea::placeholder {
  color: rgba(195, 208, 203, 0.65);
}

.context-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.file-drop {
  display: grid;
  gap: 12px;
  padding: 20px;
  border: 1px dashed rgba(88, 217, 122, 0.55);
  background: var(--card);
  cursor: pointer;
}

.file-drop-label {
  color: var(--text);
  font-weight: 600;
}

.file-drop input[type='file'] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-picker-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.file-picker-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  color: #06211e;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent) 0%, #72ed91 100%);
  text-align: center;
}

.selected-file {
  font-size: 0.9rem;
}

.status-card {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 178, 163, 0.26);
  background: rgba(255, 178, 163, 0.08);
}

.status-error {
  color: var(--danger);
}

.button-row {
  margin-top: 24px;
  margin-bottom: 0;
  align-items: center;
}

.submit-button {
  border: 0;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--accent) 0%, #72ed91 100%);
  color: #06211e;
  font-family: 'Manrope', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}

.analysis-progress {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid rgba(88, 217, 122, 0.22);
  background: rgba(255, 255, 255, 0.035);
}

.analysis-progress[hidden] {
  display: none;
}

.analysis-progress-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  color: var(--text);
}

.analysis-progress-head strong {
  font-size: 1.2rem;
  color: var(--accent);
}

.analysis-progress-head span {
  color: var(--muted);
  font-size: 0.9rem;
}

.analysis-progress-track {
  position: relative;
  margin-top: 12px;
  height: 9px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.analysis-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #46cf6c 0%, #8af2a4 100%);
  box-shadow: 0 0 18px rgba(88, 217, 122, 0.28);
  transition: width 900ms ease;
}

/* Indeterminate bar — CSS/compositor-driven so it keeps moving even while
   the browser freezes JS timers during a full-page form POST. */
.analysis-progress-bar--indeterminate {
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(
    90deg,
    rgba(88, 217, 122, 0) 0%,
    #58d97a 45%,
    #8af2a4 55%,
    rgba(88, 217, 122, 0) 100%
  );
  transition: none;
  will-change: transform;
  animation: kardion-indeterminate 1.15s ease-in-out infinite;
}

@keyframes kardion-indeterminate {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(360%); }
}

.analysis-progress-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent);
  will-change: transform;
  animation: kardion-spin 0.8s linear infinite;
}

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

.analysis-progress-message,
.analysis-progress-note {
  margin: 12px 0 0;
  line-height: 1.55;
}

.analysis-progress-message {
  color: var(--text);
  font-size: 0.92rem;
}

.analysis-progress-note {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.82rem;
}

.submit-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.is-disabled {
  opacity: 0.55;
  pointer-events: none;
  cursor: not-allowed;
}

.report-card {
  scroll-margin-top: 20px;
}

.report-warning {
  border-color: rgba(255, 178, 163, 0.32);
}

.report-pill {
  padding: 8px 12px;
  border: 1px solid rgba(88, 217, 122, 0.34);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.report-email {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(88, 217, 122, 0.34);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.report-email:hover {
  background: rgba(88, 217, 122, 0.12);
  border-color: rgba(88, 217, 122, 0.6);
  color: var(--accent);
}

.report-email svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.report-summary {
  margin: 18px 0 0;
  font-size: 1.04rem;
  line-height: 1.7;
  color: var(--text);
}

.report-opening {
  margin: 18px 0 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.65;
  font-weight: 700;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.metric-grid article,
.detail-block {
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.metric-grid span {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 1rem;
  line-height: 1.45;
}

.detail-block {
  margin-top: 16px;
}

.detail-block h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.45rem;
}

.detail-block ul {
  margin: 14px 0 0;
  padding-left: 18px;
}

.detail-paragraph {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.report-footer {
  margin-top: 18px;
  font-size: 0.95rem;
  line-height: 1.7;
}

.report-disclaimer {
  margin: 14px 0 0;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.62);
}

.report-engine {
  margin: 8px 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.4);
}

/* ---- Verdict banner ---- */
.verdict-banner {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(88, 217, 122, 0.12), rgba(88, 217, 122, 0.03));
  border: 1px solid rgba(88, 217, 122, 0.28);
  border-left: 4px solid var(--accent);
}

.verdict-kicker {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.verdict-headline {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  line-height: 1.25;
  color: var(--text);
}

/* ---- Confidence chips ---- */
.conf-chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.conf-alta { color: var(--good); background: var(--good-soft); border-color: rgba(88, 217, 122, 0.4); }
.conf-moderada { color: var(--warn); background: var(--warn-soft); border-color: rgba(240, 190, 90, 0.4); }
.conf-baixa { color: var(--bad); background: var(--bad-soft); border-color: rgba(255, 120, 100, 0.4); }

.block-note {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

/* ---- Key findings ---- */
.findings-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.findings-list .finding {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid var(--accent);
}

.findings-list .finding + .finding { margin-top: 10px; }
.finding.sev-atencao { border-left-color: var(--warn); }
.finding.sev-critico { border-left-color: var(--bad); }

.finding-dot {
  flex: none;
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.finding.sev-atencao .finding-dot { background: var(--warn); }
.finding.sev-critico .finding-dot { background: var(--bad); }

.finding-body { flex: 1; min-width: 0; }
.finding-body strong { display: block; color: var(--text); font-size: 0.98rem; line-height: 1.4; }
.finding-detail { display: block; margin-top: 4px; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }

.sev-badge {
  flex: none;
  align-self: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}
.sev-badge.sev-normal { color: var(--good); background: var(--good-soft); border-color: rgba(88, 217, 122, 0.4); }
.sev-badge.sev-atencao { color: var(--warn); background: var(--warn-soft); border-color: rgba(240, 190, 90, 0.4); }
.sev-badge.sev-critico { color: var(--bad); background: var(--bad-soft); border-color: rgba(255, 120, 100, 0.4); }

/* ---- Measurement table ---- */
.measure-table-wrap { width: 100%; overflow-x: auto; }

.measure-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.measure-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid rgba(88, 217, 122, 0.28);
  white-space: nowrap;
}

.measure-table tbody td {
  padding: 11px 12px;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.measure-table tbody tr:nth-child(even) td { background: rgba(255, 255, 255, 0.025); }
.measure-table tbody td strong { color: var(--text); }

/* ---- Não avaliável ---- */
.block-limits { border-left: 3px solid var(--warn); }
.limits-list { columns: 2; column-gap: 26px; margin: 14px 0 0; padding-left: 18px; }
.limits-list li { break-inside: avoid; margin-bottom: 8px; }

/* ---- Dual audience ---- */
.audience-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.audience-card {
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.audience-clinician { border-top: 3px solid var(--accent); }
.audience-patient { border-top: 3px solid #6fb6e8; }

.audience-tag {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.audience-patient .audience-tag { color: #8ec5ef; }

.audience-card p { margin: 0; color: var(--text); font-size: 0.94rem; line-height: 1.65; }

@media (max-width: 1024px) {
  .page-shell {
    padding: 22px;
  }

  .hero-layout {
    gap: 28px;
    grid-template-columns: 1fr;
  }

  .hero-panel {
    position: relative;
    top: auto;
    align-self: auto;
    max-width: 442px;
    width: 100%;
  }

  .eyebrow {
    max-width: none;
  }
}

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

  .hero-layout {
    gap: 18px;
  }

  .hero-panel {
    max-width: none;
  }

  .hero-panel::after {
    inset: 10px -8px -10px 10px;
  }

  .brand-mark {
    font-size: clamp(3.3rem, 19vw, 4.6rem);
  }

  .eyebrow {
    margin-top: 22px;
    font-size: clamp(1.65rem, 8vw, 2.1rem);
    line-height: 1.12;
  }

  .hero-points {
    margin-top: 18px;
  }

  .hero-point {
    white-space: normal;
    font-size: 0.96rem;
    line-height: 1.6;
  }

  .upload-card,
  .report-card {
    margin-top: 22px;
    padding: 18px;
  }

  .card-heading,
  .report-head,
  .button-row {
    flex-direction: column;
    gap: 12px;
  }

  .report-actions {
    width: 100%;
    justify-content: space-between;
  }

  .upload-card h2,
  .report-card h2 {
    font-size: 1.7rem;
  }

  .microcopy,
  .safety-note {
    max-width: none;
    font-size: 0.92rem;
  }

  .file-drop {
    padding: 16px;
  }

  .file-picker-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .file-picker-button,
  .submit-button {
    width: 100%;
    min-height: 48px;
  }

  .selected-file {
    line-height: 1.5;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .audience-grid {
    grid-template-columns: 1fr;
  }

  .limits-list {
    columns: 1;
  }

  .verdict-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .verdict-headline {
    font-size: 1.3rem;
  }

  .finding {
    flex-wrap: wrap;
  }

  .sev-badge {
    align-self: flex-start;
  }

  /* Card-style table on small screens */
  .measure-table thead { display: none; }
  .measure-table, .measure-table tbody, .measure-table tr, .measure-table td { display: block; width: 100%; }
  .measure-table tr {
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
  }
  .measure-table tbody td {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  .measure-table tbody tr:nth-child(even) td { background: transparent; }
  .measure-table tbody td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent);
    text-align: left;
  }

  .report-pill {
    width: 100%;
    text-align: center;
  }

  .detail-block,
  .metric-grid article {
    padding: 14px;
  }

  .report-footer {
    font-size: 0.92rem;
    line-height: 1.6;
  }
}

@media (max-width: 420px) {
  .page-shell {
    padding: 12px;
  }

  .brand-mark {
    font-size: clamp(3rem, 18vw, 4rem);
  }

  .eyebrow {
    font-size: clamp(1.5rem, 7.4vw, 1.9rem);
  }

  .upload-card h2,
  .report-card h2 {
    font-size: 1.52rem;
  }

  .file-drop-label {
    font-size: 0.96rem;
    line-height: 1.45;
  }
}
