/* ES360 — App styles (use design system tokens) */

* { box-sizing: border-box; }

html, body, #root {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  overflow: hidden;
}

/* ============== SHELL ============== */
.es-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  background: var(--bg-canvas);
}

/* ============== SIDEBAR ============== */
.es-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: var(--space-5) 0;
  overflow: hidden;
}

.es-sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}
.es-sidebar-brand .mark {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--secondary);
  color: var(--fg-on-secondary);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: 18px;
  letter-spacing: -0.04em;
  position: relative;
}
.es-sidebar-brand .mark::after {
  content: '';
  width: 6px; height: 6px;
  background: var(--primary);
  border-radius: var(--radius-full);
  position: absolute;
  bottom: 7px; right: 7px;
}
.es-sidebar-brand .title {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: 18px;
  color: var(--fg-primary);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
}
.es-sidebar-brand .sub {
  font-size: var(--text-caption);
  color: var(--fg-tertiary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  margin-top: 3px;
}

.es-nav-section {
  padding: var(--space-3) var(--space-5) var(--space-2);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
}

.es-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--space-3);
  flex: 1;
  overflow-y: auto;
}

.es-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-medium);
  color: var(--fg-secondary);
  cursor: pointer;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
  transition: background var(--duration-fast) var(--ease-out);
  font-family: var(--font-body);
  position: relative;
}
.es-nav-item:hover {
  background: var(--bg-subtle);
  color: var(--fg-primary);
}
.es-nav-item.active {
  background: var(--secondary-10);
  color: var(--secondary-dark);
  font-weight: var(--weight-semibold);
}
[data-theme="dark"] .es-nav-item.active {
  background: rgba(41,73,218,0.18);
  color: var(--secondary-light);
}
.es-nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; }
.es-nav-item .count {
  margin-left: auto;
  font-size: var(--text-caption);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
}
.es-nav-item.active .count {
  background: var(--secondary);
  color: var(--fg-on-secondary);
}
.es-nav-item .dot {
  width: 7px; height: 7px;
  border-radius: var(--radius-full);
  margin-left: auto;
}
.es-nav-item .dot.danger { background: var(--danger); }
.es-nav-item .dot.warning { background: var(--warning); }

.es-sidebar-foot {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.es-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  color: white;
  display: grid; place-items: center;
  font-weight: var(--weight-semibold);
  font-size: 13px;
}

/* ============== MAIN ============== */
.es-main {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.es-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}
.es-topbar h1 {
  font-size: 18px;
  font-weight: var(--weight-semibold);
  font-family: var(--font-display);
  letter-spacing: var(--tracking-tight);
}
.es-topbar .crumb {
  font-size: var(--text-body-sm);
  color: var(--fg-tertiary);
}
.es-topbar .updated {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-body-sm);
  color: var(--fg-tertiary);
  font-family: var(--font-mono);
}
.es-topbar .live-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 4px rgba(0,184,148,0.18);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0,184,148,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(0,184,148,0); }
}

.es-page {
  overflow-y: auto;
  padding: var(--space-6);
}
.es-page.compact { padding: var(--space-4); }

/* ============== CARDS ============== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-5);
  box-shadow: var(--shadow-1);
}
.card.flush { padding: 0; overflow: hidden; }
.card-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-4);
}
.card-h h3 {
  font-size: 15px;
  font-weight: var(--weight-semibold);
  font-family: var(--font-display);
  letter-spacing: var(--tracking-tight);
}
.card-h .sub {
  font-size: var(--text-body-sm);
  color: var(--fg-tertiary);
}
.card-h .action {
  font-size: var(--text-body-sm);
  color: var(--secondary);
  cursor: pointer;
  font-weight: var(--weight-medium);
  background: transparent;
  border: 0;
  font-family: var(--font-body);
}
.card-h .action:hover { text-decoration: underline; }

/* ============== KPI ============== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-5);
  position: relative;
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  font-weight: var(--weight-semibold);
  color: var(--fg-tertiary);
  margin-bottom: var(--space-3);
}
.kpi .value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  color: var(--fg-primary);
}
.kpi .unit { font-size: 18px; color: var(--fg-tertiary); font-weight: var(--weight-medium); margin-left: 3px; }
.kpi .delta {
  margin-top: var(--space-3);
  font-size: var(--text-body-sm);
  display: flex; align-items: center; gap: var(--space-2);
}
.kpi .delta.up { color: var(--success); }
.kpi .delta.down { color: var(--danger); }
.kpi .delta.neutral { color: var(--fg-tertiary); }
.kpi .accent {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 3px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* ============== BADGES ============== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  font-family: var(--font-body);
}
.badge .led { width: 6px; height: 6px; border-radius: var(--radius-full); }

.b-rojo    { background: var(--danger-bg);  color: #A8412A; }
.b-amarillo{ background: var(--warning-bg); color: #8A6A1E; }
.b-verde   { background: var(--success-bg); color: #006B56; }
.b-azul    { background: var(--secondary-10); color: var(--secondary-dark); }
.b-neutral { background: var(--bg-subtle);  color: var(--fg-secondary); }
[data-theme="dark"] .b-rojo     { background: rgba(225,112,85,0.18);  color:#F4B5A0; }
[data-theme="dark"] .b-amarillo { background: rgba(253,203,110,0.18); color:#F5D89A; }
[data-theme="dark"] .b-verde    { background: rgba(0,184,148,0.18);   color:#7CE2C6; }
[data-theme="dark"] .b-azul     { background: rgba(41,73,218,0.18);   color: var(--secondary-light); }

.b-rojo .led    { background: var(--danger); }
.b-amarillo .led{ background: var(--warning); }
.b-verde .led   { background: var(--success); }
.b-azul .led    { background: var(--secondary); }
.b-neutral .led { background: var(--fg-muted); }

/* ============== BUTTONS ============== */
.btn {
  font-family: var(--font-body);
  font-size: var(--text-body-sm);
  font-weight: var(--weight-semibold);
  padding: 9px 16px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}
.btn-primary {
  background: var(--secondary);
  color: var(--fg-on-secondary);
}
.btn-primary:hover { background: var(--secondary-dark); }
.btn-accent {
  background: var(--primary);
  color: var(--fg-on-primary);
}
.btn-accent:hover { background: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  color: var(--fg-secondary);
  border-color: var(--border-default);
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--fg-primary); }
.btn-sm { padding: 6px 12px; font-size: var(--text-body-sm); }

/* ============== ALERT CARD (treatment variants) ============== */
.alert-row {
  display: flex;
  align-items: stretch;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-out);
  margin-bottom: var(--space-3);
}
.alert-row:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }

.alert-row .stripe {
  width: 4px;
  border-radius: var(--radius-full);
  background: var(--border-default);
  flex-shrink: 0;
}
.alert-row[data-level="amarilla"] .stripe { background: var(--warning); }
.alert-row[data-level="roja"] .stripe { background: var(--danger); }
.alert-row[data-level="verde"] .stripe { background: var(--success); }

.alert-row .body { flex: 1; min-width: 0; }
.alert-row .row1 {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: 6px;
}
.alert-row .title {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: 16px;
  color: var(--fg-primary);
}
.alert-row .meta {
  font-size: var(--text-body-sm);
  color: var(--fg-tertiary);
}
.alert-row .desc {
  font-size: var(--text-body-sm);
  color: var(--fg-secondary);
}
.alert-row .stats {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-3);
}
.alert-row .stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.alert-row .stat .n {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: 18px;
  color: var(--fg-primary);
  line-height: 1;
}
.alert-row .stat .l {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--fg-tertiary);
}

/* Alert treatment variants — toggleable via data-alert-style */
[data-alert-style="subtle"] .alert-row {
  border-color: var(--border-subtle);
}
[data-alert-style="moderate"] .alert-row[data-level="amarilla"] {
  background: var(--warning-bg);
  border-color: rgba(253,203,110,0.6);
}
[data-alert-style="moderate"] .alert-row[data-level="roja"] {
  background: var(--danger-bg);
  border-color: rgba(225,112,85,0.5);
}
[data-alert-style="moderate"] .alert-row[data-level="verde"] {
  background: var(--success-bg);
  border-color: rgba(0,184,148,0.4);
}
[data-alert-style="aggressive"] .alert-row[data-level="amarilla"] {
  background: var(--warning); color: #4A3B0F;
  border-color: var(--warning);
}
[data-alert-style="aggressive"] .alert-row[data-level="amarilla"] .title,
[data-alert-style="aggressive"] .alert-row[data-level="amarilla"] .stat .n,
[data-alert-style="aggressive"] .alert-row[data-level="amarilla"] .desc {
  color: #4A3B0F;
}
[data-alert-style="aggressive"] .alert-row[data-level="amarilla"] .meta,
[data-alert-style="aggressive"] .alert-row[data-level="amarilla"] .stat .l {
  color: rgba(74,59,15,0.65);
}
[data-alert-style="aggressive"] .alert-row[data-level="roja"] {
  background: var(--danger); color: #fff;
  border-color: var(--danger);
}
[data-alert-style="aggressive"] .alert-row[data-level="roja"] .title,
[data-alert-style="aggressive"] .alert-row[data-level="roja"] .desc,
[data-alert-style="aggressive"] .alert-row[data-level="roja"] .stat .n {
  color: #fff;
}
[data-alert-style="aggressive"] .alert-row[data-level="roja"] .meta,
[data-alert-style="aggressive"] .alert-row[data-level="roja"] .stat .l {
  color: rgba(255,255,255,0.75);
}

/* ============== MAP (cards-style choropleth) ============== */
.map-wrap {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: var(--space-5);
  align-items: stretch;
}
.map-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.map-cell {
  aspect-ratio: 1.15;
  border-radius: var(--radius-xs);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-subtle);
  position: relative;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: var(--weight-medium);
  color: var(--fg-secondary);
  border: 1px solid transparent;
  transition: all 120ms;
  overflow: hidden;
}
.map-cell:hover {
  border-color: var(--secondary);
  transform: scale(1.04);
  z-index: 2;
}
.map-cell .veredita { font-size: 10px; color: inherit; opacity: 0.8; line-height: 1.1; }
.map-cell .pct { font-family: var(--font-display); font-weight: var(--weight-bold); font-size: 16px; }
.map-cell .ico {
  position: absolute; top: 4px; right: 4px;
  width: 12px; height: 12px;
  border-radius: var(--radius-full);
}

.legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-body-sm);
  color: var(--fg-secondary);
}
.legend .ramp {
  display: flex;
  height: 10px;
  border-radius: var(--radius-full);
  overflow: hidden;
}
.legend .ramp span { flex: 1; }

/* ============== TABLE ============== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-sm);
}
.tbl th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--fg-tertiary);
  font-weight: var(--weight-semibold);
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}
.tbl td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--fg-secondary);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bg-subtle); }
.tbl .strong { color: var(--fg-primary); font-weight: var(--weight-semibold); }
.tbl .mono { font-family: var(--font-mono); }

/* ============== PROGRESS ============== */
.bar {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--secondary);
  border-radius: var(--radius-full);
  transition: width 600ms var(--ease-out);
}
.bar.success > span { background: var(--success); }
.bar.warn    > span { background: var(--warning); }
.bar.danger  > span { background: var(--danger); }
.bar .meta-tick {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: var(--neutral-900);
  opacity: 0.4;
}
[data-theme="dark"] .bar .meta-tick { background: white; opacity: 0.6; }

/* ============== CHART (svg) ============== */
.chart-svg { width: 100%; height: 240px; display: block; }

/* ============== PHONE FRAME ============== */
.phone {
  width: 360px;
  height: 720px;
  background: #1A1A2E;
  border-radius: 44px;
  padding: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25), 0 4px 12px rgba(0,0,0,0.15), inset 0 0 0 2px #2D2D44;
  position: relative;
  flex-shrink: 0;
}
.phone-screen {
  width: 100%;
  height: 100%;
  background: #ECE5DD;
  border-radius: 34px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}
.phone-notch {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 110px; height: 24px;
  background: #1A1A2E;
  border-radius: 0 0 16px 16px;
  z-index: 10;
}

/* WhatsApp UI */
.wa-status {
  background: #075E54;
  color: white;
  font-size: 11px;
  font-family: -apple-system, sans-serif;
  padding: 4px 16px 2px;
  display: flex; justify-content: space-between;
  font-weight: 600;
}
.wa-header {
  background: #075E54;
  color: white;
  padding: 8px 12px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: -apple-system, sans-serif;
}
.wa-header .arrow { font-size: 18px; opacity: 0.9; }
.wa-header .ava {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--secondary);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  color: white;
  position: relative;
}
.wa-header .ava::after {
  content: '';
  width: 4px; height: 4px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute;
  bottom: 4px; right: 6px;
}
.wa-header .meta { flex: 1; line-height: 1.1; }
.wa-header .meta .name { font-weight: 600; font-size: 14px; }
.wa-header .meta .sub { font-size: 11px; opacity: 0.85; margin-top: 1px; }

.wa-body {
  flex: 1;
  background: #ECE5DD;
  background-image: 
    radial-gradient(circle at 20% 20%, rgba(7,94,84,0.04) 0%, transparent 50%),
    radial-gradient(circle at 80% 60%, rgba(7,94,84,0.04) 0%, transparent 50%);
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: -apple-system, sans-serif;
  scroll-behavior: smooth;
}
.wa-body::-webkit-scrollbar { width: 0; }

.wa-bubble {
  max-width: 78%;
  padding: 6px 10px 8px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  color: #1A1A2E;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  word-wrap: break-word;
}
.wa-bubble.in {
  align-self: flex-start;
  background: #fff;
  border-top-left-radius: 0;
}
.wa-bubble.out {
  align-self: flex-end;
  background: #DCF8C6;
  border-top-right-radius: 0;
}
.wa-bubble .time {
  font-size: 9.5px;
  color: #667;
  margin-left: 8px;
  float: right;
  margin-top: 2px;
}
.wa-bubble.out .time::after { content: ' ✓✓'; color: #4FC3F7; }

.wa-bubble.voice {
  display: flex; align-items: center; gap: 8px;
  min-width: 200px;
}
.wa-bubble.voice .play {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--secondary);
  color: white;
  display: grid; place-items: center;
  font-size: 11px;
  flex-shrink: 0;
}
.wa-bubble.voice .waveform {
  flex: 1;
  height: 24px;
  background: linear-gradient(to right,
    #999 0, #999 1px, transparent 1px, transparent 3px) repeat-x;
  background-size: 4px 24px;
  position: relative;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 24'><path d='M0 12 L4 8 L8 14 L12 6 L16 16 L20 10 L24 12 L28 4 L32 18 L36 8 L40 14 L44 10 L48 16 L52 6 L56 12 L60 8 L64 14 L68 10 L72 12 L76 4 L80 16 L84 8 L88 14 L92 10 L96 12 L100 12' stroke='black' fill='none' stroke-width='2'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 24'><path d='M0 12 L4 8 L8 14 L12 6 L16 16 L20 10 L24 12 L28 4 L32 18 L36 8 L40 14 L44 10 L48 16 L52 6 L56 12 L60 8 L64 14 L68 10 L72 12 L76 4 L80 16 L84 8 L88 14 L92 10 L96 12 L100 12' stroke='black' fill='none' stroke-width='2'/></svg>");
}
.wa-bubble.voice .dur {
  font-size: 11px; color: #667;
}

.wa-quickreply {
  display: flex; flex-direction: column; gap: 1px;
  margin-top: 6px;
  border-top: 1px solid rgba(0,0,0,0.06);
  margin-left: -10px; margin-right: -10px; margin-bottom: -8px;
}
.wa-quickreply button {
  background: transparent;
  border: 0;
  border-top: 1px solid rgba(0,0,0,0.06);
  padding: 8px;
  font-size: 12.5px;
  color: var(--secondary);
  font-weight: 600;
  cursor: pointer;
  font-family: -apple-system, sans-serif;
  display: flex; align-items: center; justify-content: center;
  gap: 4px;
}
.wa-quickreply button:first-child { border-top: 0; }
.wa-quickreply button:hover { background: rgba(0,0,0,0.03); }

.wa-input {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px;
  background: transparent;
}
.wa-input .field {
  flex: 1;
  background: white;
  border-radius: 20px;
  padding: 8px 12px;
  font-size: 13px;
  color: #888;
  font-family: -apple-system, sans-serif;
  display: flex; align-items: center; gap: 8px;
}
.wa-input-field {
  flex: 1;
  background: white;
  border-radius: 20px;
  border: 0;
  outline: 0;
  padding: 9px 14px;
  font-size: 13.5px;
  color: #1A1A2E;
  font-family: -apple-system, sans-serif;
}
.wa-input-area { background: transparent; }
.wa-input .ico-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #075E54;
  color: white;
  display: grid; place-items: center;
  font-size: 16px;
  flex-shrink: 0;
  border: 0; cursor: pointer;
}
.wa-input .ico-btn:hover { background: #0a7a6c; }

/* Voice press-and-hold */
.wa-voice-press {
  width: calc(100% - 16px);
  margin: 6px 8px;
  height: 44px;
  background: white;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 22px;
  padding: 0 14px;
  font-family: -apple-system, sans-serif;
  font-size: 12.5px;
  color: #555;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  user-select: none;
  transition: all 160ms ease;
}
.wa-voice-press:hover { background: #f5f5f5; }
.wa-voice-press.rec {
  background: #075E54;
  color: white;
  border-color: #075E54;
}
.wa-voice-pulse {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  animation: voicePulse 0.9s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(1.4); }
}

/* End tag in chat */
.wa-end-tag {
  align-self: center;
  background: rgba(0,0,0,0.06);
  color: #555;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-family: -apple-system, sans-serif;
  margin: 12px 0 4px;
}

/* Phone stage (phone + restart button) */
.phone-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.phone-restart {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--fg-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-family: var(--font-body);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 160ms;
}
.phone-restart:hover { background: var(--bg-subtle); color: var(--fg-primary); border-color: var(--secondary); }

.wa-typing {
  align-self: flex-start;
  display: flex; gap: 3px;
  padding: 10px 12px;
  background: white;
  border-radius: 8px;
  border-top-left-radius: 0;
}
.wa-typing span {
  width: 6px; height: 6px;
  border-radius: 50%; background: #999;
  animation: typing 1.4s infinite;
}
.wa-typing span:nth-child(2) { animation-delay: 0.2s; }
.wa-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ============== SPLIT VIEW ============== */
.split {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-6);
  align-items: start;
}

/* ============== ICON ============== */
.icon { width: 18px; height: 18px; stroke-width: 1.75; stroke: currentColor; fill: none; flex-shrink: 0; }
.icon.sm { width: 14px; height: 14px; }
.icon.lg { width: 24px; height: 24px; }

/* ============== UTIL ============== */
.row { display: flex; align-items: center; gap: var(--space-3); }
.row.gap-2 { gap: var(--space-2); }
.row.gap-4 { gap: var(--space-4); }
.col { display: flex; flex-direction: column; gap: var(--space-3); }
.muted { color: var(--fg-tertiary); }
.mono { font-family: var(--font-mono); }
.sep { height: 1px; background: var(--border-subtle); margin: var(--space-4) 0; }
.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--fg-tertiary);
  font-weight: var(--weight-semibold);
}

/* dense */
[data-density="compact"] .kpi { padding: var(--space-3) var(--space-4); }
[data-density="compact"] .card { padding: var(--space-4); }
[data-density="compact"] .kpi .value { font-size: 26px; }
[data-density="compact"] .es-page { padding: var(--space-4); }

/* fade-in on screen change (disabled — caused opacity:0 stick under html-to-image) */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* tweaks-panel positioning override (uses tweak-panel root from starter) */
.tweaks-panel { z-index: 99; }

/* prediction chart background grid */
.grid-bg {
  background-image:
    linear-gradient(var(--border-subtle) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-subtle) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: -1px -1px;
}

/* Onboarding wizard */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.wizard-steps .step {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-body-sm);
  color: var(--fg-tertiary);
}
.wizard-steps .step.active { background: var(--secondary-10); color: var(--secondary-dark); font-weight: 600; }
.wizard-steps .step.done { color: var(--success); }
.wizard-steps .step .num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-subtle);
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
}
.wizard-steps .step.active .num { background: var(--secondary); color: white; }
.wizard-steps .step.done .num { background: var(--success); color: white; }
.wizard-steps .conn {
  flex: 1; height: 1px; background: var(--border-default);
}

/* tag */
.tag {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: var(--weight-medium);
  font-family: var(--font-mono);
}

/* ============== TOASTS ============== */
.toast-stack {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
  max-width: 480px;
}
.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-3);
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 320px;
  pointer-events: auto;
  animation: toastIn 280ms var(--ease-out) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast-ico {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--secondary-10); color: var(--secondary);
}
.toast-success .toast-ico { background: var(--success-bg); color: var(--success); }
.toast-warning .toast-ico { background: var(--warning-bg); color: #8A6A1E; }
.toast-danger  .toast-ico { background: var(--danger-bg);  color: var(--danger); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13.5px; font-weight: 600; color: var(--fg-primary); }
.toast-desc { font-size: 12px; color: var(--fg-secondary); margin-top: 2px; }
.toast-close {
  background: transparent; border: 0; cursor: pointer;
  color: var(--fg-tertiary); font-size: 18px; line-height: 1;
  padding: 0 4px; align-self: flex-start;
}
.toast-close:hover { color: var(--fg-primary); }

/* ============== MODAL ============== */
.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: 1000;
  display: grid; place-items: center;
  animation: fadeBg 180ms ease;
}
@keyframes fadeBg { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-4);
  max-height: 86vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn 200ms var(--ease-out) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-h {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
}
.modal-title {
  font-family: var(--font-display);
  font-weight: var(--weight-semibold);
  font-size: 17px;
  letter-spacing: var(--tracking-tight);
  color: var(--fg-primary);
}
.modal-sub { font-size: 13px; color: var(--fg-tertiary); margin-top: 2px; }
.modal-x {
  background: transparent; border: 0; padding: 4px;
  cursor: pointer; color: var(--fg-tertiary);
  border-radius: var(--radius-xs);
}
.modal-x:hover { background: var(--bg-subtle); color: var(--fg-primary); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-f {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ============== POPOVER ============== */
.popover {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-3);
  padding: 12px;
  z-index: 800;
  font-size: 12.5px;
  animation: popIn 160ms var(--ease-out) both;
}
@keyframes popIn { from { opacity:0; transform: translate(-50%, -2px); } to { opacity:1; } }
.pop-arrow {
  position: absolute;
  width: 10px; height: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transform: rotate(45deg);
  left: 50%; margin-left: -5px;
}
.pop-arrow.bottom { top: -6px; border-bottom: 0; border-right: 0; }
.pop-arrow.top    { bottom: -6px; border-top: 0; border-left: 0; }

/* ============== KEBAB MENU ============== */
.kebab-btn {
  width: 28px; height: 28px;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--fg-tertiary);
  display: grid; place-items: center;
  font-size: 16px;
  line-height: 1;
}
.kebab-btn:hover { background: var(--bg-subtle); color: var(--fg-primary); }
.kebab-menu {
  position: fixed;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-3);
  padding: 4px;
  min-width: 200px;
  z-index: 900;
  animation: popIn 140ms var(--ease-out) both;
}
.kebab-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg-secondary);
  border-radius: var(--radius-xs);
  font-family: var(--font-body);
  text-align: left;
}
.kebab-item:hover { background: var(--bg-subtle); color: var(--fg-primary); }
.kebab-item.danger { color: var(--danger); }
.kebab-item.danger:hover { background: var(--danger-bg); }
.kebab-ico { width: 16px; height: 16px; display: grid; place-items: center; color: inherit; }
.kebab-ico svg { width: 16px; height: 16px; stroke: currentColor; }
.kebab-sc { margin-left: auto; font-size: 11px; color: var(--fg-muted); font-family: var(--font-mono); }
.kebab-sep { height: 1px; background: var(--border-subtle); margin: 4px 2px; }

/* ============== DROPDOWN ============== */
.dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-3);
  padding: 4px;
  z-index: 600;
  animation: popIn 140ms var(--ease-out) both;
}
.dropdown-h {
  padding: 8px 10px 6px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px;
  color: var(--fg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}
.dropdown-h .action {
  font-size: 11px; color: var(--secondary);
  background: transparent; border: 0; cursor: pointer;
  font-family: var(--font-body); font-weight: 500;
}
.dropdown-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--fg-secondary);
  border-radius: var(--radius-xs);
  text-align: left;
  font-family: var(--font-body);
}
.dropdown-item:hover { background: var(--bg-subtle); color: var(--fg-primary); }
.dropdown-item.active { background: var(--secondary-10); color: var(--secondary-dark); }
[data-theme="dark"] .dropdown-item.active { background: rgba(41,73,218,0.18); color: var(--secondary-light); }

/* ============== COMMAND PALETTE ============== */
.cmd {
  width: 600px;
  max-width: 92vw;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-4);
  overflow: hidden;
  animation: modalIn 200ms var(--ease-out) both;
}
.cmd-input {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.cmd-input input {
  flex: 1;
  border: 0; outline: 0;
  background: transparent;
  font-size: 16px;
  color: var(--fg-primary);
  font-family: var(--font-body);
}
.cmd-input input::placeholder { color: var(--fg-muted); }
.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  color: var(--fg-tertiary);
  text-transform: uppercase;
}
.cmd-list {
  max-height: 380px;
  overflow-y: auto;
  padding: 6px;
}
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  cursor: pointer;
  border-radius: var(--radius-xs);
  text-align: left;
  font-family: var(--font-body);
}
.cmd-item.active { background: var(--secondary-10); }
[data-theme="dark"] .cmd-item.active { background: rgba(41,73,218,0.18); }
.cmd-ico {
  width: 32px; height: 32px;
  background: var(--bg-subtle);
  border-radius: var(--radius-xs);
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--fg-secondary);
}
.cmd-item.active .cmd-ico { background: var(--secondary); color: white; }
.cmd-text { flex: 1; min-width: 0; }
.cmd-label { font-size: 13.5px; font-weight: 500; color: var(--fg-primary); }
.cmd-section { font-size: 11px; color: var(--fg-tertiary); margin-top: 2px; }
.cmd-empty { padding: 32px; text-align: center; color: var(--fg-tertiary); font-size: 13px; }
.cmd-foot {
  padding: 8px 14px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex; gap: 16px;
  font-size: 11px; color: var(--fg-tertiary);
}
.cmd-foot .kbd { background: var(--bg-surface); }

/* ============== ICONBTN (topbar) ============== */
.iconbtn {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--fg-secondary);
  display: grid; place-items: center;
  position: relative;
}
.iconbtn:hover { background: var(--bg-subtle); color: var(--fg-primary); }
.iconbtn-dot {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  background: var(--danger);
  color: white;
  border-radius: var(--radius-full);
  font-size: 9px;
  font-weight: 700;
  display: grid; place-items: center;
  padding: 0 4px;
  border: 2px solid var(--bg-surface);
  font-family: var(--font-mono);
}

/* ============== NOTIF ITEM ============== */
.notif {
  width: 100%;
  display: flex; gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-xs);
  align-items: flex-start;
  font-family: var(--font-body);
}
.notif:hover { background: var(--bg-subtle); }
.notif-led {
  width: 8px; height: 8px; margin-top: 6px;
  border-radius: var(--radius-full); flex-shrink: 0;
}
.notif-led.warning { background: var(--warning); }
.notif-led.danger  { background: var(--danger); }
.notif-led.success { background: var(--success); }
.notif-led.info    { background: var(--secondary); }
.notif-title { font-size: 13px; font-weight: 600; color: var(--fg-primary); }
.notif-desc  { font-size: 12px; color: var(--fg-secondary); margin-top: 2px; }
.notif-time  { font-size: 10.5px; color: var(--fg-muted); margin-top: 4px; font-family: var(--font-mono); }
.notif-unread {
  width: 7px; height: 7px;
  background: var(--secondary);
  border-radius: var(--radius-full);
  flex-shrink: 0; margin-top: 8px;
}

/* ============== PRESENCE ============== */
.presence { display: flex; }
.presence-ava {
  width: 24px; height: 24px;
  border-radius: var(--radius-full);
  background: var(--secondary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid var(--bg-surface);
  margin-left: -6px;
  font-family: var(--font-body);
}
.presence-ava:first-child { margin-left: 0; }
.presence-ava.more {
  background: var(--bg-subtle);
  color: var(--fg-tertiary);
  font-size: 9px;
}

/* ============== KPI hover + sparkline ============== */
.kpi.clickable { cursor: pointer; transition: all 180ms var(--ease-out); }
.kpi.clickable:hover {
  border-color: var(--secondary);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
.kpi-spark {
  position: absolute;
  right: var(--space-5); bottom: var(--space-5);
  opacity: 0.85;
  pointer-events: none;
}
.kpi-info {
  position: absolute;
  top: var(--space-4); right: var(--space-4);
  color: var(--fg-muted);
  width: 14px; height: 14px;
}

/* ============== ALERT ROW QUICK ACTIONS ============== */
.alert-row {
  position: relative;
}
.alert-actions {
  position: absolute;
  top: 12px; right: 12px;
  display: flex; gap: 4px;
  opacity: 0;
  transition: opacity 150ms var(--ease-out);
}
.alert-wrap:hover .alert-actions { opacity: 1; }
.alert-row .row1 {
  padding-right: 80px; /* leave space for hover actions */
}

/* ============== FEED — new item flash ============== */
.feed-new {
  animation: flashIn 700ms var(--ease-out) both;
}
@keyframes flashIn {
  0% { opacity: 0; transform: translateX(-8px); background: rgba(41,73,218,0.12); }
  60% { background: rgba(41,73,218,0.08); }
  100% { opacity: 1; transform: translateX(0); background: transparent; }
}
.feed-pause-btn {
  font-size: 11px;
  color: var(--fg-tertiary);
  background: var(--bg-subtle);
  border: 0;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: var(--font-body);
}
.feed-pause-btn:hover { color: var(--fg-primary); }

/* ============== SKELETON / REFRESH ============== */
.refresh-spin {
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* small action button in card */
.btn-mini {
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  border: 0;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 500;
}
.btn-mini:hover { background: var(--secondary-10); color: var(--secondary-dark); }

/* ============== DRAWER ============== */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: 950;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -10px 0 30px rgba(26,26,46,0.18);
  z-index: 960;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 280ms var(--ease-out);
  max-width: 90vw;
}
.drawer.open { transform: translateX(0); }

.reporte-clickable:hover > div { background: var(--bg-subtle); }
.action-btn:hover {
  border-color: var(--secondary) !important;
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

/* persona pill */
.persona-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--fg-primary);
  transition: all 140ms;
}
.persona-pill:hover { background: var(--bg-surface); border-color: var(--border-strong); }

/* ============== FILTER CHIPS ============== */
.chip-group {
  display: inline-flex;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
}
.chip {
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 5px 11px;
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--fg-tertiary);
  border-radius: var(--radius-full);
  transition: all 120ms;
}
.chip:hover { color: var(--fg-primary); }
.chip.active {
  background: var(--bg-surface);
  color: var(--secondary-dark);
  box-shadow: var(--shadow-1);
}
[data-theme="dark"] .chip.active { color: var(--secondary-light); }

/* ============== BULK BAR ============== */
.bulk-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--neutral-900);
  color: white;
  padding: 8px 14px 8px 16px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-4);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  z-index: 800;
  animation: toastIn 240ms var(--ease-out) both;
}
.bulk-bar .btn-ghost {
  background: transparent;
  color: white;
  border-color: rgba(255,255,255,0.18);
}
.bulk-bar .btn-ghost:hover { background: rgba(255,255,255,0.1); color: white; }
.bulk-bar .btn-accent { background: var(--primary); color: white; }

/* ============== ALERT STATUS PILL (on list rows) ============== */
.alert-status-pill {
  position: absolute;
  bottom: 14px;
  right: 14px;
  display: flex;
  align-items: center;
}

/* ============== STATUS STEPPER ============== */
.status-stepper {
  display: flex;
  align-items: stretch;
  gap: 0;
}
.stepper-node {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 4px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 140ms;
}
.stepper-node:hover { transform: translateY(-1px); }
.stepper-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-display);
  transition: all 180ms;
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 1px var(--border-default);
}
.stepper-node.current .stepper-dot {
  box-shadow: 0 0 0 3px rgba(41,73,218,0.18);
}
.stepper-label {
  text-align: center;
  max-width: 140px;
}
.stepper-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-primary);
  margin-bottom: 2px;
}
.stepper-node:not(.current):not(.past) .stepper-name { color: var(--fg-tertiary); }
.stepper-desc {
  font-size: 10.5px;
  color: var(--fg-tertiary);
  line-height: 1.3;
}
.stepper-line {
  flex: 0 0 30px;
  height: 1px;
  margin-top: 18px;
  background: var(--border-default);
  align-self: flex-start;
}
.stepper-line.past { background: var(--success); }

/* ============== KANBAN ============== */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
  margin-top: var(--space-2);
}
.kanban-col {
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  min-height: 360px;
}
.kanban-col-h {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}
.kanban-col-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  cursor: pointer;
  position: relative;
  transition: all 140ms;
}
.kanban-card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
  border-color: var(--secondary);
}
.kanban-move {
  position: absolute;
  top: 6px; right: 6px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 140ms;
}
.kanban-card:hover .kanban-move { opacity: 1; }
.kanban-move button {
  width: 20px; height: 20px;
  background: var(--bg-subtle);
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  color: var(--fg-secondary);
}
.kanban-move button:hover { background: var(--secondary); color: white; }

/* ============== ACCION ROW (workflow) ============== */
.accion-row {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius-xs);
  align-items: flex-start;
}
.accion-num {
  width: 26px; height: 26px;
  background: var(--secondary);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ============== link button ============== */
.link-btn {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--secondary);
  font-size: 11px;
  font-family: var(--font-body);
  font-weight: 500;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

/* ============== ADMIN: agent row ============== */
.agent-row {
  display: grid;
  grid-template-columns: 36px 2fr 1fr 1fr 1fr 1fr 100px 28px;
  gap: var(--space-3);
  padding: 12px var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  align-items: center;
  transition: background 120ms;
}
.agent-row:hover { background: var(--bg-subtle); }
.agent-row:last-child { border-bottom: 0; }
.agent-ico {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
}

/* ============== ADMIN: connection card ============== */
.conn-card {
  background: var(--bg-surface);
  padding: 14px;
  cursor: pointer;
  transition: all 140ms;
}
.conn-card:hover { background: var(--bg-subtle); transform: translateY(-1px); }
.conn-ico {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--secondary-10);
  color: var(--secondary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

/* ============== HISTORIA: paciente row ============== */
.paciente-row {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 120ms;
}
.paciente-row:hover { background: var(--bg-subtle); }
.paciente-row:last-child { border-bottom: 0; }

/* ============== BRIGADAS ============== */
.brigada-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: all 160ms var(--ease-out);
}
.brigada-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--secondary);
}
.brigada-avatar {
  width: 44px; height: 44px;
  border-radius: 10px;
  color: white;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

/* Brigade pill in map sidebar */
.brigada-pill {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 140ms;
}
.brigada-pill:hover { border-color: var(--secondary); background: var(--bg-surface); }

/* MAP */
.map-container {
  position: relative;
  background: var(--bg-subtle);
  border-radius: 8px;
  padding: 12px;
  min-height: 480px;
}
.map-bg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  min-height: 460px;
}
.map-zone {
  position: relative;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  padding: 8px;
  font-family: var(--font-body);
  background: var(--bg-surface);
}
.zona-alta    { background: #E6F0FA; }
.zona-media   { background: #FBF6E9; }
.zona-baja    { background: #F8E8E2; }
.zona-urbana  { background: var(--bg-surface); border: 1.5px solid var(--secondary); }
[data-theme="dark"] .zona-alta { background: rgba(116,185,255,0.10); }
[data-theme="dark"] .zona-media { background: rgba(253,203,110,0.10); }
[data-theme="dark"] .zona-baja { background: rgba(225,112,85,0.10); }
.map-zone-name {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--fg-secondary);
  line-height: 1.2;
}
.map-zone-tag {
  position: absolute;
  top: 4px; right: 4px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--secondary);
  background: var(--secondary-10);
  padding: 1px 6px;
  border-radius: 3px;
}
.map-brigada-pin {
  position: absolute;
  bottom: 6px; left: 6px;
  width: 30px; height: 30px;
  border-radius: 50%;
  color: white;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-display);
  display: grid;
  place-items: center;
  cursor: pointer;
  border: 2px solid var(--success);
  box-shadow: var(--shadow-2);
  transition: all 140ms;
}
.map-brigada-pin:hover { transform: scale(1.15); box-shadow: var(--shadow-3); z-index: 10; }
.pin-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0.6;
  animation: pinPulse 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes pinPulse {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(1.8); opacity: 0; }
}
.map-routes {
  position: absolute;
  inset: 12px;
  pointer-events: none;
}

/* OPERATIVOS calendar */
.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-top: 4px;
}
.cal-col {
  background: var(--bg-subtle);
  border-radius: 6px;
  padding: 8px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
.cal-col.today {
  background: var(--secondary-10);
  border: 1px solid var(--secondary);
}
.cal-h {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-secondary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cal-h-today {
  font-size: 9px;
  background: var(--secondary);
  color: white;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.cal-body { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.cal-empty { color: var(--fg-muted); font-size: 11px; text-align: center; padding: 12px 0; }
.cal-op {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--secondary);
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: all 140ms;
}
.cal-op:hover {
  border-color: var(--secondary);
  box-shadow: var(--shadow-1);
}
.cal-op-time { font-size: 9.5px; color: var(--fg-tertiary); }
.cal-op-title { font-size: 11px; font-weight: 600; color: var(--fg-primary); margin-top: 2px; }
.cal-op-sub { font-size: 10px; margin-top: 1px; }

/* OPERATIVO row */
.op-row {
  display: flex; gap: 12px;
  width: 100%;
  padding: 12px;
  background: var(--bg-subtle);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  align-items: center;
  transition: all 140ms;
}
.op-row:hover { background: var(--bg-surface); box-shadow: var(--shadow-1); }

/* ============== LOGIN ============== */
.login-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100vw; height: 100vh;
  background: var(--bg-canvas);
}
.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 80px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}
.login-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 40px;
}
.login-mark {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--secondary);
  color: white;
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.04em;
  position: relative;
}
.login-mark::after {
  content: '';
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute;
  bottom: 8px; right: 8px;
}
.login-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  color: var(--fg-primary);
  line-height: 1;
}
.login-sub {
  font-size: 11px;
  color: var(--fg-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}
.login-personas {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-persona {
  display: flex; align-items: center; gap: 12px;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  cursor: pointer;
  transition: all 140ms;
  font-family: var(--font-body);
}
.login-persona:hover {
  border-color: var(--secondary);
  box-shadow: var(--shadow-2);
  transform: translateX(2px);
}
.login-back {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  color: var(--fg-tertiary);
  padding: 0;
  font-family: var(--font-body);
  align-self: flex-start;
}
.login-back:hover { color: var(--secondary); }
.login-foot {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  color: var(--fg-tertiary);
}
.login-error {
  padding: 10px 12px;
  background: var(--danger-bg);
  color: #A8412A;
  border-radius: 4px;
  font-size: 12px;
}
.login-2fa {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}
.login-2fa input {
  width: 48px; height: 60px;
  text-align: center;
  font-size: 22px;
  font-family: var(--font-mono);
  font-weight: 600;
  border: 2px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--fg-primary);
  outline: none;
  transition: all 120ms;
}
.login-2fa input:focus { border-color: var(--secondary); box-shadow: var(--shadow-focus); }

.login-side {
  background: linear-gradient(135deg, #1F34A0 0%, #2949DA 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 60px;
  position: relative;
  overflow: hidden;
}
.login-side::before {
  content: '';
  position: absolute;
  top: -150px; right: -150px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(228,135,59,0.18), transparent 70%);
  pointer-events: none;
}
.login-side-content { position: relative; z-index: 1; }
.login-side-foot { position: relative; z-index: 1; }
.login-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 40px;
  max-width: 480px;
}
.login-stats .n {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: white;
  line-height: 1;
  margin-bottom: 6px;
}
.login-stats .l {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
@keyframes loadBar {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* ============== PIPELINES ============== */
.uc-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.uc-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  transition: all 140ms;
}
.uc-tab:hover { border-color: var(--border-default); }
.uc-tab.active { background: var(--bg-surface); box-shadow: var(--shadow-2); }

.pipeline {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  padding: 8px 4px 12px;
  scrollbar-width: thin;
}
.pipeline-node {
  flex-shrink: 0;
  width: 160px;
  min-height: 130px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: all 180ms;
  font-family: var(--font-body);
}
.pipeline-node:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
  border-color: var(--secondary);
}
.pipeline-node.selected {
  border-width: 2.5px;
  box-shadow: var(--shadow-3);
}
.pipeline-node.active {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(228,135,59,0.20), var(--shadow-3);
  animation: nodePulse 900ms ease-in-out;
}
.pipeline-node.past {
  background: var(--bg-subtle);
  opacity: 0.85;
}
@keyframes nodePulse {
  0%, 100% { transform: translateY(-2px) scale(1); }
  50%      { transform: translateY(-3px) scale(1.04); }
}
.pipeline-num {
  position: absolute;
  top: -8px; left: 10px;
  width: 22px; height: 22px;
  background: var(--neutral-900);
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.pipeline-ico {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  margin-top: 4px;
}
.pipeline-content { flex: 1; }
.pipeline-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}
.pipeline-agent {
  font-size: 11px;
  color: var(--fg-secondary);
  line-height: 1.2;
}
.pipeline-dur {
  font-size: 10px;
  color: var(--fg-tertiary);
  margin-top: 4px;
}
.pipeline-decision {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--warning);
}
.pipeline-arrow {
  display: flex;
  align-items: center;
  color: var(--fg-muted);
  flex-shrink: 0;
}
.pipeline-arrow.past { color: var(--primary); }

/* timeline */
.tl {
  position: relative;
  padding-left: 22px;
}
.tl::before {
  content: '';
  position: absolute;
  left: 7px; top: 4px; bottom: 4px;
  width: 1px; background: var(--border-default);
}
.tl-item { position: relative; padding-bottom: var(--space-4); }
.tl-item::before {
  content: '';
  position: absolute; left: -19px; top: 4px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--secondary);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 1px var(--border-default);
}
.tl-item.warn::before { background: var(--warning); }
.tl-item.danger::before { background: var(--danger); }
.tl-item.success::before { background: var(--success); }
.tl-item .meta { font-size: 11px; color: var(--fg-tertiary); }
.tl-item .text { font-size: var(--text-body-sm); color: var(--fg-primary); margin-top: 2px; }
