/* ==========================================================================
   Vértice · Agente Electoral
   ========================================================================== */
:root {
  --bg: #07080B;
  --bg-2: #0D1015;
  --surface: #12161C;
  --surface-2: #181D25;
  --surface-3: #202632;
  --line: rgba(255, 255, 255, .075);
  --line-2: rgba(255, 255, 255, .13);
  --ink: #EDF0F4;
  --ink-2: #AEB6C2;
  --muted: #6E7887;
  --accent: #22B5EE;
  --accent-2: #8BDDFF;
  --accent-soft: rgba(34, 181, 238, .14);
  --warn: #E3A040;
  --warn-soft: rgba(227, 160, 64, .14);
  --mid: #6C7482;
  --silver: linear-gradient(135deg, #F4F6F9 0%, #A3ABB6 48%, #E3E7EC 100%);
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 11px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Sora', 'Inter', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 520px at 50% -180px, rgba(34, 181, 238, .16), transparent 70%),
    radial-gradient(600px 400px at 100% 100%, rgba(140, 160, 190, .06), transparent 70%);
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
svg { width: 20px; height: 20px; display: block; }
b, strong { font-weight: 650; color: #fff; }

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; gap: 30px;
  background: var(--bg); transition: opacity .5s ease, visibility .5s;
}
.splash img { width: 150px; filter: drop-shadow(0 10px 40px rgba(34, 181, 238, .25)); animation: rise .9s cubic-bezier(.2, .8, .2, 1) both; }
.splash-bar { width: 120px; height: 2px; border-radius: 2px; background: var(--line); overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; background: var(--accent); animation: load 1s ease-in-out infinite; }
.splash.hide { opacity: 0; visibility: hidden; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- Layout ---------- */
.app {
  position: relative; z-index: 1; height: 100%; max-width: 780px; margin: 0 auto;
  display: flex; flex-direction: column;
}
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: linear-gradient(var(--bg) 40%, rgba(7, 8, 11, 0));
  position: relative; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; object-fit: contain; padding: 6px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.brand-name { font: 600 16.5px/1.15 var(--display); letter-spacing: .01em; }
.brand-name span { color: var(--muted); font-weight: 500; }
.brand-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-status i { width: 7px; height: 7px; border-radius: 50%; background: #3DDC97; box-shadow: 0 0 0 3px rgba(61, 220, 151, .15); flex: none; }
.brand-status.busy i { background: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); transition: .2s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); }
.icon-btn.on { color: var(--accent); border-color: rgba(34, 181, 238, .35); background: var(--accent-soft); }
#btnInstall { color: var(--bg); background: var(--silver); border: 0; }

.scroll { position: relative; flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 16px 18px; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.scroll::-webkit-scrollbar { width: 0; }

/* ---------- Bienvenida ---------- */
.welcome { text-align: center; padding: 18px 0 8px; animation: rise .7s .15s both; }
/* Botón principal: ocupa la mitad de la pantalla en vertical */
.orb-hero {
  --d: min(72vw, 36vh, 340px);
  position: relative; display: grid; place-items: center; width: 100%;
  height: 50vh; height: 50svh; min-height: 300px; margin: -8px auto 10px;
}
.orb-core {
  position: relative; z-index: 2; width: var(--d); height: var(--d); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--d) * .07);
  background: radial-gradient(circle at 35% 28%, #2A323F, #0E1116 70%);
  border: 1px solid rgba(34, 181, 238, .35);
  box-shadow: 0 0 90px rgba(34, 181, 238, .35), 0 0 0 10px rgba(34, 181, 238, .05), inset 0 1px 0 rgba(255, 255, 255, .1);
  animation: heartbeat 2.4s ease-in-out infinite; transition: transform .2s;
}
.orb-core img { width: 46%; filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .55)); }
.orb-cta {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 30px;
  font-size: clamp(12.5px, 3.6vw, 15px); font-weight: 600; color: #04121A; background: var(--accent);
  box-shadow: 0 6px 20px rgba(34, 181, 238, .4);
}
.orb-cta svg { width: 16px; height: 16px; }
.orb-hero:active .orb-core { transform: scale(.96); }
.orb-ring {
  position: absolute; left: 50%; top: 50%; width: var(--d); height: var(--d); margin: calc(var(--d) / -2) 0 0 calc(var(--d) / -2);
  border-radius: 50%; border: 2px solid rgba(34, 181, 238, .45); animation: pulseBig 3s ease-out infinite;
}
.orb-ring.r2 { animation-delay: 1s; }
.orb-ring.r3 { animation-delay: 2s; }
@keyframes pulseBig { from { transform: scale(.95); opacity: .9; } to { transform: scale(1.38); opacity: 0; } }
@keyframes heartbeat { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.045); } 24% { transform: scale(1); } 36% { transform: scale(1.03); } 48% { transform: scale(1); } }
@keyframes pulse { from { transform: scale(.8); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
.hello { margin: 0 0 4px; color: var(--accent-2); font-weight: 500; font-size: 14px; letter-spacing: .02em; }
.welcome h1 { margin: 0 0 22px; font: 600 clamp(24px, 6.4vw, 31px)/1.18 var(--display); letter-spacing: -.015em; }
/* ---------- Conversación ---------- */
.thread { display: flex; flex-direction: column; gap: 18px; padding-top: 6px; }
.msg { display: flex; gap: 10px; animation: rise .35s ease both; }
.msg.user { justify-content: flex-end; }
.bubble-user {
  max-width: 84%; padding: 10px 15px; border-radius: 20px 20px 6px 20px;
  background: var(--surface-3); border: 1px solid var(--line-2); font-size: 15px;
}
.bubble-user .via { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); margin-top: 3px; justify-content: flex-end; }
.bubble-user .via svg { width: 12px; height: 12px; }
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); margin-top: 2px;
}
.avatar img { width: 18px; }
.agent-body { flex: 1; min-width: 0; }
.agent-text { font-size: 15px; color: var(--ink); }
.agent-text p { margin: 0 0 10px; }
.agent-text p:last-child { margin-bottom: 0; }
.agent-text ul, .agent-text ol { margin: 0 0 10px; padding-left: 20px; }
.agent-text li { margin: 3px 0; }
.agent-text li::marker { color: var(--accent); }

.steps { display: flex; flex-direction: column; gap: 7px; padding: 4px 0; }
.step { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--muted); opacity: 0; animation: rise .3s forwards; }
.step .dot { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; flex: none; }
.step.run .dot { border-color: var(--accent); border-top-color: transparent; animation: spin .7s linear infinite; }
.step.ok { color: var(--ink-2); }
.step.ok .dot { border: 0; background: var(--accent-soft); color: var(--accent); }
.step.ok .dot svg { width: 11px; height: 11px; }
@keyframes spin { to { transform: rotate(360deg); } }

.blocks { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.blocks > * { animation: rise .45s ease both; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 14px 12px; }
.card-title { font: 600 13px/1.3 var(--font); color: var(--ink-2); margin: 0 0 12px; display: flex; justify-content: space-between; gap: 10px; }
.card-title small { color: var(--muted); font-weight: 500; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 11px 12px; position: relative; overflow: hidden; }
.kpi .l { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.kpi .v { font: 600 21px/1.2 var(--display); font-variant-numeric: tabular-nums; margin-top: 3px; }
.kpi.good .v { color: var(--accent-2); }
.kpi.warn .v { color: var(--warn); }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

.bars { display: flex; flex-direction: column; gap: 9px; position: relative; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 54px; gap: 3px 10px; align-items: center; padding: 2px 0; border-radius: 8px; position: relative; }
.bar[data-sec] { cursor: pointer; }
.bar[data-sec]:hover .bar-label { color: var(--ink); }
.bar-label { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; justify-content: space-between; gap: 8px; }
.bar-label em { font-style: normal; color: var(--muted); font-size: 11px; flex: none; }
.bar-track { height: 9px; background: var(--surface-3); border-radius: 0 4px 4px 0; position: relative; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); width: 0; transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.bar-fill.muted { background: var(--mid); }
.bar-fill.outline { background: transparent; border: 1.5px dashed var(--accent-2); }
.bar-val { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.bar-avg { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1.5px dashed var(--warn); }
.avg-note { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.avg-note i { width: 14px; border-top: 1.5px dashed var(--warn); }
.bars.compact .bar { grid-template-columns: 40px minmax(0, 1fr) 54px; }
.bars.compact .bar-label { grid-column: auto; }

.tbl-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 8px 0; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; color: var(--ink-2); }
.tbl td:first-child { color: var(--ink); font-weight: 600; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr[data-sec] { cursor: pointer; }
.tbl tr[data-sec]:hover td { color: var(--ink); background: rgba(255, 255, 255, .02); }
.more { margin-top: 8px; font-size: 12.5px; font-weight: 600; color: var(--accent-2); padding: 4px 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.g { color: var(--accent-2); background: var(--accent-soft); }
.badge.c { color: #C3C9D2; background: rgba(160, 170, 185, .12); }
.badge.d { color: var(--warn); background: var(--warn-soft); }

.insights { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.insights li { display: flex; gap: 10px; font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.insights li::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); margin-top: 8px; transform: rotate(45deg); }

/* Mapa */
.map-svg { width: 100%; height: auto; display: block; }
.map-svg .hex { stroke: var(--bg-2); stroke-width: 2; cursor: pointer; transition: opacity .2s, transform .2s; transform-box: fill-box; transform-origin: center; }
.map-svg .hex:hover, .map-svg .hex.sel { stroke: #fff; stroke-width: 1.5; }
.map-svg.dim .hex:not(.sel) { opacity: .45; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 11.5px; color: var(--ink-2); align-items: center; }
.map-legend .sw { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.map-legend .ramp { width: 110px; height: 8px; border-radius: 4px; }
.map-info { margin-top: 10px; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); }
.map-info b { color: var(--ink); }
.map-note { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* Ruta */
.route { position: relative; display: flex; flex-direction: column; gap: 0; }
.stop { display: grid; grid-template-columns: 46px 18px 1fr; gap: 0 10px; position: relative; padding-bottom: 14px; cursor: pointer; }
.stop:last-child { padding-bottom: 4px; }
.stop .t { font: 600 13px/1.4 var(--display); color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.stop .rail { position: relative; display: flex; justify-content: center; }
.stop .rail::before { content: ''; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); background: var(--bg); margin-top: 5px; position: relative; z-index: 1; }
.stop .rail::after { content: ''; position: absolute; top: 18px; bottom: -6px; width: 2px; background: linear-gradient(var(--accent), rgba(34, 181, 238, .15)); }
.stop:last-child .rail::after { display: none; }
.stop .d b { font-size: 14px; }
.stop .d .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.cta {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 12px;
  padding: 12px; border-radius: 14px; background: var(--silver); color: #0B0D10; font-weight: 650; font-size: 14px; text-decoration: none;
}
.cta svg { width: 18px; height: 18px; }

/* Comparativo */
.cmp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; height: 170px; padding-top: 16px; }
.cmp-col { display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.cmp-bars { display: flex; gap: 12px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.cmp-bar { width: 24px; border-radius: 4px 4px 0 0; background: var(--accent); position: relative; height: 0; transition: height .9s cubic-bezier(.2, .8, .2, 1); }
.cmp-bar.b { background: var(--mid); }
.cmp-bar span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.cmp-y { font: 600 12.5px var(--display); color: var(--ink-2); border-top: 1px solid var(--line); width: 100%; text-align: center; padding-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); margin-right: 6px; vertical-align: -1px; }
.legend span.b::before { background: var(--mid); }

/* Acciones */
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.act {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 10px;
  font-size: 12.5px; font-weight: 550; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); transition: .2s;
}
.act svg { width: 15px; height: 15px; }
.act:hover { color: var(--ink); border-color: var(--line-2); }
.act.primary { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(34, 181, 238, .3); }
.act.playing { color: var(--accent-2); border-color: rgba(34, 181, 238, .35); }
.doc-card {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-md);
  background: linear-gradient(135deg, rgba(34, 181, 238, .12), rgba(34, 181, 238, .03)); border: 1px solid rgba(34, 181, 238, .28);
}
.doc-card .di { width: 42px; height: 50px; border-radius: 8px; background: var(--silver); color: #0B0D10; display: grid; place-items: center; flex: none; font: 700 10px var(--display); position: relative; }
.doc-card .di::after { content: 'PDF'; position: absolute; bottom: 6px; }
.doc-card .di svg { width: 18px; height: 18px; margin-top: -10px; }
.doc-card.csv .di::after { content: 'CSV'; }
.doc-card .dt { flex: 1; min-width: 0; }
.doc-card .dt b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card .dt span { font-size: 12px; color: var(--muted); }
.doc-card .dbtns { display: flex; gap: 6px; }
.doc-card .dbtns button { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink); }
.doc-card .dbtns button.main { background: var(--accent); color: #04121A; border: 0; }
.doc-card.loading .dbtns { opacity: .4; pointer-events: none; }

/* ---------- Composer ---------- */
.composer-wrap { padding: 8px 12px calc(8px + var(--safe-b)); background: linear-gradient(rgba(7, 8, 11, 0), var(--bg) 26%); position: relative; z-index: 5; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 4px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
.chip {
  flex: none; padding: 7px 12px; border-radius: 20px; font-size: 13px; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line-2); white-space: nowrap; transition: .2s; animation: rise .4s both;
}
.chip:hover { color: var(--ink); border-color: rgba(34, 181, 238, .45); }
.composer {
  display: flex; align-items: flex-end; gap: 6px; padding: 6px; border-radius: 26px;
  background: var(--surface-2); border: 1px solid var(--line-2); box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
  transition: border-color .2s;
}
.composer:focus-within { border-color: rgba(34, 181, 238, .45); }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: none; color: var(--ink); font: 15.5px/1.4 var(--font);
  padding: 9px 4px; max-height: 120px; min-height: 40px;
}
.composer textarea::placeholder { color: var(--muted); }
.c-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--ink-2); transition: .2s; position: relative; }
.c-btn:hover { color: var(--ink); background: var(--surface-3); }
.c-send { background: var(--silver); color: #0B0D10; }
.c-send:hover { background: var(--silver); color: #0B0D10; filter: brightness(1.05); }
.c-send:disabled { background: var(--surface-3); color: var(--muted); cursor: default; }
.c-mic.rec { color: #04121A; background: var(--accent); }
.c-mic.rec::before, .c-mic.rec::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent); animation: pulse 1.4s ease-out infinite; }
.c-mic.rec::after { animation-delay: .7s; }
.foot-note { text-align: center; font-size: 10.5px; color: var(--muted); margin-top: 7px; opacity: .8; }

/* ---------- Modo voz ---------- */
.voice {
  position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px;
  padding: calc(60px + var(--safe-t)) 28px calc(40px + var(--safe-b));
  background: radial-gradient(700px 500px at 50% 45%, rgba(34, 181, 238, .14), transparent 70%), rgba(7, 8, 11, .97);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: fade .3s both;
}
.voice[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.voice-close { position: absolute; top: calc(14px + var(--safe-t)); right: 16px; }
.voice-top { position: absolute; top: calc(24px + var(--safe-t)); left: 0; right: 0; text-align: center; font: 600 13px var(--display); color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.voice-orb { position: relative; width: 230px; height: 230px; display: grid; place-items: center; margin-top: -30px; }
.vo-core {
  width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; position: relative; z-index: 3;
  background: radial-gradient(circle at 35% 30%, #2A323F, #0E1116 72%); border: 1px solid var(--line-2);
  box-shadow: 0 0 80px rgba(34, 181, 238, .35), inset 0 1px 0 rgba(255, 255, 255, .1); transition: transform .3s;
}
.vo-core img { width: 58px; }
.vo-glow { position: absolute; inset: 30px; border-radius: 50%; background: radial-gradient(circle, rgba(34, 181, 238, .5), transparent 65%); filter: blur(18px); opacity: .5; transition: .4s; }
.vo-ring { position: absolute; inset: 40px; border-radius: 50%; border: 1.5px solid rgba(34, 181, 238, .4); opacity: 0; }
.voice[data-state="listening"] .vo-ring { animation: pulse 2s ease-out infinite; }
.voice[data-state="listening"] .vo-ring.b { animation-delay: .66s; }
.voice[data-state="listening"] .vo-ring.c { animation-delay: 1.33s; }
.voice[data-state="listening"] .vo-glow { opacity: .9; }
.voice[data-state="thinking"] .vo-core { animation: think 1.2s ease-in-out infinite; }
.voice[data-state="thinking"] .vo-ring.a { opacity: 1; inset: 44px; border-color: transparent; border-top-color: var(--accent); animation: spin 1s linear infinite; }
.voice[data-state="speaking"] .vo-core { animation: talk .5s ease-in-out infinite alternate; }
.voice[data-state="speaking"] .vo-glow { opacity: 1; inset: 10px; }
@keyframes think { 50% { transform: scale(.94); } }
@keyframes talk { from { transform: scale(1); } to { transform: scale(1.07); } }
.voice-state { font: 600 22px var(--display); }
.voice-text { max-width: 440px; text-align: center; color: var(--ink-2); font-size: 16px; line-height: 1.5; min-height: 72px; max-height: 30vh; overflow-y: auto; }
.voice-actions { display: flex; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 30px; background: var(--surface-2); border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; }
.pill svg { width: 17px; height: 17px; }
.pill.primary { background: var(--silver); color: #0B0D10; border: 0; width: 100%; justify-content: center; }

/* ---------- Hoja iOS / toast ---------- */
.sheet { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; animation: fade .25s both; }
.sheet[hidden] { display: none; }
.sheet-card { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 26px 26px 0 0; padding: 26px 22px calc(22px + var(--safe-b)); text-align: center; animation: up .35s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes up { from { transform: translateY(100%); } }
.sheet-icon { width: 64px; border-radius: 16px; }
.sheet-card h3 { font: 600 19px var(--display); margin: 12px 0 14px; }
.sheet-card ol { text-align: left; color: var(--ink-2); padding-left: 22px; margin: 0 0 20px; line-height: 1.9; }
.inline { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; color: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translate(-50%, 20px); z-index: 80;
  padding: 10px 16px; border-radius: 14px; background: var(--surface-3); border: 1px solid var(--line-2); font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .3s; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  .scroll { padding: 4px 24px 24px; }
  .composer-wrap { padding: 8px 20px calc(14px + var(--safe-b)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Revelado progresivo del texto */
.w { opacity: 0; transition: opacity .28s ease; }
.w.on { opacity: 1; }
.brand > div { min-width: 0; }
.brand-status span { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .brand-name span { display: none; } }

/* ==========================================================================
   Agente real: acceso, historial, mapa, gráficas y archivos
   ========================================================================== */
.login { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: calc(30px + var(--safe-t)) 24px calc(30px + var(--safe-b)); background: var(--bg); }
.login[hidden] { display: none; }
.login::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(700px 420px at 50% 0, rgba(34, 181, 238, .16), transparent 70%); }
.login > * { position: relative; }
.login img { width: 130px; }
.login h2 { margin: 0; font: 600 22px/1.25 var(--display); text-align: center; }
.login p { margin: 0; color: var(--ink-2); font-size: 14px; text-align: center; max-width: 320px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.login input { font: 600 20px/1 var(--font); letter-spacing: .06em; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 14px 16px; outline: 0; text-align: center; }
.login input:focus { border-color: rgba(34, 181, 238, .55); }
.login .error { min-height: 20px; color: var(--warn); font-size: 13px; text-align: center; }
.login button[type=submit] { padding: 14px; border-radius: 14px; background: var(--silver); color: #0B0D10; font-weight: 700; font-size: 15px; }
.login button[disabled] { opacity: .6; }

.drawer { position: fixed; inset: 0; z-index: 65; display: flex; background: rgba(0, 0, 0, .55); animation: fade .2s both; }
.drawer[hidden] { display: none; }
.drawer-card { width: min(360px, 88vw); height: 100%; background: var(--bg-2); border-right: 1px solid var(--line-2); display: flex; flex-direction: column; padding: calc(14px + var(--safe-t)) 12px calc(14px + var(--safe-b)); animation: deslizar .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes deslizar { from { transform: translateX(-100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px 12px; }
.drawer-head b { font: 600 16px var(--display); }
.drawer-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.conv { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px; color: var(--ink-2); }
.conv:hover, .conv.on { background: var(--surface-2); color: var(--ink); }
.conv b { display: block; font-size: 13.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; }
.conv span { font-size: 11.5px; color: var(--muted); }
.drawer-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.drawer-foot .who { font-size: 12.5px; color: var(--muted); padding: 4px 8px; }
.link-btn { display: flex; align-items: center; gap: 8px; padding: 10px 8px; border-radius: 10px; color: var(--ink-2); font-size: 13.5px; text-align: left; }
.link-btn:hover { background: var(--surface-2); color: var(--ink); }
.link-btn svg { width: 17px; height: 17px; }
.vacio { color: var(--muted); font-size: 13px; padding: 12px 8px; }

.step.note { color: var(--ink-2); font-style: italic; }
.step.note .dot { border: 0; }
.agent-text.error { color: var(--warn); }

.mapa-leaflet { height: 300px; border-radius: 14px; overflow: hidden; background: #0b0e13; border: 1px solid var(--line); }
.mapa-leaflet .leaflet-container { background: #0b0e13; font: inherit; }
.mapa-leaflet .leaflet-control-attribution { background: rgba(7, 8, 11, .7); color: var(--muted); font-size: 9px; }
.mapa-leaflet .leaflet-control-attribution a { color: var(--ink-2); }
.mapa-leaflet .leaflet-bar a { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.chart-svg { width: 100%; height: auto; display: block; }
.card-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.doc-card.xls .di::after { content: 'XLSX'; }
.td-num { text-align: right; }
/* Mapa base de OpenStreetMap en tono oscuro */
.mapa-leaflet .leaflet-tile-pane { filter: invert(1) hue-rotate(185deg) brightness(.78) contrast(.92) saturate(.35); }
/* La regla global de íconos (svg 20 px) no aplica a la capa de polígonos de Leaflet */
.leaflet-container svg { width: auto; height: auto; max-width: none; display: inline; }
