/* Binetz Legal — variables de tema compartidas por login y chat (OP#25841).
   data-theme lo fija el script inline de cada página antes de pintar. */
:root, [data-theme="dark"] {
  --bg:#060708; --surface:#101216; --surface-soft:#171a20; --text:#f4f7ff; --muted:#b3b8c7; --faint:#6f778d;
  --border:rgba(255,255,255,.08); --border-strong:rgba(255,255,255,.14);
  --bubble-user:#1B3C6D; --primary:#5b6cf7; --accent:#2BE3EA; --legal:#2BE3EA; --iso:url('/isotipo.png');
  --on-primary:#ffffff;
  --accent-soft:rgba(43,227,234,.06); --accent-border:rgba(43,227,234,.3);
  --code-bg:rgba(255,255,255,.08);
  --err-bg:rgba(255,60,60,.1); --err-border:rgba(255,80,60,.3); --err-text:#ffb3a7;
  --ok-bg:rgba(43,227,170,.08); --ok-border:rgba(43,227,170,.3); --ok-text:#9ff0d0;
  --overlay:rgba(0,0,0,.6); --glow:#12203a;
  --warn:#f5b544; --danger:#ff7b72;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg:#f6f7fb; --surface:#ffffff; --surface-soft:#eef0f6; --text:#0b1220; --muted:#4a5266; --faint:#8a92a6;
  --border:rgba(11,18,32,.08); --border-strong:rgba(11,18,32,.16);
  --bubble-user:#dfe7f5; --primary:#1B3C6D; --accent:#1B3C6D; --legal:#1B3C6D; --iso:url('/isotipo-dark.png');
  --on-primary:#ffffff;
  --accent-soft:rgba(27,60,109,.06); --accent-border:rgba(27,60,109,.28);
  --code-bg:rgba(11,18,32,.06);
  --err-bg:#fdecea; --err-border:#f3b8b0; --err-text:#9b1c10;
  --ok-bg:#e7f6ef; --ok-border:#a8dcc3; --ok-text:#14593b;
  --overlay:rgba(11,18,32,.35); --glow:#dfe7f5;
  --warn:#8a5300; --danger:#b42318;
  color-scheme: light;
}
.brand { display:flex; align-items:center; gap:10px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
.brand .iso { width:26px; height:26px; background:var(--iso) center/contain no-repeat; flex-shrink:0; }
.brand .legal { color:var(--legal); }

/* ── Cowork (P2): secciones, tareas en vivo y propuestas ── */
.sections { display:flex; flex-direction:column; gap:2px; margin:10px 0; }
.sections .sec { text-align:left; background:none; border:0; color:var(--muted); padding:8px 10px; border-radius:8px; cursor:pointer; font:inherit; font-size:14px; }
.sections .sec:hover { color:var(--text); }
.sections .sec.active { background:var(--surface-soft); color:var(--text); font-weight:600; }
.filters { display:flex; flex-wrap:wrap; gap:4px; margin:4px 0 8px; }
.filters .filter { background:none; border:1px solid var(--border-strong); color:var(--muted); border-radius:999px; padding:2px 8px; font-size:12px; cursor:pointer; }
.filters .filter.active { border-color:var(--accent); color:var(--text); }
.sess .info { display:flex; flex-direction:column; gap:3px; min-width:0; flex:1; }
.sess .info small { color:var(--faint); font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.status { display:inline-block; width:max-content; font-size:11px; padding:1px 8px; border-radius:999px; border:1px solid currentColor; white-space:nowrap; }
.st-running { color:var(--accent); }
.st-wait, .act-pending { color:var(--warn); }
.st-done, .act-rejected { color:var(--muted); }
.st-error, .act-failed { color:var(--danger); }
.act-approved, .act-executed { color:var(--ok-text); }
.soon { padding:16px 10px; color:var(--muted); font-size:13px; }
.soon b { display:block; color:var(--text); margin-bottom:4px; }
.task-head { display:flex; align-items:center; gap:10px; padding:4px 0 10px; border-bottom:1px solid var(--border); margin-bottom:10px; flex-shrink:0; }
.task-head b { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.timeline { align-self:stretch; border-left:2px solid var(--border-strong); padding:4px 0 4px 12px; margin:8px 0; color:var(--muted); font-size:13px; }
.timeline .now { font-weight:600; color:var(--text); }
.timeline.live .now::after { content:''; display:inline-block; width:8px; height:8px; margin-left:8px; border-radius:50%; background:var(--accent); animation:bl-pulse 1.2s infinite; }
.timeline ol { margin:4px 0 0; padding-left:18px; }
@keyframes bl-pulse { 0%,100% { opacity:.25 } 50% { opacity:1 } }
@media (prefers-reduced-motion: reduce) { .timeline.live .now::after { animation:none; } }
.actions-box { display:flex; flex-direction:column; gap:8px; margin:10px 0; }
.action-card { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:12px; border:1px solid var(--border-strong); border-radius:12px; background:var(--surface); }
.action-card.pending { border-color:var(--warn); }
.action-card .summary { flex:1 1 100%; color:var(--text); overflow-wrap:anywhere; }
.action-card .status { margin-right:auto; }

/* ── Causas (P3): lista, alta, detalle con pestañas ── */
.causa-view { flex:1; overflow:auto; padding:8px 4px 24px; display:flex; flex-direction:column; gap:12px; min-height:0; }
.causa-view h2 { font-size:20px; line-height:1.3; overflow-wrap:anywhere; }
.causa-sub { font-size:11px; text-transform:uppercase; letter-spacing:.08em; color:var(--faint); margin-top:8px; }
.causa-meta { color:var(--muted); font-size:13px; margin:0; }
.causa-bar { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.causa-new { width:100%; margin-bottom:6px; }
.causa-form { display:grid; gap:10px; max-width:520px; }
.causa-form label { display:flex; flex-direction:column; gap:4px; color:var(--muted); font-size:13px; }
.causa-form .send { justify-self:start; }
.causa-form input, .foja-q, .ficha-edit { background:var(--surface-soft); color:var(--text); border:1px solid var(--border-strong); border-radius:8px; padding:8px 10px; font:inherit; font-size:14px; }
.causa-form input:focus, .foja-q:focus, .ficha-edit:focus { outline:2px solid var(--accent-border); outline-offset:1px; }
.ficha-edit { flex:none; min-height:420px; max-height:none; width:100%; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:13px; resize:vertical; }
.tabs { display:flex; gap:4px; border-bottom:1px solid var(--border); flex-wrap:wrap; }
.tabs .tab { background:none; border:0; border-bottom:2px solid transparent; color:var(--muted); padding:8px 12px; cursor:pointer; font:inherit; font-size:14px; }
.tabs .tab:hover { color:var(--text); }
.tabs .tab.active { color:var(--text); border-bottom-color:var(--accent); font-weight:600; }
.tab-body { display:flex; flex-direction:column; gap:10px; }
.tab-body > .send { align-self:flex-start; }
.ficha { background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:14px 18px; font-size:15px; line-height:1.6; overflow-wrap:anywhere; color:var(--text); }
.ficha h2, .ficha h3 { font-size:16px; margin:12px 0 6px; }
.ficha h2:first-child, .ficha h3:first-child { margin-top:0; }
.ficha p { margin:6px 0; }
.ficha ul, .ficha ol { margin:6px 0 6px 20px; }
.ficha blockquote { border-left:3px solid var(--accent); background:var(--accent-soft); padding:6px 12px; margin:6px 0; border-radius:0 6px 6px 0; }
.ficha code { background:var(--code-bg); padding:1px 5px; border-radius:4px; font-size:13px; }
.upload { align-self:flex-start; border:1px dashed var(--border-strong); color:var(--muted); border-radius:8px; padding:8px 12px; font-size:13px; cursor:pointer; }
.upload:hover { color:var(--text); border-color:var(--accent); }
.volumes { list-style:none; padding:0; margin:0; display:grid; gap:6px; }
.vol { padding:8px 10px; border:1px solid var(--border); border-radius:8px; font-size:14px; overflow-wrap:anywhere; }
.vol-processing { border-color:var(--accent-border); }
.vol-failed { border-color:var(--err-border); }
.foja-row .foja-q { flex:1; min-width:0; }
.foja-results { display:flex; flex-direction:column; gap:8px; }
.foja { border-left:3px solid var(--accent); background:var(--accent-soft); padding:8px 12px; border-radius:6px; font-size:14px; }
.foja b { color:var(--accent); font-size:13px; }
.foja p { white-space:pre-wrap; margin:6px 0 0; overflow-wrap:anywhere; }
.error-text { color:var(--danger); font-size:13px; }
.error-text:empty { display:none; }
@media (max-width: 760px) {
  .causa-view { padding:4px 0 16px; }
  .tabs { flex-wrap:nowrap; overflow-x:auto; scrollbar-width:none; }
  .tabs .tab { white-space:nowrap; flex-shrink:0; }
  .foja-row { flex-wrap:wrap; }
}
.upload.busy { opacity:.55; cursor:progress; pointer-events:none; }

/* ── Conectores (P4): campanita, bandeja, Conexiones, tarjeta de evento y toast ── */
.bell { position:relative; background:none; border:1px solid var(--border-strong); color:var(--muted); border-radius:8px; padding:5px 9px; font-size:13px; line-height:1; cursor:pointer; }
.bell:hover, .bell[aria-expanded="true"] { color:var(--text); border-color:var(--accent-border); }
.bell-count { position:absolute; top:-7px; right:-7px; min-width:18px; height:18px; padding:0 5px; border-radius:999px; background:var(--danger); color:#fff; font-size:11px; font-weight:700; line-height:18px; text-align:center; }
.bell-panel { position:fixed; top:58px; right:16px; width:min(380px, calc(100vw - 24px)); max-height:70vh; overflow-y:auto; background:var(--surface); border:1px solid var(--border-strong); border-radius:14px; box-shadow:0 16px 48px rgba(0,0,0,.28); z-index:30; padding:10px; }
.bell-head { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:2px 4px 10px; border-bottom:1px solid var(--border); font-size:14px; }
.bell-list { display:flex; flex-direction:column; gap:2px; padding-top:6px; }
.bell-list .empty { padding:10px 6px; }
.bell-item { position:relative; display:flex; flex-direction:column; gap:3px; text-align:left; background:none; border:0; border-radius:8px; padding:9px 10px 9px 24px; color:var(--muted); font:inherit; font-size:13px; line-height:1.4; cursor:pointer; overflow-wrap:anywhere; }
.bell-item:hover, .bell-item:focus-visible { background:var(--surface-soft); color:var(--text); }
.bell-item.unread { color:var(--text); font-weight:600; }
.bell-item.unread::before { content:''; position:absolute; left:9px; top:15px; width:7px; height:7px; border-radius:50%; background:var(--accent); }
.bell-item small { color:var(--faint); font-weight:400; font-size:12px; }
.bell-item .bell-body { font-weight:400; color:var(--muted); }
.conn-view { flex:1; overflow:auto; padding:8px 4px 24px; display:flex; flex-direction:column; gap:12px; min-height:0; }
.conn-view h2 { font-size:20px; line-height:1.3; }
.conn-list { display:grid; gap:12px; max-width:640px; }
.conn-card { display:flex; flex-wrap:wrap; align-items:center; gap:12px 16px; padding:16px 18px; border:1px solid var(--border-strong); border-radius:14px; background:var(--surface); }
.conn-card.soon-card { border-style:dashed; }
.conn-info { flex:1 1 240px; display:flex; flex-direction:column; gap:3px; min-width:0; }
.conn-info b { font-size:15px; color:var(--text); }
.conn-info small { color:var(--faint); font-size:12px; }
.conn-state { margin-top:4px; font-size:13px; color:var(--muted); overflow-wrap:anywhere; }
.conn-state.ok { color:var(--ok-text); }
.conn-state.warn { color:var(--warn); }
.conn-actions { display:flex; flex-wrap:wrap; gap:8px; }
.event-card { align-items:stretch; flex-direction:column; flex-wrap:nowrap; gap:8px; }
.event-head { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:12px; color:var(--muted); }
.event-card .status { margin-right:0; }
.event-title { font-size:15px; color:var(--text); overflow-wrap:anywhere; }
.event-meta { display:grid; grid-template-columns:max-content 1fr; gap:4px 14px; margin:0; font-size:13px; }
.event-meta dt { color:var(--faint); }
.event-meta dd { margin:0; color:var(--text); overflow-wrap:anywhere; }
.event-meta dd:first-of-type::first-letter { text-transform:uppercase; }
.event-desc { margin:0; font-size:13px; color:var(--muted); white-space:pre-wrap; overflow-wrap:anywhere; display:-webkit-box; -webkit-line-clamp:4; -webkit-box-orient:vertical; overflow:hidden; }
.event-actions { display:flex; gap:8px; }
.toast { position:fixed; left:50%; bottom:24px; transform:translateX(-50%); max-width:calc(100vw - 32px); background:var(--surface); color:var(--ok-text); border:1px solid var(--ok-border); border-radius:12px; padding:10px 16px; font-size:14px; box-shadow:0 12px 32px rgba(0,0,0,.25); z-index:40; }
.toast.err { color:var(--err-text); border-color:var(--err-border); }
@media (max-width: 760px) {
  .bell-panel { top:56px; right:12px; }
  .conn-view { padding:4px 0 16px; }
}
