/* El widget vive en un iframe de HubSpot (400×620 registrado, pero la ventana de llamada
   se puede redimensionar). Regla de oro: la página nunca hace scroll. Banda arriba, acciones
   abajo, y solo la zona central desborda si no cabe.
   Se ve como una pieza más de HubSpot: pizarra y gris azulado del CRM, la banda oscura de su
   barra superior, y el color solo para el estado de la llamada. */

/* Lexend Deca, la sans de HubSpot. Autoalojada (subconjunto latino, cubre el español) para no
   depender de otra red ni bloquear el auto-init de app.js. Licencia en fonts/OFL.txt. */
@font-face {
  font-family: "Lexend Deca";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("./fonts/lexend-deca-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --ink-strong: #213343;
  --ink: #33475b;
  --ink-soft: #516f90;
  --surface: #ffffff;
  --canvas: #f5f8fa;
  --line: #cbd6e2;
  --line-soft: #dfe3eb;
  --shell: #2d3e50;
  --accent: #007a8c;
  --accent-ink: #00606e;
  --accent-tint: #e5f5f8;
  --live: #0b7a5a;
  --live-ink: #09684d;
  --live-tint: #e3f4ee;
  --ring: #b45309;
  --ring-ink: #8a4108;
  --ring-tint: #fdf0e1;
  --stop: #c93637;
  --stop-ink: #a12a2b;
  --stop-tint: #fcebeb;

  --font: "Lexend Deca", system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  --gutter: clamp(12px, 4vw, 20px);
  --radius: 6px;
  --tap: 44px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Iconos de los botones de llamada (Material Icons, Apache 2.0), pintados con currentColor. */
  --icon-call: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 0 1.25.2 2.45.57 3.57.11.35.03.74-.25 1.02l-2.2 2.2z'/%3E%3C/svg%3E");
  --icon-end: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 9c-1.6 0-3.15.25-4.6.72v3.1c0 .39-.23.74-.56.9-.98.49-1.87 1.12-2.66 1.85-.18.18-.43.28-.7.28-.28 0-.53-.11-.71-.29L.29 13.08c-.18-.17-.29-.42-.29-.7 0-.28.11-.53.29-.71C3.34 8.78 7.46 7 12 7s8.66 1.78 11.71 4.67c.18.18.29.43.29.71 0 .28-.11.53-.29.71l-2.48 2.48c-.18.18-.43.29-.71.29-.27 0-.52-.11-.7-.28-.79-.74-1.69-1.36-2.67-1.85-.33-.16-.56-.5-.56-.9v-3.1C15.15 9.25 13.6 9 12 9z'/%3E%3C/svg%3E");
  --icon-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z'/%3E%3C/svg%3E");
  --icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
  --icon-mic-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 11h-1.7c0 .74-.16 1.43-.43 2.05l1.23 1.23c.56-.98.9-2.09.9-3.28zm-4.02.17c0-.06.02-.11.02-.17V5c0-1.66-1.34-3-3-3S9 3.34 9 5v.18l5.98 5.99zM4.27 3 3 4.27l6.01 6.01V11c0 1.66 1.33 3 2.99 3 .22 0 .44-.03.65-.08l1.66 1.66c-.71.33-1.5.52-2.31.52-2.76 0-5.3-2.1-5.3-5.1H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c.91-.13 1.77-.45 2.54-.9L19.73 21 21 19.73 4.27 3z'/%3E%3C/svg%3E");
  --icon-backspace: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M22 3H7c-.69 0-1.23.35-1.59.88L0 12l5.41 8.11c.36.53.9.89 1.59.89h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H7.07L2.4 12l4.66-7H22v14zm-11.59-2L14 13.41 17.59 17 19 15.59 15.41 12 19 8.41 17.59 7 14 10.59 10.41 7 9 8.41 12.59 12 9 15.59z'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

p {
  margin: 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--ink-strong);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Banda de estado: el color dice en qué está la llamada --- */

.band {
  --band-bg: var(--shell);
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 48px;
  padding: 6px 6px 6px var(--gutter);
  background: var(--band-bg);
  color: #fff;
  transition: background-color 320ms var(--ease-out);
}

.band[data-call="outbound"] {
  --band-bg: var(--accent);
}

.band[data-call="inbound"] {
  --band-bg: var(--ring);
}

.band[data-call="in-call"] {
  --band-bg: var(--live);
}

.band :focus-visible {
  outline-color: #fff;
}

.band-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.band-pills {
  display: flex;
  gap: 6px;
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
}

/* Reloj de la banda: cuenta regresiva del timbre o duración de la llamada. */
.band-clock {
  display: none;
  margin-left: auto;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.band[data-call="inbound"] #ring-countdown,
.band[data-call="in-call"] #in-call-timer {
  display: block;
}

/* Con la llamada sonando, en curso o en cierre la banda no muestra las pastillas: ahí manda la
   llamada, y los fallos de audio siguen saliendo en el aviso de abajo. */
.band[data-call="inbound"] .band-pills,
.band[data-call="in-call"] .band-pills,
.band[data-call="wrapup"] .band-pills {
  display: none;
}

/* El turno: la barra se vacía en los 20 s que timbra antes de pasar a otro asesor. */
.band[data-call="inbound"]::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: rgb(255 255 255 / 0.85);
  transform-origin: left;
  animation: ring-drain 20s linear forwards;
}

@keyframes ring-drain {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.22);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Punto delante del texto: el estado se lee por texto y no solo por color. */
.pill::before {
  content: "";
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9fb0c2;
}

.pill.ok::before {
  background: #4fd1a5;
}

.pill.busy::before {
  background: #f6b45b;
}

.pill.err::before {
  background: #ff8a80;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--canvas);
  color: var(--ink-strong);
}

.band .icon-btn {
  color: rgb(255 255 255 / 0.8);
}

/* En el cierre no hay pastillas ni reloj que empujen el engranaje a la derecha. */
.band[data-call="wrapup"] .icon-btn {
  margin-left: auto;
}

.band .icon-btn:hover {
  background: rgb(255 255 255 / 0.14);
  color: #fff;
}

/* --- Aviso de audio --- */

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--gutter);
  background: var(--stop-tint);
  border-bottom: 1px solid color-mix(in srgb, var(--stop) 25%, transparent);
  color: var(--stop-ink);
  font-size: 13px;
}

.alert-text {
  flex: 1;
  min-width: 0;
}

.alert-action {
  flex-shrink: 0;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.alert-action:hover {
  background: color-mix(in srgb, var(--stop) 8%, var(--surface));
}

/* --- Zona central y vistas --- */

.stage {
  /* Fila fija: si el aviso está oculto (display: none) no ocupa celda, y sin esto el
     main caería en la fila auto y las acciones quedarían a media altura. */
  grid-row: 3;
  min-height: 0;
  display: grid;
  /* El selector del número de salida se superpone a la vista dentro de esta zona. */
  position: relative;
}

.view {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--surface);
}

.view-body {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 20px var(--gutter);
}

.view-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-strong);
}

.view-hint {
  max-width: 38ch;
  color: var(--ink-soft);
}

.call-name {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
  overflow-wrap: anywhere;
}

.call-number {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.view-actions {
  display: flex;
  gap: 8px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}

.view-actions .btn {
  flex: 1;
}

/* Contestar pesa más que rechazar: una acción principal por estado. */
.view-actions .btn.go {
  flex: 2;
}

/* --- Botones --- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    border-color 120ms ease;
}

.btn:hover {
  background: var(--canvas);
  border-color: var(--ink-soft);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--shell);
  border-color: var(--shell);
  color: #fff;
}

.btn.primary:hover {
  background: var(--ink-strong);
}

.btn.go {
  background: var(--live);
  border-color: var(--live);
  color: #fff;
}

.btn.go:hover {
  background: var(--live-ink);
}

.btn.danger {
  border-color: color-mix(in srgb, var(--stop) 50%, transparent);
  color: var(--stop);
}

.btn.danger:hover {
  background: var(--stop-tint);
  border-color: var(--stop);
  color: var(--stop-ink);
}

.btn.danger.solid {
  background: var(--stop);
  border-color: var(--stop);
  color: #fff;
}

.btn.danger.solid:hover {
  background: var(--stop-ink);
}

.icon-call::before,
.icon-end::before {
  content: "";
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  background: currentColor;
  mask: var(--icon-call) center / contain no-repeat;
}

.icon-end::before {
  mask-image: var(--icon-end);
}

.btn.small {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
}

input,
textarea {
  min-height: var(--tap);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink-strong);
  font: inherit;
  caret-color: var(--accent);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-soft);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* --- Marcador: indicativo + número arriba, teclado de teléfono, "Llamar" abajo --- */

/* El formulario ocupa toda la vista; adentro repite el reparto cuerpo / acciones. */
#view-idle {
  grid-template-rows: minmax(0, 1fr);
}

.dialer {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.dial-body {
  position: relative;
  gap: 8px;
  padding-top: 16px;
}

.dial-entry {
  display: flex;
  align-items: stretch;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--canvas);
  transition:
    border-color 120ms ease,
    box-shadow 120ms ease;
}

.dial-entry:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.country-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 0 8px 0 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: var(--radius) 0 0 var(--radius);
  background: transparent;
  color: var(--ink-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.country-btn:hover {
  background: var(--line-soft);
}

.country-btn::after {
  content: "";
  width: 16px;
  height: 16px;
  background: var(--ink-soft);
  mask: var(--icon-chevron) center / contain no-repeat;
}

.country-iso {
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--line-soft);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.country-code {
  font-variant-numeric: tabular-nums;
}

#dial-number {
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 0 12px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

#dial-number::placeholder {
  color: var(--ink-soft);
}

.dial-help {
  min-height: 1.45em;
  font-size: 12px;
  color: var(--ink-soft);
}

.dial-help[data-state="ok"] {
  color: var(--live-ink);
}

.dial-help[data-state="err"] {
  color: var(--stop-ink);
}

.keypad {
  --key-size: 64px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: center;
  gap: 8px 12px;
  margin-top: 4px;
}

/* Teclas redondas, como las de un teléfono. */
.key {
  display: grid;
  place-items: center;
  align-content: center;
  width: var(--key-size);
  height: var(--key-size);
  padding: 0;
  border: 1px solid var(--line-soft);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-strong);
  font: inherit;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    transform 80ms ease;
}

.key:hover {
  background: var(--canvas);
  border-color: var(--line);
}

.key:active {
  transform: scale(0.97);
  background: var(--line-soft);
}

.key-digit {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.1;
}

.key-letters {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.key-del {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
}

.key-del::before {
  content: "";
  width: 24px;
  height: 24px;
  background: currentColor;
  mask: var(--icon-backspace) center / contain no-repeat;
}

.key-del:hover {
  border-color: transparent;
  color: var(--ink-strong);
}

/* Selector de indicativo: flota bajo el campo, encima del teclado. */
.country-pop {
  position: absolute;
  top: 76px;
  left: var(--gutter);
  right: var(--gutter);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100% - 88px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(33 51 67 / 0.16);
  animation: drawer-in 160ms var(--ease-out);
}

#country-search {
  min-height: 40px;
}

.country-list {
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.country-list li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
}

.country-list li:hover,
.country-list li.is-active {
  background: var(--canvas);
}

.country-list li[aria-selected="true"] {
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 600;
}

.country-list .country-code {
  color: var(--ink-soft);
}

.country-empty {
  padding: 8px;
  color: var(--ink-soft);
}

/* Panel anclado o ventana baja: teclado compacto, sin letras. */
@media (max-height: 540px) {
  .dial-body {
    padding-top: 12px;
    gap: 6px;
  }
  .dial-entry {
    min-height: 46px;
  }
  #dial-number {
    font-size: 20px;
  }
  .keypad {
    --key-size: 48px;
    gap: 6px 12px;
  }
  .key-letters {
    display: none;
  }
  .country-pop {
    top: 64px;
  }
}

/* --- Wrap-up --- */

.view-body.wrapup {
  gap: 16px;
}

.wrapup-summary {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
}

/* Control segmentado: dos opciones pegadas, como los selectores de HubSpot. */
.outcome {
  display: flex;
  margin: 0;
  padding: 0;
  border: 0;
}

.outcome legend {
  margin-bottom: 6px;
  padding: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}

.choice {
  flex: 1;
  position: relative;
  cursor: pointer;
}

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
  min-height: 0;
  margin: 0;
  cursor: pointer;
}

.choice span {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 500;
  color: var(--ink);
  transition:
    background-color 120ms ease,
    color 120ms ease;
}

.choice:first-of-type span {
  border-radius: var(--radius) 0 0 var(--radius);
}

.choice:last-of-type span {
  margin-left: -1px;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.choice:hover span {
  background: var(--canvas);
}

.choice input:checked + span {
  position: relative;
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-ink);
  font-weight: 600;
}

.choice input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
}

.field textarea {
  resize: none;
  font-size: 14px;
  font-weight: 400;
}

/* --- Cajón de diagnóstico --- */

.drawer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--canvas);
  animation: drawer-in 220ms var(--ease-out);
}

@keyframes drawer-in {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 6px 6px 6px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}

.drawer-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-strong);
}

.drawer-body {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 10px var(--gutter) var(--gutter);
}

.panel {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-strong);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.grid input {
  min-height: 36px;
  font-size: 13px;
  font-weight: 400;
}

.status-list {
  display: grid;
  gap: 4px;
  margin: 0;
  font-size: 12px;
}

.status-list div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 8px;
}

.status-list dt {
  color: var(--ink-soft);
}

.status-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.log {
  margin: 0;
  height: 220px;
  overflow: auto;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--ink-strong);
  color: #dbe3f5;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --- Ventanas bajas: compactar sin perder las acciones --- */

@media (max-height: 460px) {
  .view-hint {
    display: none;
  }
  .view-body {
    padding-block: 12px;
  }
  .view-actions {
    padding-block: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* --- Contexto de la entrante (entrante y en llamada): propiedades como en la ficha --- */

.ctx {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}

.ctx-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}

.tag-mine {
  border-color: transparent;
  background: var(--live-tint);
  color: var(--live-ink);
}

.tag-backup {
  border-color: transparent;
  background: var(--ring-tint);
  color: var(--ring-ink);
}

.ctx-summary {
  color: var(--ink);
}

/* Pares dt/dd sin envoltorio: cada par es una columna, etiqueta arriba y valor abajo. */
.ctx-meta,
.ctx-lead {
  display: grid;
  grid-template-rows: auto auto;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  column-gap: 16px;
  margin: 0;
}

.ctx-meta dt,
.ctx-lead dt {
  font-size: 12px;
  color: var(--ink-soft);
}

.ctx-meta dd,
.ctx-lead dd {
  margin: 0;
  color: var(--ink-strong);
}

/* La etapa del Lead va como etiqueta: verde si ganó, roja si se perdió, neutra en el resto. */
.ctx-lead .tag {
  display: inline-block;
  margin-top: 2px;
}

.tag-lost {
  border-color: transparent;
  background: var(--stop-tint);
  color: var(--stop-ink);
}

.ctx-note {
  font-size: 12px;
  color: var(--ink-soft);
}

.btn.ctx-open {
  justify-self: start;
  gap: 6px;
  min-height: 32px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.btn.ctx-open:hover {
  background: none;
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn.ctx-open::after {
  content: "";
  width: 14px;
  height: 14px;
  background: currentColor;
  mask: var(--icon-open) center / contain no-repeat;
}

/* Panel anclado: poco espacio, solo etiquetas y motivo. La ventana de llamada la muestra completa. */
[data-loc="remote"] .ctx-meta,
[data-loc="remote"] .ctx-open {
  display: none;
}

@media (max-height: 460px) {
  .ctx {
    margin-top: 10px;
    padding-top: 10px;
  }
  .ctx-meta {
    display: none;
  }
}

/* --- Riel: cada llamada es un recorrido Desde → Para → Ahora → Resultado --- */

/* Color de la parada actual: el del estado de la llamada, igual que la banda. */
.view {
  --tone: var(--accent);
}

#view-inbound {
  --tone: var(--ring);
}

#view-in-call {
  --tone: var(--live);
}

.rail {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0;
  padding: 0 0 0 26px;
  list-style: none;
}

/* La vía: une los nodos de la primera a la última parada. */
.rail::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  border-radius: 1px;
  background: var(--line-soft);
}

.stop {
  position: relative;
  min-width: 0;
  transition: opacity 200ms var(--ease-out);
}

.stop[hidden] {
  display: none;
}

/* Nodo: anillo gris en las paradas pasadas, lleno con el color del estado en la actual. */
.stop::before {
  content: "";
  position: absolute;
  left: -26px;
  top: 2px;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  transition:
    background-color 200ms var(--ease-out),
    border-color 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out);
}

.stop[data-st="done"]::before {
  border-color: var(--ink-soft);
  background: var(--ink-soft);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.stop[data-st="now"]::before {
  border-color: var(--tone);
  background: var(--tone);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tone) 18%, transparent);
}

.stop[data-st="next"] {
  opacity: 0.45;
}

.stop-label {
  display: block;
  margin: 0 0 2px;
  padding: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink-soft);
}

.stop-line {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.stop-line b {
  font-weight: 600;
  color: var(--ink-strong);
}

.stop-num {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.stop-meta {
  font-size: 13px;
  color: var(--ink-soft);
}

.stop-status {
  margin-top: 4px;
  font-weight: 600;
  color: var(--tone);
}

.stop-why {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

/* El contexto ya va dentro de su parada: sin la línea ni el margen de la tarjeta suelta. */
.stop .ctx {
  gap: 8px;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
}

/* En llamada la ficha ya está en los controles: sin el enlace repetido. */
#in-call-ctx .ctx-open {
  display: none;
}

/* Etapa, grado y año en columnas a su medida: la etapa no se parte en dos líneas. */
.stop .ctx-lead,
.stop .ctx-meta {
  grid-auto-columns: max-content;
  column-gap: 24px;
}

.stop .ctx-lead .tag {
  white-space: nowrap;
}

/* --- Fila "Desde": la línea de salida, con "Cambiar" a la derecha --- */

.from-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 12px;
  width: calc(100% + 8px);
  margin: -2px -4px 0;
  padding: 2px 4px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.from-row:hover {
  background: var(--canvas);
}

.from-row:active {
  background: var(--line-soft);
}

.from-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 6px;
  min-width: 0;
}

.from-name {
  font-weight: 600;
  color: var(--ink-strong);
  overflow-wrap: anywhere;
}

.from-number {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.from-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.from-row:hover .from-cta {
  color: var(--accent-ink);
}

.from-meta {
  grid-column: 1;
  font-size: 13px;
  color: var(--ink-soft);
}

/* Sin número elegido: la parada lo pide, porque sin él no se puede llamar. */
.from-row[data-state="empty"] .from-name {
  color: var(--accent-ink);
}

/* --- Selector del número de salida, dentro de la parada "Desde" --- */

.line-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.select-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.select-field > span,
.select-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.select-field select {
  min-height: 42px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-strong);
  font: inherit;
  appearance: none;
  cursor: pointer;
}

.select-field::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 12px;
  width: 18px;
  height: 18px;
  background: var(--ink-soft);
  mask: var(--icon-chevron) center / contain no-repeat;
  pointer-events: none;
}

.select-field select:hover {
  border-color: var(--ink-soft);
}

.select-field select:disabled {
  background: var(--canvas);
  color: var(--ink-soft);
  cursor: not-allowed;
}

.line-group,
.line-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Cada número: nombre de la línea arriba, el número abajo; el elegido con su marca. */
.line-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
  min-height: 52px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    border-color 120ms ease;
}

.line-option:hover {
  background: var(--canvas);
  border-color: var(--ink-soft);
}

.line-option:active {
  background: var(--line-soft);
}

.line-option[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.line-option[aria-pressed="true"]::after {
  content: "";
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 20px;
  height: 20px;
  background: var(--accent);
  mask: var(--icon-check) center / contain no-repeat;
}

.line-name {
  grid-column: 1;
  font-weight: 600;
  color: var(--ink-strong);
  overflow-wrap: anywhere;
}

.line-number {
  grid-column: 1;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.sheet-note {
  color: var(--ink-soft);
}

.link-btn {
  align-self: flex-start;
  min-height: 32px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--accent-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- Marcador: el teclado sigue al riel, alineado con el contenido de las paradas --- */

.dial-body {
  gap: 10px;
}

.dial-body .keypad {
  --key-size: 56px;
  margin: 2px 0 0 26px;
}

.dial-body .key-letters {
  font-size: 9px;
}

/* Mientras se elige el número, el marcador espera. */
.is-picking .keypad {
  display: none;
}

.stop-to {
  position: relative;
}

.stop-to .country-pop {
  top: 74px;
  left: 0;
  right: 0;
  max-height: 280px;
}

/* --- En llamada: silenciar y ficha --- */

.ctrls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 8px;
  margin-top: 2px;
}

.ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 62px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-strong);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.ctrl[hidden] {
  display: none;
}

.ctrl::before {
  content: "";
  width: 22px;
  height: 22px;
  background: var(--ink-soft);
  mask: center / contain no-repeat;
}

.icon-mute::before {
  mask-image: var(--icon-mic-off);
}

.icon-record::before {
  mask-image: var(--icon-open);
}

.ctrl:hover {
  background: var(--canvas);
  border-color: var(--ink-soft);
}

.ctrl:active {
  transform: translateY(1px);
}

/* Silenciado: se ve desde lejos, porque el otro lado no está oyendo. */
.ctrl[aria-pressed="true"] {
  border-color: var(--ink-strong);
  background: var(--ink-strong);
  color: #fff;
}

.ctrl[aria-pressed="true"]::before {
  background: #fff;
}

/* --- Cierre: resultado y nota en la última parada --- */

.stop-close {
  display: grid;
  gap: 14px;
}

.stop-close .outcome {
  flex-wrap: wrap;
}

.stop-close .outcome legend {
  float: left;
  width: 100%;
  margin-bottom: 6px;
}

.stop-close .field textarea {
  min-height: 112px;
}

/* Notas durante la llamada: pasan al cierre ya escritas. */
.call-notes {
  margin-top: 12px;
}

.call-notes textarea {
  min-height: 72px;
}

/* --- Ventanas bajas: compactar sin perder el riel ni las acciones --- */

@media (max-height: 540px) {
  .rail {
    gap: 10px;
  }
  .dial-body .keypad {
    --key-size: 46px;
  }
  .ctrl {
    min-height: 52px;
  }
  .stop-close .field textarea {
    min-height: 72px;
  }
}
