:root {
  --ink: #22342b;
  --muted: #5d7065;
  --green: #2f6d42;
  --green-2: #76ad83;
  --mint: #eef7ef;
  --line: #b8d4bf;
  --rose: #b85a73;
  --amber: #d5a743;
  --blue: #4f86a8;
  --page-w: 816px;
  --page-h: 1056px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #dfe9e1;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 64px;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(250, 253, 250, .94);
  border-bottom: 1px solid #ccdccf;
  backdrop-filter: blur(12px);
}

.topbar strong {
  display: block;
  font-size: 18px;
  color: #1f3e2b;
}

.topbar span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.topbar nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  border: 1px solid #b8d2bd;
  border-radius: 999px;
  background: #fff;
  color: #24442e;
  min-height: 36px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

button.primary {
  background: linear-gradient(135deg, #2d7044, #1d4e31);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px rgba(29, 78, 49, .18);
}

button.ghost {
  width: 100%;
  margin-top: 10px;
  border-style: dashed;
}

.instructions-dialog {
  width: min(760px, calc(100vw - 36px));
  border: 1px solid #bcd5c2;
  border-radius: 18px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(24, 45, 31, .24);
}

.instructions-dialog::backdrop {
  background: rgba(22, 38, 27, .42);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  background: linear-gradient(135deg, #eef8ef, #fff);
  border-bottom: 1px solid #cfe1d3;
}

.dialog-head strong {
  display: block;
  color: var(--green);
  font-size: 20px;
}

.dialog-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.instructions-body {
  padding: 20px 24px 24px;
  font-size: 14px;
  line-height: 1.55;
}

.instructions-body ol {
  margin: 0;
  padding-left: 22px;
}

.instructions-body li {
  margin-bottom: 12px;
}

.manual-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  margin-top: 8px;
  padding: 0 16px;
  border-radius: 999px;
  background: #2d7044;
  color: #fff;
  text-decoration: none;
  font-weight: 900;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 430px) 1fr;
  gap: 18px;
  padding: 22px 22px 0;
}

.app-view.hidden {
  display: none !important;
}

.history-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 22px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.dashboard-card {
  border: 1px solid #c6d9cb;
  border-radius: 16px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 12px 30px rgba(35, 63, 43, .08);
  padding: 18px;
}

.hero-card {
  min-height: 190px;
  display: grid;
  align-content: space-between;
  background:
    linear-gradient(135deg, rgba(238,247,239,.98), rgba(255,255,255,.94)),
    url("/assets/fondo_genoma.jpg");
  background-size: cover;
}

.eyebrow {
  color: var(--rose);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.dashboard h1 {
  margin: 6px 0 8px;
  color: #244d31;
  font-size: 28px;
}

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

.dashboard-results {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}

.empty-dashboard {
  border: 1px dashed #b8d4bf;
  border-radius: 12px;
  padding: 18px;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.empty-dashboard b {
  color: var(--green);
}

.patient-result {
  border: 1px solid #c9ddce;
  border-radius: 13px;
  background: #fbfdfb;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
}

.patient-result-main b {
  display: block;
  color: #203c2a;
  font-size: 14px;
}

.patient-result-main span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.patient-actions {
  display: flex;
  align-items: start;
}

.report-versions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 7px;
}

.report-version-card {
  border: 1px solid #d2e2d6;
  border-radius: 11px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 9px;
}

.report-version-card b {
  display: block;
  color: #244d31;
  font-size: 12px;
}

.report-version-card span {
  color: var(--muted);
  font-size: 11px;
}

.version-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.version-actions button {
  min-height: 30px;
  padding: 0 11px;
  font-size: 11px;
  background: #eef7ef;
}

.no-reports {
  color: var(--muted);
  font-size: 11px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: 360px;
  border-radius: 14px;
  background: #203c2a;
  color: #fff;
  padding: 13px 16px;
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
  box-shadow: 0 16px 35px rgba(20, 40, 27, .22);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 430px) 1fr;
  gap: 22px;
  padding: 22px;
}

.panel {
  display: grid;
  gap: 14px;
  align-content: start;
}

.card {
  border: 1px solid #c9d9cd;
  border-radius: 12px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 12px 28px rgba(45, 75, 55, .08);
  padding: 16px;
}

.card h2,
.section-head h2 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--green);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.section-head span {
  max-width: 180px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.grid {
  display: grid;
  gap: 10px;
}

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

label {
  display: grid;
  gap: 5px;
  color: #4f6658;
  font-size: 11px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c4d6c9;
  border-radius: 8px;
  background: #fbfdfb;
  color: #17271d;
  min-height: 36px;
  padding: 8px 10px;
  font: 13px Arial, Helvetica, sans-serif;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.genotype-inputs {
  display: grid;
  gap: 12px;
}

.risk-group {
  border: 1px solid #d9e5dc;
  border-radius: 10px;
  padding: 10px;
  background: #f8fbf8;
}

.risk-group h3 {
  margin: 0 0 8px;
  font-size: 12px;
  color: #263e2e;
}

.geno-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.geno-grid input {
  min-height: 30px;
  padding: 5px 7px;
}

.history-rows {
  display: grid;
  gap: 7px;
}

.history-row {
  display: grid;
  grid-template-columns: 70px 1fr 1fr 1.1fr 30px;
  gap: 6px;
}

.history-row input,
.history-row select {
  min-height: 32px;
  padding: 5px 7px;
}

.history-row button {
  min-height: 32px;
  padding: 0;
  border-radius: 8px;
  color: #884050;
}

.preview {
  min-width: 0;
  display: flex;
  justify-content: center;
}

.report {
  display: grid;
  gap: 22px;
}

.page {
  width: var(--page-w);
  min-height: var(--page-h);
  position: relative;
  overflow: hidden;
  padding: 56px 62px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(30, 55, 38, .18);
}

.page-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .12;
  pointer-events: none;
}

.page > *:not(.page-bg) {
  position: relative;
  z-index: 1;
}

.report-header {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 24px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 2px solid #d7e8db;
}

.report-header img {
  width: 220px;
}

.report-header b {
  display: block;
  color: var(--rose);
  font-size: 25px;
  letter-spacing: .2px;
}

.report-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.patient-band {
  margin: 16px 0;
  border: 1px solid #acd0b5;
  border-radius: 14px;
  background: rgba(255,255,255,.82);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
}

.patient-band span {
  min-height: 44px;
  padding: 8px 10px;
  display: grid;
  gap: 3px;
  border-right: 1px solid #d8e9dc;
  font-size: 11px;
}

.patient-band span:last-child { border-right: 0; }
.patient-band b { color: var(--green); text-transform: uppercase; font-size: 9px; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.status-grid article {
  border: 1px solid #c7dccb;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f3faf4);
  padding: 11px;
}

.status-grid b {
  display: block;
  min-height: 26px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.status-grid strong {
  color: #204f31;
  font-size: 15px;
}

h1 {
  margin: 8px 0 10px;
  font-size: 22px;
  color: #244d31;
}

.summary-table,
.probiotic-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid #9fc6a8;
  border-radius: 13px;
  background: rgba(255,255,255,.9);
  font-size: 11px;
}

th {
  background: #e5f2e7;
  color: #1f4a2d;
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: .2px;
}

td,
th {
  padding: 8px;
  border-bottom: 1px solid #c8dfcd;
  border-right: 1px solid #d7e6da;
  vertical-align: top;
}

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

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.pill,
.risk {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .3px;
}

.pill.low,
.risk.low { background: #6aa976; }
.pill.medium,
.risk.medium { background: #d4a448; }
.pill.high,
.risk.high { background: #b34a5f; }
.pill.none { background: #83958a; }

.history-line {
  margin-top: 7px;
  border-left: 3px solid #a7c9af;
  padding-left: 7px;
  color: #435648;
  font-size: 10px;
}

.not-detected {
  margin: 12px 0 0;
  border-radius: 12px;
  background: #f1f7f2;
  border: 1px solid #c9dfce;
  padding: 10px 12px;
  font-size: 11px;
}

.section-title {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title span {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.section-title h2 {
  margin: 0;
  color: #244d31;
  font-size: 21px;
}

.chart-card {
  border: 1px solid #c3dac8;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(241,248,242,.94));
  padding: 18px;
  margin-bottom: 22px;
  box-shadow: 0 12px 25px rgba(31, 70, 43, .08);
}

.load-chart {
  width: 100%;
  height: 340px;
}

.axis {
  stroke: #9bbba4;
  stroke-width: 2;
}

.axis-title,
.bar-label,
.bar-value {
  fill: #31523b;
  font: 12px Arial, Helvetica, sans-serif;
  font-weight: 800;
}

.bar-value {
  font-size: 9.5px;
}

.bar {
  fill: #7aaa84;
}

.bar.medium { fill: var(--amber); }
.bar.high { fill: var(--rose); }
.bar.none { fill: #879a8e; }

.text-block {
  border: 1px solid #c7ddcc;
  border-radius: 16px;
  background: rgba(255,255,255,.86);
  padding: 18px 20px;
  color: #25392d;
  font-size: 14px;
  line-height: 1.55;
}

.text-block p {
  margin: 0 0 11px;
}

.text-block p:last-child {
  margin-bottom: 0;
}

.text-block.columns {
  columns: 2;
  column-gap: 28px;
}

.risk-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.wellness-box {
  margin-top: 18px;
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(135deg, #e6f2e8, #fff7f9);
  border: 1px solid #c6ddca;
  font-size: 14px;
}

.probiotic-table {
  margin-top: 8px;
  font-size: 12px;
}

.closing-page {
  display: grid;
  align-content: center;
  gap: 28px;
}

blockquote {
  margin: 0;
  border-left: 8px solid var(--rose);
  padding: 22px 28px;
  border-radius: 18px;
  background: rgba(255,255,255,.9);
  color: #244d31;
  font-size: 25px;
  line-height: 1.35;
  font-weight: 900;
  text-transform: uppercase;
}

.signature {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: end;
  gap: 18px;
  justify-self: end;
  width: 430px;
  color: #21382a;
  font-size: 13px;
}

.signature img {
  width: 170px;
}

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .panel { max-width: none; }
  .dashboard { grid-template-columns: 1fr; }
  .history-header { align-items: stretch; flex-direction: column; }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .panel,
  .dashboard,
  .instructions-dialog {
    display: none !important;
  }

  .workspace,
  .preview,
  .report {
    display: block;
    padding: 0;
    margin: 0;
  }

  .page {
    width: 216mm;
    min-height: 279.4mm;
    box-shadow: none;
    page-break-after: always;
    break-after: page;
  }

  @page {
    size: Letter;
    margin: 0;
  }
}
