:root {
  --bg: #0f172a;
  --card: #ffffff;
  --muted: #64748b;
  --text: #0f172a;
  --line: #e2e8f0;
  --primary: #dc2626;
  --primary-dark: #991b1b;
  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #dc2626;
  --blue: #2563eb;
  --shadow: 0 20px 60px rgba(15,23,42,.18);
}
* { box-sizing: border-box; }
html, body { margin:0; min-height:100%; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif; background:#f1f5f9; color:var(--text); }
body { padding-bottom: env(safe-area-inset-bottom); }
.app-shell { min-height:100vh; }
.topbar { position:sticky; top:0; z-index:10; display:flex; align-items:center; justify-content:space-between; padding:calc(12px + env(safe-area-inset-top)) 16px 12px; background:rgba(15,23,42,.96); color:#fff; box-shadow:0 12px 30px rgba(15,23,42,.25); }
.brand { display:flex; gap:10px; align-items:center; }
.brand img { width:42px; height:42px; border-radius:12px; }
.brand strong { display:block; font-size:17px; }
.brand span { display:block; color:#cbd5e1; font-size:13px; }
main { padding:16px; max-width:860px; margin:0 auto; }
.card, .status-card { background:var(--card); border:1px solid var(--line); border-radius:22px; padding:18px; box-shadow:var(--shadow); margin-bottom:14px; }
.login-card h1 { margin:0 0 8px; }
label { display:block; font-size:13px; color:var(--muted); margin:14px 0 6px; font-weight:800; }
input, textarea { width:100%; border:1px solid var(--line); border-radius:14px; padding:14px; font-size:16px; outline:none; font-family:inherit; }
textarea { min-height:120px; resize:vertical; }
button { border:0; border-radius:14px; padding:13px 15px; font-weight:850; cursor:pointer; font-size:15px; }
button:disabled, .disabled { opacity:.55; cursor:not-allowed; }
.primary { width:100%; background:var(--primary); color:#fff; margin-top:14px; }
.primary:hover { background:var(--primary-dark); }
.secondary { background:#e2e8f0; color:#0f172a; }
.ghost { background:transparent; color:#fff; border:1px solid rgba(255,255,255,.2); }
.small { padding:9px 11px; font-size:13px; }
.hidden { display:none !important; }
.msg { color:var(--bad); min-height:20px; }
.muted { color:var(--muted); }
.strong { font-weight:800; }
.status-card { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.status-card h2 { margin:3px 0; font-size:22px; }
.status-card p { margin:0; color:var(--muted); }
.eyebrow { text-transform:uppercase; color:var(--muted); font-size:11px; font-weight:900; letter-spacing:.08em; }
.status-pill { padding:8px 11px; border-radius:999px; font-size:12px; font-weight:900; white-space:nowrap; }
.status-pill.available { background:#dcfce7; color:#166534; }
.status-pill.busy { background:#fef3c7; color:#92400e; }
.status-pill.en_route, .status-pill.on_site { background:#dbeafe; color:#1e40af; }
.status-pill.offline { background:#e2e8f0; color:#334155; }
.controls-grid { display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; margin-bottom:14px; }
.control.available { background:#16a34a; color:#fff; }
.control.busy { background:#f59e0b; color:#111827; }
.control.offline { background:#334155; color:#fff; }
.notice { border-left:5px solid var(--warn); background:#fffbeb; padding:12px 14px; border-radius:16px; margin-bottom:14px; }
.notice p { margin:5px 0 0; color:#92400e; }
.compact { padding:14px; box-shadow:none; }
.row { display:flex; gap:10px; align-items:center; }
.between { justify-content:space-between; }
#gpsText { margin:3px 0 0; color:var(--muted); font-size:13px; }
.tabs { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:12px 0; }
.tab { background:#e2e8f0; color:#334155; }
.tab.active { background:#0f172a; color:#fff; }
.tab span { display:inline-flex; min-width:22px; height:22px; align-items:center; justify-content:center; border-radius:999px; margin-left:5px; background:rgba(255,255,255,.25); }
.ticket-card { background:#fff; border:1px solid var(--line); border-radius:20px; padding:15px; margin-bottom:12px; box-shadow:0 12px 30px rgba(15,23,42,.08); border-left:7px solid #94a3b8; }
.ticket-card.priority-1 { border-left-color:#dc2626; }
.ticket-card.priority-2 { border-left-color:#f59e0b; }
.ticket-card.priority-3 { border-left-color:#64748b; }
.ticket-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.ticket-title { margin:0; font-size:18px; font-weight:950; }
.ticket-meta { margin:6px 0 0; color:var(--muted); font-size:13px; }
.ticket-body { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:12px 0 0; font-size:14px; color:#334155; }
.badge { display:inline-flex; align-items:center; border-radius:999px; padding:5px 8px; font-size:11px; font-weight:900; background:#fee2e2; color:#991b1b; white-space:nowrap; }
.badge.medical { background:#dcfce7; color:#166534; }
.badge.security, .badge.vif { background:#fee2e2; color:#991b1b; }
.badge.fire { background:#ffedd5; color:#9a3412; }
.actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:12px; }
.actions button { font-size:13px; }
.actions .full { grid-column:1 / -1; }
.action-title { margin-top:8px; color:var(--muted); font-size:11px; font-weight:900; text-transform:uppercase; letter-spacing:.07em; }
.field-action { background:#eff6ff; color:#1d4ed8; }
.danger-soft { background:#fee2e2; color:#991b1b; }
.empty { color:var(--muted); text-align:center; padding:30px 10px; background:white; border:1px dashed var(--line); border-radius:20px; }
.modal { position:fixed; inset:0; background:rgba(15,23,42,.72); z-index:50; padding:20px; overflow:auto; }
.modal-card { background:#fff; border-radius:24px; padding:18px; max-width:780px; margin:40px auto; position:relative; box-shadow:var(--shadow); }
.modal-close { position:absolute; right:12px; top:12px; width:40px; height:40px; border-radius:999px; background:#e2e8f0; font-size:24px; padding:0; }
.ticket-map { height:280px; border-radius:18px; overflow:hidden; margin-top:14px; border:1px solid var(--line); }

.resolver-activity-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.resolver-activity-head h3 {
  margin: 4px 0 3px;
  color: #0f172a;
}

.resolver-activity-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.resolver-activity-list {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.resolver-activity-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid #dbeafe;
  background: #fff;
}

.resolver-activity-item.actor-neighbor {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.resolver-activity-item.actor-resolver {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.resolver-activity-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.resolver-activity-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.resolver-activity-row strong {
  color: #0f172a;
  font-size: 15px;
}

.resolver-activity-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.resolver-activity-role {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.resolver-activity-content p {
  margin: 6px 0 0;
  color: #334155;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.resolver-activity-file {
  color: var(--muted) !important;
  font-weight: 800;
}

.resolver-activity-link {
  display: inline-flex;
  margin-top: 8px;
  color: var(--blue);
  font-weight: 900;
  text-decoration: none;
}

.resolver-activity-empty,
.resolver-activity-error {
  margin: 12px 0 0;
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.detail-actions { margin-top:16px; }
.field-card { padding-top:54px; }
.field-mode { margin-top:16px; }
.route-panel { position:fixed; inset:0; z-index:60; background:rgba(15,23,42,.72); display:flex; align-items:stretch; justify-content:center; padding:14px; }
.route-card { width:min(960px,100%); height:calc(100vh - 28px); background:#fff; border-radius:26px; padding:16px; box-shadow:0 20px 70px rgba(0,0,0,.32); display:flex; flex-direction:column; overflow:hidden; position:relative; }
.route-head { display:flex; justify-content:space-between; gap:14px; align-items:flex-start; margin-bottom:12px; padding-right:46px; }
.route-head h2 { margin:3px 0; }
.route-subtitle { margin:0; font-size:14px; font-weight:700; }
.in-route { top:14px; right:14px; }
.route-map { flex:1; min-height:360px; width:100%; border-radius:20px; overflow:hidden; border:2px solid #e5e7eb; background:#e5e7eb; }
.route-status { margin-top:10px; padding:12px; border-radius:16px; background:#f9fafb; color:var(--text); font-size:15px; font-weight:800; }
.route-actions { display:grid; grid-template-columns:1fr 1fr 1fr 1fr; gap:10px; margin-top:12px; }
.resolver-route-marker, .incident-route-marker { width:42px; height:42px; border-radius:50%; border:3px solid white; display:flex; align-items:center; justify-content:center; color:white; font-size:22px; box-shadow:0 4px 14px rgba(0,0,0,.35); }
.resolver-route-marker { background:#2563eb; }
.incident-route-marker { background:#dc2626; animation:routeIncidentPulse 1.2s infinite; }
@keyframes routeIncidentPulse { 0% { transform:scale(1); box-shadow:0 0 0 0 rgba(220,38,38,.7); } 70% { transform:scale(1.06); box-shadow:0 0 0 18px rgba(220,38,38,0); } 100% { transform:scale(1); box-shadow:0 0 0 0 rgba(220,38,38,0); } }
.recording-banner { position:fixed; top:calc(16px + env(safe-area-inset-top)); left:16px; right:16px; z-index:100; background:#dc2626; color:white; border-radius:18px; padding:16px 18px; display:flex; align-items:center; justify-content:center; gap:12px; font-size:20px; font-weight:900; box-shadow:0 12px 30px rgba(220,38,38,.35); }
.rec-dot { width:18px; height:18px; border-radius:50%; background:white; animation:recPulse 1s infinite; }
@keyframes recPulse { 0% { transform:scale(1); opacity:1; } 50% { transform:scale(1.45); opacity:.55; } 100% { transform:scale(1); opacity:1; } }
.toast { position:fixed; left:16px; right:16px; bottom:calc(16px + env(safe-area-inset-bottom)); background:#0f172a; color:#fff; padding:14px 16px; border-radius:18px; box-shadow:var(--shadow); z-index:100; text-align:center; }
@media (max-width:620px) {
  main { padding:12px; }
  .controls-grid, .actions, .ticket-body { grid-template-columns:1fr; }
  .route-panel { padding:8px; }
  .route-card { height:calc(100vh - 16px); border-radius:22px; padding:12px; }
  .route-map { min-height:300px; }
  .route-actions { grid-template-columns:1fr 1fr; }
  .status-card { align-items:flex-start; flex-direction:column; }
  .modal { padding:10px; }
  .modal-card { margin:20px auto; }
}


/* v9 - configuración operacional, sin URL técnica visible */
.settings-card { max-width: 860px; }
.settings-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:14px; margin-top:16px; }
.settings-section { border:1px solid var(--line); background:#f8fafc; border-radius:18px; padding:14px; }
.settings-section h3 { margin:0 0 10px; color:#0f172a; }
.settings-section p { margin:7px 0; }
.setting-row { display:grid; grid-template-columns:34px minmax(0,1fr); gap:12px; align-items:start; margin:12px 0; font-weight:800; color:#334155; width:100%; max-width:100%; line-height:1.25; }
.setting-row input[type=checkbox] { width:28px; height:28px; min-width:28px; margin:0; padding:0; }
.setting-row span { min-width:0; white-space:normal; overflow-wrap:anywhere; display:block; }
.settings-section { overflow:hidden; }
.settings-section select { width:100%; border:1px solid var(--line); border-radius:12px; padding:11px; font-weight:800; background:#fff; }
@media (max-width: 760px) { .settings-grid { grid-template-columns:1fr; } }

.settings-actions { margin-top: 12px; }
.tiny { font-size: 12px; line-height: 1.35; }
.full { width: 100%; }
.danger-soft { color: #b91c1c; border-color: #fecaca; background: #fff1f2; }
.danger-soft:hover { background: #ffe4e6; }

#resolverRemoteAudio { width:1px; height:1px; opacity:0; position:fixed; left:-9999px; }

.resolver-voice-overlay {
  position: fixed;
  z-index: 500;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: rgba(6, 13, 28, .9);
  backdrop-filter: blur(14px);
}

.resolver-voice-overlay.hidden { display: none !important; }

.resolver-voice-card {
  width: min(100%, 380px);
  padding: 30px 22px 22px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 28px;
  background: linear-gradient(180deg, #172033, #0b1220);
  color: #fff;
  text-align: center;
  box-shadow: 0 28px 70px rgba(0,0,0,.42);
}

.resolver-voice-icon {
  display: grid;
  width: 82px;
  height: 82px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  font-size: 40px;
}

.resolver-voice-card h2 { margin: 0 0 8px; color: #fff; }
.resolver-voice-card p { margin: 6px 0; color: #d8e0ed; }
.resolver-voice-card #resolverVoiceCase { font-weight: 800; color: #fff; }
.resolver-voice-timer { margin: 16px 0 0; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.resolver-voice-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 24px; }
.resolver-voice-actions button { min-height: 50px; margin: 0; border-radius: 16px; }
.resolver-voice-actions .danger { border: 0; background: #dc2626; color: #fff; font-weight: 800; }

.incoming-call-banner {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  border-radius: 16px;
  background: #fef2f2;
  border: 2px solid #fca5a5;
  color: #7f1d1d;
  animation: incomingCallPulse 1.2s infinite;
}
.incoming-call-banner strong { font-size: 16px; }
.incoming-call-banner span { font-size: 13px; font-weight: 800; color: #991b1b; }
.incoming-call-button {
  background: #dc2626 !important;
  color: #fff !important;
  box-shadow: 0 12px 28px rgba(220,38,38,.24);
}
@keyframes incomingCallPulse {
  0% { box-shadow: 0 0 0 0 rgba(220,38,38,.32); }
  70% { box-shadow: 0 0 0 12px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}


.resolver-active-call-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  background: #ecfdf5;
  border: 2px solid #86efac;
  color: #14532d;
  box-shadow: 0 12px 28px rgba(22,163,74,.14);
}
.resolver-active-call-panel strong { font-size: 16px; }
.resolver-active-call-panel span { font-size: 13px; font-weight: 800; color: #166534; line-height: 1.35; }
.resolver-active-call-panel button { justify-self: start; }


/* ==========================================================================
   REDISEÑO UI/UX v11 — Refresh visual "app nativa" (VS&TI / UX Refresh)
   Capa 100% aditiva: no se eliminó ni renombró ninguna regla anterior.
   Solo se refinan tokens visuales, tipografía, elevación, motion y estados.
   No toca IDs, no toca lógica, no cambia el árbol de eventos de app.js.
   ========================================================================== */

:root{
  --rz-ink:#0b1120;
  --rz-surface:#eef1f6;
  --rz-line:#e3e7ef;
  --rz-blue:#2563eb;
  --rz-blue-dark:#1e40af;
  --rz-radius-lg:26px;
  --rz-radius-md:18px;
  --rz-shadow-sm:0 2px 10px rgba(15,23,42,.06);
  --rz-shadow-md:0 12px 30px rgba(15,23,42,.10);
  --rz-shadow-lg:0 26px 60px rgba(15,23,42,.20);
  --rz-ease:cubic-bezier(.22,.9,.32,1.1);
  --rz-safe-top:env(safe-area-inset-top,0px);
  --rz-safe-bottom:env(safe-area-inset-bottom,0px);
}

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

html, body{
  background:
    radial-gradient(1100px 500px at 50% -14%, #1c2740 0%, var(--rz-surface) 40%),
    var(--rz-surface);
}

body{
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior-y:contain;
}

button{ touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible{
  outline:3px solid #93c5fd;
  outline-offset:2px;
}

/* Topbar: blur nativo + status bar segura */
.topbar{
  padding:calc(12px + var(--rz-safe-top)) 16px 12px;
  background:rgba(11,17,32,.92);
  -webkit-backdrop-filter:blur(14px);
  backdrop-filter:blur(14px);
  box-shadow:0 12px 30px rgba(15,23,42,.28);
}
.brand img{ box-shadow:0 6px 16px rgba(0,0,0,.3); }
.ghost{ border-radius:14px; transition:transform .1s; }
.ghost:active{ transform:scale(.9); }

main{ padding-bottom:calc(16px + var(--rz-safe-bottom)); }

/* Tarjetas: elevación consistente tipo app nativa */
.card, .status-card{
  border-radius:var(--rz-radius-md);
  box-shadow:var(--rz-shadow-md);
  border-color:var(--rz-line);
}
.login-card{ border-radius:var(--rz-radius-lg); }
.login-card h1{ font-weight:900; letter-spacing:-.01em; }
input, textarea{ border-radius:14px; min-height:50px; }
input:focus, textarea:focus, select:focus{
  outline:none;
  border-color:var(--rz-blue);
  box-shadow:0 0 0 4px rgba(37,99,235,.14);
}

button{ transition:transform .1s var(--rz-ease), filter .15s, box-shadow .15s; border-radius:14px; }
button:active{ transform:scale(.97); }
.primary{ background:linear-gradient(180deg,#ef4444,#b91c1c); box-shadow:0 14px 30px rgba(220,38,38,.28); }
.primary:hover{ background:linear-gradient(180deg,#ef4444,#991b1b); }
.secondary{ background:#e7ebf3; }

/* Estado operacional: segmented control grande y muy legible */
.status-card{ align-items:center; }
.status-pill{
  padding:10px 14px;
  font-weight:900;
  letter-spacing:.02em;
  box-shadow:inset 0 0 0 1px rgba(15,23,42,.04);
}
.status-pill.available{ background:#dcfce7; color:#14532d; box-shadow:inset 0 0 0 1px rgba(22,163,74,.25); }
.status-pill.busy{ background:#fef3c7; color:#78350f; box-shadow:inset 0 0 0 1px rgba(245,158,11,.3); }
.status-pill.offline{ background:#e2e8f0; color:#334155; }
.status-pill.en_route, .status-pill.on_site{ background:#dbeafe; color:#1e3a8a; box-shadow:inset 0 0 0 1px rgba(37,99,235,.25); }

.controls-grid{ gap:10px; }
.control{
  min-height:58px;
  border-radius:16px;
  font-weight:900;
  box-shadow:var(--rz-shadow-sm);
}
.control.available{ background:linear-gradient(180deg,#22c55e,#15803d); }
.control.busy{ background:linear-gradient(180deg,#fbbf24,#d97706); color:#1c1300; }
.control.offline{ background:linear-gradient(180deg,#475569,#1e293b); }

.notice{ border-radius:18px; box-shadow:var(--rz-shadow-sm); }

/* Ubicación / GPS */
.card.compact{ border-radius:18px; }

/* Tabs tipo segmented control */
.tabs{
  background:#e2e8f0;
  padding:5px;
  border-radius:16px;
  gap:4px;
}
.tab{
  border-radius:12px;
  font-weight:900;
  transition:background .15s, color .15s, transform .1s;
  background:transparent;
  color:#334155;
}
.tab.active{
  background:var(--rz-ink);
  color:#fff;
  box-shadow:0 8px 18px rgba(15,23,42,.22);
}
.tab:active{ transform:scale(.97); }

/* Tickets: tarjeta de alerta con jerarquía clara (tipo, prioridad, sector, estado) */
.ticket-card{
  border-radius:22px;
  box-shadow:var(--rz-shadow-md);
  transition:transform .12s var(--rz-ease), box-shadow .15s;
  border-left-width:8px;
}
.ticket-card:active{ transform:scale(.995); }
.ticket-card.priority-1{
  box-shadow:0 16px 34px rgba(220,38,38,.20);
  animation:ticketPriorityGlow 2.4s ease-in-out infinite;
}
@keyframes ticketPriorityGlow{
  0%, 100%{ box-shadow:0 16px 34px rgba(220,38,38,.14); }
  50%{ box-shadow:0 16px 34px rgba(220,38,38,.30); }
}
.ticket-title{ font-weight:950; letter-spacing:-.01em; }
.badge{ font-weight:950; letter-spacing:.02em; }
.actions button{ min-height:46px; }
.field-action{ border-radius:14px; font-weight:900; }
.field-action:active{ background:#dbeafe; }

.empty{ border-radius:22px; }

/* Modales: hoja tipo bottom-sheet con vidrio esmerilado */
.modal{
  background:rgba(8,12,22,.62);
  -webkit-backdrop-filter:blur(6px);
  backdrop-filter:blur(6px);
}
.modal-card{
  border-radius:28px;
  box-shadow:0 30px 70px rgba(0,0,0,.4);
}
.modal-close{ transition:transform .1s; }
.modal-close:active{ transform:scale(.9); }

/* Ticket asignado: llamada a la acción muy visible con vibración visual */
.incoming-call-banner{
  border-radius:18px;
}
.incoming-call-button{ border-radius:16px; }

.resolver-activity-item{ border-radius:16px; }

/* Ruta / navegación */
.route-card{ border-radius:30px; box-shadow:0 30px 80px rgba(0,0,0,.35); }
.route-map{ border-radius:22px; }

/* Recording banner */
.recording-banner{ border-radius:20px; top:calc(16px + var(--rz-safe-top)); }

.toast{ border-radius:18px; bottom:calc(16px + var(--rz-safe-bottom)); box-shadow:var(--rz-shadow-lg); }

/* Settings */
.settings-card{ border-radius:28px; }
.settings-section{ border-radius:18px; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce){
  *{ animation-duration:.001ms !important; animation-iteration-count:1 !important; transition-duration:.001ms !important; }
}
