/* base.css — la piel de la casa (Hotelos): fondo crema, navy y aguamarina.
   Una sola hoja para todas las pantallas: la CSP no admite style= ni <style> en línea, así
   que todo lo visual vive aquí (también lo de search-select y «Cómo funciona»). */
:root {
  --navy: #003865;
  --aqua: #0FB7B2;
  --aqua-dark: #0d9e9a;
  --aqua-light: #e6f9f8;
  --bg: #f7f3ec;
  --surface: #ffffff;
  --border: #ece5d8;
  --text: #1a2b3c;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --ok: #16a34a;
  --warn: #f59e0b;
  --warn-light: #fef3c7;
  --err: #dc2626;
  --err-light: #fee2e2;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 4px 22px rgba(0, 30, 55, .07), 0 1px 3px rgba(0, 30, 55, .04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--aqua-dark); }
h1 { margin: 0 0 8px; color: var(--navy); font-size: 22px; }
h2 { margin: 0 0 12px; color: var(--navy); font-size: 17px; }
h3 { margin: 0 0 8px; color: var(--navy); font-size: 14px; }
p { color: var(--text-muted); margin: 0 0 16px; }
.oculto { display: none !important; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ── Cabecera ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 28px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  min-height: 56px;
}
.marca { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.marca .olas { width: 52px; height: 12px; }
.marca .nombre { color: var(--navy); font-weight: 700; font-size: 18px; letter-spacing: .02em; }
.version { color: var(--text-muted); font-size: 12px; }
.nav { display: flex; gap: 4px; flex: 1; justify-content: center; flex-wrap: wrap; }
.nav a { color: var(--text-muted); text-decoration: none; padding: 7px 12px; border-radius: 999px; font-weight: 500; }
.nav a:hover { background: var(--aqua-light); color: var(--aqua-dark); }
.nav a.activa { background: var(--navy); color: #fff; }
.usuario { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.usuario .chip { background: var(--aqua-light); color: var(--aqua-dark); border-radius: 999px; padding: 4px 10px; font-weight: 600; white-space: nowrap; }
.usuario .rol { color: var(--text-light); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
/* En ventanas estrechas la barra se parte en dos filas: marca y usuario arriba, el menú
   debajo en una fila. Sin esto el menú se apilaba en columna y el usuario desbordaba. */
@media (max-width: 960px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .nav { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .usuario { margin-left: auto; min-width: 0; }
  .usuario .chip { overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
  .usuario .rol { display: none; }
  .content { padding: 0 16px; }
}

/* ── Contenido ─────────────────────────────────────────────────────────────── */
.content { flex: 1; width: 100%; margin: 24px auto; padding: 0 28px; }
.content.estrecho { max-width: 760px; margin-top: 40px; }
.content.formulario { max-width: 900px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 28px; margin-bottom: 18px; }
.card.compacta { padding: 16px 20px; }
.cabecera-pagina { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.cabecera-pagina p { margin: 0; }
.pie { padding: 16px 28px; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border); }

/* ── Estado (portada /estado) ───────────────────────────────────────────────── */
.estado { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; }
.estado dt { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; align-self: center; }
.estado dd { margin: 0; font-weight: 600; }
.estado dd.ok { color: var(--ok); }
.estado dd.warn { color: var(--warn); }
.estado dd.err { color: var(--err); }

/* ── Formularios ──────────────────────────────────────────────────────────────
   Inputs de texto siempre (jamás type=number); los desplegables son search-select. */
.campo { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.campo label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.campo .ayuda { font-size: 12px; color: var(--text-light); }
.input, .textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; color: var(--text); background: #fff; transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus { outline: none; border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(15, 183, 178, .12); }
.fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.acciones { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.error-form { background: var(--err-light); color: var(--err); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.error-form:empty { display: none; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
  text-decoration: none; line-height: 1.3;
}
.btn:hover { border-color: var(--aqua); color: var(--aqua-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primario { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primario:hover { background: #00284a; color: #fff; }
.btn-aqua { background: var(--aqua); border-color: var(--aqua); color: #fff; }
.btn-aqua:hover { background: var(--aqua-dark); color: #fff; }
.btn-peligro { color: var(--err); }
.btn-peligro:hover { border-color: var(--err); background: var(--err-light); }
.btn-suave { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-suave:hover { background: var(--aqua-light); }
.btn.pequeno { padding: 4px 10px; font-size: 12px; }

/* ── Barra de filtros (38 px) y KPIs ───────────────────────────────────────── */
.filtros { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filtros .campo { margin: 0; min-width: 170px; flex: 1 1 170px; }
.filtros .campo.ancho { flex: 2 1 240px; }
.filtros .input, .filtros .ss-input { height: 38px; padding-top: 0; padding-bottom: 0; display: flex; align-items: center; }
.filtros .toggle { display: flex; align-items: center; gap: 6px; height: 38px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 12px 16px; cursor: pointer; border: 2px solid transparent; }
.kpi:hover { border-color: var(--aqua-light); }
.kpi.activo { border-color: var(--aqua); }
.kpi .n { font-size: 24px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.kpi .t { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* ── Tablas ─────────────────────────────────────────────────────────────────── */
.tabla-scroll { overflow-x: auto; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); padding: 12px 14px; border-bottom: 1px solid var(--border); background: #fbf9f5; white-space: nowrap; position: sticky; top: 0; }
.tabla td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tabla tr:last-child td { border-bottom: none; }
.tabla tbody tr.clic { cursor: pointer; }
.tabla tbody tr.clic:hover td { background: var(--aqua-light); }
.tabla .num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; color: var(--navy); white-space: nowrap; }
.tabla .asunto { font-weight: 600; color: var(--text); }
.tabla .sub { display: block; color: var(--text-light); font-size: 12px; font-weight: 400; }
.tabla .vacio td { text-align: center; color: var(--text-muted); padding: 32px; }
.tabla .der { text-align: right; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: #eef2f6; color: var(--text-muted); }
.badge.estado-NUEVO { background: #e0f2fe; color: #0369a1; }
.badge.estado-ABIERTO { background: var(--aqua-light); color: var(--aqua-dark); }
.badge.estado-PENDIENTE { background: var(--warn-light); color: #b45309; }
.badge.estado-RESUELTO { background: #dcfce7; color: #15803d; }
.badge.estado-CERRADO { background: #e5e7eb; color: #4b5563; }
.prio { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.prio .punto { width: 9px; height: 9px; border-radius: 50%; background: var(--text-light); display: inline-block; }
.aviso { background: var(--warn-light); color: #92400e; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }
.aviso.dev { background: #fdf2f8; color: #9d174d; border: 1px dashed #f9a8d4; }

/* ── Ticket ─────────────────────────────────────────────────────────────────── */
.ticket-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ticket-cab h1 { font-size: 20px; }
.ticket-cab .num { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--aqua-dark); font-weight: 700; font-size: 13px; }
.ticket-cab .badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ticket-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .ticket-grid { grid-template-columns: 1fr; } }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; font-size: 13px; }
.meta dt { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; align-self: center; }
.meta dd { margin: 0; }
.hilo { display: flex; flex-direction: column; gap: 12px; }
.msg { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; background: #fff; }
.msg.saliente { border-left: 4px solid var(--aqua); }
.msg.entrante { border-left: 4px solid var(--navy); }
.msg.nota { background: var(--warn-light); border-color: #fde68a; border-left: 4px solid var(--warn); }
.msg.sistema { background: #f8fafc; color: var(--text-muted); font-size: 12.5px; }
.msg .quien { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; flex-wrap: wrap; }
.msg .quien b { color: var(--text); }
.msg .cuerpo p { color: var(--text); margin: 0 0 8px; }
.msg .cuerpo p:last-child { margin-bottom: 0; }
.msg .envio { font-size: 11.5px; color: var(--text-light); }
.msg .envio.err { color: var(--err); }
.responder .textarea { min-height: 110px; }
.eventos { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--text-muted); }
.eventos li { padding: 5px 0; border-bottom: 1px dashed var(--border); }
.eventos li:last-child { border-bottom: none; }
.eventos b { color: var(--text); font-weight: 600; }
details.plegable summary { cursor: pointer; color: var(--aqua-dark); font-weight: 600; font-size: 13px; }

/* ── Modal y toast (nada de alert/confirm nativos) ─────────────────────────── */
.modal-fondo { position: fixed; inset: 0; background: rgba(0, 30, 55, .45); display: flex; align-items: center; justify-content: center; z-index: 100000; padding: 20px; }
.modal { background: #fff; border-radius: var(--radius); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); padding: 24px 28px; width: min(460px, 100%); }
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal p { margin-bottom: 18px; }
.modal .acciones { justify-content: flex-end; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); z-index: 100001; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.visible { opacity: 1; }
.toast.err { background: var(--err); }
.toast.ok { background: var(--ok); }

/* ── search-select (la casa no usa <select> nativo) ────────────────────────── */
.ss-wrap { position: relative; width: 100%; }
.ss-input { width: 100%; min-height: 38px; padding: 8px 32px 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text); background: #fff; cursor: pointer; transition: border-color .2s, box-shadow .2s; line-height: 1.4; }
.ss-input:focus { outline: none; border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(15, 183, 178, .12); }
.ss-input.ss-ph { color: var(--text-light); }
.ss-input.ss-disabled { opacity: .5; cursor: not-allowed; }
.ss-caret { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-muted); font-size: 11px; }
.ss-dropdown { position: fixed; top: 0; left: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0, 56, 101, .14); z-index: 99999; display: none; flex-direction: column; max-height: 260px; overflow: hidden; }
.ss-dropdown.open { display: flex; }
.ss-search { padding: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ss-search input { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 12.5px; outline: none; }
.ss-search input:focus { border-color: var(--aqua); }
.ss-list { overflow-y: auto; flex: 1; }
.ss-opt { padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--text); line-height: 1.4; }
.ss-opt:hover, .ss-opt.ss-activa { background: var(--aqua-light); color: var(--aqua-dark); }
.ss-opt.ss-selected { font-weight: 600; color: var(--aqua-dark); }
.ss-opt.ss-vacia-opt { color: var(--text-muted); font-style: italic; }
.ss-opt .ss-hint { display: block; font-size: 11px; color: var(--text-light); font-weight: 400; }
.ss-empty { padding: 12px; text-align: center; font-size: 12px; color: var(--text-muted); }

/* ── «Cómo funciona» ───────────────────────────────────────────────────────── */
.leyenda { display: block; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); margin: 0 0 16px; overflow: hidden; }
.ley-h { display: flex; align-items: center; gap: 9px; padding: 11px 16px; background: linear-gradient(90deg, var(--aqua-light), transparent); cursor: pointer; list-style: none; }
.ley-h::-webkit-details-marker { display: none; }
.ley-h::marker { content: ""; }
.ley-h b { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--navy); }
.ley-h span { font-size: 12px; color: var(--text-muted); }
.ley-h .chev { margin-left: auto; color: var(--aqua-dark); transition: transform .18s; transform: rotate(-90deg); }
.leyenda[open] .ley-h { border-bottom: 1px solid var(--border); }
.leyenda[open] .chev { transform: rotate(0); }
.ley-g { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.ley-c { padding: 14px 18px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.ley-c h4 { font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--aqua-dark); margin: 0 0 8px; }
.ley-c ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ley-c li { font-size: 12.5px; line-height: 1.5; color: var(--text-muted); padding-left: 12px; position: relative; }
.ley-c li::before { content: ""; position: absolute; left: 0; top: 7px; width: 4px; height: 4px; border-radius: 50%; background: var(--border); }
.ley-c li.ojo::before { background: var(--warn); }
.ley-c li b { color: var(--text); font-weight: 600; }
.ley-aviso { padding: 10px 16px; background: var(--warn-light); color: #92400e; font-size: 12.5px; border-top: 1px solid #fde68a; }

/* ── Departamento: dos columnas, árbol de categorías, muestra de color ──────── */
.dos-columnas { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px; align-items: start; }
.arbol, .arbol ul { list-style: none; margin: 0; padding: 0; }
.arbol ul { margin-left: 22px; border-left: 2px solid var(--border); padding-left: 12px; }
.arbol li { margin: 4px 0; }
.arbol .nodo { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); }
.arbol .nodo:hover { background: var(--aqua-light); }
.arbol .nodo .nombre-cat { font-weight: 600; color: var(--text); flex: 1; }
.arbol .nodo.inactiva .nombre-cat { color: var(--text-light); text-decoration: line-through; font-weight: 400; }
.arbol .nodo .orden-cat { font-size: 11px; color: var(--text-light); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.arbol .nodo .btn { visibility: hidden; }
.arbol .nodo:hover .btn { visibility: visible; }
.con-muestra { display: flex; align-items: center; gap: 8px; }
.muestra { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border); background: var(--aqua); flex: 0 0 auto; }
.punto-dep { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--aqua); }
.tabla tr.inactivo td { color: var(--text-light); }
.fila .toggle { align-self: end; padding: 9px 0; }

/* ── SLA ────────────────────────────────────────────────────────────────────── */
.sla { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: #eef2f6; color: var(--text-muted); }
.sla-plazo { background: var(--aqua-light); color: var(--aqua-dark); }
.sla-aviso { background: var(--warn-light); color: #b45309; }
.sla-vencido { background: var(--err-light); color: var(--err); }
.sla-ok { background: #dcfce7; color: #15803d; }
.sla-nada { background: #eef2f6; color: var(--text-light); font-weight: 500; }
.celda-sla { white-space: nowrap; }
.celda-sla .sla { display: block; width: max-content; margin: 2px 0; }
.tabla-sla .input { width: 120px; }
#sla dd .sla { font-size: 12.5px; }

/* ── Adjuntos ───────────────────────────────────────────────────────────────── */
.input-fichero { font: inherit; font-size: 13px; color: var(--text-muted); }
.adjuntos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.adjuntos:empty { display: none; }
.adjunto { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; background: var(--aqua-light); color: var(--aqua-dark); text-decoration: none; border: 1px solid transparent; max-width: 100%; }
.adjunto:hover { border-color: var(--aqua); }
.adjunto.bloqueado { background: var(--err-light); color: var(--err); }
.adjunto.omitido { background: #eef2f6; color: var(--text-muted); text-decoration: line-through; }
.adjunto.elegido { background: #fff; border-color: var(--border); color: var(--text); }
.adjunto .quitar { border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.adjunto .quitar:hover { color: var(--err); }
.msg .adjuntos { margin-top: 10px; }

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login { max-width: 420px; margin: 60px auto; }
.login .marca { justify-content: center; margin-bottom: 18px; }
.login h1 { text-align: center; font-size: 20px; }
.login p { text-align: center; }
