/* Chriscadi Electricidad — interfaz.
   Tema oscuro único: negro predominante, superficies grafito y un solo acento azul eléctrico. */
:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #111114;
  --panel-2: #17171b;
  --panel-3: #1e1e24;
  --field: #0c0c0f;
  --line: #222229;
  --line-2: #2e2e37;
  --text: #ededf0;
  --muted: #8b8b97;
  --brand: #4d8df6;
  --brand-2: #142341;
  --brand-3: #6ea2ff;
  --volt: #f6c433;
  --ok: #3ccb7f;
  --ok-bg: #0f2a1d;
  --warn: #e9b13b;
  --warn-bg: #2c2210;
  --bad: #f06565;
  --bad-bg: #351618;
  --info: #a3a3ff;
  --info-bg: #222247;
  --radius: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14.5px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-3); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -.015em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-size: 11.5px; font-weight: 600; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.hidden { display: none !important; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- iconos */
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; display: inline-block; vertical-align: -4px; }
.btn .ic { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------- layout */
.sidebar {
  width: 236px; flex: none; background: var(--bg); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px 16px; }
.brand-mark { width: 40px; height: 40px; flex: none; display: block; }
.brand-mark svg { width: 100%; height: 100%; display: block; font-family: var(--font); }
.brand-mark .mark-bg { fill: var(--brand-2); stroke: var(--line-2); }
.brand-mark .mark-line { fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-linecap: round; opacity: .55; }
.brand-mark .mark-text { fill: var(--brand-3); font-size: 14.5px; font-weight: 800; letter-spacing: -.03em; }
.brand strong { display: block; font-size: 17px; font-weight: 650; letter-spacing: -.01em; line-height: 1.15; }
#nav { display: flex; flex-direction: column; padding: 6px 12px; gap: 2px; flex: 1; }
#nav a {
  display: flex; gap: 11px; align-items: center; padding: 8px 11px; border-radius: 8px; color: var(--muted);
  font-weight: 500; font-size: 14px; transition: background .12s, color .12s;
}
#nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
#nav a.active { background: var(--panel-2); color: var(--text); }
#nav a.active .ic { color: var(--brand-3); stroke: var(--brand-3); }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group-head {
  display: flex; gap: 11px; align-items: center; width: 100%; padding: 8px 11px; border-radius: 8px; border: 0; background: none;
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
.nav-group-head:hover { background: var(--panel); color: var(--text); }
.nav-group-head span { flex: 1; letter-spacing: .02em; }
.nav-group-head .chev { width: 14px; height: 14px; transition: transform .15s; opacity: .7; }
.nav-group.open .nav-group-head .chev { transform: rotate(90deg); }
.nav-group-items { display: none; flex-direction: column; gap: 2px; margin-left: 19px; padding-left: 10px; border-left: 1px solid var(--line); }
.nav-group.open .nav-group-items { display: flex; }
.nav-group-items a { padding: 7px 10px; font-size: 13.5px; }
.nav-group-items a .ic { width: 16px; height: 16px; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.sidebar-foot .btn { width: 100%; justify-content: center; }
body.servidor #btn-obsidian, body.servidor [data-carpeta] { display: none; }

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; gap: 12px; padding: 12px 28px; align-items: center;
  background: rgba(9, 9, 11, .82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line);
}
.quick-ask {
  flex: 1; display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 0 12px; color: var(--muted); max-width: 720px; transition: border-color .12s, box-shadow .12s;
}
.quick-ask:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-2); }
.quick-ask input { border: 0; outline: 0; background: transparent; flex: 1; padding: 9px 0; font: inherit; color: var(--text); min-width: 0; }
.quick-ask input::placeholder { color: var(--muted); }
#view { padding: 26px 28px 80px; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.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)); }
.stack > * + * { margin-top: 14px; }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

.btn {
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); padding: 7px 13px; border-radius: 8px;
  font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; display: inline-flex; gap: 7px; align-items: center; white-space: nowrap;
  line-height: 1.3; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--panel-3); border-color: #3a3a45; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-3); border-color: var(--brand-3); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #07160e; }
.btn.ok:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad-bg); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.small .ic { width: 14px; height: 14px; }
.btn.icon { padding: 7px 8px; }
.btn.icon .ic { width: 17px; height: 17px; vertical-align: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.rec { background: var(--bad); color: #fff; border-color: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .btn.rec, .typing::after { animation: none; } }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; width: 100%; transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: #5f5f6b; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-2); }
input[type="file"] { padding: 6px 8px; color: var(--muted); }
label.field { display: block; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
.search { width: 300px; max-width: 100%; }
.toolbar .grow, .selbar .grow { flex: 1; }
.btn.active { border-color: var(--brand); color: var(--brand-3); background: var(--brand-2); }
.btn .cuenta { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 600; padding: 0 6px; line-height: 16px; }
.filtros { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.filtros-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 12px; }
.filtros-foot { margin-top: 8px; }
.selbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--brand-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 12px; margin-bottom: 12px; font-size: 13.5px; }
th.selcol, td.selcol { width: 34px; padding-right: 0; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; vertical-align: -3px; cursor: pointer; }
tr.sel td { background: var(--brand-2); }
.btn.small.danger:not(:disabled):hover { background: var(--bad-bg); border-color: var(--bad-bg); }
.split-agenda { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.split-factura { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
td.right, th.right { white-space: nowrap; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--panel-3); color: var(--muted); white-space: nowrap; letter-spacing: .01em;
}
.badge.borrador { background: var(--info-bg); color: var(--info); }
.badge.aprobada { background: var(--brand-2); color: var(--brand-3); }
.badge.enviada { background: var(--warn-bg); color: var(--warn); }
.badge.vencida { background: var(--bad-bg); color: var(--bad); }
.badge.pagada, .badge.hecho, .badge.terminado, .badge.cobrado { background: var(--ok-bg); color: var(--ok); }
.badge.facturado { background: var(--brand-2); color: var(--brand-3); }
.badge.anulada { text-decoration: line-through; }
.badge.en-curso { background: var(--brand-2); color: var(--brand-3); }
.badge.presupuesto { background: var(--info-bg); color: var(--info); }
.badge.cancelado { text-decoration: line-through; }
.kpi.mini { padding: 10px 12px; background: var(--panel-2); border-radius: 8px; }
.split-proy { grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
.acciones-cerebro { display: flex; gap: 8px; flex-wrap: wrap; }
.acciones-cerebro .btn { padding: 9px 14px; }
.drop-on { outline: 2px dashed var(--brand); outline-offset: -6px; background: var(--brand-2); }
.lote { display: flex; flex-direction: column; gap: 8px; }
.lote-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lote-th { width: 46px; height: 46px; border-radius: 7px; object-fit: cover; background: var(--field); flex: none; display: grid; place-items: center; padding: 0; font-size: 11px; }
.lote-st { flex: none; white-space: nowrap; }
.lote-st.bad { color: var(--bad); }
.lote-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.lote-form { margin-top: 8px; }
.lote-analisis { margin-top: 6px; }
.lote-analisis .analisis { max-height: 32vh; margin-top: 6px; }
.lote-nuevo { margin-top: 12px; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; }
.chk input { width: auto; margin: 0; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.doc { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.doc-prev { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--field); overflow: hidden; color: var(--muted); text-decoration: none; }
.doc-prev:hover { text-decoration: none; }
.doc-prev img, .doc-prev video { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-prev.audio { aspect-ratio: auto; padding: 14px 8px; }
.doc-prev.audio audio { width: 100%; }
.doc-ext { font-weight: 700; letter-spacing: .08em; font-size: 13px; text-transform: uppercase; background: var(--panel-3); color: var(--text); padding: 6px 10px; border-radius: 6px; }
.doc-ext.big { display: grid; place-items: center; height: 120px; font-size: 20px; }
.doc-info { padding: 8px 10px 4px; min-width: 0; }
.doc-info strong { display: block; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-acts { display: flex; justify-content: flex-end; gap: 2px; padding: 0 6px 6px; }
.prev-media { width: 100%; max-height: 320px; object-fit: contain; border-radius: 8px; background: var(--field); display: block; }
.analisis { max-height: 46vh; overflow: auto; padding-right: 4px; }
.msg-adj { max-width: 260px; max-height: 200px; border-radius: 8px; display: block; margin-bottom: 8px; }
.msg-adj-doc { display: inline-flex; gap: 6px; align-items: center; margin-bottom: 8px; font-weight: 500; }
.bloqueo { max-width: 520px; }
.bloqueo .codigo { font-size: 22px; letter-spacing: .25em; font-variant-numeric: tabular-nums; text-align: center; width: 200px; }
.qr { background: #fff; border-radius: 10px; padding: 10px; display: grid; place-items: center; }
.qr svg { width: 230px; height: 230px; display: block; }
.secreto { font-family: var(--mono); font-size: 14px; letter-spacing: .08em; word-break: break-all; background: var(--field); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; margin: 6px 0 8px; }
.codigos-rec { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 8px; }
.codigos-rec span { font-family: var(--mono); font-size: 15px; letter-spacing: .06em; background: var(--field); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; text-align: center; }
.creds td { vertical-align: middle; }
.creds td:nth-child(2), .creds td:nth-child(3) { white-space: nowrap; }
.cred-sitio { display: flex; gap: 10px; align-items: center; min-width: 0; }
.cred-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; background: #fff; padding: 3px; flex: none; }
.cred-inicial { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.kpi.mini .value { font-size: 17px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 1px solid var(--line-2); border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 6px 10px; }

.list { display: flex; flex-direction: column; }
.list .item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.list .item .grow { flex: 1; min-width: 0; }
.empty { color: var(--muted); padding: 14px 0; font-size: 13.5px; }
.tag-type { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; background: var(--panel-3); padding: 2px 6px; border-radius: 4px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; }
.section-title h2 { margin: 0; }

/* ---------- clientes */
.client { padding: 0; overflow: hidden; }
.client + .client { margin-top: 10px; }
.client-head { display: grid; grid-template-columns: 1.6fr repeat(5, 1fr) 24px; gap: 12px; align-items: center; padding: 14px 18px; cursor: pointer; }
.client-head:hover { background: var(--panel-2); }
.client-head .name strong { display: block; font-weight: 600; }
.client-head .stat { font-size: 12.5px; }
.client-head .stat b { display: block; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.client-body { border-top: 1px solid var(--line); padding: 18px; background: var(--bg); }
.chev { transition: transform .15s; color: var(--muted); text-align: center; }
.client.open .chev { transform: rotate(90deg); }
dl.data { display: grid; grid-template-columns: 140px 1fr; gap: 7px 12px; margin: 0; }
dl.data dt { color: var(--muted); font-size: 13px; }
dl.data dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- materiales */
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.mat { padding: 0; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; transition: border-color .12s; }
.mat:hover { border-color: var(--line-2); }
.mat .photo { aspect-ratio: 4/3; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.mat .photo .ic { width: 40px; height: 40px; stroke-width: 1.2; }
.mat .photo img { width: 100%; height: 100%; object-fit: cover; }
.mat .info { padding: 12px 14px; }
.mat .code { font-size: 11.5px; font-weight: 650; color: var(--brand-3); letter-spacing: .04em; }
.mat-photo-big { width: 100%; max-height: 360px; object-fit: contain; border-radius: 10px; background: var(--panel-2); }
.mat-photo-empty { display: grid; place-items: center; height: 200px; color: var(--muted); }
.mat-photo-empty .ic { width: 56px; height: 56px; stroke-width: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--brand-2); color: var(--brand-3); padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; cursor: pointer; border: 0; font-family: inherit; }
.chip:hover { filter: brightness(1.15); }

/* ---------- agenda */
.capture { display: flex; gap: 8px; align-items: stretch; }
.capture input { flex: 1; font-size: 15px; padding: 11px 14px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 11px; color: var(--muted); text-align: center; padding: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.cal .day {
  min-height: 84px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 7px; cursor: pointer; background: var(--field);
  overflow: hidden; transition: border-color .12s, background .12s;
}
.cal .day:hover { border-color: var(--line-2); }
.cal .day.out { opacity: .38; }
.cal .day.today { border-color: var(--brand); }
.cal .day.today .num { color: var(--brand-3); }
.cal .day.sel { background: var(--brand-2); border-color: var(--brand); }
.cal .num { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal .ev { font-size: 11.5px; border-radius: 4px; padding: 1px 5px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--panel-3); color: var(--text); }
.cal .ev.cobro, .cal .ev.factura { background: var(--warn-bg); color: var(--warn); }
.cal .ev.visita { background: var(--info-bg); color: var(--info); }
.cal .ev.hecho { text-decoration: line-through; opacity: .55; }
.event { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.event:last-child { border-bottom: 0; }
.event .time { width: 56px; flex: none; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.event .grow { flex: 1; min-width: 0; }
.event .grow strong { font-weight: 600; }
.event.done .grow strong { text-decoration: line-through; color: var(--muted); }
.check { width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-2); background: var(--field); cursor: pointer; flex: none; display: grid; place-items: center; color: #07160e; padding: 0; margin-top: 1px; transition: background .12s, border-color .12s; }
.check:hover { border-color: var(--brand); }
.check .ic { width: 13px; height: 13px; stroke-width: 2.6; }
.check.on { background: var(--ok); border-color: var(--ok); }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }

/* ---------- facturas */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { background: none; border: 0; padding: 9px 12px; font: inherit; font-size: 13.5px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-color: var(--brand); }
.lines td { padding: 6px 4px; }
.lines input, .lines textarea { padding: 6px 8px; }
.lines textarea { min-height: 38px; }
.totals { margin-left: auto; width: 300px; }
.totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.totals .grand { font-size: 18px; font-weight: 650; border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 8px; }
.preview-frame { width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.steps { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.steps .s { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-2); }
.steps .s.done { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.steps .s.now { background: var(--brand); color: #fff; border-color: transparent; }
.steps-sep { width: 12px; height: 1px; background: var(--line-2); flex: none; }

/* ---------- mail */
.split-mail { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); align-items: start; }
.split-inicio { grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-items: start; }
.mail-cuenta {
  display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: background .12s;
}
.mail-cuenta:hover { background: var(--panel-2); text-decoration: none; }
.mail-cuenta.sel { background: var(--brand-2); }
.mail-cuenta .grow { flex: 1; min-width: 0; }
.mail-cuenta strong { display: block; font-weight: 600; }
.mail-cuenta .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-lista { display: flex; flex-direction: column; gap: 2px; margin: 0 -6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-2); color: var(--brand-3); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.mail-inbox { margin-top: 16px; padding: 18px; border: 1px dashed var(--line-2); border-radius: 8px; }
.card h3.sub { margin: 16px 0 4px; }
.card .section-title + h3.sub { margin-top: 4px; }

/* ---------- cerebro */
.chat-layout { grid-template-columns: 250px minmax(0, 1fr); align-items: start; }
.chat-lista { padding: 6px; max-height: calc(100vh - 190px); overflow-y: auto; }
.chat-lista-head { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 8px 10px 6px; }
.conv { display: flex; align-items: center; gap: 2px; border-radius: 8px; }
.conv:hover { background: var(--panel-2); }
.conv.sel { background: var(--brand-2); }
.conv-abrir { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; background: none; border: 0; padding: 8px 10px; color: var(--text); font: inherit; cursor: pointer; border-radius: 8px; }
.conv-abrir strong { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-borrar { opacity: 0; flex: none; }
.conv:hover .conv-borrar, .conv.sel .conv-borrar { opacity: 1; }
.chat { display: flex; flex-direction: column; height: calc(100vh - 190px); min-height: 420px; padding: 0; }
.chat-log { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; white-space: normal; }
.msg.bot p { margin: 0 0 6px; }
.msg.bot ul { margin: 4px 0; padding-left: 20px; }
.msg .acts { margin-top: 8px; font-size: 13px; color: var(--ok); }
.msg.bot.ancho { max-width: 100%; width: 100%; }
.fuentes { margin-top: 10px; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- widgets del chat: tablas y gráficas */
.widget { margin-top: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.widget-title { font-weight: 600; margin-bottom: 8px; }
.widget-nota { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.w-tabla th, .w-tabla td { padding: 6px 8px; font-size: 13px; }
.w-tabla td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.w-svg { width: 100%; max-width: 720px; height: auto; display: block; font-family: var(--font); }
.widget.grafica { max-width: 760px; }
.w-svg .grid { stroke: var(--line); stroke-width: 1; }
.w-svg .axis { stroke: var(--line-2); stroke-width: 1; }
.w-svg .lbl { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.w-svg .lbl.end { fill: var(--text); font-size: 11.5px; font-weight: 600; }
.w-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.w-svg .dot { stroke: var(--panel); stroke-width: 2; }
.w-svg .hit { fill: transparent; stroke: none; }
.w-svg .bar:hover { filter: brightness(1.15); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.w-datos { margin-top: 6px; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; }
.typing::after { content: "…"; animation: pulse 1s infinite; }

/* ---------- modal & toasts */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 4vh 16px; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; width: 100%; max-width: 640px; box-shadow: var(--shadow); }
.modal.wide { max-width: 1040px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal-head h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--panel); border-radius: 0 0 12px 12px; z-index: 1; }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 99; }
.toast { background: #f3f3f6; color: #111114; padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow); max-width: 380px; font-weight: 500; font-size: 13.5px; }
.toast.bad { background: var(--bad); color: #fff; }
.notice { background: var(--warn-bg); color: var(--warn); padding: 10px 14px; border-radius: 9px; font-size: 13.5px; }
.notice.info { background: var(--brand-2); color: var(--brand-3); }
code { background: var(--panel-3); border: 1px solid var(--line-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
details summary { cursor: pointer; color: var(--muted); }

/* ---------- responsive */
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr; }
  .client-head { grid-template-columns: 1.6fr 1fr 1fr 24px; }
  .client-head .opt { display: none; }
}
@media (max-width: 760px) {
  body { flex-direction: column; }
  .sidebar { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; z-index: 20; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); background: rgba(9, 9, 11, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .brand, .sidebar-foot { display: none; }
  #nav { flex-direction: row; overflow-x: auto; padding: 4px; gap: 0; }
  #nav a { flex: 1 0 auto; flex-direction: column; gap: 3px; font-size: 9.5px; padding: 7px 2px 5px; min-width: 46px; text-align: center; border-radius: 6px; }
  #nav a .ic { width: 20px; height: 20px; }
  .nav-group, .nav-group-items, .nav-group.open .nav-group-items { display: contents; }
  .nav-group-head { display: none; }
  .nav-group-items a { padding: 7px 2px 5px; font-size: 9.5px; }
  .nav-group-items a .ic { width: 20px; height: 20px; }
  .topbar { padding: 10px 16px; }
  .quick-ask { max-width: none; }
  #btn-agendar { padding: 8px 10px; }
  #view { padding: 16px 16px 110px; }
  .g2, .g4, .split-agenda, .split-factura, .split-mail, .split-inicio, .chat-layout, .split-proy { grid-template-columns: 1fr; }
  .docs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-lista { max-height: 180px; }
  .conv-borrar { opacity: 1; }
  .capture { flex-wrap: wrap; }
  .capture input { flex: 1 1 100%; }
  .capture .btn.primary { flex: 1; justify-content: center; }
  .search { width: 100%; }
  .page-head .toolbar { width: 100%; }
  .mat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .preview-frame { height: 60vh; }
  .form { grid-template-columns: 1fr; }
  .client-head { grid-template-columns: 1fr auto 24px; }
  .client-head .stat.opt2 { display: none; }
  dl.data { grid-template-columns: 1fr; }
  dl.data dt { margin-top: 6px; }
  .cal .day { min-height: 54px; }
  .cal .ev { display: none; }
  .cal .day.has::after { content: ""; display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-top: 6px; }
  .msg { max-width: 92%; }
  .totals { width: 100%; }
  .chat { height: calc(100vh - 230px); }
}
