/* ---------- Fonts (vendored locally; no external requests) ---------- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("vendor/fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("vendor/fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("vendor/fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("vendor/fonts/inter-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 600; font-display: swap; src: url("vendor/fonts/poppins-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 700; font-display: swap; src: url("vendor/fonts/poppins-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-style: normal; font-weight: 800; font-display: swap; src: url("vendor/fonts/poppins-latin-800-normal.woff2") format("woff2"); }

:root {
  /* Brand */
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Poppins", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --navy: #2a2c57;
  --navy-2: #24264c;
  --violet: #6c5ce7;
  --violet-2: #8b7bff;
  --primary: #343c73;
  --primary-hover: #2a3160;

  /* Surfaces */
  --bg: #f4f6f9;
  --panel: #ffffff;
  --panel-2: #f7f8fb;
  --border: #e5e8ef;
  --border-strong: #d3d8e3;

  /* Text */
  --text: #1e2748;
  --muted: #6b7488;
  --accent: #2f6fed;

  /* Status */
  --amber-bg: #fef3e2; --amber-fg: #c47d1e; --amber-solid: #f0a13a;
  --blue-bg: #e8f1fd;  --blue-fg: #2f6fed;
  --green-bg: #e6f6ec; --green-fg: #1f9d57;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar ---------- */
.accent-bar {
  height: 4px;
  background: linear-gradient(90deg, var(--violet), var(--violet-2) 60%, #b9a9ff);
}
.navbar {
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #fff;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 10px rgba(20, 22, 48, .18);
}
.navbar-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; gap: 32px;
  padding: 0 28px; height: 64px;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--font-head); font-size: 19px; font-weight: 800; letter-spacing: .2px; }
.brand-ver { color: var(--violet-2); font-weight: 800; }
.brand-sub { font-size: 10.5px; letter-spacing: 2.5px; color: #b9bdd6; font-weight: 600; margin-top: 3px; }
.nav-links { display: flex; gap: 6px; flex: 1; }
.nav-item {
  color: #c9cce4; font-size: 14px; font-weight: 600; padding: 8px 4px;
  border-bottom: 2px solid transparent; cursor: default;
}
.nav-item.active { color: #fff; border-bottom-color: var(--violet-2); }
.navbar-right { display: flex; align-items: center; gap: 14px; }
.privacy {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(31, 157, 87, .18);
  border: 1px solid rgba(52, 199, 123, .45);
  color: #7ee6a8; border-radius: 999px;
  padding: 6px 13px; font-size: 12.5px; font-weight: 600;
}
.privacy .lock { filter: grayscale(0); }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 28px 28px 90px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0; font-family: var(--font-head); font-size: 27px; font-weight: 800; color: var(--navy); letter-spacing: -.3px; }
.page-head h1 .arrow { color: var(--violet); font-weight: 700; }
.page-head p { margin: 8px 0 0; color: var(--muted); font-size: 14px; max-width: 760px; }

/* ---------- Cards / steps ---------- */
.step {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.step[hidden] { display: none; }
.step h2 {
  margin: 0 0 4px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .8px; color: var(--violet); font-weight: 800;
}
.step h3 { color: var(--muted); }
.step .hint { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.hint b { color: var(--text); }

/* ---------- Dropzone ---------- */
#dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 44px 24px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s;
  background: var(--panel-2);
}
#dropzone:hover { border-color: var(--violet-2); }
#dropzone.drag { border-color: var(--violet); background: rgba(108, 92, 231, .06); }
#dropzone .big { font-size: 15px; font-weight: 700; color: var(--text); }
#dropzone .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }
#fileInput { display: none; }

/* ---------- Stat cards (summary chips) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 4px; }
.chip {
  flex: 1 1 190px;
  display: flex; align-items: center; gap: 13px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; font-size: 13px; color: var(--muted);
  font-weight: 600;
}
.chip .stat-icon {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center; font-size: 20px; line-height: 1;
  background: var(--blue-bg); color: var(--blue-fg);
}
.chip .stat-body { display: flex; flex-direction: column; }
.chip b { font-family: var(--font-head); color: var(--navy); font-size: 22px; font-weight: 800; line-height: 1.15; }
.chip .stat-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
/* color variants */
.chip.c-blue   .stat-icon { background: var(--blue-bg);  color: var(--blue-fg); }
.chip.c-blue   b { color: var(--blue-fg); }
.chip.c-violet .stat-icon { background: rgba(108,92,231,.14); color: var(--violet); }
.chip.c-violet b { color: var(--violet); }
.chip.c-green  .stat-icon { background: var(--green-bg); color: var(--green-fg); }
.chip.c-green  b { color: var(--green-fg); }
.chip.c-amber  .stat-icon { background: var(--amber-bg); color: var(--amber-fg); }
.chip.c-amber  b { color: var(--amber-fg); }

/* ---------- Status filter pills ---------- */
.status-list { display: flex; flex-wrap: wrap; gap: 10px; }
.status-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600;
  cursor: pointer; color: var(--text);
}
.status-item:hover { border-color: var(--border-strong); }
.status-item input { width: 16px; height: 16px; accent-color: var(--violet); }
.status-item .count { color: var(--muted); font-weight: 500; }

/* ---------- Tables ---------- */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th, table.grid td {
  border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; vertical-align: middle;
}
table.grid th {
  background: var(--panel-2); color: var(--muted); font-weight: 700;
  position: sticky; top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .3px;
  border-bottom: 1px solid var(--border-strong);
}
table.grid tbody tr:hover { background: #fafbfe; }
table.grid input, table.grid select {
  width: 100%; background: #fff; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 7px; padding: 7px 9px; font-size: 13px;
}
table.grid input:focus, table.grid select:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(108,92,231,.14); }
.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }

/* ---------- Fields ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
label.field select, label.field input,
#hospitalFilter, input[type="date"] {
  width: 100%; background: #fff; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 11px; font-size: 13.5px;
}
label.field select:focus, label.field input:focus,
#hospitalFilter:focus, input[type="date"]:focus {
  outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(108,92,231,.14);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }

fieldset.defaults {
  border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin: 0 0 18px;
  background: var(--panel-2);
}
fieldset.defaults legend { padding: 0 8px; color: var(--violet); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Buttons ---------- */
button.btn {
  background: var(--primary); color: #fff; border: none;
  border-radius: 9px; padding: 11px 22px; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: background .15s, transform .05s; box-shadow: var(--shadow);
}
button.btn:hover { background: var(--primary-hover); }
button.btn:active { transform: translateY(1px); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--border-strong); box-shadow: none; }
button.btn.secondary:hover { background: var(--panel-2); border-color: var(--violet-2); }
.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Progress ---------- */
.progress-bar { height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 12px 0; }
.progress-bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--green-fg)); transition: width .2s; }
#genLog { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; max-height: 170px; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
#genLog:empty { display: none; }
#genCount { color: var(--muted); font-weight: 600; }

.notice { font-size: 12.5px; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.notice.warn { background: var(--amber-bg); border: 1px solid #f3d19a; color: var(--amber-fg); }
.notice.ok { background: var(--green-bg); border: 1px solid #b6e6c8; color: var(--green-fg); }
.notice b { color: inherit; }

/* ---------- Preview (rendered Anexo 05) ---------- */
#previewWrap { background: #fff; color: #000; border-radius: 10px; padding: 22px; overflow: auto; border: 1px solid var(--border); box-shadow: var(--shadow-md); }
.anexo { width: 720px; margin: 0 auto; font-family: "Times New Roman", Georgia, serif; font-size: 13px; color: #000; }
.anexo .title { text-align: center; font-weight: bold; font-size: 18px; }
.anexo .subtitle { text-align: center; font-size: 18px; margin-bottom: 8px; }
.anexo table { border-collapse: collapse; width: 100%; margin-top: 6px; }
.anexo td { border: 1px solid #000; padding: 4px 6px; vertical-align: top; }
.anexo td.nobox { border: none; }
.anexo .head { background: #a6a6a6; font-weight: bold; text-align: center; }
.anexo .sig { border: none; text-align: center; padding-top: 40px; }
.small { font-size: 11px; color: var(--muted); }
a.download-again { color: var(--accent); font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .navbar-inner { gap: 16px; padding: 0 16px; }
  .nav-links { display: none; }
  main { padding: 20px 16px 70px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 22px; }
}
