* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1f2430;
  background: #f6f7f9;
  line-height: 1.5;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid #e3e6ea;
}

.topnav .brand {
  font-weight: 700;
  margin-right: auto;
}

.topnav a {
  color: #2451a6;
  text-decoration: none;
  font-weight: 500;
}

.topnav a:hover {
  text-decoration: underline;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.15rem;
  margin-top: 0;
}

.card {
  background: #ffffff;
  border: 1px solid #e3e6ea;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid #e9ebee;
}

th {
  font-weight: 600;
  color: #4a5262;
  background: #fafbfc;
}

.chip {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.chip.verde {
  background: #d8f2dd;
  color: #185c2a;
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.verde {
  background: #d8f2dd;
  color: #185c2a;
}

.badge.amarillo {
  background: #fdeeba;
  color: #6b5308;
}

.badge.rojo {
  background: #fadbd8;
  color: #7c1f18;
}

.alerts-banner {
  background: #fdecea;
  border: 1px solid #f2b8b5;
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  color: #7c1f18;
}

.alerts-banner ul {
  margin: 0.4rem 0 0;
  padding-left: 1.25rem;
}

.hidden {
  display: none;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e9ebee;
}

.upload-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: #4a5262;
}

input[type="text"],
input[type="file"] {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid #cfd4db;
  border-radius: 6px;
  background: #ffffff;
}

button {
  font: inherit;
  padding: 0.45rem 0.9rem;
  border: 1px solid #2451a6;
  border-radius: 6px;
  background: #2451a6;
  color: #ffffff;
  cursor: pointer;
}

button:hover {
  background: #1d4288;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.btn-danger {
  background: #ffffff;
  border-color: #c0392b;
  color: #c0392b;
}

button.btn-danger:hover {
  background: #fdecea;
}

.calls-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.call-card {
  border: 1px solid #e3e6ea;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  background: #fafbfc;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.call-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.call-card button {
  align-self: flex-start;
  margin-top: 0.3rem;
}

.call-meta {
  font-size: 0.85rem;
  color: #6a7180;
}

.call-summary {
  margin: 0;
  font-size: 0.93rem;
}

.escalada {
  color: #7c1f18;
  background: #fadbd8;
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
}

code {
  background: #eef0f3;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

dialog {
  border: 1px solid #cfd4db;
  border-radius: 10px;
  padding: 1.25rem;
  width: min(680px, 92vw);
  max-height: 80vh;
  overflow-y: auto;
}

dialog::backdrop {
  background: rgba(20, 25, 35, 0.45);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.dialog-header h3 {
  margin: 0;
}

.turn {
  border-bottom: 1px solid #e9ebee;
  padding: 0.6rem 0;
}

.turn:last-child {
  border-bottom: none;
}

.turn p {
  margin: 0.25rem 0;
}

.turn-patient strong {
  color: #2451a6;
}

.turn-agent strong {
  color: #185c2a;
}

.turn-refs {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: #4a5262;
}

.turn-refs ul {
  margin: 0.3rem 0 0;
  padding-left: 1.25rem;
}

.muted {
  color: #6a7180;
}

.call-quien {
  font-size: 0.88rem;
  font-weight: 600;
  color: #2b3140;
}

.call-summary-card {
  border: 1px solid #e3e6ea;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  background: #fafbfc;
  margin-bottom: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.9rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.summary-grid dt {
  color: #6a7180;
  font-weight: 600;
}

.summary-grid dd {
  margin: 0;
}

.call-summary-narrativa {
  font-size: 0.93rem;
  margin: 0.5rem 0;
}

.dialog-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.turns-heading {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.95rem;
  color: #4a5262;
}

.error {
  color: #c0392b;
  font-weight: 600;
}

@media (max-width: 640px) {
  .upload-form {
    flex-direction: column;
    align-items: stretch;
  }

  .calls-list {
    grid-template-columns: 1fr;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   Identidad VALAI.ORG
   Paleta extraída del manual de marca (muestreo directo de los archivos
   originales del logotipo, no estimada a ojo):
     #01383F petróleo profundo · #10B89F turquesa · #9DFB65 lima · #DBFBFA menta
   Tipografía: Funnel Display (incluida en /static/marca/).
   Va al final del archivo para sobrescribir los estilos base sin tocarlos.
   El semáforo clínico (verde/amarillo/rojo) NO se rebrandea: esos colores
   comunican criticidad al personal de salud, no identidad de marca.
   ───────────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: "Funnel Display";
  src: url("/static/marca/FunnelDisplay-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Funnel Display";
  src: url("/static/marca/FunnelDisplay-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Funnel Display";
  src: url("/static/marca/FunnelDisplay-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --valai-petroleo: #01383F;
  --valai-turquesa: #10B89F;
  --valai-lima: #9DFB65;
  --valai-menta: #DBFBFA;
  --valai-borde: #cfe6e4;
}

body {
  font-family: "Funnel Display", system-ui, -apple-system, sans-serif;
  color: var(--valai-petroleo);
  background: #f4fbfa;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }

.topnav {
  background: var(--valai-petroleo);
  border-bottom: 3px solid var(--valai-turquesa);
  gap: 1.5rem;
}
.topnav .brand {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-right: auto;
  text-decoration: none;
}
.brand-logo { height: 26px; width: auto; display: block; }
.brand-sub {
  color: var(--valai-menta);
  font-size: 0.82rem;
  opacity: 0.75;
  letter-spacing: 0.02em;
}
.topnav a { color: var(--valai-menta); }
.topnav a:hover { color: var(--valai-lima); text-decoration: none; }

.card {
  border: 1px solid var(--valai-borde);
  border-radius: 12px;
}

th { color: var(--valai-petroleo); background: var(--valai-menta); }

/* Botón principal (iniciar llamada, subir documento) */
.call-btn, #upload-btn {
  background: var(--valai-turquesa);
  color: var(--valai-petroleo);
  font-family: inherit;
  font-weight: 700;
}
.call-btn.in-call { background: #c0392b; color: #fff; }
.mute-btn { font-family: inherit; border-color: var(--valai-borde); }
.mute-btn[aria-pressed="true"] { background: var(--valai-petroleo); border-color: var(--valai-petroleo); }

/* Burbujas de la transcripción */
.agent .bubble { background: var(--valai-menta); }
.patient .bubble { background: #eaf6ee; }
.bubble-label { color: #5b7d7a; }

.call-status[data-state="listening"] { color: var(--valai-turquesa); }
.call-status[data-state="speaking"] { color: var(--valai-petroleo); }
