/* CSS único de Soporte (migrado de maqueta/maqueta.css). Marca Cognitia: Brand #875BF7 (foco e indicadores), texto/botón con #6A3FDE (AA). Sin fuentes ni recursos remotos. */
:root {
  --font: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bg: #F6F5F9; --surface: #FFFFFF; --surface-2: #F0EEF6; --line: #E2DFEA; --line-2: #CFCBDB;
  --text: #1B1A22; --muted: #5E5B6B;
  --brand: #875BF7;          /* decoración: foco, indicadores */
  --brand-strong: #6A3FDE;   /* texto y botón (AA con blanco) */
  --brand-ink: #4F2BB3; --brand-soft: #EFE9FF;
  --accent: #DEFF43; --accent-ink: #1B1A22;
  --ok: #157347; --warn: #8A4F00; --bad: #B42318;
  --bad-soft: #FDECEA; --warn-soft: #FFF1D6; --ok-soft: #E3F4EA;
  --note-bg: #FFF6DA; --note-line: #E2CC7A; --note-ink: #4D3B00;
  --pub-bg: #FFFFFF; --cli-bg: #F4F1FB;
  --radius: 8px; --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --row-pad: 7px; --shadow: 0 8px 24px rgba(27, 26, 34, .14);
  --side-w: 188px; --top-h: 52px; --tabs-h: 38px;
  color-scheme: light;
}
:root[data-theme="oscuro"] {
  --bg: #14131A; --surface: #1C1B24; --surface-2: #25232F; --line: #34323F; --line-2: #4A4758;
  --text: #ECEBF2; --muted: #A9A6B8;
  --brand-strong: #7B4FEA; --brand-ink: #CDBBFF; --brand-soft: #2D2450;
  --ok: #6FD39A; --warn: #F2B35E; --bad: #FF9A8F;
  --bad-soft: #3A1E1E; --warn-soft: #3A2D12; --ok-soft: #14301F;
  --note-bg: #2F2A14; --note-line: #6B5E22; --note-ink: #F1E3A3;
  --cli-bg: #23202F; --pub-bg: #1C1B24; --shadow: 0 8px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
:root[data-dens="comoda"] { --row-pad: 11px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13px/1.45 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
body.app { display: flex; flex-direction: column; overflow: hidden; }
h1, h2, h3, p { margin: 0; text-wrap: balance; }
p, li, dd { text-wrap: pretty; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico.sm { width: 14px; height: 14px; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* Botones: primario = único color Brand lleno */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { min-height: 26px; padding: 0 8px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.link-btn { background: none; border: 0; padding: 4px 6px; cursor: pointer; color: var(--text); text-decoration: underline; text-decoration-color: var(--line-2); border-radius: 4px; display: inline-flex; gap: 4px; align-items: center; }
.link-btn:hover { text-decoration: underline; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line-2); font-size: 12px; background: var(--surface); line-height: 1.6; }
.chip.tag { background: var(--surface-2); border-color: transparent; }
.chip button { background: none; border: 0; cursor: pointer; padding: 0; display: grid; }
.chip.urgente { background: var(--bad-soft); color: var(--bad); border-color: transparent; font-weight: 600; }
.chip.alta { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.nuevo { background: #3B82F6; } .dot.abierto { background: var(--bad); } .dot.pendiente { background: #2E9CCA; }
.dot.en-espera { background: var(--warn); } .dot.resuelto { background: var(--ok); } .dot.cerrado { background: var(--muted); }
.estado { display: inline-flex; align-items: center; gap: 6px; text-transform: capitalize; }

/* Barra superior (fila 1) */
.topbar { height: var(--top-h); background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: var(--sp-4); padding: 0 var(--sp-4); flex: none; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); width: calc(var(--side-w) - 16px); font-weight: 700; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--text); color: var(--surface); display: grid; place-items: center; font-weight: 800; }
.search { position: relative; flex: 1; max-width: 560px; display: flex; align-items: center; }
.search .ico { position: absolute; left: 10px; color: var(--muted); }
.search input { width: 100%; height: 34px; padding: 0 34px 0 34px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--bg); }
.search kbd { position: absolute; right: 8px; border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; font-size: 11px; color: var(--muted); }
.q-res { position: absolute; top: 40px; left: 0; right: 0; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 40; }
.q-res li { padding: 7px 10px; border-radius: 6px; cursor: pointer; display: flex; gap: 8px; }
.q-res li[aria-selected="true"], .q-res li:hover { background: var(--surface-2); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; cursor: pointer; color: var(--text); }

/* Pestañas de entidad (fila 2) */
.tabsbar { height: var(--tabs-h); background: var(--surface-2); border-bottom: 1px solid var(--line); display: flex; align-items: flex-end; padding: 0 var(--sp-4) 0 calc(var(--side-w) + 4px); flex: none; gap: 8px; }
.recents { position: relative; align-self: center; }
.menu { position: absolute; right: 0; top: 30px; min-width: 240px; list-style: none; margin: 0; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 40; }
.menu li > a, .menu li > button { display: flex; width: 100%; text-align: left; gap: 8px; padding: 7px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; text-decoration: none; color: var(--text); }
.menu li > a:hover, .menu li > button:hover, .menu [aria-selected="true"], .menu li > button:focus { background: var(--surface-2); }
.menu li small { color: var(--muted); margin-left: auto; }

.layout { display: flex; flex: 1; min-height: 0; }
.side { width: var(--side-w); flex: none; padding: var(--sp-4) var(--sp-2); display: flex; flex-direction: column; gap: 2px; background: var(--surface); border-right: 1px solid var(--line); }
.side a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.side a:hover { background: var(--surface-2); }
.side a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav-count { margin-left: auto; font-weight: 600; font-size: 12px; color: var(--muted); }
body.app main { flex: 1; min-width: 0; overflow: auto; outline: 0; display: flex; flex-direction: column; }
body.app main > * { flex: 1 0 auto; }
.page { padding: var(--sp-5) var(--sp-6) var(--sp-7); max-width: 1400px; }
.page-head { display: flex; align-items: flex-end; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head h1 { font-size: 22px; line-height: 1.25; font-weight: 700; }
.page-head .sub { color: var(--muted); }
.page-head .grow { flex: 1; }

/* Banners */
.banner { display: flex; align-items: center; gap: var(--sp-3); padding: 9px var(--sp-4); border-bottom: 1px solid var(--line); background: var(--warn-soft); color: var(--text); flex: none; }
.banner.bad { background: var(--bad-soft); } .banner.info { background: var(--surface-2); }
.banner .ico { color: var(--warn); } .banner.bad .ico { color: var(--bad); }
.banner .grow { flex: 1; }

/* Vistas: panel de vistas + lista densa */
.views { display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.views-nav { border-right: 1px solid var(--line); padding: var(--sp-4) var(--sp-2); background: var(--surface); position: sticky; top: 0; align-self: start; height: calc(100vh - var(--top-h) - var(--tabs-h)); overflow: auto; }
.views-nav h2 { font-size: 15px; padding: 0 10px var(--sp-3); display: flex; align-items: center; gap: 8px; }
.views-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.views-nav a { display: flex; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.views-nav a:hover { background: var(--surface-2); }
.views-nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.views-nav .n { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 22px; text-align: right; }
.views-nav .n.up::after { content: ' ↑'; color: var(--bad); }
.views-nav .upd { padding: var(--sp-4) 10px 0; color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.view-main { padding: var(--sp-5) var(--sp-5) var(--sp-7); min-width: 0; }
.toolbar { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-3); }
.toolbar input[type=search], .toolbar select, .field input, .field select, .field textarea { height: 32px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.toolbar input[type=search] { width: 220px; }
.bulk { display: flex; gap: var(--sp-2); align-items: center; padding: 8px var(--sp-3); margin-bottom: var(--sp-3); background: var(--brand-soft); border-radius: 10px; color: var(--brand-ink); flex-wrap: wrap; }
.bulk .btn { color: var(--text); }
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
table.tickets { width: 100%; border-collapse: collapse; }
.tickets th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.tickets th button { background: none; border: 0; padding: 0; font-weight: 600; color: inherit; cursor: pointer; display: inline-flex; gap: 4px; }
.tickets th button[aria-pressed="true"] { color: var(--text); }
.tickets td { padding: var(--row-pad) 8px; white-space: nowrap; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tickets tr:last-child td { border-bottom: 0; }
.tickets tbody tr:hover { background: var(--surface-2); }
.tickets tbody tr:focus-visible { outline-offset: -2px; }
.tickets .c-grupo { white-space: normal; min-width: 90px; }
.tickets .c-asig { min-width: 96px; }
.tickets .c-id { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tickets .c-asunto a { display: block; text-wrap: balance; color: var(--text); font-weight: 600; text-decoration: none; }
.tickets .c-asunto a:hover { text-decoration: underline; }
.tickets .c-asunto { min-width: 230px; max-width: 340px; white-space: normal; }
.tickets .sub { color: var(--muted); font-size: 12px; }
.tickets .c-check { width: 34px; }
.tickets .sla.bad { color: var(--bad); font-weight: 600; } .tickets .sla.warn { color: var(--warn); font-weight: 600; }
.canal { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.empty { text-align: center; padding: var(--sp-7) var(--sp-5); background: var(--surface); border: 1px dashed var(--line-2); border-radius: 10px; }
.empty h2 { font-size: 15px; margin-bottom: 4px; } .empty p { color: var(--muted); margin-bottom: var(--sp-4); }

/* Inicio / tarjetas planas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: var(--sp-4); }
.card > h2 { font-size: 15px; margin-bottom: var(--sp-3); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: var(--sp-3); align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow a { color: var(--text); font-weight: 600; text-decoration: none; }
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }

/* Ticket: tres zonas */
.ticket { display: flex; flex-direction: column; flex: 1 1 0 !important; min-height: 0; }
.t-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4) var(--sp-3); background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; flex: none; }
.t-head h1 { text-wrap: balance; font-size: 18px; line-height: 1.3; font-weight: 700; flex: 1; min-width: 200px; }
.t-head .num { color: var(--muted); font-variant-numeric: tabular-nums; }
.presence { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.presence .av { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--surface); display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--text); margin-left: -6px; }
.presence .av:first-child { margin-left: 0; }
.t-grid { display: grid; grid-template-columns: 272px minmax(0, 1fr) 320px; flex: 1; min-height: 0; }
.t-fields, .t-ctx { overflow: auto; background: var(--surface); padding: var(--sp-4); }
.t-fields { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.fsec { display: flex; flex-direction: column; gap: var(--sp-3); }
.fsec + .fsec, .fgroup { margin-top: var(--sp-5); padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.t-ctx { border-left: 1px solid var(--line); }
.t-center { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.timeline { flex: 1; overflow: auto; padding: var(--sp-5) var(--sp-5) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label, .field > .lbl { font-size: 12px; color: var(--muted); font-weight: 600; }
.field select, .field input[type=text], .field input:not([type]) { width: 100%; }
.field .req::after { content: ' *'; color: var(--bad); }
.field input:disabled, .field select:disabled { background: var(--surface-2); color: var(--muted); }
.fgroup { display: flex; flex-direction: column; gap: var(--sp-3); }
.fgroup > h2 { font-size: 15px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.check { display: flex; gap: 8px; align-items: center; }
.msg { max-width: 760px; border: 1px solid var(--line); border-radius: 10px; padding: var(--sp-3) var(--sp-4); background: var(--pub-bg); }
.msg.cliente { background: var(--cli-bg); }
.msg .meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.msg .meta b { color: var(--text); font-size: 13px; }
.msg .body { white-space: pre-wrap; max-width: 68ch; }
.msg.nota { background: var(--note-bg); border: 1px dashed var(--note-line); color: var(--note-ink); }
.msg.nota .meta, .msg.nota .meta b { color: var(--note-ink); }
.evs { max-width: 760px; color: var(--muted); font-size: 12px; }
.evs summary { cursor: pointer; padding: 4px 0; list-style: none; display: flex; gap: 6px; align-items: center; }
.evs summary::-webkit-details-marker { display: none; }
.evs summary::before { content: '▸'; } .evs[open] summary::before { content: '▾'; }
.evs ul { list-style: none; margin: 4px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.evs li { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.evs .regla { color: var(--text); font-weight: 600; }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: var(--sp-3) var(--sp-5) var(--sp-4); flex: none; }
.composer.nota { background: var(--note-bg); border-top-color: var(--note-line); }
.ctabs { display: flex; gap: var(--sp-4); margin-bottom: var(--sp-3); border-bottom: 1px solid var(--line); }
.ctabs button { background: none; border: 0; padding: 6px 0 8px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.ctabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.composer textarea { width: 100%; min-height: 64px; resize: vertical; padding: 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); }
.composer.nota textarea { background: transparent; border-color: var(--note-line); color: var(--note-ink); }
.c-aviso { display: flex; gap: 8px; align-items: center; color: var(--muted); margin-bottom: var(--sp-2); font-size: 12px; }
.c-tools { display: flex; gap: var(--sp-2); align-items: center; margin-top: var(--sp-3); flex-wrap: wrap; }
.c-tools .grow { flex: 1; }
.split { display: inline-flex; position: relative; }
.split .btn.primary:first-child { border-radius: 8px 0 0 8px; }
.split .btn.caret { border-radius: 0 8px 8px 0; border-left: 1px solid rgba(255, 255, 255, .35); padding: 0 8px; }
.split .menu { right: 0; top: auto; bottom: 38px; }
.motivo { color: var(--bad); font-size: 12px; display: flex; gap: 6px; align-items: center; margin-top: var(--sp-2); justify-content: flex-end; }
.chip.toggle { cursor: pointer; } .chip.toggle[aria-pressed="true"] { background: var(--text); color: var(--surface); }
.mode-tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: var(--sp-4); }
.mode-tabs button { border: 0; background: none; padding: 5px 9px; border-radius: 99px; cursor: pointer; color: var(--muted); font-weight: 600; }
.mode-tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
dl.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px var(--sp-3); margin: var(--sp-3) 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.ctx-block { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.ctx-block h3 { font-size: 13px; color: var(--muted); margin-bottom: var(--sp-2); }
.ro { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); }
.drawer-btn { display: none; }

/* Diálogos y avisos */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: var(--sp-5); background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 8, 20, .5); }
dialog h2 { font-size: 18px; margin-bottom: var(--sp-4); }
dialog .actions { display: flex; gap: var(--sp-2); justify-content: flex-end; margin-top: var(--sp-5); }
dialog table { width: 100%; border-collapse: collapse; } dialog td { padding: 5px 0; }
dialog kbd, .kbd { border: 1px solid var(--line-2); border-radius: 4px; padding: 0 6px; background: var(--surface-2); font-size: 12px; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; align-items: center; }
.toast { background: var(--text); color: var(--surface); padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; }
.switch { position: relative; width: 34px; height: 20px; flex: none; }
.switch input { appearance: none; position: relative; display: block; width: 34px; height: 20px; border-radius: 99px; background: var(--line-2); margin: 0; cursor: pointer; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--ok); } .switch input:checked::after { transform: translateX(14px); }
.tabs-mini { display: flex; gap: var(--sp-4); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-4); }
.tabs-mini a { padding: 6px 0 8px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs-mini a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ≤1360: barra lateral de iconos */
@media (max-width: 1360px) {
  :root { --side-w: 60px; }
  .side a span, .brand-name { display: none; } .side a { justify-content: center; } .nav-count { display: none; }
  .brand { width: 36px; }
}
/* 1024–1180: el panel de contexto pasa a cajón; las vistas pasan a fila de chips */
@media (max-width: 1180px) {
  .t-grid { grid-template-columns: 250px minmax(0, 1fr); }
  .t-ctx { position: fixed; top: calc(var(--top-h) + var(--tabs-h)); right: 0; bottom: 0; width: min(340px, 92vw); transform: translateX(100%); transition: transform .2s; z-index: 30; box-shadow: var(--shadow); }
  body.ctx-open .t-ctx { transform: none; }
  .drawer-btn { display: inline-flex; }
  .views { grid-template-columns: minmax(0, 1fr); } .views-nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: var(--sp-3); }
  .views-nav h2 { display: none; } .views-nav ul { flex-direction: row; overflow-x: auto; } .views-nav a { white-space: nowrap; } .views-nav .upd { display: none; }
  .page { padding: var(--sp-5) var(--sp-4) var(--sp-7); }
}
/* Móvil: lista en tarjetas, ticket en una columna */
@media (max-width: 760px) {
  html, body { height: auto; } body.app { display: block; overflow: visible; }
  .topbar { position: sticky; top: 0; z-index: 25; gap: 8px; padding: 0 8px; } .brand { width: auto; } .search { max-width: none; } .search kbd { display: none; }
  .tabsbar { padding-left: 8px; }
  .layout { display: block; }
  .side { position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; width: 100%; flex-direction: row; border-right: 0; border-top: 1px solid var(--line); padding: 4px; justify-content: space-around; }
  .side a { flex-direction: column; gap: 2px; padding: 4px 6px; font-size: 11px; } .side a span { display: block; }
  body.app main { overflow: visible; display: block; padding-bottom: 64px; } body.app main > * { flex: none; }
  .views { grid-template-columns: minmax(0, 1fr); } .views-nav ul { flex-direction: row; overflow-x: auto; } .views-nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: var(--sp-3); } .views-nav h2, .views-nav .upd { display: none; }
  html, body { overflow-x: hidden; } .toolbar select { flex: 1 1 40%; min-width: 0; }
  .view-main { padding: var(--sp-4) 12px var(--sp-6); } .page-head h1 { font-size: 18px; }
  .toolbar input[type=search] { width: 100%; }
  .tbl-wrap { border: 0; background: none; overflow: visible; }
  table.tickets, .tickets tbody { display: block; } .tickets thead { display: none; }
  .tickets tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
  .tickets td { padding: 0; border: 0; } .tickets td.c-check { order: 0; } .tickets td.c-asunto { order: 1; flex: 1 1 0; min-width: 0; max-width: none; }
  .tickets td:nth-child(4) { order: 2; flex-basis: 100%; } .tickets td.c-id { order: 3; } .tickets td:nth-child(5) { order: 4; } .tickets td:nth-child(6) { order: 5; }
  .tickets td:nth-child(7) { order: 6; } .tickets td:nth-child(10) { order: 7; margin-left: auto; text-align: right; }
  .tickets td.c-grupo, .tickets td.c-asig { display: none; }
  .ticket { display: block; } .t-grid { display: flex; flex-direction: column; } .t-fields { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .t-center { min-height: 0; } .timeline { padding: var(--sp-4) 12px; overflow: visible; } .composer { padding: var(--sp-3) 12px; }
  .page { padding: var(--sp-4) 12px var(--sp-6); }
  .search input { font-size: 16px; }
  dl.kv { grid-template-columns: 90px 1fr; }
  .t-head h1 { font-size: 16px; }
}

/* ───────── Zona UI: añadidos de la app real ───────── */
.sprite { position: absolute; width: 0; height: 0; }
/* Páginas sin shell (entrar, error, sin acceso) y admin de la fundación */
body:not(.app) main.plain { max-width: 1100px; margin: 24px auto; padding: 0 24px; display: grid; gap: 24px; }
body:not(.app) .top { display: flex; align-items: center; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.card.narrow { max-width: 460px; margin: 48px auto 0; padding: var(--sp-5); }
.card h1, .card h2, .card h3 { margin: 0 0 var(--sp-3); }
.row { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
form.inline { display: inline; }
.flash { background: var(--warn-soft); border: 1px solid var(--note-line); border-radius: 10px; padding: 10px 14px; margin-bottom: var(--sp-4); }
.btn.ghost { background: transparent; }
body.app main table:not(.tickets) { width: 100%; border-collapse: collapse; margin-bottom: var(--sp-4); }
body.app main table:not(.tickets) th, body.app main table:not(.tickets) td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
input, select, textarea { background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; }
.admin-page { padding: var(--sp-5) var(--sp-6) var(--sp-7); max-width: 1100px; display: grid; gap: var(--sp-5); align-content: start; }
.chip.ok-plain { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* htmx: estado de petición y avisos */
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.avisos { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.avisos:empty { display: none; }
.aviso { background: var(--text); color: var(--surface); padding: 9px 14px; border-radius: 10px; box-shadow: var(--shadow); pointer-events: auto; max-width: min(560px, 92vw); }
.aviso.bad { background: var(--bad); color: #fff; }
.live { color: var(--muted); font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.live .dot.on { background: var(--ok); }
.banner .btn { flex: none; }
.banner details { flex-basis: 100%; }
.banner table { margin: 6px 0 0; }
.banner td, .banner th { padding: 3px 12px 3px 0; text-align: left; border: 0; }
.aviso-voz { display: flex; gap: var(--sp-3); align-items: center; padding: 8px var(--sp-4); background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--muted); }
.hueco { border: 1px dashed var(--line-2); border-radius: 10px; padding: var(--sp-4); color: var(--muted); }
.hueco b { color: var(--text); display: block; margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 12px; }
.link-btn.danger { color: var(--bad); }
.cargar-mas td { text-align: center; padding: var(--sp-3); }
.tickets .c-edad { padding-right: var(--sp-5); min-width: 96px; }
.tickets th.c-edad { padding-right: var(--sp-5); }
.tickets tr.no-leido .c-asunto a { font-weight: 700; }
.tickets tr.leido .c-asunto a { font-weight: 500; }
.field input[readonly] { background: var(--surface-2); }
.tag-form { display: flex; gap: 4px; }
.msg .body.vacio { color: var(--muted); font-style: italic; }
.adj { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.menu[hidden] { display: none; }
.split .menu { min-width: 200px; }
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.composer .motivo { justify-content: flex-start; }
.t-ctx .hueco + .hueco { margin-top: var(--sp-3); }
.hist li { align-items: flex-start; }
.view-main .page-head { margin-bottom: var(--sp-4); }
.toolbar .btn[type=submit] { min-height: 32px; }
.toolbar label.check { font-size: 12px; color: var(--muted); }
.ayuda-atajos { width: 100%; }
.ayuda-atajos td { padding: 5px 8px 5px 0; }
.mini-form { display: inline; }
:root[data-theme="auto"] { color-scheme: light dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="claro"]):not([data-theme="oscuro"]) {
    --bg: #14131A; --surface: #1C1B24; --surface-2: #25232F; --line: #34323F; --line-2: #4A4758;
    --text: #ECEBF2; --muted: #A9A6B8; --brand-strong: #7B4FEA; --brand-ink: #CDBBFF; --brand-soft: #2D2450;
    --ok: #6FD39A; --warn: #F2B35E; --bad: #FF9A8F; --bad-soft: #3A1E1E; --warn-soft: #3A2D12; --ok-soft: #14301F;
    --note-bg: #2F2A14; --note-line: #6B5E22; --note-ink: #F1E3A3; --cli-bg: #23202F; --pub-bg: #1C1B24; --shadow: 0 8px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
[x-cloak] { display: none !important; }

/* Pestañas de entidad: lista de enlaces (aria-current en la activa) */
.tabs { flex: 1; overflow-x: auto; scrollbar-width: none; align-self: flex-end; }
.tabs ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; align-items: flex-end; }
.tabs li { display: inline-flex; align-items: center; gap: 2px; height: 32px; padding: 0 4px 0 12px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; max-width: 240px; flex: none; }
.tabs li.on { background: var(--bg); border-color: var(--line); margin-bottom: -1px; height: 33px; }
.tabs li a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; color: var(--muted); }
.tabs li.on a { color: var(--text); font-weight: 600; }
.tabs .x { width: 22px; height: 22px; display: grid; place-items: center; background: none; border: 0; border-radius: 4px; color: var(--muted); cursor: pointer; }
.tabs .x:hover { background: var(--line); }
.banner { flex-wrap: wrap; }
.banner .grow { flex: 1 1 320px; }
.hint { margin: 0 0 var(--sp-3); }
.fab-responder { display: none; }
@media (max-width: 760px) {
  .fab-responder { display: inline-flex; position: fixed; right: 12px; bottom: 72px; z-index: 26; min-height: 40px; padding: 0 16px; align-items: center; border-radius: 99px; background: var(--brand-strong); color: #fff; font-weight: 600; text-decoration: none; box-shadow: var(--shadow); }
}
.c-aviso, .motivo, .hint { text-wrap: pretty; }
@media (max-width: 760px) {
  .t-center { order: 1; } .t-fields { order: 2; border-top: 1px solid var(--line); } .t-ctx { order: 3; }
}
.msg .meta { flex-wrap: wrap; }
::placeholder { color: var(--muted); opacity: 1; }

/* Barra de llamada (estado REAL de calls: GET /api/calls/active + SSE; sin llamada = estado neutro) */
.callbar { position: relative; margin-right: 8px; }
.callbar summary { list-style: none; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; background: var(--surface); }
.callbar summary::-webkit-details-marker { display: none; }
.callbar[data-estado="sonando"] summary, .callbar[data-estado="en-curso"] summary, .callbar[data-estado="buzon"] summary { color: var(--brand-ink); border-color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.call-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 300px; padding: var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); display: flex; flex-direction: column; gap: var(--sp-3); }
.call-panel textarea { width: 100%; resize: vertical; }
.evt-voz { display: flex; gap: 6px; align-items: center; max-width: 760px; padding: 6px 10px; margin: 6px 0; border-left: 3px solid var(--brand); background: var(--brand-soft); color: var(--brand-ink); font-size: 13px; border-radius: 0 6px 6px 0; }
.evt-voz .muted { color: inherit; opacity: .8; }
.form-campos h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: var(--sp-4) 0 var(--sp-2); }

/* F4B-7: menú de macros del editor */
.macros { position: relative; }
.macros .menu { left: 0; right: auto; top: auto; bottom: 38px; max-height: 260px; overflow: auto; }
.macros .menu .macro-item { white-space: normal; }
