:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --ink: #0f1b26;
  --muted: #566776;
  --line: #d3dae1;
  --accent: #0a6a96;
  --accent-ink: #ffffff;
  --accent-soft: #dcedf5;
  --alta: #b3261e;
  --alta-soft: #fbe4e2;
  --media: #8a5a00;
  --media-soft: #fbefd2;
  --baja: #1b7a4a;
  --baja-soft: #dff2e7;
  --font-display: "Familjen Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141a; --surface: #141e26; --surface-2: #1a2630; --ink: #e5edf3; --muted: #92a3b2;
    --line: #28363f; --accent: #55b6e2; --accent-ink: #06202d; --accent-soft: #15384a;
    --alta: #ff8f87; --alta-soft: #432120; --media: #f0bf63; --media-soft: #3d2f12;
    --baja: #6fd49c; --baja-soft: #163a28; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 16px 56px; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }

/* Encabezado */
.top { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.top > div { min-width: 0; }
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-mark { display: block; width: 56px; height: 56px; flex: 0 0 56px; }
.brand-copy { min-width: 0; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin: 0 0 6px; }
h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.05; font-weight: 700; }
.lede { color: var(--muted); margin: 8px 0 0; max-width: 52ch; }
@media (max-width: 420px) { .brand-lockup { gap: 10px; } .brand-mark { width: 46px; height: 46px; flex-basis: 46px; } }
.foot { margin-top: 32px; color: var(--muted); font-size: 13px; }

/* Estructura */
.cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; min-width: 0; }
.panel h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.panel .sub { color: var(--muted); margin: 0 0 18px; }
.panel .sub.tight { margin-bottom: 12px; }
.account-panel { margin-bottom: 24px; }
.account-panel #account-forms { max-width: 460px; }
.account-session { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.account-session p { margin: 0; }
.analytics-panel { margin-bottom: 20px; }
.analytics-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 18px; align-items: end; }
.analytics-heading .sub { margin-bottom: 0; }
.analytics-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.analytics-controls .field { min-width: 130px; }
.analytics-controls .btn { white-space: nowrap; }
.analytics-grid { display: grid; grid-template-columns: minmax(220px, 0.75fr) minmax(0, 2fr); gap: 20px; margin-top: 18px; }
.analytics-grid h3 { font-size: 16px; margin-bottom: 8px; }
.analytics-users { display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.analytics-user { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; }
.analytics-user input { margin: 0; }
.analytics-user-name { overflow-wrap: anywhere; }
.analytics-user-total { color: var(--muted); font-size: 12px; white-space: nowrap; }
.analytics-chart { min-width: 0; overflow-x: auto; }
.analytics-chart svg { display: block; width: 100%; min-width: 520px; height: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.chart-legend span { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; overflow-wrap: anywhere; }
.chart-legend i { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.chart-label { fill: var(--muted); font: 11px var(--font-body); }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
@media (max-width: 720px) { .analytics-grid { grid-template-columns: minmax(0, 1fr); } }

/* Formularios */
.form { display: grid; gap: 16px; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 520px) { .row2 { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 6px; min-width: 0; }
label, .legend { font-weight: 600; font-size: 13px; }
.legend { margin-bottom: 6px; padding: 0; }
.opt { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="password"], input[type="date"], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
.password-control { display: block; position: relative; }
.password-control > input { padding-right: 44px; }
.password-toggle { position: absolute; top: 50%; right: 6px; display: grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; transform: translateY(-50%); }
.password-toggle:hover { background: var(--line); color: var(--ink); }
.password-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.password-toggle .eye-slash { display: none; }
.password-toggle[aria-pressed="true"] .eye-slash { display: block; }
textarea { resize: vertical; min-height: 110px; }
textarea.short { min-height: 80px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
.urg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; border: 0; padding: 0; margin: 0; min-width: 0; }
@media (max-width: 520px) { .urg { grid-template-columns: minmax(0, 1fr); } }
.urg.dos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 520px) { .urg.dos { grid-template-columns: minmax(0, 1fr); } }
.urg label { display: block; cursor: pointer; font-weight: 400; position: relative; }
.urg input { position: absolute; opacity: 0; pointer-events: none; }
.urg .card { display: block; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); height: 100%; }
.urg .card b { display: block; font-weight: 600; }
.urg .card span { color: var(--muted); font-size: 13px; }
.urg input:checked + .card { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.urg input:focus-visible + .card { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { border: 0; background: var(--accent); color: var(--accent-ink); padding: 11px 18px; border-radius: 8px; font-weight: 600; cursor: pointer; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--alta); border: 1px solid var(--alta); }
.btn.danger.armed { background: var(--alta); color: var(--surface); }
.err { color: var(--alta); font-size: 13px; min-height: 1em; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.lookup { display: flex; gap: 8px; margin-bottom: 14px; }
.lookup input { font-family: var(--font-mono); text-transform: uppercase; }
.lookup .btn { padding: 10px 14px; white-space: nowrap; }

/* Confirmación con forma de tiquete */
.stub { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.stub-head { padding: 20px 22px; background: var(--accent-soft); }
.stub-head p { margin: 0; color: var(--muted); font-size: 13px; }
.stub-head .code-big { color: var(--ink); }
.code-big { font-family: var(--font-mono); font-size: 26px; font-weight: 500; letter-spacing: 0.04em; margin: 4px 0 0; word-break: break-all; }
.stub-body { padding: 18px 22px 22px; border-top: 2px dashed var(--line); display: grid; gap: 12px; }
.stub-body p { margin: 0; }

/* Tickets */
.list { display: grid; gap: 10px; }
.t { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); min-width: 0; }
.t-head { display: grid; gap: 6px; padding: 12px 14px; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 10px; }
button.t-head { cursor: pointer; }
.t-line { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-width: 0; }
.t-code { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.t-title { font-weight: 600; overflow-wrap: anywhere; }
.t-meta { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.chip.alta { background: var(--alta-soft); color: var(--alta); }
.chip.media { background: var(--media-soft); color: var(--media); }
.chip.baja { background: var(--baja-soft); color: var(--baja); }
.chip.abierto { background: var(--accent-soft); color: var(--accent); }
.chip.en_proceso { background: var(--media-soft); color: var(--media); }
.chip.resuelto { background: var(--baja-soft); color: var(--baja); }
.t-body { padding: 4px 14px 14px; display: grid; gap: 14px; border-top: 1px solid var(--line); }
.t-body.reply { padding-top: 12px; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; margin: 12px 0 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 16px; margin: 0; }
.kv div { min-width: 0; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; justify-self: start; }
.seg button { border: 0; background: var(--surface-2); padding: 8px 14px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nota { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.nota a { font-weight: 600; word-break: break-all; }
.nota small { display: block; color: var(--muted); margin-bottom: 2px; }
.chat-toggle-row { padding: 0 14px 12px; }
.chat { display: grid; gap: 10px; min-width: 0; }
.chat h3 { font-size: 16px; }
.chat-messages { display: grid; gap: 8px; max-height: 320px; overflow: auto; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.chat-message { max-width: 90%; padding: 8px 10px; border-radius: 8px; background: var(--surface); overflow-wrap: anywhere; }
.chat-message.from-admin { justify-self: end; background: var(--accent-soft); }
.chat-unread { background: var(--alta-soft); color: var(--alta); }
.chat-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; justify-content: space-between; font-size: 12px; }
.chat-meta time { color: var(--muted); }
.chat-message p { margin: 4px 0 0; white-space: pre-wrap; }
.chat-empty { margin: 0; color: var(--muted); text-align: center; }
.chat-compose { display: grid; gap: 8px; }

/* Bandeja */
.stats { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.stats b { font-family: var(--font-mono); font-weight: 500; font-size: 18px; color: var(--ink); margin-right: 4px; }
.stats .hot b { color: var(--alta); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.fbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.fbtn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 22px; color: var(--muted); text-align: center; }
.empty b { display: block; color: var(--ink); margin-bottom: 2px; font-family: var(--font-display); font-size: 17px; }
.notice { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 14px 16px; color: var(--muted); margin-bottom: 16px; }
.login { max-width: 380px; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) { .fbtn, .btn { transition: background-color 0.15s, color 0.15s; } }

/* Ayuda en video (botón flotante) */
.help-fab { position: fixed; right: 18px; bottom: 18px; z-index: 900; display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer; background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 12px 18px 12px 14px; border-radius: 999px; box-shadow: 0 6px 20px rgba(15, 27, 38, 0.3); }
.help-fab svg { width: 26px; height: 26px; flex: 0 0 26px; }
.help-fab:hover { filter: brightness(1.08); }
.help-fab:focus-visible { outline-color: var(--ink); outline-offset: 3px; }
@media (max-width: 480px) { .help-fab { right: 14px; bottom: 14px; padding: 12px; } .help-fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } }
.help-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 14, 20, 0.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.help-dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; width: min(760px, 100%); max-height: 100%; overflow-y: auto; padding: 18px 20px 20px; }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.help-head h2 { font-size: 20px; font-weight: 600; }
.help-close { border: 1px solid var(--line); background: transparent; border-radius: 8px; width: 36px; height: 36px; font-size: 24px; line-height: 1; cursor: pointer; }
.help-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.help-tab { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 7px 14px; cursor: pointer; font-size: 14px; }
.help-tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.help-panel video { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 10px; }
.help-panel p { margin: 10px 0 0; color: var(--muted); }
body.help-open { overflow: hidden; }
.help-panel .help-fail { color: var(--alta); }
.help-retry { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
