/* whatsapiapp · estilos base. Solo se permiten colores definidos en :root (§2.2). */

:root {
  /* Marca */
  --brand-50:  #E8F8EE;
  --brand-100: #D9FDD3;  /* burbuja saliente */
  --brand-400: #25D366;  /* acento: punto "online", badges, nunca texto sobre blanco */
  --brand-600: #0E7C6B;  /* botón primario (contraste AA con texto blanco) */
  --brand-700: #0B6356;  /* hover */
  --brand-900: #075E54;  /* sidebar */
  --brand-950: #05453E;  /* cabeceras de modal, estado activo oscuro */

  /* Neutros */
  --ink:       #111B21;
  --ink-2:     #3B4A54;
  --ink-3:     #667781;
  --ink-4:     #8696A0;
  --line:      #E9EDEF;
  --line-2:    #D1D7DB;
  --bg:        #F0F2F5;   /* fondo general */
  --bg-chat:   #EFEAE2;   /* fondo de la conversación */
  --surface:   #FFFFFF;
  --surface-2: #F7F8FA;

  /* Mensajes */
  --bubble-in:  #FFFFFF;
  --bubble-out: var(--brand-100);
  --tick-read:  #53BDEB;  /* doble check leído */

  /* Estados */
  --danger:  #C62828;  --danger-soft:  #FDECEA;
  --warning: #B26A00;  --warning-soft: #FFF4D6;
  --success: var(--brand-600); --success-soft: var(--brand-50);
  --info:    #1565C0;  --info-soft:    #E3F2FD;

  /* Gráficos (distinguibles, aptos para daltonismo) */
  --chart-1: #0E7C6B; --chart-2: #1565C0; --chart-3: #B26A00;
  --chart-4: #8E24AA; --chart-5: #C62828; --chart-6: #546E7A;

  /* Forma */
  --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 48px;
  --shadow-1: 0 1px 2px rgba(17,27,33,.08);
  --shadow-2: 0 2px 6px rgba(17,27,33,.10);
  --shadow-modal: 0 24px 48px rgba(17,27,33,.24);

  /* Tipografía */
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --fs-xs: 11px; --fs-sm: 12px; --fs-base: 14px; --fs-md: 15px; --fs-lg: 16px; --fs-xl: 18px; --fs-2xl: 22px; --fs-3xl: 28px;

  /* Layout y movimiento */
  --sidebar-w: 260px; --topbar-h: 56px; --chatlist-w: 360px;
  --t-fast: 120ms; --t-base: 200ms; --ease: cubic-bezier(.2,.8,.2,1);
  --z-nav: 30; --z-overlay: 50; --z-modal: 60; --z-toast: 70;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: var(--fs-2xl); font-weight: 700; }
h2 { font-size: var(--fs-md); font-weight: 600; }

p { margin: 0; }

img, svg { display: block; max-width: 100%; }

input, select, textarea, button { font: inherit; }
input, select, textarea { font-size: var(--fs-lg); }

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

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

[hidden] { display: none !important; }

a { color: var(--brand-700); }

.muted { color: var(--ink-3); }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

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

/* ---------- Iconos ---------- */

.icon {
  width: 20px; height: 20px; flex-shrink: 0; display: inline-block; vertical-align: middle;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-4);
  border: 1px solid transparent; border-radius: var(--r-md);
  font-size: var(--fs-base); font-weight: 600; line-height: 1;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:disabled { opacity: .55; }
.btn-primary { background: var(--brand-600); color: var(--surface); }
.btn-primary:not(:disabled):hover { background: var(--brand-700); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:not(:disabled):hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:not(:disabled):hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger); color: var(--surface); }
.btn-danger:not(:disabled):hover { filter: brightness(.92); }
.btn-lg { min-height: 48px; padding: 0 var(--s-6); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: var(--r-pill);
  border: 2px solid currentColor; border-color: var(--surface) var(--surface) transparent transparent;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--brand-600) var(--brand-600) transparent transparent; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
}

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

/* ---------- Formularios ---------- */

.field { display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-4); }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: var(--fs-sm); color: var(--ink-3); }
.field .error-text { font-size: var(--fs-sm); color: var(--danger); }

.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 0 var(--s-3);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { padding: var(--s-3); min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-600);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-600) 18%, transparent);
}
.input[aria-invalid="true"] { border-color: var(--danger); }

.input-group { position: relative; }
.input-group .input { padding-right: 48px; }
.input-group .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }

.form-error {
  display: flex; gap: var(--s-2); align-items: flex-start;
  padding: var(--s-3); margin-bottom: var(--s-4);
  border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger);
  font-size: var(--fs-sm); font-weight: 500;
}
.form-error[hidden] { display: none; }

.strength { display: flex; gap: var(--s-1); margin-top: var(--s-1); }
.strength span { flex: 1; height: 4px; border-radius: var(--r-pill); background: var(--line); transition: background-color var(--t-base) var(--ease); }
.strength[data-level="1"] span:nth-child(-n+1) { background: var(--danger); }
.strength[data-level="2"] span:nth-child(-n+2) { background: var(--warning); }
.strength[data-level="3"] span:nth-child(-n+3) { background: var(--brand-600); }
.strength[data-level="4"] span:nth-child(-n+4) { background: var(--brand-700); }

/* ---------- Píldoras, chips y avatares ---------- */

.pill {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px var(--s-2); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 18px; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.pill-success { background: var(--success-soft); color: var(--brand-700); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-dot { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--brand-400); }

.tlf-chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  padding: 2px var(--s-2); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 18px; white-space: nowrap;
  border: 1px solid currentColor;
}
.tlf-chip.tlf-1 { color: var(--chart-1); background: color-mix(in srgb, var(--chart-1) 8%, var(--surface)); }
.tlf-chip.tlf-2 { color: var(--chart-2); background: color-mix(in srgb, var(--chart-2) 8%, var(--surface)); }
.tlf-chip.tlf-3 { color: var(--chart-4); background: color-mix(in srgb, var(--chart-4) 8%, var(--surface)); }
.tlf-chip .tlf-off { width: 6px; height: 6px; border-radius: var(--r-pill); background: var(--warning); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: var(--r-pill); overflow: hidden;
  font-size: var(--fs-base); font-weight: 600; color: var(--surface); user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-xl); }
.av-c0 { background: var(--chart-1); } .av-c1 { background: var(--chart-2); }
.av-c2 { background: var(--chart-3); } .av-c3 { background: var(--chart-4); }
.av-c4 { background: var(--chart-5); } .av-c5 { background: var(--chart-6); }
.av-c6 { background: var(--brand-700); } .av-c7 { background: var(--brand-950); }

/* ---------- Tarjetas, estados vacíos y esqueletos ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-body { padding: var(--s-5); }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: var(--s-3); padding: var(--s-8) var(--s-5); color: var(--ink-3);
}
.empty-state .empty-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: var(--r-pill);
  background: var(--brand-50); color: var(--brand-600);
}
.empty-state .empty-icon .icon { width: 30px; height: 30px; }
.empty-state h2 { color: var(--ink); font-size: var(--fs-lg); }
.empty-state p { max-width: 420px; }

.skeleton {
  display: block; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Tablas responsivas ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: var(--s-3) var(--s-4); text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); background: var(--surface-2); }
.table tbody tr:hover { background: var(--surface-2); }

@media (max-width: 720px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { margin-bottom: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
  .table td { display: flex; justify-content: space-between; gap: var(--s-3); border-bottom: 1px solid var(--line); }
  .table td:last-child { border-bottom: 0; }
  .table td::before { content: attr(data-label); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); }
}

/* ---------- Modales ---------- */

body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-4); background: rgba(17,27,33,.5);
  animation: fade-in var(--t-base) var(--ease);
}
.modal {
  display: flex; flex-direction: column; width: 100%; max-width: 480px; max-height: calc(100dvh - 32px);
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-modal);
  animation: modal-in var(--t-base) var(--ease);
}
.modal-lg { max-width: 760px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5); border-bottom: 1px solid var(--line);
}
.modal-header h2 { font-size: var(--fs-lg); font-weight: 600; }
.modal-header.modal-header-brand {
  border-bottom: 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: linear-gradient(135deg, var(--brand-950), var(--brand-900)); color: var(--surface);
}
.modal-header.modal-header-brand .icon-btn { color: var(--surface); }
.modal-header.modal-header-brand .icon-btn:hover { background: rgba(255,255,255,.14); }
.modal-body { padding: var(--s-5); overflow-y: auto; }
.modal-body > p + p { margin-top: var(--s-3); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--s-2); flex-wrap: wrap;
  padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line);
}

@media (max-width: 720px) {
  .modal-backdrop { padding: 0; }
  .modal, .modal-lg {
    max-width: none; height: 100dvh; max-height: none; border-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-header.modal-header-brand { border-radius: 0; padding-top: max(var(--s-4), env(safe-area-inset-top)); }
  .modal-body { flex: 1; }
  .modal-footer .btn { flex: 1; }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Toasts ---------- */

.toast-region {
  position: fixed; z-index: var(--z-toast); right: var(--s-4); bottom: max(var(--s-4), env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s-2); width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-lg);
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow-modal);
  font-size: var(--fs-base); pointer-events: auto;
  animation: modal-in var(--t-base) var(--ease);
}
.toast .icon { margin-top: 1px; }
.toast-success .icon { color: var(--brand-400); }
.toast-error { background: var(--danger); }
.toast-warning .icon { color: var(--warning-soft); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease); }

@media (max-width: 720px) {
  .toast-region { left: var(--s-4); right: var(--s-4); width: auto; }
}

/* ---------- Login ---------- */

.auth-screen {
  min-height: 100dvh; display: grid; place-items: center;
  padding: max(var(--s-4), env(safe-area-inset-top)) var(--s-4) max(var(--s-4), env(safe-area-inset-bottom));
  background: linear-gradient(160deg, var(--brand-950), var(--brand-900));
}
.auth-card {
  width: 100%; max-width: 400px; padding: var(--s-7) var(--s-6);
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-modal);
}
.auth-card .brand { display: flex; align-items: center; justify-content: center; gap: var(--s-3); margin-bottom: var(--s-5); }
.auth-card .brand-logo { width: 44px; height: 44px; }
.auth-card .brand-wordmark { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }
.auth-card h1 { text-align: center; font-size: var(--fs-xl); font-weight: 600; margin-bottom: var(--s-6); }
.auth-help { margin-top: var(--s-5); text-align: center; font-size: var(--fs-sm); color: var(--ink-3); }
.auth-version { margin-top: var(--s-4); text-align: center; font-size: var(--fs-xs); color: var(--ink-4); }

@media (max-width: 480px) {
  .auth-card { padding: var(--s-6) var(--s-5); }
}

/* ---------- Shell de la aplicación ---------- */

.app-shell { display: flex; min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh; width: var(--sidebar-w); flex-shrink: 0;
  display: flex; flex-direction: column;
  background: var(--brand-900); color: rgba(255,255,255,.9);
  padding-top: env(safe-area-inset-top);
}
.sidebar-brand { display: flex; align-items: center; gap: var(--s-3); height: var(--topbar-h); padding: 0 var(--s-5); }
.sidebar-brand .logo-mark { width: 32px; height: 32px; }
.logo-mark { --logo-bubble: var(--surface); --logo-check: var(--brand-900); }
.sidebar-brand span { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; color: var(--surface); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--s-2) 0; }
.nav-section { padding: var(--s-4) var(--s-5) var(--s-1); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 44px; padding: 0 var(--s-5); border-left: 3px solid transparent;
  color: rgba(255,255,255,.9); text-decoration: none; font-weight: 500;
  transition: background-color var(--t-fast) var(--ease);
}
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.is-active { background: rgba(255,255,255,.14); border-left-color: var(--brand-400); color: var(--surface); font-weight: 600; }
.nav-item .nav-badge {
  margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--brand-400); color: var(--brand-950); font-size: var(--fs-xs); font-weight: 700; line-height: 20px; text-align: center;
}
.nav-item .nav-badge[hidden] { display: none; }
.nav-item:focus-visible { outline-color: var(--brand-400); outline-offset: -3px; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.12); padding: var(--s-2) 0 max(var(--s-3), env(safe-area-inset-bottom)); }
.user-card { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); }
.user-card .user-meta { min-width: 0; flex: 1; }
.user-card .user-name { font-weight: 600; color: var(--surface); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .user-role { font-size: var(--fs-xs); color: rgba(255,255,255,.65); }
.user-card .icon-btn { color: rgba(255,255,255,.8); }
.user-card .icon-btn:hover { background: rgba(255,255,255,.12); color: var(--surface); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: var(--s-3);
  height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) var(--s-4) 0;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; min-width: 0; font-size: var(--fs-xl); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .menu-btn { display: none; }
.conn-dot { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--ink-3); }
.conn-dot::before { content: ''; width: 10px; height: 10px; border-radius: var(--r-pill); background: var(--ink-4); transition: background-color var(--t-base) var(--ease); }
.conn-dot.is-online::before { background: var(--brand-400); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-400) 25%, transparent); }

.view { flex: 1; min-width: 0; padding: var(--s-6); }
.view-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-5); flex-wrap: wrap; }

.drawer-backdrop { display: none; }

@media (max-width: 1024px) {
  .sidebar {
    position: fixed; z-index: var(--z-overlay); left: 0; top: 0; bottom: 0; height: auto;
    transform: translateX(-100%); transition: transform var(--t-base) var(--ease);
    box-shadow: var(--shadow-modal);
  }
  .app-shell.drawer-open .sidebar { transform: none; }
  .app-shell.drawer-open .drawer-backdrop {
    display: block; position: fixed; inset: 0; z-index: calc(var(--z-overlay) - 1); background: rgba(17,27,33,.45);
  }
  .topbar .menu-btn { display: inline-flex; }
}

@media (max-width: 720px) {
  .view { padding: var(--s-4); }
  .topbar .conn-label { display: none; }
  .topbar .logout-label { display: none; }
}

/* ---------- Vistas: piezas comunes ---------- */

.view-heading { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.view-title { font-size: var(--fs-lg); font-weight: 600; }

.skeleton-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--r-pill); }
.skeleton-line { flex: 1; height: 14px; max-width: 360px; }

.chip-list { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.cell-actions { white-space: nowrap; text-align: right; }
.icon-btn-danger:hover { background: var(--danger-soft); color: var(--danger); }

.user-cell { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.user-cell-meta { min-width: 0; }
.user-cell-name { font-weight: 600; }
.user-cell-email { font-size: var(--fs-sm); color: var(--ink-3); overflow-wrap: anywhere; }
.table td .pill + .pill { margin-left: var(--s-1); }

@media (max-width: 720px) {
  .table td.cell-user::before { display: none; }
  .table td.cell-actions { justify-content: flex-end; }
  .table td.cell-actions::before { display: none; }
}

/* ---------- Casillas, interruptores y filas de campo ---------- */

.check-group { border: 0; padding: 0; margin: 0 0 var(--s-4); min-width: 0; }
.check-group legend { padding: 0; margin-bottom: var(--s-2); font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); }
.check-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.check-pill {
  display: inline-flex; align-items: center; gap: var(--s-2);
  min-height: 44px; padding: 0 var(--s-4); border: 1px solid var(--line-2); border-radius: var(--r-pill);
  font-weight: 600; cursor: pointer; user-select: none;
  transition: background-color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.check-pill input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-600); }
.check-pill:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); color: var(--brand-700); }
.check-pill:has(input:focus-visible) { outline: 2px solid var(--brand-600); outline-offset: 2px; }

.input-row { display: flex; gap: var(--s-2); }
.input-row .input-group { flex: 1; }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); min-height: 44px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 44px; height: 24px; flex-shrink: 0; border-radius: var(--r-pill); background: var(--line-2);
  transition: background-color var(--t-fast) var(--ease);
}
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: var(--r-pill);
  background: var(--surface); box-shadow: var(--shadow-1); transition: transform var(--t-fast) var(--ease);
}
.switch input:checked + .switch-track { background: var(--brand-600); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.switch-label { font-weight: 600; }

/* ---------- Conexiones ---------- */

.phones-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); align-items: start; }
@media (max-width: 1200px) { .phones-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .phones-grid { grid-template-columns: 1fr; } }

.phone-card { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); min-height: 180px; }
.phone-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.phone-card-head .tlf-chip { font-size: var(--fs-sm); padding: var(--s-1) var(--s-3); }
.phone-card-body { display: flex; flex-direction: column; gap: var(--s-3); }
.phone-card-body .field { margin-bottom: 0; }
.phone-number { font-size: var(--fs-xl); font-weight: 600; letter-spacing: .01em; }
.phone-card-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.phone-later { border-top: 1px solid var(--line); padding-top: var(--s-3); }
.btn-ghost-danger { color: var(--danger); }
.btn-ghost-danger:not(:disabled):hover { background: var(--danger-soft); color: var(--danger); }

.qr-box {
  display: flex; align-items: center; justify-content: center; align-self: center;
  width: 100%; max-width: 280px; aspect-ratio: 1; padding: var(--s-3);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.qr-img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.qr-placeholder { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); width: 100%; height: 100%; justify-content: center; }
.qr-skeleton { width: 70%; aspect-ratio: 1; border-radius: var(--r-md); }
.qr-help { text-align: center; font-size: var(--fs-sm); color: var(--ink-2); }
.qr-countdown {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); align-self: center;
  padding: var(--s-1) var(--s-3); border-radius: var(--r-pill);
  background: var(--warning-soft); color: var(--warning); font-weight: 600; font-variant-numeric: tabular-nums;
}
.qr-countdown.is-expired { background: var(--danger-soft); color: var(--danger); }

.plain-list { margin: var(--s-2) 0; padding-left: var(--s-5); }
.plain-list li + li { margin-top: var(--s-1); }

.disconnected-list { list-style: none; margin: var(--s-4) 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.disconnected-item { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding: var(--s-3); border: 1px solid var(--line); border-radius: var(--r-md); }
