/* ---------- Letra del Help Desk: un poco más grande y marcada ---------- */
/* Las piezas de base.css también las usa el sitio del cliente; aquí solo cambian dentro del Help Desk (body.helpdesk).
   Va al principio y con :where() para no ganarle a las reglas de este archivo que ya las ajustan. */
body.helpdesk { font-size: 15px; font-weight: 500; }
:where(body.helpdesk) h1, :where(body.helpdesk) h2, :where(body.helpdesk) h3, :where(body.helpdesk) h4 { font-weight: 700; }
:where(body.helpdesk) .logo { font-weight: 700; }
:where(body.helpdesk) .logo-mark { font-size: 14px; font-weight: 700; }
:where(body.helpdesk) .logo b { font-weight: 700; }
:where(body.helpdesk) .logo small { font-size: 12px; font-weight: 600; }
:where(body.helpdesk) .btn { font-weight: 600; }
:where(body.helpdesk) .btn.sm { font-size: 14px; }
:where(body.helpdesk) .btn.xs { font-size: 13px; }
:where(body.helpdesk) .link { font-weight: 600; }
:where(body.helpdesk) .kbd { font-size: 12px; font-weight: 600; }
:where(body.helpdesk) .field > label, :where(body.helpdesk) .label { font-size: 14px; font-weight: 600; }
:where(body.helpdesk) .hint { font-size: 13px; }
:where(body.helpdesk) .input.sm { font-size: 14px; }
:where(body.helpdesk) .error { font-size: 14px; }
:where(body.helpdesk) .check { font-size: 14px; }
:where(body.helpdesk) .badge { font-size: 13px; font-weight: 600; }
:where(body.helpdesk) .prio { font-size: 13px; font-weight: 700; }
:where(body.helpdesk) .avatar { font-size: 13px; font-weight: 700; }
:where(body.helpdesk) .avatar.xs { font-size: 11px; }
:where(body.helpdesk) .avatar.sm { font-size: 12px; }
:where(body.helpdesk) .avatar.lg { font-size: 17px; }
:where(body.helpdesk) .avatar.xl { font-size: 30px; }
:where(body.helpdesk) .avatar.more { font-size: 12px; }
:where(body.helpdesk) .eyebrow { font-size: 12px; font-weight: 700; }
:where(body.helpdesk) .modal-head h3 { font-size: 17px; }
:where(body.helpdesk) .modal-head p { font-size: 14px; }
:where(body.helpdesk) .pop-title { font-size: 12px; font-weight: 700; }
:where(body.helpdesk) .pop-note { font-size: 13px; }
:where(body.helpdesk) .pop-item { font-size: 14px; }
:where(body.helpdesk) .tip { font-size: 13px; }
:where(body.helpdesk) .toast { font-size: 14px; }
:where(body.helpdesk) .toast b { font-weight: 700; }
:where(body.helpdesk) .toast button { font-size: 14px; font-weight: 700; }
:where(body.helpdesk) .sim { font-size: 13px; }
:where(body.helpdesk) .code-box { font-size: 14px; }
:where(body.helpdesk) .code-box b { font-size: 18px; font-weight: 700; }
:where(body.helpdesk) .otp input { font-size: 21px; font-weight: 700; }

/* ---------- Inicio de sesión ---------- */
/* Solo la tarjeta, centrada sobre el azul grafito de la marca; la barra de la demo se oculta (body.on-login) */
body.on-login .demo-bar { display: none; }
.auth { position: relative; isolation: isolate; overflow: hidden; display: grid; place-items: center; min-height: var(--vh); padding: 48px 16px; padding-top: max(48px, env(safe-area-inset-top)); padding-bottom: max(48px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse 60% 50% at 50% 45%, rgba(200, 167, 107, .13), transparent 70%), linear-gradient(160deg, var(--ink-2) 0%, var(--ink) 55%, #080e19 100%); background-color: var(--ink); }
.auth::before { content: ""; position: absolute; inset: 0; z-index: -1; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 40px 40px; mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000, transparent 80%); -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, #000, transparent 80%); }
/* Proporciones de la tarjeta de inicio de sesión de Google: 450px de ancho, 500px de alto mínimo */
.auth-wrap { width: 100%; max-width: 450px; display: grid; gap: 24px; }
.auth-card { box-sizing: border-box; width: 100%; max-width: 450px; min-height: 500px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45), 0 0 0 1px rgba(200, 167, 107, .08); padding: 48px 40px 36px; display: grid; align-content: start; gap: 16px; font-size: 16px; animation: auth-in .3s ease-out both; }
/* La tarjeta siempre es blanca (también con el tema oscuro), para que contraste con el fondo grafito */
:root .auth-card { --surface: #ffffff; --surface-2: #f8f9fb; --surface-3: #eef1f5; --line: #e2e6ec; --line-strong: #cbd2dc; --fg: #0f1a2a; --fg-2: #3a4657; --muted: #6a7586;
  --btn: #0f1a2a; --btn-hover: #24324a; --btn-fg: #ffffff; --gold: #a7844a; --gold-2: #c8a76b; --gold-soft: #f6f0e5; --ok: #11785a; --ok-soft: #e2f3ec; --warn: #a96500; --warn-soft: #fcf0dc;
  --bad: #c0392f; --bad-soft: #fbe8e6; --info: #2c5ea6; --info-soft: #e6edf8; --focus: rgba(44, 94, 166, .28); color-scheme: light; }
@keyframes auth-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .auth-card { animation: none; } }
.auth-brand { display: grid; justify-items: center; gap: 12px; }
.auth-brand .logo { gap: 12px; }
.auth-brand .logo-mark { width: 44px; height: 44px; border-radius: 11px; }
.auth-brand .logo-mark .icon { width: 24px; height: 24px; stroke-width: 1.9; }
.auth-brand .logo b { font-size: 19px; letter-spacing: .02em; }
.auth-brand .logo small { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.auth-rule { display: block; width: 44px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.auth-legal { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 0; text-align: center; font-size: 14px; color: rgba(229, 234, 241, .5); }
.auth-legal .icon { color: var(--gold-2); opacity: .8; }
.auth-box { display: grid; gap: 24px; min-width: 0; }
.auth-step { display: grid; gap: 18px; min-width: 0; animation: fade-up .22s ease; }
.auth-step h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3; }
.auth-step .lead { color: var(--muted); font-size: 16px; line-height: 1.5; }
/* Encabezado de cada paso centrado; los campos quedan alineados a la izquierda */
.auth-box > .auth-step > div:first-child, .auth-box > .auth-step > .lead { text-align: center; }
.auth-box > .auth-step > .chip-user { margin-inline: auto; }
/* Espaciado de cada paso con márgenes (no gap): título → 8px → subtítulo → 32px → campos (24px entre sí) → 32px → botón */
.auth-box .auth-step { gap: 0; }
.auth-box .auth-step > * { margin: 0; }
.auth-box .auth-step > * + * { margin-top: 24px; }
.auth-box > .auth-step > div:first-child + * { margin-top: 8px; }
.auth-box > .auth-step > .lead + *, .auth-box > .auth-step > .chip-user + * { margin-top: 32px; }
.auth-box .auth-step > .error { margin-top: 12px; }
.auth-box .auth-step > .btn.block { margin-top: 32px; }
.auth-box .auth-step > .btn.block + .btn.block { margin-top: 12px; }
.auth-box .field { gap: 8px; }
.auth-box .field > label, .auth-box .label { font-size: 15px; }
.auth-box .input { box-sizing: border-box; width: 100%; height: 56px; padding: 0 16px; font-size: 16px; border-radius: 4px; }
.auth-box .btn.block { box-sizing: border-box; width: 100%; height: 48px; font-size: 15px; }
.auth-box .link { font-size: 14px !important; }
.auth-box .error { font-size: 15px; }
.auth-box .chip-user { font-size: 15px; padding: 6px 6px 6px 10px; }
.auth-box .btn:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.auth-box .pw .input { padding-right: 84px; }
.auth-box .pw .btn { top: 10px; right: 8px; height: 36px; }
.auth-box .otp { justify-content: center; gap: 8px; }
.auth-box .otp input { box-sizing: border-box; flex: 1 1 0; min-width: 0; max-width: 48px; height: 52px; }
.chip-user { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border-radius: 999px; border: 1px solid var(--line); width: fit-content; max-width: 100%; font-size: 14px; }
.chip-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pw { position: relative; }
.pw .input { padding-right: 76px; }
.pw .btn { position: absolute; right: 4px; top: 4px; height: 32px; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; color: var(--muted); }
.rules li { display: flex; gap: 6px; align-items: center; }
.rules li::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; }
.rules li.ok { color: var(--ok); }
.rules li.ok::before { background: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 3px var(--surface); }
.strength { height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.strength i { display: block; height: 100%; width: 0; background: var(--bad); transition: width .2s, background .2s; }
.demo-accounts { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.auth-box .demo-accounts { border-style: dashed; }
.auth-box .demo-accounts summary { font-weight: 500; color: var(--muted); background: transparent; }
.auth-box .demo-accounts[open] summary { color: var(--fg-2); }
.auth-box .demo-list { max-height: 260px; overflow-y: auto; }
.demo-accounts summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 600; background: var(--surface-2); }
.demo-accounts summary::-webkit-details-marker { display: none; }
.demo-accounts summary .icon:last-child { margin-left: auto; transition: transform .2s; }
.demo-accounts[open] summary .icon:last-child { transform: rotate(180deg); }
.demo-list { display: grid; }
.demo-acc { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0; border-top: 1px solid var(--line); background: var(--surface); text-align: left; font-size: 14px; }
.demo-acc:hover { background: var(--surface-2); }
.demo-acc small { display: block; color: var(--muted); font-size: 13px; }
.demo-acc .badge { margin-left: auto; }
.secure-note { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); justify-content: center; }

/* ---------- Help desk: estructura ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: calc(var(--vh) - var(--bar-h)); min-height: 420px; }
.rail { background: var(--ink); color: var(--ink-fg); display: flex; flex-direction: column; gap: 6px; padding: 14px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
.rail-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rail .logo { color: #fff; padding: 4px 8px 14px; }
.rail .rail-close { display: none; color: var(--ink-fg); }
.rail-close:hover { background: var(--ink-3); color: #fff; }
.rail-scrim { display: none; }
.rail-sec { display: grid; gap: 1px; padding-top: 10px; }
.rail-sec .eyebrow { color: #5f6c81; padding: 0 10px 6px; font-size: 11.5px; }
.rail-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--ink-fg); font-size: 14.5px; text-align: left; transition: background .12s, color .12s; }
.rail-item:hover { background: var(--ink-3); color: #fff; }
.rail-item.on { background: var(--ink-3); color: #fff; }
.rail-item.on .icon { color: var(--gold-2); }
.rail-item .count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 6px; display: grid; place-items: center; font: 600 12px var(--mono); color: #8a97ab; background: rgba(255,255,255,.05); }
.rail-item.on .count { color: #fff; background: rgba(200,167,107,.22); }
.rail-item .count.hot { background: var(--bad); color: #fff; }
.rail-foot { margin-top: auto; padding: 12px 8px 4px; display: grid; gap: 10px; border-top: 1px solid var(--ink-3); }
.rail-me { display: flex; gap: 10px; align-items: center; width: 100%; padding: 6px; margin: -6px -6px 0; width: calc(100% + 12px); border: 0; border-radius: 8px; background: none; font-size: 14px; color: #fff; text-align: left; }
.rail-me:hover, .rail-me.on { background: var(--ink-3); }
.rail-me .rail-me-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-me small { display: block; color: #7d8aa0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.rail-me .avatar .presence { border-color: var(--ink); }
.presence-sel { display: flex; gap: 4px; }
.presence-sel button { flex: 1; border: 1px solid var(--ink-3); background: none; color: var(--ink-fg); border-radius: 6px; font-size: 12.5px; padding: 4px 0; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.presence-sel button i { width: 7px; height: 7px; border-radius: 50%; }
.presence-sel button.on { border-color: var(--ink-fg); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { flex: none; height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tb-title { display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; }
.topbar h1 { font-size: 16px; font-weight: 700; }
.menu-btn { display: none !important; margin-left: -6px; }
.topbar .crumb { color: var(--muted); font-size: 14px; }
.topbar .spacer { flex: 1; }
.topbar .icon-btn { flex: none; }
/* Iconos de la barra superior al mismo alto que el buscador (40px) */
.topbar .icon-btn { width: 40px; height: 40px; }
.topbar .icon-btn > .icon { width: 20px; height: 20px; }
.topbar #me .avatar { width: 30px; height: 30px; font-size: 12.5px; }
.topbar .icon-btn .dot { top: 4px; right: 3px; }
/* Buscador: 360px en computadora; se encoge antes de empujar los iconos de la derecha */
.cmd { display: flex; align-items: center; gap: 10px; flex: 0 1 360px; min-width: 180px; height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 15px; text-align: left; }
.cmd .icon { width: 18px; height: 18px; }
.cmd:hover { border-color: var(--line-strong); }
.cmd span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { position: relative; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--fg-2); }
.icon-btn:hover { background: var(--surface-3); color: var(--fg); }
.icon-btn .dot { position: absolute; top: 5px; right: 5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--bad); color: #fff; font: 700 11px var(--mono); display: grid; place-items: center; border: 2px solid var(--surface); }
.region { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; overflow-y: auto; }
.page-in { padding: 24px; padding-bottom: max(24px, env(safe-area-inset-bottom)); display: grid; gap: 20px; align-content: start; max-width: 1400px; margin: 0 auto; }
.page-in.narrow { max-width: 900px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head:not(:has(p)) { align-items: center; }
.page-head h2 { font-size: 21px; }
.page-head p { color: var(--muted); }

/* ---------- Bandeja de 3 paneles ---------- */
.inbox { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px minmax(0, 1fr); }
.list-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.list-head { flex: none; padding: 14px 16px 10px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-title h2 { font-size: 17px; }
.list-title .muted { font-size: 13px; }
.list-tools { display: flex; gap: 6px; align-items: center; }
.list-search { position: relative; flex: 1; }
.list-search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 15px; height: 15px; }
.list-search input { padding-left: 32px; }
.seg { display: flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--surface-3); overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1; border: 0; background: none; padding: 4px 6px; border-radius: 6px; font-size: 13px; color: var(--fg-2); white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); font-weight: 600; }
.seg button b { font-weight: 600; color: var(--muted); margin-left: 3px; font-family: var(--mono); font-size: 12px; }
.list { flex: 1; overflow-y: auto; }
.row { display: grid; grid-template-columns: 4px minmax(0, 1fr); width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; padding: 0; transition: background .1s; }
.row:hover { background: var(--surface-2); }
.row.on { background: var(--info-soft); }
.row.flash { animation: flash 2.2s ease; }
.row .stripe { background: transparent; }
.row.P1 .stripe { background: var(--bad); }
.row.P2 .stripe { background: var(--warn); }
.row-in { padding: 12px 14px 12px 12px; display: grid; gap: 5px; min-width: 0; }
.row-top { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.row-top .who { color: var(--fg); font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .row-top .who::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--info); margin-right: 6px; vertical-align: middle; }
.row-top .when { margin-left: auto; white-space: nowrap; }
.row-subj { font-size: 14px; color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .row-subj { color: var(--fg); font-weight: 600; }
.row-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.row-meta .sla { margin-left: auto; }
.sla { display: inline-flex; align-items: center; gap: 6px; font: 600 13px var(--mono); color: var(--muted); white-space: nowrap; }
.sla.risk { color: var(--warn); }
.sla.late { color: var(--bad); }
/* Vencido: etiqueta roja con reloj */
.sla.late { gap: 4px; padding: 1px 8px 1px 6px; border-radius: 999px; background: var(--bad-soft); font-weight: 700; cursor: help; font-family: var(--font); }
.sla.late .icon { width: 12px; height: 12px; }
.sla[tabindex]:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 999px; }
.sla.ok { color: var(--fg-2); }
.list-empty { padding: 48px 24px; text-align: center; color: var(--muted); display: grid; gap: 8px; justify-items: center; }
.list-empty .ic { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }

/* Detalle */
.detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.detail-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 24px; }
.detail-empty .big { width: 88px; height: 88px; border-radius: 22px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); margin: 0 auto 12px; color: var(--muted); }
.detail-empty .big .icon { width: 32px; height: 32px; }
.detail-empty b { font-size: 19px; font-weight: 700; }
.d-head { flex: none; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.d-top { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; flex-wrap: wrap; }
.d-top .grow { flex: 1; }
.d-title { display: flex; align-items: flex-start; gap: 12px; }
.d-title h2 { font-size: 19px; flex: 1; min-width: 0; }
.d-props { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.prop { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; color: var(--fg-2); }
button.prop:hover { border-color: var(--line-strong); background: var(--surface-2); }
.prop .icon { width: 14px; height: 14px; }
.prop .k { color: var(--muted); }
.d-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 330px; }
.conv { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.conv-tabs { flex: none; display: flex; gap: 4px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.conv-tabs button { border: 0; background: none; padding: 10px 4px; margin-right: 14px; font-size: 14px; color: var(--muted); box-shadow: inset 0 -2px 0 transparent; }
.conv-tabs button.on { color: var(--fg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--fg); }
.thread { flex: 1; overflow-y: auto; padding: 20px; display: grid; gap: 14px; align-content: start; }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); flex-wrap: wrap; font-size: 14px; }
.banner > .icon { color: var(--warn); }
.banner p { flex: 1; min-width: 220px; }
.banner.ok { background: var(--ok-soft); }
.banner.ok > .icon { color: var(--ok); }
.msg { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; animation: fade-up .2s ease; }
.msg-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.msg.agent .msg-card { background: var(--surface-2); }
.msg.internal .msg-card { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.msg-who { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 14px; margin-bottom: 6px; }
.msg-who b { font-weight: 700; }
.msg-who small { color: var(--muted); }
.msg-who .badge { height: 18px; font-size: 12px; }
.msg-card p { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--fg-2); }
.msg-sys { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); }
.msg-sys::before, .msg-sys::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.composer { position: relative; flex: none; margin: 0 20px 16px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--info); box-shadow: 0 0 0 3px var(--focus); }
.composer.note { background: var(--warn-soft); }
.composer.note:focus-within { border-color: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 25%, transparent); }
.comp-tabs { display: flex; gap: 2px; padding: 6px 6px 0; }
.comp-tabs button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; font-size: 13.5px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.comp-tabs button.on { color: var(--fg); background: var(--surface-3); font-weight: 600; }
.composer.note .comp-tabs button.on { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.composer textarea { width: 100%; border: 0; background: transparent; resize: none; min-height: 84px; max-height: 240px; padding: 10px 14px; outline: none; line-height: 1.5; }
.comp-foot { display: flex; align-items: center; gap: 6px; padding: 6px 8px 8px; }
.comp-foot .spacer { flex: 1; }
/* Adjuntos: bandeja antes de enviar (arrastrar y soltar sobre el cuadro) */
.composer.drop { border-color: var(--info); box-shadow: 0 0 0 3px var(--focus); }
.att-tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 10px 4px; }
.att-tray:empty { display: none; }
.att-chip { display: flex; align-items: center; gap: 8px; width: min(240px, 100%); padding: 6px 4px 6px 6px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.att-chip.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.att-chip.bad small { color: var(--bad); white-space: normal; }
.att-thumb { flex: none; width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); }
.att-meta { flex: 1; min-width: 0; display: grid; gap: 2px; }
.att-meta b { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-meta small { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-bar { display: none; height: 3px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.att-chip.up .att-bar { display: block; }
.att-bar i { display: block; height: 100%; width: 0; background: var(--info); transition: width .15s; }
.att-x { flex: none; width: 26px; height: 26px; }
.att-err { flex-basis: 100%; margin: 0; display: flex; gap: 6px; align-items: flex-start; font-size: 13.5px; color: var(--bad); }
.att-err .icon { flex: none; margin-top: 2px; }
/* Correo recibido: HTML ya limpio en el servidor */
.msg-html { font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.msg-html > :first-child { margin-top: 0; }
.msg-html > :last-child { margin-bottom: 0; }
.msg-html p { margin: 0 0 8px; }
.msg-html a { color: var(--info); }
.msg-html img { max-width: 100%; height: auto; border-radius: 6px; }
.msg-html table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.msg-html ul, .msg-html ol { padding-left: 20px; }
.mail-retry { font-size: 13px; margin-left: 2px; }
/* Adjuntos en la conversación */
.att-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att-img { padding: 0; width: 132px; height: 96px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-3); cursor: zoom-in; }
.att-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.att-doc { display: flex; align-items: center; gap: 10px; width: min(260px, 100%); padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--fg); text-decoration: none; }
.att-doc:hover { border-color: var(--line-strong); background: var(--surface-2); }
.att-doc > .icon { flex: none; color: var(--muted); }
.att-doc .ic { flex: none; width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; background: var(--info-soft); color: var(--info); }
.lightbox { place-items: center; padding: 16px; background: rgba(8, 12, 20, .82); }
.lightbox figure { margin: 0; display: grid; gap: 10px; max-width: min(1100px, 100%); }
.lightbox img { justify-self: center; max-width: 100%; max-height: calc(100dvh - 110px); object-fit: contain; border-radius: 8px; background: var(--surface); }
.lightbox figcaption { display: flex; align-items: center; gap: 8px; color: #e5eaf1; font-size: 14px; }
.lightbox figcaption span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Ticket cerrado: en lugar del cuadro de respuesta */
.closed-note { flex: none; margin: 0 20px 16px; display: flex; gap: 8px; align-items: center; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: 14px; }
/* Respuestas guardadas: se abre hacia arriba desde el cuadro de respuesta, por encima de la conversación y del panel del cliente */
.macro-pop { position: absolute; top: auto; bottom: calc(100% + 8px); left: 0; z-index: 90; width: min(340px, 100%); display: flex; flex-direction: column; gap: 6px; animation: macro-up .14s ease-out; }
@keyframes macro-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.macro-list { position: relative; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; display: grid; align-content: start; }
.macro-list .pop-item { display: grid; gap: 2px; }
.macro-list .pop-item small { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.macro-empty { margin: 0; padding: 10px; font-size: 14px; color: var(--muted); }
.split { display: inline-flex; flex: none; }
.split #send { white-space: nowrap; }
.split .btn:first-child { border-radius: 8px 0 0 8px; }
.split .btn:only-child { border-radius: 8px; }
.split #send-more { border-radius: 0 8px 8px 0; border-left: 1px solid rgba(255,255,255,.18); width: 30px; padding: 0; }
.timeline { padding: 20px; overflow-y: auto; flex: 1; }
.tl { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; padding-bottom: 18px; position: relative; }
.tl::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl .ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.tl .ic .icon { width: 14px; height: 14px; }
.tl small { display: block; color: var(--muted); font-size: 13px; }

/* Panel 360 del cliente */
.c360 { border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; display: flex; flex-direction: column; }
.c-head { padding: 18px; display: grid; gap: 14px; border-bottom: 1px solid var(--line); }
.c-id { display: flex; gap: 12px; align-items: center; }
.c-id h3 { font-size: 16px; }
.c-id small { display: block; color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.c-id .icon-btn { margin-left: auto; }
.c-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.c-tabs { display: flex; padding: 0 12px; border-bottom: 1px solid var(--line); }
.c-tabs button { flex: 1; border: 0; background: none; padding: 10px 0; font-size: 13.5px; color: var(--muted); box-shadow: inset 0 -2px 0 transparent; }
.c-tabs button.on { color: var(--fg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--fg); }
.c-sec { padding: 16px 18px; display: grid; gap: 12px; border-bottom: 1px solid var(--line); }
.c-sec h4 { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--fg); overflow-wrap: anywhere; }
.locked { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13.5px; }
.locked .icon { width: 13px; height: 13px; }
.risk-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.risk-bar i { display: block; height: 100%; border-radius: 999px; background: var(--rc, var(--muted)); transition: background-color .4s ease; }
/* Sección Riesgo del panel del cliente: el número, la barra y el nivel comparten color */
.risk-sec { --rc: var(--risk-low); }
.risk-sec[data-level="crit"] { --rc: var(--risk-crit); }
.risk-sec[data-level="high"] { --rc: var(--risk-high); }
.risk-sec[data-level="med"] { --rc: var(--risk-med); }
.risk-sec .risk-num { color: var(--rc); font-size: 13px; letter-spacing: 0; transition: color .4s ease; }
.risk-sec .risk-bar { height: 8px; }
.risk-hint { font-size: 13.5px; color: var(--muted); margin: 0; }
.risk-hint b { color: var(--rc); font-weight: 700; transition: color .4s ease; }
.risk-sig { display: flex; flex-wrap: wrap; gap: 6px; }
.risk-sig .badge { font-size: 12px; }
.risk-line { display: flex; justify-content: space-between; font-size: 13.5px; }
.balance { font: 700 24px var(--mono); letter-spacing: -.02em; }
.tx { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.tx:last-child { border-bottom: 0; }
.tx .d { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .a { font-family: var(--mono); text-align: right; }
.tx .a.in { color: var(--ok); }
.tx small { color: var(--muted); font-size: 13px; }
.assignee { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; width: 100%; background: var(--surface); text-align: left; }
button.assignee:hover { border-color: var(--line-strong); background: var(--surface-2); }
.assignee b { display: block; font-size: 14px; font-weight: 700; }
.assignee small { color: var(--muted); font-size: 13px; }
.assignee .icon:last-child { margin-left: auto; color: var(--muted); }
.acts { display: grid; gap: 6px; }
.act { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; text-align: left; transition: border-color .12s, background .12s; }
.act:hover { border-color: var(--line-strong); background: var(--surface-2); }
.act .icon:first-child { color: var(--muted); }
.act .icon:last-child { margin-left: auto; color: var(--muted); width: 14px; }
.act.primary { background: var(--btn); color: var(--btn-fg); border-color: var(--btn); }
.act.primary .icon { color: var(--btn-fg) !important; }
/* Motivo del último cambio de agente o área */
.assign-why { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; }
.assign-why > .icon { flex: none; margin-top: 2px; color: var(--muted); }
.assign-why b { font-weight: 600; }
.assign-why .why-c { display: block; color: var(--fg-2); margin-top: 2px; overflow-wrap: anywhere; }
.assign-why small { display: block; color: var(--muted); margin-top: 2px; }
.act.current { opacity: .6; cursor: default; }
.act.away { opacity: .55; cursor: not-allowed; }
.follow { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--info-soft); font-size: 13.5px; }
.follow .icon { color: var(--info); }
.hist { display: flex; gap: 10px; align-items: center; padding: 8px 0; font-size: 14px; border-bottom: 1px solid var(--line); }
.hist:last-child { border-bottom: 0; }
.hist .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tablero ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px 18px 12px; display: grid; gap: 4px; }
.kpi .lbl { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13.5px; }
.kpi .val { font: 700 30px var(--mono); letter-spacing: -.03em; }
.kpi .val small { font-size: 15px; color: var(--muted); font-weight: 600; margin-left: 2px; }
.delta { font: 600 13px var(--mono); }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-h h3 { font-size: 15px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 3px; border-radius: 2px; }
.chart { width: 100%; overflow: visible; }
.chart text { fill: var(--muted); font: 12px var(--mono); }
.chart .grid { stroke: var(--line); }
.donut-wrap { display: grid; place-items: center; position: relative; }
.donut-wrap .c { position: absolute; text-align: center; }
.donut-wrap .c b { font: 700 28px var(--mono); display: block; letter-spacing: -.03em; }
.donut-wrap .c small { color: var(--muted); font-size: 13px; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.mini-stats div { padding: 10px; border-radius: 8px; background: var(--surface-2); font-size: 13px; color: var(--muted); }
.mini-stats b { display: block; font: 700 17px var(--mono); color: var(--fg); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.t td { padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--surface-2); }
.t .c { text-align: center; }
.t .r { text-align: right; }
.table-wrap { overflow-x: auto; }
.load { display: flex; align-items: center; gap: 8px; min-width: 90px; }
.load .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.load .bar i { display: block; height: 100%; background: var(--fg-2); border-radius: 999px; }
.att { display: grid; }
.att-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 11px 16px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; font-size: 14px; }
.att-row:hover { background: var(--surface-2); }
.att-row:last-child { border-bottom: 0; }
.att-row .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perm-group td { background: var(--surface-2); font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 8px 16px; }

/* Paleta de comandos */
.palette { width: 100%; max-width: 560px; align-self: start; margin-top: 12vh; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.palette input { width: 100%; height: 52px; border: 0; border-bottom: 1px solid var(--line); padding: 0 18px; font-size: 16px; background: transparent; outline: none; }
.palette .res { max-height: 360px; overflow-y: auto; padding: 6px; }
.palette .pop-item { padding: 10px 12px; }
.palette .pop-item.on { background: var(--surface-3); }
.palette .foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); background: var(--surface-2); }
.notif-list { max-height: 400px; overflow-y: auto; }
.notif { display: grid; grid-template-columns: 30px minmax(0, 1fr) 8px; gap: 10px; align-items: start; width: 100%; padding: 10px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 14px; }
.notif:hover { background: var(--surface-3); }
.notif .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--fg-2); }
.notif .ic.alert { background: var(--bad-soft); color: var(--bad); }
.notif .ic.clock { background: var(--warn-soft); color: var(--warn); }
.notif .ic.inbox { background: var(--info-soft); color: var(--info); }
.notif small { display: block; color: var(--muted); font-size: 13px; }
.notif .u { width: 8px; height: 8px; border-radius: 50%; background: var(--info); margin-top: 6px; }
.notif.read .u { background: transparent; }
.notif.read b { font-weight: 500; }

.team-t th, .team-t td { padding-left: 10px; padding-right: 10px; }
.team-t th:first-child, .team-t td:first-child { padding-left: 18px; }
.team-t th:last-child, .team-t td:last-child { padding-right: 18px; }
.team-t .load { min-width: 60px; }
/* Usuarios: Nombre ancho, Rol y Área medianos, Acciones a la derecha */
.users-t th:nth-child(1) { width: 40%; }
.users-t th:nth-child(2) { width: 20%; }
.users-t th:nth-child(3) { width: 22%; }
.users-t td { vertical-align: middle; }
.users-t td.cell-main .badge { height: 20px; font-size: 12px; margin-left: 4px; vertical-align: 1px; }
.u-acts { display: inline-grid; grid-template-columns: 78px 140px 96px; align-items: center; justify-items: start; gap: 4px; }
.u-acts .u-me { grid-column: span 2; justify-self: center; font-size: 13px; }
.btn.soft-danger { color: color-mix(in srgb, var(--bad) 85%, var(--muted)); }
.btn.soft-danger:hover:not(:disabled) { background: var(--bad-soft); color: var(--bad); }
.u-del-off { display: inline-flex; cursor: not-allowed; }
.badge.gone { height: 18px; padding: 0 6px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); margin-left: 6px; vertical-align: 1px; }

/* Catálogos */
.cat-t td { vertical-align: middle; }
.cat-acts { display: inline-flex; gap: 4px; justify-content: flex-end; }
.cat-del-off { display: inline-flex; border-radius: 6px; }
.cat-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--surface-3); color: var(--fg-2); flex: none; }
.cf-icons { display: flex; flex-wrap: wrap; gap: 6px; }
.cf-icons label { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--fg-2); cursor: pointer; }
.cf-icons input { position: absolute; opacity: 0; pointer-events: none; }
.cf-icons label:has(input:checked) { border-color: var(--btn); box-shadow: 0 0 0 1px var(--btn); color: var(--fg); }
.cf-icons label:has(input:focus-visible) { outline: 2px solid var(--btn); outline-offset: 2px; }
.dur { grid-template-columns: 1fr 1fr; }

/* ---------- Roles y permisos ---------- */
.role-ic { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--fg-2); }
.role-ic[data-r="admin"] { background: var(--gold-soft); color: var(--gold); }
.role-ic[data-r="supervisor"] { background: var(--info-soft); color: var(--info); }
.role-ic[data-r="guard"] { background: var(--violet-soft); color: var(--violet); }
.role-ic[data-r="agent_l2"] { background: var(--ok-soft); color: var(--ok); }
/* Todas las tarjetas del mismo ancho y alto, de borde a borde del contenido */
.role-cards { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 12px; }
@media (max-width: 1100px) { .role-cards { --cols: 2; } }
@media (max-width: 560px) { .role-cards { --cols: 1; } }
.role-card { width: 100%; height: 100%; min-width: 0; padding: 14px 16px; display: grid; gap: 6px; align-content: start; }
.rc-top { display: flex; align-items: center; gap: 10px; }
.rc-top b { flex: 1; font-size: 15px; line-height: 1.25; }
.role-card .num { font: 700 13.5px var(--mono); color: var(--fg-2); overflow-wrap: anywhere; }
.rc-top b { min-width: 0; overflow-wrap: anywhere; }
.role-panel { overflow: hidden; animation: fade-up .18s ease; }
.rp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.rp-head h3 { font-size: 16px; }
.rp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.rp-person { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 18px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-size: 14px; }
.rp-person.past { opacity: .55; }
.rp-name { flex: 1; min-width: 0; display: grid; }
.rp-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-name small { color: var(--muted); font-size: 13px; }
.rp-sp { width: 26px; }
.rp-empty { padding: 16px 18px; font-size: 14px; }
/* Tarjeta de rol como botón: la elegida queda marcada y abre su panel debajo */
button.role-card { font: inherit; color: inherit; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
button.role-card:hover { border-color: var(--line-strong); }
.role-card.on { border-color: var(--btn); box-shadow: 0 0 0 1px var(--btn); }
.role-card:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
.role-new { place-content: center; justify-items: center; grid-template-rows: none; border-style: dashed; color: var(--fg-2); background: none; }
.role-new b { font-size: 15px; font-weight: 700; }
.rp-title { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: min(260px, 100%); }
.rp-title > div { min-width: 0; display: grid; gap: 2px; }
.rp-title h3 { overflow-wrap: anywhere; }
.rp-meta { font: 700 13.5px var(--mono); color: var(--fg-2); margin-top: 4px; }
.rp-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.perm-secs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); }
.perm-sec { min-width: 0; border-bottom: 1px solid var(--line); }
.perm-sec h4 { background: var(--surface-2); font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 8px 18px; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 14px; cursor: pointer; }
.perm-row > span:first-child { min-width: 0; display: grid; overflow-wrap: anywhere; }
.perm-row small { color: var(--muted); font-size: 12.5px; }
.perm-row:has(input:disabled) { cursor: default; }

/* ---------- Mi perfil ---------- */
.p-head { display: flex; gap: 20px; align-items: center; }
.p-head .avatar .presence { width: 18px; height: 18px; border-width: 3px; right: 2px; bottom: 2px; }
.p-id { min-width: 0; display: grid; gap: 4px; }
.p-id h2 { font-size: 24px; }
.p-id p { color: var(--muted); overflow-wrap: anywhere; }
.p-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.p-body { display: grid; gap: 16px; }
.p-card-h { padding: 18px 20px 0; display: grid; gap: 2px; }
.p-card-h h3 { font-size: 16px; }
.p-card-h p { color: var(--muted); font-size: 14px; }
.p-card-b { padding: 16px 20px 20px; display: grid; gap: 14px; }
.p-card-f { padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); display: flex; justify-content: flex-end; gap: 8px; border-radius: 0 0 var(--radius) var(--radius); }
.p-save { display: flex; justify-content: flex-end; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.photo-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.photo-acts .hint { flex-basis: 100%; }
.photo-acts label.btn { cursor: pointer; }
.photo-acts label.busy { opacity: .6; pointer-events: none; }
.input:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.sess-t { flex: 1; min-width: 0; display: grid; gap: 1px; }
.sess-t b { font-weight: 600; }
.sess-t small { color: var(--muted); font-size: 13.5px; }
.ses-list { display: grid; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.ses-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; font-size: 14.5px; }
.ses-row + .ses-row { border-top: 1px solid var(--line); }
.ses-row > .icon { color: var(--muted); }
.ses-row .badge, .ses-row .btn { flex: none; }
.p-sec { font-size: 18px; margin-top: 12px; scroll-margin-top: 16px; }
.pref-row { display: flex; align-items: center; gap: 16px; cursor: pointer; }
.pref-row > span:first-child { flex: 1; display: grid; gap: 2px; }
.pref-row b { font-weight: 600; }
.pref-row small { color: var(--muted); font-size: 13.5px; }
.pop-me { display: flex; gap: 12px; align-items: center; padding: 8px 10px 10px; }
.pop-me b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-me small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

/* ---------- Responsivo ---------- */
@media (min-width: 1361px) { .only-narrow { display: none !important; } }
@media (max-width: 1360px) {
  .d-body { grid-template-columns: minmax(0, 1fr); }
  .c360 { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); z-index: 60; box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform .2s ease; padding-bottom: env(safe-area-inset-bottom); }
  .c360.open { transform: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Tableta: barra lateral solo con iconos */
@media (max-width: 1180px) and (min-width: 901px) {
  .app { grid-template-columns: 72px minmax(0, 1fr); }
  .rail { padding: 14px 10px; align-items: stretch; }
  .rail .logo { padding: 4px 0 14px; justify-content: center; }
  .rail .logo-txt, .rail-sec .eyebrow, .rail-label, .rail-me-t, .presence-sel span { display: none; }
  .rail-sec { padding-top: 6px; border-top: 1px solid var(--ink-3); }
  .rail-sec:first-of-type { border-top: 0; }
  .rail-item { justify-content: center; position: relative; padding: 10px 0; }
  .rail-item .count { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 16px; padding: 0 4px; font-size: 11px; margin: 0; }
  .rail-foot { padding: 10px 0 4px; justify-items: center; }
  .rail-me { width: auto; margin: 0; justify-content: center; }
  .presence-sel { flex-direction: column; width: 100%; }
  .presence-sel button { padding: 6px 0; }
  .inbox { grid-template-columns: 320px minmax(0, 1fr); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
/* Teléfono y tableta vertical: la barra lateral se abre como menú */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); position: relative; }
  .rail { position: fixed; z-index: 70; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: none; padding-top: max(14px, env(safe-area-inset-top)); }
  .app.rail-open .rail { transform: none; box-shadow: var(--shadow-lg); }
  .rail-scrim { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(8, 12, 20, .5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.rail-open .rail-scrim { opacity: 1; pointer-events: auto; }
  .rail .rail-close { display: grid; }
  .rail .logo { padding-bottom: 10px; }
  .rail-item { padding: 10px; font-size: 15px; }
  .menu-btn { display: grid !important; }
  .topbar { padding: 0 12px; gap: 4px; }
  .topbar .crumb { display: none; }
  .cmd { flex: none; min-width: 0; width: 40px; height: 40px; padding: 0; justify-content: center; border-color: transparent; background: none; color: var(--fg-2); }
  .cmd span { display: none; }
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox .detail { display: none; }
  .inbox.show-detail .list-pane { display: none; }
  .inbox.show-detail .detail { display: flex; }
  .list-pane { border-right: 0; }
  .d-head { padding: 12px 16px; }
  .d-title h2 { font-size: 17px; }
  .d-top .badge.outline { display: none; }
  .thread { padding: 16px; }
  .page-in { padding: 16px; }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}
/* Tablas que se vuelven tarjetas */
@media (max-width: 900px) {
  .table-wrap:has(table.stack) { background: none; border: 0; overflow: visible; }
  table.stack, table.stack tbody { display: block; }
  table.stack thead { display: none; }
  table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  table.stack tbody tr:hover td { background: none; }
  table.stack td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; white-space: normal; text-align: right; min-width: 0; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font: 500 13px var(--font); letter-spacing: 0; text-align: left; flex: none; }
  table.stack td.cell-main, table.stack td:first-child { padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line); text-align: left; }
  table.stack td.cell-main::before, table.stack td:first-child::before, table.stack td:not([data-label])::before, table.stack td[data-label=""]::before { display: none; }
  table.stack td.r[data-label]:not([data-label='']), table.stack td.c[data-label]:not([data-label='']) { justify-content: space-between; }
  table.stack td.r, table.stack td.c { justify-content: flex-end; }
  table.stack td:last-child:empty { display: none; }
  .u-acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  }
@media (max-width: 560px) {
  .kpis, .mini-stats { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px 12px 8px; }
  .kpi .val { font-size: 24px; }
  .kpi > small { display: none; }
  .d-head { padding-left: 14px; padding-right: 14px; }
  .thread { padding: 14px 12px; }
  .msg { grid-template-columns: 28px minmax(0, 1fr); gap: 8px; }
  .composer { margin: 0 8px 8px; margin-bottom: max(8px, env(safe-area-inset-bottom)); }
  .closed-note { margin: 0 8px 8px; margin-bottom: max(8px, env(safe-area-inset-bottom)); }
  .att-chip { width: 100%; }
  .d-head { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .d-props { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding: 0 14px; }
  .d-props::-webkit-scrollbar { display: none; }
  .prop { flex: none; }
  .d-title { flex-wrap: wrap; gap: 8px; }
  .d-title h2 { flex-basis: 100%; }
  .composer textarea { min-height: 56px; }
  .macro-list { max-height: min(320px, 38vh); }
  .comp-tabs button { padding: 6px 8px; }
  .rules { grid-template-columns: minmax(0, 1fr); }
  .page-head { align-items: stretch; }
  .page-head > .btn { width: 100%; }
  .page-head > .seg { width: 100%; }
  .att-row { grid-template-columns: 40px minmax(0, 1fr) auto; padding: 10px 12px; }
  .att-row > span:nth-child(3) { display: none; }
  .p-head { gap: 14px; }
  .p-head .avatar.xl { width: 64px; height: 64px; font-size: 24px; }
  .p-id h2 { font-size: 19px; }
  .p-card-h { padding: 16px 16px 0; }
  .p-card-b { padding: 14px 16px 16px; }
  .p-card-f { padding: 12px 16px; }
  .p-card-f .btn, .p-save .btn { flex: 1; }
    .tl { gap: 10px; }
  .kv { grid-template-columns: 100px minmax(0, 1fr); }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
}

/* Inicio de sesión en teléfono: la tarjeta ocupa todo el ancho con 16px de margen; campos y botón con la misma altura */
@media (max-width: 480px) {
  .auth { padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); padding-left: 16px; padding-right: 16px; }
  .auth-wrap, .auth-card { max-width: none; }
  .auth-card { min-height: 0; padding: 32px 24px 24px; }
  .auth-box .rules { grid-template-columns: minmax(0, 1fr); }
  .auth-box .otp { gap: 6px; }
}
