/* ============================================================
   ZapDesk — sistema de diseño (marca Zap Soluciones TI)
   Fraunces (display) · Inter (UI) · JetBrains Mono (datos)
   Animaciones SOLO transform/opacity · reduced-motion respetado
   ============================================================ */

:root {
  --bg: #0a0908;
  --surface: #14110d;
  --surface-2: #1b1712;
  --surface-3: #241d14;
  --line: rgba(212, 165, 116, .14);
  --line-strong: rgba(212, 165, 116, .3);
  --text: #f0eae0;
  --muted: #a89e8d;
  --faint: #8d8475; /* ≥4.5:1 sobre superficies oscuras (WCAG AA texto pequeño) */
  --gold: #d4a574;
  --gold-bright: #ffd75e;
  --bronze: #c8874a;
  --ok: #4ecfa5;
  --info: #9c95e8;
  --danger: #ef7361;
  --radius: 14px;
  --radius-sm: 10px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------- Reset y base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }
p a, .auth-alt a, .empty a { text-decoration: underline; text-underline-offset: 3px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
code.mono { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; }

/* ---------- Accesibilidad ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; top: -60px; left: 16px; z-index: 200;
  background: var(--gold); color: #0a0908; font-weight: 600;
  padding: 10px 18px; border-radius: 0 0 10px 10px;
  transition: transform .2s ease;
}
.skip-link:focus { transform: translateY(60px); color: #0a0908; }
:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; border-radius: 4px; }

/* ---------- Tipografía de página ---------- */
.eyebrow {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--bronze);
}
.eyebrow::before { content: '— '; color: var(--gold); }
.page-title {
  font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 4vw, 34px);
  line-height: 1.15; letter-spacing: -.01em;
}
.page-title--ticket { font-size: clamp(22px, 3vw, 28px); max-width: 30ch; }
.section-title { font-family: var(--font-display); font-weight: 600; font-size: 19px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 24px; border-radius: 100px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; letter-spacing: .04em; cursor: pointer;
  position: relative; overflow: hidden; white-space: nowrap;
  transition: transform .25s var(--spring), opacity .2s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn--gold { background: linear-gradient(135deg, var(--gold), var(--bronze)); color: #14100a; }
.btn--gold::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .35) 50%, transparent 60%);
  transform: translateX(-120%); transition: transform .6s ease; will-change: transform;
}
.btn--gold:hover::after { transform: translateX(120%); }
.btn--gold:hover { color: #14100a; }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--gold); }
.btn--ghost:hover { border-color: var(--gold); color: var(--gold-bright); }
.btn--danger { background: transparent; border-color: rgba(239, 115, 97, .45); color: var(--danger); }
.btn--danger:hover { border-color: var(--danger); background: rgba(239, 115, 97, .08); color: #ff9384; }
.btn--sm { min-height: 38px; padding: 7px 18px; font-size: 13px; }
.btn--block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: transform .2s var(--spring);
}
.icon-btn:hover { color: var(--gold-bright); }
.icon-btn:active { transform: scale(.94); }
.icon-btn--sm { width: 34px; height: 34px; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 18px; }
.field--sm { margin-bottom: 12px; }
.field label, .fieldset legend {
  display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--text);
}
.field-hint { font-weight: 400; color: var(--faint); font-size: 12.5px; }
.field-help { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.req { color: var(--gold-bright); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="month"], textarea, select {
  width: 100%; min-height: 46px; padding: 11px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--text); transition: border-color .2s ease;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); outline: none; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled { opacity: .55; cursor: not-allowed; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23d4a574' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; margin: 0 0 18px; }
.fieldset legend { padding: 0 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-error {
  background: rgba(239, 115, 97, .12); border: 1px solid rgba(239, 115, 97, .4);
  color: #ffb3a8; border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 14px; margin-bottom: 18px;
}
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; margin: 12px 0; min-height: 44px; }
.check input { width: 19px; height: 19px; accent-color: var(--gold); flex: none; }

/* Contraseña con toggle */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 48px; }
.pass-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; display: grid; place-items: center;
  background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: 8px;
}
.pass-toggle:hover { color: var(--gold); }
.pass-toggle[aria-pressed="true"] { color: var(--gold-bright); }

/* Input de archivos */
.file-input { width: 100%; color: var(--muted); font-size: 13.5px; }
.file-input::file-selector-button {
  margin-right: 12px; min-height: 40px; padding: 8px 18px; cursor: pointer;
  background: transparent; color: var(--gold); font-weight: 600; font-size: 13px;
  border: 1px solid var(--line-strong); border-radius: 100px;
}
.file-btn {
  display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--line-strong); border-radius: 100px; color: var(--gold);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.file-btn:hover { color: var(--gold-bright); border-color: var(--gold); }

/* ---------- Badges de estado y prioridad ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  padding: 4px 12px; border-radius: 100px; border: 1px solid;
  white-space: nowrap;
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge--abierto   { color: var(--gold);        border-color: rgba(212, 165, 116, .4);  background: rgba(212, 165, 116, .1); }
.badge--en_curso  { color: var(--gold-bright); border-color: rgba(255, 215, 94, .4);   background: rgba(255, 215, 94, .08); }
.badge--en_espera { color: var(--info);        border-color: rgba(156, 149, 232, .4);  background: rgba(156, 149, 232, .1); }
.badge--resuelto  { color: var(--ok);          border-color: rgba(78, 207, 165, .4);   background: rgba(78, 207, 165, .1); }
.badge--cerrado   { color: var(--muted);       border-color: rgba(168, 158, 141, .35); background: rgba(168, 158, 141, .08); }
.prio { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.prio::before { content: '● '; font-size: 9px; vertical-align: 1px; }
.prio--baja    { color: var(--faint); }
.prio--media   { color: var(--gold); }
.prio--alta    { color: #e0955a; }
.prio--urgente { color: var(--danger); }

/* ---------- Chips de filtro ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px;
  padding: 7px 16px; border-radius: 100px; font-size: 13.5px; font-weight: 500;
  color: var(--muted); border: 1px solid var(--line); background: var(--surface);
  transition: transform .2s var(--spring);
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip:active { transform: scale(.96); }
.chip.is-active { color: #14100a; background: linear-gradient(135deg, var(--gold), var(--bronze)); border-color: transparent; font-weight: 600; }
.chip-n { font-family: var(--font-mono); font-size: 12px; opacity: .8; }

/* ---------- Shell: topbar + sidebar + main ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 60;
  background: rgba(10, 9, 8, .92); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--text); }
.topbar-brand em, .sidebar-brand-name em { font-style: italic; color: var(--gold); }
.nav-toggle { background: none; border: 0; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; border-radius: 10px; }
.nav-toggle-bars { display: grid; gap: 5px; width: 22px; }
.nav-toggle-bars i { height: 2px; background: var(--gold); border-radius: 2px; transition: transform .25s ease, opacity .25s ease; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars i:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.shell { display: flex; min-height: 100dvh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 80; width: 272px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 22px 16px calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-105%); transition: transform .3s ease; will-change: transform;
  overflow-y: auto;
}
.sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow); }
.scrim {
  position: fixed; inset: 0; z-index: 70; background: rgba(5, 4, 3, .6);
  opacity: 0; transition: opacity .3s ease; border: 0;
}
.scrim.is-show { opacity: 1; }
.sidebar-brand { display: grid; grid-template-columns: 42px 1fr; column-gap: 12px; align-items: center; padding: 4px 10px 18px; border-bottom: 1px solid var(--line); }
.sidebar-brand img { grid-row: span 2; border-radius: 10px; }
.sidebar-brand-name { font-family: var(--font-display); font-size: 21px; font-weight: 600; color: var(--text); line-height: 1.1; }
.sidebar-brand-sub { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .18em; color: var(--faint); }
.sidebar-nav { flex: 1; }
.sidebar-nav ul { list-style: none; padding: 12px 0 0; display: grid; gap: 4px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px; min-height: 44px;
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14.5px; font-weight: 500;
  color: var(--muted); position: relative;
}
.sidebar-nav a:hover { color: var(--text); background: var(--surface-2); }
.sidebar-nav a[aria-current="page"] { color: var(--gold-bright); background: var(--surface-2); font-weight: 600; }
.sidebar-nav a[aria-current="page"]::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 3px; background: linear-gradient(180deg, var(--gold-bright), var(--bronze));
}
.sidebar-user { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); padding-top: 14px; }
.sidebar-user-link { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; padding: 8px; border-radius: var(--radius-sm); color: var(--text); }
.sidebar-user-link:hover, .sidebar-user-link[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.sidebar-user-meta { min-width: 0; display: grid; }
.sidebar-user-meta strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta small { font-size: 11.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--surface-3); color: var(--gold); border: 1px solid var(--line-strong);
}
.avatar--zap { background: linear-gradient(135deg, var(--gold), var(--bronze)); color: #14100a; border-color: transparent; }

.main { flex: 1; min-width: 0; padding: 26px 18px calc(60px + env(safe-area-inset-bottom)); max-width: 1160px; margin-inline: auto; width: 100%; }

@media (min-width: 1024px) {
  .topbar { display: none; }
  .sidebar { position: sticky; top: 0; height: 100dvh; transform: none; transition: none; flex: none; }
  .scrim { display: none; }
  .main { padding: 40px 40px 80px; }
}

/* ---------- Encabezado de página / toolbar ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.search { flex: 1; min-width: 220px; max-width: 340px; }
.backlink { margin-bottom: 14px; font-size: 13.5px; }
.link-more { font-size: 13.5px; font-weight: 600; }

/* ---------- Paneles ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.panel--flush { padding: 0; overflow: hidden; }
.panel--narrow { max-width: 560px; }
.panel--side { padding: 18px; margin-bottom: 16px; }
.side-title { font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--bronze); margin-bottom: 14px; }

/* ---------- Tarjeta de ticket (firma visual) ---------- */
.tlist { list-style: none; padding: 0; display: grid; gap: 12px; }
.tcard {
  display: block; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 22px; color: var(--text);
  transition: transform .25s var(--spring), border-color .2s ease;
  will-change: transform;
}
.tcard:hover { transform: translateY(-2px); border-color: var(--line-strong); color: var(--text); }
.tcard:active { transform: scale(.99); }
.tcard-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.tcard-code { font-size: 12.5px; color: var(--bronze); letter-spacing: .06em; }
.tcard-badges { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tcard-subject { font-size: 16.5px; font-weight: 600; line-height: 1.35; }
.tcard-meta { font-size: 13px; color: var(--muted); margin-top: 5px; }
.tprogress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: rgba(212, 165, 116, .12);
}
.tprogress i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--bronze), var(--gold), var(--gold-bright));
  transform-origin: left center;
  transform: scaleX(calc((var(--step, 1) - 1) / 3));
}

/* ---------- Stepper (umbral del ticket) ---------- */
.stepper { list-style: none; display: flex; padding: 6px 0 2px; margin: 18px 0 6px; }
.stepper li { flex: 1; position: relative; text-align: center; }
.stepper li::before {
  content: ''; position: absolute; top: 7px; left: -50%; width: 100%; height: 2px;
  background: rgba(212, 165, 116, .15);
}
.stepper li:first-child::before { display: none; }
.stepper li.is-done::before, .stepper li.is-current::before {
  background: linear-gradient(90deg, var(--bronze), var(--gold));
}
.stepper-dot {
  position: relative; z-index: 1; display: inline-block; width: 16px; height: 16px;
  border-radius: 50%; background: var(--surface-3); border: 2px solid rgba(212, 165, 116, .3);
}
.is-done .stepper-dot { background: var(--gold); border-color: var(--gold); }
.is-current .stepper-dot {
  background: var(--gold-bright); border-color: var(--gold-bright);
  box-shadow: 0 0 0 5px rgba(255, 215, 94, .15), 0 0 18px rgba(255, 215, 94, .35);
}
.stepper-label { display: block; margin-top: 7px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.is-done .stepper-label { color: var(--muted); }
.is-current .stepper-label { color: var(--gold-bright); font-weight: 600; }
.wait-note { font-size: 14px; color: var(--info); margin: 10px 0 0; }

/* ---------- Cabecera del ticket ---------- */
.ticket-head { margin-bottom: 6px; }
.ticket-head-badges { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.ticket-head-cat { font-size: 13px; color: var(--muted); }

/* ---------- Split (contenido + aside) ---------- */
.split { display: grid; gap: 24px; align-items: start; }
.split--ticket { margin-top: 22px; }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr) 320px; }
}
.side-note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.side-note-title { font-family: var(--font-display); font-size: 18px; margin-bottom: 8px; }
.side-note p { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.side-note-small { font-size: 12.5px; }
.side-rule { border: 0; height: 1px; background: var(--line); margin: 16px 0; }

/* ---------- Hilo de conversación ---------- */
.thread { display: grid; gap: 14px; }
.msg { display: grid; grid-template-columns: 38px 1fr; gap: 12px; }
.msg-body {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; min-width: 0;
}
.msg--staff .msg-body { background: var(--surface-2); border-color: var(--line-strong); }
.msg--internal .msg-body { background: rgba(255, 215, 94, .05); border: 1px dashed rgba(255, 215, 94, .35); }
.msg-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13.5px; }
.msg-tag { font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); border: 1px solid var(--line-strong); border-radius: 100px; padding: 2px 9px; }
.msg-tag--internal { color: var(--gold-bright); border-color: rgba(255, 215, 94, .4); }
.msg-time { margin-left: auto; font-size: 11.5px; color: var(--faint); }
.msg-text { font-size: 14.5px; overflow-wrap: break-word; }
.attach {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; margin-right: 8px;
  font-size: 13px; padding: 7px 14px; border: 1px solid var(--line); border-radius: 100px;
  color: var(--gold); background: var(--surface-2);
}
.attach:hover { border-color: var(--gold); color: var(--gold-bright); }
.attach-size { font-size: 11px; color: var(--faint); }

/* ---------- Responder ---------- */
.reply { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.reply textarea { background: var(--surface-2); }
.reply-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.reply-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.closed-note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; justify-items: start; }
.closed-note p { color: var(--muted); font-size: 14px; }

/* ---------- Banner de resolución + calificación ---------- */
.resolve-banner {
  background: rgba(78, 207, 165, .07); border: 1px solid rgba(78, 207, 165, .3);
  border-radius: var(--radius); padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.resolve-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.rate-card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 18px; display: grid; gap: 12px; justify-items: start; }
.rate-title { font-family: var(--font-display); font-size: 17px; }
.stars { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars label { cursor: pointer; color: var(--surface-3); padding: 4px; border-radius: 6px; transition: transform .15s var(--spring); }
.stars label:hover { transform: scale(1.12); }
.stars label:hover, .stars label:hover ~ label,
.stars input:checked ~ label { color: var(--gold-bright); }
.stars input:focus-visible + label { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.rate-card input[type="text"] { max-width: 420px; }
.rating-show { color: var(--gold-bright); letter-spacing: 2px; }

/* ---------- Facts + timeline ---------- */
.facts { display: grid; gap: 10px; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.facts dt { color: var(--faint); }
.facts dd { text-align: right; }
.timeline { list-style: none; padding: 0; display: grid; gap: 14px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.timeline li { display: grid; grid-template-columns: 12px 1fr; gap: 10px; font-size: 13px; }
.timeline-dot { position: relative; z-index: 1; width: 11px; height: 11px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--gold); margin-top: 4px; }
.timeline li:first-child .timeline-dot { background: var(--gold); }
.timeline-by { color: var(--faint); }
.timeline-time { font-size: 11px; color: var(--faint); }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi-card {
  display: grid; gap: 2px; align-content: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; color: var(--text);
  transition: transform .25s var(--spring), border-color .2s ease;
}
a.kpi-card:hover { transform: translateY(-2px); border-color: var(--line-strong); color: var(--text); }
.kpi-num { font-family: var(--font-display); font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-sub { font-size: 16px; color: var(--faint); }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-card--warn .kpi-num { color: var(--gold-bright); }
.kpi-card--danger .kpi-num { color: var(--danger); }

/* ---------- Gráficos ---------- */
.charts-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.charts-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.charts-filters select { min-height: 40px; width: auto; }
.charts-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 800px) { .charts-grid { grid-template-columns: 1fr 1fr; } }
.chart-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; }
.chart-card--wide { grid-column: 1 / -1; }
.chart-card figcaption { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.chart { min-height: 180px; position: relative; }
.chart svg text { font-family: var(--font-mono); }
.chart-empty { display: grid; place-items: center; min-height: 180px; color: var(--faint); font-size: 13.5px; }
.chart-tip {
  position: fixed; z-index: 150; pointer-events: none;
  background: #050403; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 7px 11px; font-size: 12.5px; font-family: var(--font-mono);
  color: var(--text); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
}
.chart-tip.is-show { opacity: 1; transform: translateY(0); }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 720px; }
.table th {
  text-align: left; font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
  padding: 14px 16px; border-bottom: 1px solid var(--line-strong);
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(212, 165, 116, .04); }
.table-link { display: grid; gap: 2px; color: var(--text); min-width: 0; }
.table-link:hover .table-subject { color: var(--gold-bright); }
.table-code { font-size: 11.5px; color: var(--bronze); }
.table-subject { font-weight: 500; }
.table-user { display: flex; align-items: center; gap: 10px; }
.table-user .avatar { width: 30px; height: 30px; font-size: 11px; }
.row--urgent td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row--off { opacity: .55; }
.report-links { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Filtros del admin ---------- */
.filterbar { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0 20px; }
.filterbar-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filterbar-group--grow { flex: 1; min-width: 240px; }
.filterbar-group--grow input { flex: 1; }
.filterbar select, .filterbar input { min-height: 42px; width: auto; }

/* ---------- Empresas ---------- */
.company-grid { list-style: none; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.company-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 12px; align-content: start; }
.company-card--off { opacity: .6; }
.company-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.company-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.company-code { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.company-stats { display: flex; gap: 22px; }
.company-stats div { display: grid; }
.company-stats dt { font-size: 11px; color: var(--faint); }
.company-stats dd { font-size: 17px; font-weight: 600; }
.company-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Prioridad (selector en nuevo ticket) ---------- */
.prio-picker { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
@media (min-width: 640px) { .prio-picker { grid-template-columns: repeat(4, 1fr); } }
.prio-option {
  position: relative; display: grid; gap: 2px; padding: 12px 14px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .2s ease, transform .2s var(--spring);
}
.prio-option:active { transform: scale(.98); }
.prio-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.prio-option-label { font-weight: 600; font-size: 14px; }
.prio-option-help { font-size: 11.5px; color: var(--faint); line-height: 1.35; }
.prio-option:has(input:checked) { border-color: var(--gold); background: rgba(212, 165, 116, .08); }
.prio-option--urgente:has(input:checked) { border-color: var(--danger); background: rgba(239, 115, 97, .08); }
.prio-option:has(input:focus-visible) { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

/* ---------- Diálogos ---------- */
.dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 26px; width: min(520px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(5, 4, 3, .65); backdrop-filter: blur(3px); }
.dialog-title { font-family: var(--font-display); font-size: 21px; margin-bottom: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
.toast {
  position: sticky; top: 12px; z-index: 90;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 13px 18px; margin-bottom: 20px; font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in .35s var(--spring) both;
}
.toast--ok { border-color: rgba(78, 207, 165, .45); }
.toast--ok::before { content: '✓'; color: var(--ok); font-weight: 700; }
.toast--error { border-color: rgba(239, 115, 97, .5); }
.toast--error::before { content: '!'; color: var(--danger); font-weight: 700; }
.toast-close { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; width: 32px; height: 32px; border-radius: 8px; flex: none; }
.toast-close:hover { color: var(--text); }
.toast.is-hide { opacity: 0; transform: translateY(-8px); transition: opacity .3s ease, transform .3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Vacíos ---------- */
.empty { text-align: center; padding: 60px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty h2 { font-family: var(--font-display); font-size: 22px; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 8px; }
.empty-icon { color: var(--faint); letter-spacing: .2em; margin-bottom: 14px; font-size: 13px; }

/* ---------- Paginación ---------- */
.pager { display: flex; gap: 6px; justify-content: center; margin: 22px 0; flex-wrap: wrap; }
.pager-item {
  min-width: 40px; height: 40px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px; font-family: var(--font-mono); font-size: 13px;
  color: var(--muted);
}
.pager-item:hover { border-color: var(--gold); color: var(--gold-bright); }
.pager-item.is-active { background: linear-gradient(135deg, var(--gold), var(--bronze)); color: #14100a; border-color: transparent; font-weight: 700; }

/* ---------- Autenticación ---------- */
.auth { display: block; }
.auth-glow {
  position: fixed; inset: -20% -10% auto; height: 60vh; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse 60% 55% at 50% 0%, rgba(212, 165, 116, .16), transparent 70%);
}
.auth-wrap { position: relative; z-index: 1; min-height: 100dvh; display: grid; place-items: center; align-content: center; gap: 22px; padding: 40px 16px; }
.auth-card {
  width: min(430px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; padding: 34px 30px;
  box-shadow: var(--shadow);
}
.auth-head { display: grid; justify-items: center; gap: 12px; margin-bottom: 20px; text-align: center; }
.auth-head img { border-radius: 12px; }
.auth-title { font-family: var(--font-display); font-size: 27px; font-weight: 600; line-height: 1.2; text-align: center; margin-bottom: 8px; }
.auth-title em { font-style: italic; color: var(--gold); }
.auth-sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-alt { text-align: center; font-size: 13.5px; color: var(--muted); margin-top: 20px; }
.auth-foot { font-size: 10.5px; letter-spacing: .22em; color: var(--faint); text-align: center; }
.error-card { text-align: center; }
.error-code { font-size: 13px; letter-spacing: .3em; color: var(--bronze); margin-bottom: 10px; }
.error-title { font-family: var(--font-display); font-size: 26px; margin-bottom: 10px; }
.error-msg { color: var(--muted); font-size: 14.5px; margin-bottom: 22px; }

/* ---------- "Escribiendo…" (hilo en vivo) ---------- */
.typing {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--muted); padding: 2px 6px;
}
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--gold);
  animation: typing-dot 1.2s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes typing-dot {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Tiempo invertido (gestión) ---------- */
.fieldset--time { margin-bottom: 12px; }
.time-inputs { display: flex; align-items: center; gap: 8px; }
.time-inputs input { width: 74px; text-align: right; font-family: var(--font-mono); }
.time-sep { color: var(--faint); font-size: 13px; }

/* ---------- Chip de WhatsApp (datos del ticket) ---------- */
.wa-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ok);
}
.wa-chip:hover { color: #8ce9cd; }
.wa-chip svg { flex: none; }

/* ---------- Modelo de cobro (empresas) ---------- */
.company-billing { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.billing-tag {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 100px;
  color: var(--muted); border: 1px solid var(--line-strong);
}
.billing-tag--horas { color: var(--gold-bright); border-color: rgba(255, 215, 94, .4); }

/* ---------- Auditoría ---------- */
.audit-when { white-space: nowrap; font-size: 12px; }
.audit-detail { font-size: 13px; color: var(--muted); max-width: 420px; overflow-wrap: break-word; }
.audit-action { font-size: 13px; }
.audit-action--ticket_eliminado { color: var(--danger); font-weight: 600; }
.audit-action--login_fallido { color: var(--danger); }
.audit-action--login { color: var(--ok); }
.table-user small { display: block; }

/* ---------- Documento legal (privacidad) ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 8px 4px 40px; text-align: left; }
.legal-head { padding-bottom: 22px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.legal-back { font-size: 13.5px; display: inline-block; margin-bottom: 16px; }
.legal-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(26px, 4vw, 34px); line-height: 1.15; margin: 6px 0; }
.legal-title em { font-style: italic; color: var(--gold); }
.legal-sub { color: var(--faint); font-size: 13px; }
.legal-body h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--gold); margin: 26px 0 10px; }
.legal-body p { margin-bottom: 12px; font-size: 14.5px; color: var(--text); line-height: 1.65; }
.legal-body ul { margin: 0 0 14px; padding-left: 22px; display: grid; gap: 6px; }
.legal-body li { font-size: 14.5px; line-height: 1.6; color: var(--muted); }
.legal-body li strong { color: var(--text); }
.legal-foot { margin-top: 34px; padding-top: 22px; border-top: 1px solid var(--line); }

/* Layout mínimo: la política es un documento largo, alinéalo arriba */
.auth-wrap:has(.legal) { align-content: start; }

.check--legal { align-items: flex-start; margin: 18px 0 16px; }
.check--legal span { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.auth-foot-links { text-align: center; font-size: 12px; margin-top: 6px; }

/* Pie de la app */
.app-foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--faint); }
.app-foot .mono { font-size: 11.5px; }

/* ---------- Animaciones de entrada (GPU only) ---------- */
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.stagger > * { animation: fade-up .45s ease both; animation-delay: calc(var(--i, 0) * 55ms); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
