:root { color-scheme: light; font-family: "Segoe UI", system-ui, sans-serif; color: #1b2544; background: #f1f4fa; font-size: 16px; }
* { box-sizing: border-box; }
body { margin: 0; display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #a33649; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.rail { display: flex; flex-direction: column; background: #202d58; color: #fffffe; padding: 25px 16px 20px; gap: 42px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 5px; font-weight: 730; line-height: 1.2; }
.brand small { display: block; margin-top: 5px; color: #d7e2ff; font-size: .8125rem; font-weight: 500; }
.brand-mark, .chat-avatar { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border-radius: 10px; font-weight: 500; font-size: 1.55rem; }
.brand-mark { background: #a33649; }
nav { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; font-size: .875rem; font-weight: 600; gap: 10px; background: transparent; border: 0; color: #ecf2ff; border-radius: 9px; padding: 11px; text-align: left; }
.nav-item span { font-size: 1.15rem; line-height: 1; }
.nav-item:hover, .nav-item.active { background: #334988; color: #fff; }
.rail-bottom { margin-top: auto; padding: 12px 8px; display: flex; align-items: center; gap: 8px; font-size: .875rem; color: #d7e2ff; }
.connection-dot { width: 8px; height: 8px; background: #a7dec9; border-radius: 50%; }
.topbar { min-height: 67px; padding: 10px 28px; background: #fff; border-bottom: 1px solid #d7e0f1; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .9rem; font-weight: 650; }
.access, .quiet, .example, .primary { border: 1px solid transparent; border-radius: 8px; padding: 8px 12px; font-size: .875rem; font-weight: 650; }
.access, .quiet { color: #253d76; background: #fff; border-color: #cbd7ed; }
.access:hover, .quiet:hover { background: #e8edf8; }
.layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(330px, 1fr); gap: 22px; padding: 32px 28px; max-width: 1570px; margin: auto; }
.inbox, .chat { min-width: 0; scroll-margin-top: 16px; }
h1 { font-size: clamp(1.75rem, 3vw, 2.1rem); line-height: 1.2; letter-spacing: -.04em; }
.intro { margin-top: 8px; color: #505b72; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 21px 0 17px; }
.stat, .ticket-card, .chat { background: #fff; border: 1px solid #d7e0f1; border-radius: 13px; }
.stat { display: grid; gap: 8px; padding: 13px 15px; }
.stat span { color: #505b72; font-size: .875rem; }
.stat strong { font-size: 1.5rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ticket-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 14px 17px; border-bottom: 1px solid #e4eaf6; }
.ticket-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#ticket-feedback:not(:empty) { padding-inline: 17px; }
h2 { font-size: 1.05rem; }
select { border: 1px solid #cbd7ed; background: #fff; color: #253d76; border-radius: 8px; padding: 7px 10px; font-size: .875rem; }
.empty { text-align: center; display: grid; justify-items: center; gap: 8px; min-height: 216px; align-content: center; padding: 20px; }
.empty span:last-child { color: #505b72; font-size: .875rem; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: #dfe8fe; color: #29499e; font-size: 1.4rem; }
.ticket-row { padding: 14px 17px; display: grid; gap: 7px; border-bottom: 1px solid #e4eaf6; overflow-wrap: anywhere; }
.ticket-row:last-child { border: 0; }
.ticket-row-header, .ticket-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ticket-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ticket-row p { color: #394760; }
.ticket-link { color: #263e86; font-weight: 750; padding: 0; border: 0; background: none; text-decoration: underline; text-underline-offset: 3px; }
.ticket-meta { color: #505b72; font-size: .875rem; }
.reply-status { font-size: .875rem; }
.ticket-row .reply-status.failed, #reply-feedback:not(:empty) { color: #9b263c; }
.tag { border-radius: 20px; padding: 4px 9px; font-size: .875rem; font-weight: 650; background: #e2ebff; color: #284ca6; }
.tag.en_atencion { background: #fff0d9; color: #724316; }
.tag.cerrado { background: #e0f2e9; color: #1d654e; }
.chat { display: flex; flex-direction: column; align-self: start; overflow: hidden; }
.chat-header { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid #e4eaf6; }
.chat-avatar { color: #2450ad; background: #e2edff; }
.chat-header p { margin-top: 2px; color: #505b72; font-size: .875rem; }
.chat-header .quiet { margin-left: auto; }
.messages { min-height: 237px; max-height: 350px; overflow-y: auto; padding: 16px 14px; display: flex; align-items: flex-start; flex-direction: column; gap: 10px; background: #f1f5fc; }
.bubble { padding: 9px 12px; max-width: 89%; border-radius: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble.bot { background: #e6edff; border-top-left-radius: 4px; }
.bubble.user { align-self: flex-end; background: #dfeaff; border-top-right-radius: 4px; }
.collected { padding: 12px 14px; border-top: 1px solid #e4eaf6; background: #f8faff; }
.collected h3 { font-size: .875rem; }
.collected dl { margin: 8px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 11px; font-size: .875rem; }
.collected dt { color: #505b72; }
.collected dd { margin: 0; overflow-wrap: anywhere; }
.composer { border-top: 1px solid #e4eaf6; padding: 12px 14px; }
.example { color: #2450ad; background: #e5edff; margin-bottom: 10px; text-align: left; }
.example:hover { background: #d4e3ff; }
#chat-form { display: flex; gap: 8px; align-items: flex-end; }
textarea, input { width: 100%; min-width: 0; border: 1px solid #c8d3eb; border-radius: 8px; background: #fff; color: #1b2544; padding: 8px; }
textarea { flex: 1; min-height: 39px; resize: vertical; }
.primary { color: #fff; background: #a33649; min-height: 39px; }
.primary:hover { background: #81273b; }
.feedback { color: #9b263c; font-size: .875rem; }
.feedback:not(:empty) { margin-top: 8px; }
.engine-note { color: #505b72; font-size: .875rem; margin-top: 8px; }
dialog { width: min(95%, 415px); padding: 22px; border: 1px solid #d7e0f1; border-radius: 14px; color: #1b2544; }
dialog::backdrop { background: rgb(25 39 79 / 62%); }
dialog p { margin: 8px 0 13px; color: #505b72; }
dialog label { display: block; margin-bottom: 5px; font-size: .875rem; font-weight: 650; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.sr-only { width: 1px; height: 1px; position: absolute; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

:root {
  --ink: #1b2544;
  --muted: #505b72;
  --line: #d7e0f1;
  --ink-blue: #202d58;
  --coral: #a33649;
  --shadow: 0 12px 32px rgb(36 55 112 / 10%);
  color: var(--ink);
  background: #f1f4fa;
}
[hidden] { display: none !important; }
body { grid-template-columns: 218px minmax(0, 1fr); }
main { min-width: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { transition: background-color .18s, color .18s, border-color .18s, box-shadow .18s, transform .18s; }
button:not(:disabled):active { transform: translateY(1px); }
:focus-visible { outline: 2px solid #a33649; outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }
.rail {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100dvh;
  background: var(--ink-blue);
  padding: 25px 14px 18px;
  gap: 34px;
}
.brand-mark { background: var(--coral); box-shadow: 0 6px 18px #1724556b; }
.brand small, .rail-bottom { color: #d7e2ff; }
.nav-item { color: #eef3ff; padding: 12px 9px; }
.nav-item:hover { background: #ffffff21; }
.nav-item.active { background: #315bc6; box-shadow: 0 5px 16px #15234955; }
.connection-dot { background: #98dfc3; box-shadow: 0 0 0 4px #98dfc326; }
.topbar { min-height: 60px; padding-inline: clamp(16px, 3vw, 36px); color: #253d76; border-color: var(--line); }
#breadcrumb { margin-left: .45rem; color: var(--muted); }
.session-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
#session-name { color: var(--muted); overflow-wrap: anywhere; }
.login-fields { display: grid; gap: 6px; margin-top: 14px; }
.login-fields label { margin: 0; }
.login-fields input + label { margin-top: 7px; }
#activate-account { margin: 14px 0 0; }
.unit-picker { display: grid; gap: 5px; margin-bottom: 10px; }
.unit-picker select { width: 100%; }
.unit-picker label { font-weight: 650; color: var(--muted); font-size: .86rem; }
.layout { display: block; max-width: 1610px; padding: clamp(16px, 2.5vw, 32px); }
.view { min-width: 0; animation: enter .28s ease-out both; }
.inbox-header, .detail-header {
  isolation: isolate;
  position: relative;
  overflow: hidden;
  color: #fff;
  background: var(--ink-blue);
  border-radius: 20px;
  box-shadow: 0 12px 28px #263c8329;
}
.inbox-header::before {
  position: absolute;
  z-index: -1;
  right: clamp(12px, 6vw, 110px);
  top: -50px;
  width: 174px;
  aspect-ratio: 1;
  border: 22px solid #4261ac;
  border-radius: 42px;
  box-shadow: 28px 23px 0 -12px #f2828e;
  transform: rotate(-25deg);
  content: "";
}
.inbox-header { padding: clamp(22px, 4vw, 40px); }
.inbox-header .intro { color: #e9efff; line-height: 1.5; }
.stats { gap: clamp(8px, 1.5vw, 17px); margin-block: 19px; }
.stat {
  border-color: var(--stat-line);
  background: var(--stat-bg);
  color: var(--stat-ink);
  box-shadow: 0 4px 16px rgb(36 55 112 / 6%);
  border-radius: 15px;
  padding: 14px clamp(10px, 2vw, 20px);
}
.stat span { color: inherit; font-weight: 650; }
.stat strong { font-size: clamp(1.55rem, 3vw, 2.15rem); }
.stat-new, .state-nuevo { --stat-bg: #e2ebff; --stat-ink: #284ca6; --stat-line: #c9d9ff; --accent: #4769cf; }
.stat-active, .state-en_atencion { --stat-bg: #fff0d9; --stat-ink: #724316; --stat-line: #f0d7ad; --accent: #b66d2d; }
.stat-closed, .state-cerrado { --stat-bg: #e0f2e9; --stat-ink: #1d654e; --stat-line: #c1e4d4; --accent: #438c73; }
.ticket-card, .chat { box-shadow: var(--shadow); border-color: var(--line); border-radius: 17px; }
.ticket-toolbar { padding: 16px 19px; border-color: var(--line); }
#ticket-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; padding: 15px; background: #f9faff; border-radius: 0 0 17px 17px; }
.empty { grid-column: 1 / -1; }
.empty-icon { background: #e2ebff; color: #284ca6; }
.ticket-row, .ticket-row:last-child {
  align-content: start;
  grid-template-rows: auto auto 1fr auto;
  gap: 9px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 14px 15px;
  background: #fff;
  box-shadow: 0 4px 9px #21386d10;
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
.ticket-row:hover, .ticket-row:focus-within { transform: translateY(-2px); box-shadow: 0 9px 24px #28438422; border-color: var(--accent); }
.ticket-code { display: inline-block; color: var(--stat-ink); font-weight: 750; font-size: .8rem; font-variant-numeric: tabular-nums; }
.ticket-link { width: fit-content; text-align: left; color: var(--ink); text-decoration: none; font-size: 1.075rem; }
.ticket-link:hover { color: var(--ink-blue); text-decoration: underline; }
.ticket-meta { border-top: 1px solid #e9edf6; margin-top: 2px; padding-top: 9px; font-size: .8rem; color: var(--muted); }
.back-button {
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  color: #922f48;
  background: #fbe6eb;
  font-size: .82rem;
  font-weight: 750;
}
.back-button:hover { background: #f5d1dc; }
.back-button { margin-bottom: 11px; }
.back-button span { margin-right: 3px; font-size: 1rem; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; font-size: .8rem; background: #e2ebff; color: #284ca6; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.en_atencion { background: #fff0d9; color: #724316; }
.tag.cerrado { background: #e0f2e9; color: #1d654e; }
.access, .quiet { color: #253d76; background: #fff; border-color: #cbd7ed; }
.access:hover, .quiet:hover { background: #fff0f3; border-color: #e3aab7; }
.primary { background: #a33649; color: #fff; box-shadow: 0 4px 10px #9b335329; }
.primary:hover { background: #81273b; }
.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px clamp(14px, 2vw, 26px);
  overflow-wrap: anywhere;
}
.detail-header h1 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
.detail-heading-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 7px; }
.detail-folio { color: #e7efff; font-size: .83rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.detail-heading-meta .tag { animation: badge-in .25s ease-out; }
.detail-header .primary { color: #202d58; background: #fff; }
.detail-header .primary:hover { background: #e2ebff; }
.detail-header .close-ticket { color: #fff; background: #304477; border-color: #b2c2ef; }
.detail-header .close-ticket:hover { background: #40568d; }
.detail-body { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 3fr); gap: clamp(12px, 2vw, 22px); margin-top: 15px; }
.detail-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: min(480px, 65dvh);
  height: calc(100dvh - 228px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-header { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.thread-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; background: #f9e4ea; }
#detail-refresh { font-size: .8rem; padding: 6px 8px; }
.panel-note { font-size: .8rem; color: var(--muted); margin-top: .22rem; }
.record-panel .panel-header { background: #e2ebff; }
.thread-scroll, .record-content { flex: 1; min-height: 0; overflow: auto; scrollbar-color: #aebedd transparent; }
.thread-scroll { padding: 14px; background: #f2f5fc; }
.thread-scroll:focus-visible, .record-content:focus-visible { outline-offset: -3px; }
.record-content { padding: 14px; }
.record-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(152px, .42fr); gap: 14px; }
.activity { align-self: start; background: #fff5f7; border: 1px solid var(--line); border-radius: 9px; padding: 13px; }
.activity h3 { color: #922f48; font-size: .9rem; }
.activity ol { list-style: none; margin: 13px 0 0; padding: 0 0 0 4px; }
.activity li { position: relative; display: grid; gap: 3px; padding: 0 0 14px 13px; border-left: 1px solid #cbd7ed; font-size: .84rem; overflow-wrap: anywhere; }
.activity li:last-child { padding-bottom: 0; border-color: transparent; }
.activity li::before { content: ""; position: absolute; top: .28rem; left: -5px; width: 9px; height: 9px; border-radius: 50%; background: #4769cf; }
.activity li.activity-en_atencion::before { background: #b66d2d; }
.activity li.activity-cerrado::before { background: #438c73; }
.activity time, .activity li > span { color: var(--muted); font-size: .75rem; }
.record-summary { padding: 13px; margin-bottom: 13px; background: #e9f0ff; border-left: 3px solid #438c73; border-radius: 9px; }
.record-summary h3 { color: #25468c; font-size: .9rem; margin-bottom: 6px; }
.record-summary p, .history-message p { line-height: 1.5; overflow-wrap: anywhere; }
.detail-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.detail-fields div { min-width: 0; padding: 9px 10px; border: 1px solid #e0e7f5; background: #f7f9fe; border-radius: 8px; }
.detail-fields dt { color: #505b72; font-size: .78rem; }
.detail-fields dd { margin: .2rem 0 0; font-weight: 650; font-size: .9rem; overflow-wrap: anywhere; }
.detail-messages { display: grid; gap: 12px; }
.history-empty { padding: 12px; background: #fff; border-radius: 9px; color: var(--muted); }
.history-message {
  justify-self: start;
  max-width: min(94%, 680px);
  min-width: 0;
  padding: 10px 12px;
  color: var(--ink);
  border-radius: 4px 13px 13px 13px;
  background: #fff;
  border: 1px solid #d7e0f1;
  box-shadow: 0 4px 12px #2b376a12;
  animation: enter .24s ease-out both;
}
.history-message.bot, .history-message.engineer { justify-self: end; border-radius: 13px 4px 13px 13px; }
.history-message.bot { background: #e5edff; border-color: #cddcff; }
.history-message.engineer { background: #e5f4ee; border-color: #c8e4d8; }
.history-message p, .history-transcript { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .4rem; }
.history-header, .history-attachments { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.history-header strong { font-size: .86rem; color: #263e86; }
.history-message.engineer .history-header strong { color: #1d654e; }
.history-header span { font-size: .76rem; color: #505b72; }
.history-attachments { margin-top: .55rem; }
.history-attachments .quiet { font-size: .8rem; }
.history-preview { display: block; max-width: min(100%, 520px); max-height: 330px; height: auto; margin-top: .7rem; border-radius: .5rem; }
audio.history-preview { width: min(65vw, 100%, 420px); min-width: min(175px, 65vw); height: 42px; }
.history-transcript { margin-top: .65rem; font-size: .875rem; }
.history-transcript summary { color: #263e86; font-weight: 650; cursor: pointer; }
#detail-next { margin-top: 12px; }
.reply-panel:not(:has(> :not([hidden]):not(:empty))) { display: none; }
.reply-panel { padding: 11px 14px; border-top: 1px solid var(--line); background: #fff; }
.reply-panel label { display: block; margin-bottom: 5px; color: #253d76; font-size: .82rem; font-weight: 700; }
.reply-panel textarea { max-height: 20dvh; }
.reply-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 5px; }
.reply-footer .primary { margin-left: auto; }
.reply-status.pending { color: #724316; }
.reply-status.sent { color: #1d654e; }
.reply-status.failed { color: #9b263c; }
#detail-delivery:not(:empty) { margin-bottom: 6px; font-weight: 650; }
.chat { max-width: 840px; margin-inline: auto; }
.chat-header { background: #e2ebff; }
.chat-header h1 { font-size: 1.28rem; }
.chat-avatar, .example { color: #922f48; background: #fbe6eb; }
.example:hover { background: #f5d1dc; }
.messages { background: #f9faff; }
.bubble { animation: enter .2s ease-out both; }
.bubble.bot { background: #e5edff; }
.bubble.user { background: #fbe6eb; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes badge-in { from { opacity: .55; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@media (min-width: 1550px) { #ticket-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1080px) { body { grid-template-columns: 186px minmax(0, 1fr); } }
@media (max-width: 1000px) { .record-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 940px) {
  .detail-body { grid-template-columns: minmax(0, 1fr); }
  .detail-panel { height: auto; min-height: 0; }
  .thread-scroll { max-height: 58dvh; min-height: 140px; }
}
@media (max-width: 850px) {
  #ticket-list { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  body { display: block; }
  .rail { position: static; min-height: 0; padding: 11px 13px; gap: 10px; }
  nav { display: flex; flex-wrap: wrap; }
  .nav-item { padding: 8px 9px; }
  .rail-bottom { display: none; }
  .topbar { min-height: 50px; }
  .inbox-header, .detail-header { border-radius: 14px; }
  .stat span { font-size: .79rem; }
  .stat { padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .ticket-row:hover, .ticket-row:focus-within { transform: none; }
}
