/* Fuentes servidas desde el propio servidor (sin depender de Google Fonts) */
@font-face { font-family: Inter; font-style: normal; font-weight: 100 900; font-display: swap; src: url(../fonts/inter-latin-wght-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url(../fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url(../fonts/jetbrains-mono-latin-500-normal.woff2) format("woff2"); }

/* Identidad Lexflowia: azul marino profundo, cian eléctrico y azul.
   Tema oscuro por defecto (como el logo); tema claro con data-theme="light". */
:root {
  --brand-navy: #070b1f;
  --brand-cyan: #40f0f8;
  --brand-blue: #147bfe;
  --bg: #070b1f;
  --surface: #0d1536;
  --surface-2: #141f4a;
  --border: #22306a;
  --text: #eef6ff;
  --muted: #93a3c9;
  --accent: #40f0f8;
  --accent-strong: #7ff5fb;
  --accent-soft: #0e2f4c;
  --on-accent: #06102b;
  --danger: #ff6b7d;
  --danger-soft: #3a1426;
  --warn: #ffc24d;
  --warn-soft: #3a2e14;
  --info: #5aa2ff;
  --info-soft: #132a55;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 6px 22px rgba(3,8,30,.45);
  --radius: 12px;
  --sidebar: 248px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f6fc;
  --surface: #ffffff;
  --surface-2: #eaf0fa;
  --border: #d6dff0;
  --text: #0a1433;
  --muted: #5d6a8a;
  --accent: #0a78a0;
  --accent-strong: #075d7d;
  --accent-soft: #dff4fb;
  --on-accent: #ffffff;
  --danger: #d0334a;
  --danger-soft: #fdebee;
  --warn: #b87a00;
  --warn-soft: #fdf4e0;
  --info: #1f63e0;
  --info-soft: #e7efff;
  --shadow: 0 1px 2px rgba(10,20,51,.05), 0 4px 16px rgba(10,20,51,.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.hidden { display: none !important; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; box-shadow: 0 0 0 1px var(--border), 0 0 18px rgba(64,240,248,.18); }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand-name .hl { color: var(--accent); }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text);
  font-weight: 500; font-size: 13.5px; text-decoration: none !important; cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; opacity: .8; font-size: 14px; }
.nav-item .step { margin-left: auto; font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); border-radius: 99px; padding: 0 6px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.ai-status { font-size: 11.5px; color: var(--muted); padding: 8px 10px 0; display: flex; gap: 6px; align-items: center; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
}
.crumb { font-weight: 600; flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  border-radius: 9px; padding: 6px 10px; font: inherit; cursor: pointer; min-width: 240px;
}
.search-trigger kbd { margin-left: auto; font-family: inherit; font-size: 11px; border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.icon-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; width: 34px; height: 34px; cursor: pointer; color: var(--text); font-size: 15px; }
.mobile-only { display: none; }
.view { padding: 28px 32px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* Common UI */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-head > div:first-child { flex: 1 1 340px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .row > .card + .card { margin-top: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.stack > * + * { margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.bold { font-weight: 650; }
.right { text-align: right; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 9px; padding: 8px 14px;
  font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); transition: background .12s, transform .05s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: .88; }
.btn.accent { background: linear-gradient(135deg, var(--accent), var(--brand-blue)); border-color: transparent; color: var(--on-accent); }
.btn.accent:hover { filter: brightness(1.08); }
:root[data-theme="light"] .btn.accent { background: linear-gradient(135deg, var(--accent), #1450c8); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

label.field { display: block; }
.field > span { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 6px; }
.field > small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 4px; }
input[type=text], input[type=number], input[type=email], input[type=url], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=range] { accent-color: var(--accent); width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); border-radius: 99px; padding: 4px 11px;
  font-size: 12.5px; cursor: pointer; background: var(--surface); user-select: none;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.green { background: var(--accent-soft); color: var(--accent-strong); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--info-soft); color: var(--info); }

.check-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; cursor: pointer;
}
.check-row:hover { background: var(--surface-2); }
.check-row.on { border-color: var(--accent); background: var(--accent-soft); }
.check-row .price { margin-left: auto; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.check-list { display: grid; gap: 8px; }

/* Stepper */
.stepper { display: flex; align-items: center; gap: 8px; margin-bottom: 26px; flex-wrap: wrap; }
.stepper .s { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 500; font-size: 13px; cursor: default; }
.stepper .s .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.stepper .s.done .n { background: var(--text); color: var(--bg); border-color: var(--text); }
.stepper .s.cur { color: var(--text); font-weight: 600; }
.stepper .s.cur .n { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.stepper .s.done { cursor: pointer; }
.stepper .line { width: 36px; height: 1px; background: var(--border); }
.narrow { max-width: 720px; margin: 0 auto; }

/* Stats */
.stat { padding: 16px 18px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat .v { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 500; }

.bar { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .5s; }
.bar.red > i { background: var(--danger); }
.bar.amber > i { background: var(--warn); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tab { padding: 9px 12px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.on { color: var(--text); border-color: var(--accent); }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click:hover td { background: var(--surface-2); cursor: pointer; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

.score-ring { --p: 50; --c: var(--accent); width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-2) 0); flex-shrink: 0; }
.score-ring > div { width: 74px; height: 74px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 800; font-size: 24px; }
.score-ring.sm { width: 48px; height: 48px; } .score-ring.sm > div { width: 38px; height: 38px; font-size: 13px; }

pre.out { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; line-height: 1.6; max-height: 560px; overflow: auto; margin: 0; }

.callout { border-radius: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); }
.callout.green { background: var(--accent-soft); border-color: transparent; }
.callout.amber { background: var(--warn-soft); border-color: transparent; }
.callout.red { background: var(--danger-soft); border-color: transparent; }
.callout.blue { background: var(--info-soft); border-color: transparent; }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { text-align: center; padding: 50px 10px; color: var(--muted); }
.loading .spinner { margin-bottom: 14px; }

/* Flow on home */
.flow { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 10px; }
.flow-step { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); cursor: pointer; transition: border-color .12s, transform .12s; }
.flow-step:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.flow-step .n { font-size: 11px; font-weight: 700; color: var(--accent-strong); }
.flow-step .t { font-weight: 650; margin: 4px 0 3px; color: var(--text); }
.flow-step .d { font-size: 12px; color: var(--muted); }
.hero { background: radial-gradient(120% 140% at 85% 20%, #123a9e 0%, #0b1a52 45%, #070b1f 100%); color: #eef6ff; border: 1px solid #1c2b66; position: relative; overflow: hidden; }
.hero h1 { color: #fff; }
.hero h1 .hl { color: var(--brand-cyan); }
.hero p { color: #b9c8ec; }
.hero .kicker { color: var(--brand-cyan); font-weight: 600; }
.hero .btn { border-color: rgba(255,255,255,.2); white-space: normal; max-width: 100%; text-align: left; }
.hero .btn.accent { color: #06102b; background: linear-gradient(135deg, #40f0f8, #147bfe); }
.hero::after { content: ""; position: absolute; right: 70px; top: 40px; width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #bfe4ff 0%, #2f8dff 30%, #1251d6 60%, transparent 72%); filter: blur(.3px); opacity: .9; }
.hero::before { content: ""; position: absolute; right: 120px; top: -40px; width: 22px; height: 220px; transform: rotate(35deg);
  background: linear-gradient(to bottom, transparent, rgba(64,240,248,.35), transparent); filter: blur(6px); }
.hero > div { position: relative; z-index: 1; }
@media (max-width: 860px) { .hero::after, .hero::before { opacity: .35; } }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--surface-2); border-radius: 12px; padding: 10px; min-height: 200px; }
.kcol.drag { outline: 2px dashed var(--accent); }
.kcol h4 { font-size: 12.5px; display: flex; justify-content: space-between; margin: 2px 4px 10px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px; margin-bottom: 8px; cursor: grab; font-size: 13px; }
.kcard:active { cursor: grabbing; }

/* Prospector */
.prospect-layout { display: grid; grid-template-columns: 380px 1fr; gap: 16px; height: calc(100vh - 260px); min-height: 520px; }
.plist { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.pitem { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface); cursor: pointer; }
.pitem:hover, .pitem.sel { border-color: var(--accent); }
#map { border-radius: 12px; border: 1px solid var(--border); height: 100%; min-height: 400px; z-index: 0; }
.leaflet-container { font-family: inherit; }

/* Quote document */
.doc { background: #fff; color: #111; border-radius: 10px; padding: 34px; box-shadow: var(--shadow); border: 1px solid var(--border); font-size: 12.5px; }
.doc h2 { color: #111; font-size: 22px; }
.doc .tbl th { color: #666; border-color: #e5e5e5; }
.doc .tbl td { border-color: #eee; }
.doc .muted { color: #666; }
.doc .tbl td.right, .doc .tbl th.right { white-space: nowrap; }
.doc-logo { width: 40px; height: 40px; border-radius: 9px; background: #111; color: #fff; display: grid; place-items: center; font-weight: 700; }

/* Palette */
.palette-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 100; display: flex; justify-content: center; padding-top: 12vh; }
.palette { width: min(560px, 92vw); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; align-self: flex-start; }
.palette input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 16px 18px; font-size: 15px; box-shadow: none !important; }
#paletteList { max-height: 360px; overflow-y: auto; padding: 6px; }
.pal-item { padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.pal-item.sel { background: var(--accent-soft); }
.pal-item .d { color: var(--muted); font-size: 12px; margin-left: auto; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 90; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }

/* Toasts */
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-weight: 500; box-shadow: var(--shadow); animation: up .2s ease; max-width: 360px; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }

.swatch { height: 74px; border-radius: 10px; display: flex; align-items: flex-end; padding: 8px; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.name-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.name-card .nm { font-weight: 700; font-size: 16px; }

.sec-item { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.sec-item > .h { display: flex; gap: 10px; align-items: center; padding: 12px 14px; cursor: pointer; }
.sec-item > .b { padding: 0 14px 12px 40px; }
.find { display: flex; gap: 8px; padding: 4px 0; font-size: 13px; }

@media (max-width: 1100px) {
  .flow { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .mobile-only { display: inline-block; }
  .view { padding: 20px 16px 60px; }
  .topbar { padding: 0 16px; }
  .search-trigger { min-width: 0; }
  .search-trigger kbd, .search-trigger { font-size: 0; } .search-trigger span { font-size: 15px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0,1fr); }
  .flow { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .prospect-layout { grid-template-columns: 1fr; height: auto; }
  #map { height: 360px; }
}

@media print {
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none !important; border: 0 !important; }
  .no-print { display: none !important; }
}

/* ---------- acceso (login, 2FA, recuperación) ---------- */
body.locked .app { display: none; }
.auth-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 520px at 80% -10%, rgba(20,123,254,.28), transparent 60%), radial-gradient(700px 480px at -10% 110%, rgba(64,240,248,.14), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 24px; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.auth-card > a { align-self: center; }
.auth-logo { width: 56px; height: 56px; align-self: center; border-radius: 12px; }
.auth-brand { text-align: center; font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin-top: -4px; }
.auth-brand .hl { color: var(--accent); }
.auth-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-top: -10px; }
.auth-err { color: var(--danger); font-size: 13px; min-height: 0; }
.auth-err:empty { display: none; }
.auth-sec { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.auth-sec p { margin: 0; }
.field em { font-style: normal; font-weight: 400; }

/* ---------- Ajustes → seguridad ---------- */
.sec-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sec-row.col { flex-direction: column; align-items: stretch; }
.sec-row .btn { flex: none; }
.sec-smtp { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.sec-smtp summary { cursor: pointer; display: flex; gap: 8px; align-items: center; }
.sec-smtp[open] summary { margin-bottom: 10px; }
.qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 12px; width: 220px; margin: 12px auto; }
.qr svg { width: 196px; height: 196px; display: block; }
.secret { word-break: break-all; font-size: 13px; letter-spacing: .04em; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; }
.codes code { text-align: center; padding: 8px; background: var(--surface-2); border-radius: 8px; font-size: 15px; letter-spacing: .06em; }
.meter-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; margin: 6px 0; }
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; }
.masked { -webkit-text-security: disc; }

/* ---------- respuesta de la IA en directo ---------- */
.ai-live { position: fixed; right: 16px; bottom: 16px; z-index: 60; width: min(380px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.4); padding: 12px 14px; animation: aiIn .2s ease-out; }
.ai-live.out { opacity: 0; transform: translateY(8px); transition: .25s; }
.ai-live-head { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.ai-live-head .muted { margin-left: auto; font-size: 12px; }
.ai-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: aiPulse 1.4s infinite; }
.ai-live-body { margin-top: 8px; max-height: 180px; overflow: hidden; font-size: 12.5px; line-height: 1.5; color: var(--muted); white-space: pre-wrap;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 30%); mask-image: linear-gradient(to bottom, transparent, #000 30%); }
.ai-live-body:empty { display: none; }
@keyframes aiPulse { 0% { box-shadow: 0 0 0 0 rgba(64,240,248,.6); } 70% { box-shadow: 0 0 0 8px rgba(64,240,248,0); } 100% { box-shadow: 0 0 0 0 rgba(64,240,248,0); } }
@keyframes aiIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- asistente ---------- */
.chat { display: flex; flex-direction: column; padding: 0; height: calc(100vh - 230px); min-height: 420px; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.chat-input { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-input textarea { flex: 1; resize: none; max-height: 160px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent-soft); color: var(--text); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; white-space: normal; }
.msg .md p { margin: 0 0 4px; }
.msg .md h4 { margin: 8px 0 4px; font-size: 14px; }
.msg .md ul, .msg .md ol { margin: 4px 0 6px; padding-left: 20px; }
.msg .md .sp { height: 6px; }
.msg .btn.sm { margin-top: 6px; }
.chat-empty { margin: auto; text-align: center; max-width: 560px; }
.chat-empty .big { font-size: 34px; color: var(--accent); }
.chat-empty .chips { justify-content: center; }
@media (max-width: 760px) { .chat { height: calc(100vh - 200px); } .msg { max-width: 92%; } }


/* ---------- Inicio: pendientes y gráficas ---------- */
:root { --chart-1: #147bfe; }
:root[data-theme="light"] { --chart-1: #0a78a0; }
.due { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; font-size: 13.5px; }
.due:last-of-type { border-bottom: 0; }
.due:hover { color: var(--accent-strong); }
.due-ico { color: var(--warn); text-align: center; }
.bars { position: relative; height: 190px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; align-items: end; padding-top: 18px; }
.bars-grid { position: absolute; inset: 18px 0 22px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.bars-grid i { border-top: 1px solid var(--border); opacity: .5; }
.bar-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 22px; cursor: default; }
.vbar { position: relative; width: min(34px, 60%); background: var(--chart-1); border-radius: 4px 4px 0 0; transition: filter .15s; }
.bar-col:hover .vbar { filter: brightness(1.25); }
.bar-val { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--text); font-weight: 600; white-space: nowrap; }
.bar-lbl { position: absolute; bottom: 0; font-size: 11px; color: var(--muted); text-transform: capitalize; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.f-row { display: grid; grid-template-columns: 120px 1fr 32px; gap: 10px; align-items: center; font-size: 13px; padding: 2px 0; }
.f-lbl { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-track { height: 12px; }
.f-bar { height: 100%; background: var(--chart-1); border-radius: 0 4px 4px 0; transition: filter .15s; }
.f-row:hover .f-bar { filter: brightness(1.25); }
.f-n { text-align: right; font-weight: 600; }
.tbl-view { margin-top: 10px; }
.tbl-view summary { cursor: pointer; }
.chart-tip { position: absolute; display: none; z-index: 30; pointer-events: none; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); white-space: nowrap; }

.btn.wa { background: #1fa855; color: #fff; border-color: transparent; }
.btn.wa:hover { background: #18914a; }
.qr-out { width: 260px; height: 260px; display: grid; place-items: center; background: #fff; border-radius: 14px; padding: 14px; }
.qr-out svg { width: 100%; height: 100%; display: block; }
.qr-out .muted { color: #6b7591; text-align: center; }
.sig-view { margin-top: 8px; background: #fff; color: #0b1433; border-radius: 8px; display: inline-block; padding: 2px 6px; }
.sig-view svg { display: block; }
.pick { display: grid; grid-template-columns: 20px 1fr auto 64px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; cursor: pointer; }
.pick input[type=number] { padding: 6px 8px; }
.acts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.act { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.act.done { border-color: transparent; background: var(--accent-soft); }
.act .btn { flex: none; }
.acts > .btn { align-self: flex-end; }
.tasks { display: flex; flex-direction: column; }
.task { display: grid; grid-template-columns: 20px 1fr auto auto auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.task.done span:first-of-type { text-decoration: line-through; color: var(--muted); }
.task .late { color: var(--danger); font-weight: 600; }
.timer { font-size: 30px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.idlogo { width: 120px; height: 52px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; flex: none; }
.idlogo.empty { display: grid; place-items: center; color: #8a95b3; font-size: 12px; font-weight: 700; border: 1px dashed #c8d0e4; }
.idsec { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.idcard { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.idcard > div:nth-child(2) { flex: 1; }
.doc-logoimg { max-width: 150px; max-height: 56px; object-fit: contain; }
.xblock { border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.xbar { display: flex; justify-content: space-between; align-items: center; }
.ximg { max-width: 100%; max-height: 220px; object-fit: contain; border-radius: 6px; background: #fff; align-self: flex-start; }
.legal-box { margin-top: 16px; border-left: 4px solid #147bfe; background: #eef4ff; color: #0b1433; padding: 10px 12px; border-radius: 6px; font-size: 12.5px; font-weight: 600; }

/* ---------- selector de empresa ---------- */
#wsSwitch { position: relative; margin: 4px 0 10px; }
.ws-btn { width: 100%; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; }
.ws-btn:hover { border-color: var(--accent); }
.ws-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.ws-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-car { color: var(--muted); }
.ws-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0,0,0,.35); padding: 4px; display: flex; flex-direction: column; }
.ws-item { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; background: none; border: 0; color: var(--text); font: inherit; font-size: 13px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.ws-item:hover, .ws-item.on { background: var(--surface-2); }
.ws-item.add { color: var(--accent); font-weight: 600; }
