/* Tokens: paleta de referencia validada (categórica de 8 colores, secuencial
   azul, divergente azul/rojo) con su escalón propio para modo oscuro. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface2: #f3f2ee;
  --ink: #0b0b0b;
  --ink2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axisline: #c3c2b7;
  --border: rgba(11, 11, 11, .10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --good: #006300;
  --bad: #d03b3b;
  --warn-bg: #fff6e0;
  --warn-ink: #6b4a00;
  --seq: #2a78d6;
  --div-neg: #e34948;
  --s0: #a8a7a0;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface2: #232321; --ink: #ffffff; --ink2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axisline: #383835; --border: rgba(255,255,255,.10); --accent: #3987e5; --accent-ink: #86b6ef;
    --good: #0ca30c; --bad: #e66767; --warn-bg: #3a2f12; --warn-ink: #f3d68a; --seq: #3987e5; --div-neg: #e66767; --s0: #6b6a65;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface2: #232321; --ink: #ffffff; --ink2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axisline: #383835; --border: rgba(255,255,255,.10); --accent: #3987e5; --accent-ink: #86b6ef;
  --good: #0ca30c; --bad: #e66767; --warn-bg: #3a2f12; --warn-ink: #f3d68a; --seq: #3987e5; --div-neg: #e66767; --s0: #6b6a65;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.02rem; font-weight: 650; } h3 { font-size: 1rem; } h4 { font-size: .92rem; }
h2.inline { display: inline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.neg { color: var(--bad); }

/* ---------- Barra superior */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 750; font-size: 1.05rem; color: var(--ink); white-space: nowrap; }
.brand span { font-weight: 500; color: var(--muted); margin-left: 6px; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 7px 10px; border-radius: 8px; color: var(--ink2); white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--surface2); text-decoration: none; }
.nav a.on { background: var(--surface2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.tb-right { display: flex; align-items: center; gap: 10px; }
.tb-right form { margin: 0; }
.badge { font-size: 11px; padding: 3px 8px; border-radius: 99px; background: var(--surface2); color: var(--ink2); border: 1px solid var(--border); white-space: nowrap; }
.badge.demo { background: var(--warn-bg); color: var(--warn-ink); }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink2); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--surface2); }
.menu-btn { display: none; }
.linkbtn { border: 0; background: none; color: var(--accent-ink); cursor: pointer; font: inherit; padding: 4px; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 16px 20px 96px; }

/* ---------- Tarjetas, rejillas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); min-width: 0; }
.cardhead { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.cardhead h2 { margin: 0; }
.cardhead .muted { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 > .card { margin-bottom: 14px; }
.grid2.inner { gap: 16px; align-items: start; }
details.card summary { cursor: pointer; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::before { content: "▸ "; color: var(--muted); }
details.card[open] summary::before { content: "▾ "; }

/* ---------- Filtros */
.filters { display: flex; flex-direction: column; gap: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.frow, .toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.toolbar { padding: 12px 16px; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink2); font-weight: 550; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axisline);
  border-radius: 8px; padding: 6px 9px; min-height: 34px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.scope { margin: 0; font-size: 12px; color: var(--muted); }
.chip {
  border: 1px solid var(--border); background: var(--surface2); color: var(--ink2); border-radius: 99px;
  padding: 5px 11px; font: inherit; font-size: 12.5px; cursor: pointer; text-align: left;
}
.chip:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.seg { display: flex; gap: 6px; }
.btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff; border-radius: 8px;
  padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; min-height: 34px; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 4px 10px; min-height: 28px; font-size: 12.5px; }
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.alert { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 14px; }
.alert ul { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; }
.notice { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 12px; border-radius: 8px; }
.pill { display: inline-block; background: var(--surface2); border-radius: 99px; padding: 4px 12px; margin: 0 0 12px; }
.crumbs { margin: 0 0 6px; }
.ptitle { margin-bottom: 12px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface2); }
.tag.bad { background: var(--bad); color: #fff; }

/* ---------- KPIs */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.tl { font-size: 12.5px; color: var(--ink2); font-weight: 550; }
.tv { font-size: 1.55rem; font-weight: 650; margin: 2px 0; overflow-wrap: anywhere; }
.tv.small-v { font-size: 1.05rem; }
.tile.hero .tv { font-size: 2rem; }
.tm { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 18px; }
.tn { font-size: 12px; color: var(--muted); margin-top: 3px; }
.spark { width: 110px; height: 28px; flex: none; }
.spark .ln { fill: none; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .dot { stroke: var(--surface); stroke-width: 1.5; }
.delta { font-size: 12px; font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--muted); }

/* ---------- Tablas */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--ink2); padding: 7px 8px; border-bottom: 1px solid var(--axisline); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data.compact td, table.data.compact th { padding: 5px 6px; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:hover td { background: var(--surface2); }
table.data tr.void td { color: var(--muted); }
table.data tr.sub td { color: var(--ink2); font-size: 12.5px; border-bottom-style: dashed; }
table.sortable th { cursor: pointer; user-select: none; }
table.sortable th[data-dir="asc"]::after { content: " ▲"; font-size: 9px; }
table.sortable th[data-dir="desc"]::after { content: " ▼"; font-size: 9px; }
.tablenote { margin: 6px 0 0; font-size: 12px; }
.abc { display: inline-block; width: 22px; text-align: center; border-radius: 6px; font-weight: 700; font-size: 11.5px; }
.abc-A { background: var(--s1); color: #fff; } .abc-B { background: var(--surface2); color: var(--ink); } .abc-C { color: var(--muted); }
.lift { font-weight: 600; } .lift.hi { color: var(--good); } .lift.lo { color: var(--bad); }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.actions { white-space: nowrap; display: flex; gap: 6px; }
.actions form { margin: 0; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--ink2); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- Gráficos (SVG del servidor) */
.chart { margin: 0; }
.chart-empty { padding: 28px; text-align: center; color: var(--muted); background: var(--surface2); border-radius: 8px; }
.viz { width: 100%; height: auto; display: block; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; overflow: visible; }
.viz text { font-size: 11px; }
.viz .grid { stroke: var(--grid); stroke-width: 1; }
.viz .base { stroke: var(--axisline); stroke-width: 1; }
.viz .axis { fill: var(--muted); font-variant-numeric: tabular-nums; }
.viz .lblrow { fill: var(--ink2); }
.viz .lbl { fill: var(--ink2); font-weight: 600; font-variant-numeric: tabular-nums; }
.viz .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz .dash { stroke-dasharray: 6 4; stroke-width: 1.5; }
.viz .area { fill-opacity: .10; stroke: none; }
.viz .dot { stroke: var(--surface); stroke-width: 2; }
.viz .hov rect { fill: transparent; }
.viz .hov .xh { stroke: var(--muted); stroke-width: 1; opacity: 0; }
.viz .hov:hover .xh { opacity: 1; }
.viz .mk .hit { fill: transparent; }
.viz .mk:hover path { opacity: .82; }
.viz .seg { stroke: var(--surface); stroke-width: 2; }
.viz .seg:hover { opacity: .85; }
.viz .dc { fill: var(--ink); font-size: 17px; font-weight: 650; }
.viz .hq { fill: var(--seq); }
.viz .hr { fill: var(--div-neg); }
.viz .hnull { fill: var(--grid); fill-opacity: .45; }
.viz .hv { font-size: 10.5px; pointer-events: none; font-variant-numeric: tabular-nums; }
.viz .hv.hi { fill: var(--ink); } .viz .hv.ho { fill: #fff; }
.viz [data-tip] { cursor: default; }
.f0{fill:var(--s0)}.f1{fill:var(--s1)}.f2{fill:var(--s2)}.f3{fill:var(--s3)}.f4{fill:var(--s4)}.f5{fill:var(--s5)}.f6{fill:var(--s6)}.f7{fill:var(--s7)}.f8{fill:var(--s8)}
.k0{stroke:var(--s0)}.k1{stroke:var(--s1)}.k2{stroke:var(--s2)}.k3{stroke:var(--s3)}.k4{stroke:var(--s4)}.k5{stroke:var(--s5)}.k6{stroke:var(--s6)}.k7{stroke:var(--s7)}.k8{stroke:var(--s8)}
.b0{background:var(--s0)}.b1{background:var(--s1)}.b2{background:var(--s2)}.b3{background:var(--s3)}.b4{background:var(--s4)}.b5{background:var(--s5)}.b6{background:var(--s6)}.b7{background:var(--s7)}.b8{background:var(--s8)}
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink2); margin-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swdash { height: 3px; border-radius: 0; background-image: linear-gradient(90deg, transparent 50%, var(--surface) 50%); background-size: 6px 3px; }
.donutwrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donutwrap .viz.donut { width: 190px; flex: none; }
.dlegend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 200px; font-size: 13px; }
.dlegend li { display: grid; grid-template-columns: 14px 1fr auto 56px; gap: 8px; align-items: center; padding: 3px 0; border-bottom: 1px solid var(--grid); }
.dlegend .dv, .dlegend .dp { text-align: right; font-variant-numeric: tabular-nums; }
.dlegend .dp { color: var(--muted); }
.net .edge { stroke: var(--muted); stroke-opacity: .35; stroke-linecap: round; }
.net .node circle { stroke: var(--surface); stroke-width: 2; }
.net .nlbl { fill: var(--ink2); font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.net .nlbl-h { opacity: 0; }
.net .node:hover .nlbl-h { opacity: 1; }
.net.focus .edge { stroke-opacity: .05; }
.net.focus .edge.on { stroke-opacity: .85; stroke: var(--s1); }
.net.focus .node { opacity: .2; }
.net.focus .node.on { opacity: 1; }
.net.focus .node.on .nlbl-h { opacity: 1; }
#tip {
  position: fixed; z-index: 100; pointer-events: none; display: none; max-width: 320px;
  background: var(--ink); color: var(--surface); padding: 7px 10px; border-radius: 8px;
  font-size: 12px; line-height: 1.4; white-space: pre-line; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
#tip b { font-weight: 650; }

/* ---------- Panel de IA */
.ai-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 40; border: 0; border-radius: 99px;
  background: var(--accent); color: #fff; padding: 12px 18px; font: inherit; font-weight: 650;
  cursor: pointer; box-shadow: 0 6px 20px rgba(42,120,214,.35);
}
.ai-fab:hover { filter: brightness(1.07); }
.ai-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(640px, 100vw);
  background: var(--page); border-left: 1px solid var(--border); box-shadow: -8px 0 30px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
}
.ai-drawer[hidden] { display: none; }
.ai-drawer.wide { width: min(1100px, 100vw); }
.ai-dhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
.ai-dbtns { display: flex; gap: 6px; align-items: center; }
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ai-drawer .thread { flex: 1; overflow-y: auto; padding: 14px; }
.assistant .chat { min-height: 60vh; }
.assistant .thread { padding: 6px 0 14px; }
.ask { display: flex; gap: 8px; padding: 10px 14px; background: var(--surface); border-top: 1px solid var(--border); align-items: flex-end; }
.assistant .ask { padding: 10px 0 0; background: none; position: sticky; bottom: 0; }
.ask textarea { flex: 1; resize: vertical; min-height: 44px; max-height: 240px; }
.ai-intro p { margin: 0 0 10px; color: var(--ink2); }
.ai-sugs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.msg { margin: 0 0 14px; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user p { margin: 0; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 14px 14px 4px 14px; max-width: 85%; white-space: pre-wrap; }
.msg.bot { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.progress { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--ink2); }
.progress li { padding: 3px 0; display: flex; flex-direction: column; gap: 2px; }
.progress li .st { color: var(--muted); }
.progress li.err .st { color: var(--bad); }
.progress details summary { cursor: pointer; color: var(--muted); font-size: 11.5px; }
.progress pre, .ai-steps pre { background: var(--surface2); padding: 8px; border-radius: 6px; overflow-x: auto; margin: 4px 0; white-space: pre-wrap; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--grid); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-answer h3 { font-size: 1.05rem; margin: 0; }
.ai-ans-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.ai-ans-actions { display: flex; gap: 6px; }
.ai-block { margin: 12px 0; }
.ai-block h4 { margin-bottom: 6px; }
.ai-text p { margin: 0 0 8px; }
.ai-text ul, .ai-text ol { margin: 0 0 8px; padding-left: 20px; }
.ai-text table { border-collapse: collapse; margin: 6px 0; }
.ai-text th, .ai-text td { border: 1px solid var(--grid); padding: 4px 8px; }
.ai-answer .tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 0; }
.ai-answer .tile { box-shadow: none; background: var(--surface2); }
.ai-answer .tile .tv { font-size: 1.3rem; }
.ai-html { width: 100%; min-height: 160px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.ai-steps { margin-top: 10px; font-size: 12.5px; }
.ai-steps summary { cursor: pointer; color: var(--ink2); }
.ai-steps ol { padding-left: 18px; }
.ai-foot { font-size: 11.5px; margin-top: 8px; }
.saved { font-size: 12.5px; color: var(--good); }

/* ---------- Ingreso */
.login { max-width: 360px; margin: 12vh auto; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }

/* ---------- Reporte autocontenido */
body.report { background: var(--surface); }
.rep-head { max-width: 980px; margin: 0 auto; padding: 28px 24px 8px; border-bottom: 1px solid var(--grid); }
.rep-head .brand { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.rep-head p { margin: 2px 0; font-size: 13px; }
.rep-main { max-width: 980px; margin: 0 auto; padding: 8px 24px 40px; }
.report .ai-ans-head { display: none; }
.report .ai-steps[open] pre { font-size: 11px; }

/* ---------- Responsivo */
@media (max-width: 1000px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 1180px) {
  /* Con el nombre completo de la app, el menú se pliega antes. */
  .topbar { flex-wrap: wrap; }
  .menu-btn { display: inline-block; margin-left: auto; }
  .nav { display: none; order: 3; flex-basis: 100%; flex-direction: column; }
  .nav.open { display: flex; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; }
  .tb-right .badge { display: none; }
  .wrap { padding: 12px 16px 96px; }
  .tile.hero .tv { font-size: 1.6rem; }
  .ai-fab { right: 16px; bottom: 16px; }
  .frow label, .toolbar label { flex: 1 1 140px; }
}
@media print {
  .topbar, .filters, .toolbar, .ai-fab, .ai-drawer { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ---------- Pie de página con la marca */
.site-foot {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px;
  padding: 18px 20px 90px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border);
}
.site-foot strong { color: var(--ink2); font-weight: 600; }
.site-foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.rep-foot { padding-bottom: 24px; max-width: 980px; margin: 0 auto; }
.login-brand span { font-weight: 500; color: var(--muted); margin-left: 6px; }
.login + .site-foot, body:not(:has(.topbar)) .site-foot { border-top: 0; padding-bottom: 24px; }

/* ---------- Sucursal de trabajo */
.branch-chip {
  font-size: 12.5px; padding: 5px 10px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--ink2); white-space: nowrap; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis;
}
.branch-chip:hover { border-color: var(--accent); color: var(--ink); text-decoration: none; }
.branch-pick { max-width: 920px; margin: 4vh auto 0; }
.branch-pick h1 { font-size: 1.3rem; }
.branch-search { width: 100%; margin: 6px 0 12px; }
.branch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 14px 0; }
.branch-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); border-radius: 10px;
  padding: 12px 14px; font: inherit; box-shadow: var(--shadow);
}
.branch-opt:hover { border-color: var(--accent); }
.branch-opt.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.branch-opt .bn { font-weight: 600; }
.branch-opt .bi { font-size: 12px; color: var(--muted); }
.branch-opt.all { width: 100%; background: var(--surface2); }
@media (max-width: 760px) { .branch-chip { max-width: 140px; } }

/* ---------- Inicio */
:root { --hero-a: #e8f1fc; --hero-b: #f1eefc; --hero-ink: #0b2a52; --card-glow: rgba(42,120,214,.10); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --hero-a: #10233d; --hero-b: #1d1838; --hero-ink: #e7f0ff; --card-glow: rgba(57,135,229,.16); }
}
:root[data-theme="dark"] { --hero-a: #10233d; --hero-b: #1d1838; --hero-ink: #e7f0ff; --card-glow: rgba(57,135,229,.16); }

.home { display: flex; flex-direction: column; gap: 18px; }
.hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 34px 36px 28px;
  background: radial-gradient(120% 140% at 0% 0%, var(--hero-a) 0%, transparent 60%),
              radial-gradient(120% 140% at 100% 100%, var(--hero-b) 0%, transparent 55%), var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); animation: fadeUp .5s ease both;
}
.hero::after {
  content: "✦"; position: absolute; right: 28px; top: 6px; font-size: 140px; line-height: 1;
  color: var(--accent); opacity: .07; pointer-events: none;
}
.hero-date { margin: 0 0 6px; font-size: 13px; color: var(--ink2); }
.hero-date a { color: var(--ink2); }
.hero-greet { font-size: clamp(1.7rem, 3.2vw, 2.5rem); font-weight: 750; margin: 0 0 6px; color: var(--hero-ink); letter-spacing: -.01em; }
.hero-greet span { background: linear-gradient(90deg, var(--s1), var(--s7)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { margin: 0 0 20px; font-size: 1.02rem; color: var(--ink2); }
.hero-sub strong { color: var(--ink); }
.hero-spark { color: var(--accent); }
.hero-ask {
  display: flex; gap: 10px; align-items: flex-end; max-width: 880px; padding: 8px 8px 8px 16px;
  background: var(--surface); border: 1px solid var(--axisline); border-radius: 16px;
  box-shadow: 0 6px 24px var(--card-glow); transition: border-color .15s, box-shadow .15s;
}
.hero-ask:focus-within { border-color: var(--accent); box-shadow: 0 8px 30px var(--card-glow), 0 0 0 3px var(--card-glow); }
.hero-ask textarea {
  flex: 1; border: 0; background: transparent; resize: none; min-height: 44px; padding: 11px 0;
  font-size: 1.05rem; outline: none; box-shadow: none; overflow-y: auto;
}
.hero-ask textarea:focus { outline: none; }
.hero-ask .btn { border-radius: 12px; min-height: 44px; padding: 0 18px; }
.hero-sugs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; max-width: 980px; }
.hero-sugs .chip { background: var(--surface); padding: 7px 13px; font-size: 13px; transition: transform .12s, border-color .12s; }
.hero-sugs .chip:hover { transform: translateY(-1px); }
.hero-off { margin: 12px 0 0; color: var(--ink2); }
.chip.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.accent:hover { color: #fff; filter: brightness(1.07); }

.home-thread:empty { display: none; }
.home-thread { display: flex; flex-direction: column; }
.home-thread .msg.bot { animation: fadeUp .35s ease both; }
.home-new { text-align: right; margin-top: -8px; }

.home-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.home-panel { display: contents; }
.hcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0;
  animation: fadeUp .45s ease both;
}
.hcard:nth-child(2) { animation-delay: .05s; } .hcard:nth-child(3) { animation-delay: .1s; }
.hc-kicker { margin: 0; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hc-big { margin: 2px 0; font-size: 1.9rem; font-weight: 700; }
.hc-text { margin: 0; color: var(--ink); line-height: 1.5; }
.hc-foot { margin: 4px 0 0; font-size: 13px; color: var(--ink2); }
.hc-link { margin-top: auto; padding-top: 6px; font-size: 13px; font-weight: 600; }
.hc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: auto; padding-top: 8px; }
.hcard.today { border-top: 3px solid var(--s1); }
.hcard.insight { border-top: 3px solid var(--s7); }
.hcard.tip { border-top: 3px solid var(--s3); background: linear-gradient(180deg, var(--surface2), var(--surface)); }
.hcard.tip.sys { border-top-color: var(--s4); }
.hcard.skeleton { min-height: 150px; }
.sk-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface2) 25%, var(--grid) 50%, var(--surface2) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear; margin: 6px 0; }
.sk-line.big { height: 28px; } .sk-line.w40 { width: 40%; } .sk-line.w70 { width: 70%; } .sk-line.w90 { width: 90%; }

.quick h2 { font-size: 1rem; margin: 6px 0 10px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.qlink {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); transition: transform .12s, border-color .12s, box-shadow .12s;
}
.qlink:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 18px var(--card-glow); }
.qlink .qi { font-size: 22px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--surface2); flex: none; }
.qlink strong { display: block; }
.qlink small { display: block; color: var(--muted); font-size: 12px; }
.ai-brand { line-height: 1.25; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .hero, .hcard, .home-thread .msg.bot { animation: none; }
  .sk-line { animation: none; }
  .qlink:hover, .hero-sugs .chip:hover { transform: none; }
}
@media (max-width: 1100px) { .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .hero { padding: 22px 18px 18px; border-radius: 14px; }
  .hero::after { font-size: 90px; }
  .home-grid { grid-template-columns: 1fr; }
  .hero-ask { flex-direction: column; align-items: stretch; padding: 8px 8px 8px 12px; }
  .hero-ask .btn { width: 100%; }
  .hero-sugs .chip:nth-child(n+4) { display: none; }
}
.home-thread .msg { scroll-margin-top: 76px; }
