/* ==========================================================================
   Mesa de Servicio · sistema de diseño
   1. Tokens   2. Base   3. Estructura   4. Componentes   5. Pantallas   6. Responsive
   Paleta base «Oscuro» (#EEEEEE · #9BA0AE · #4A5263 · #222B38 · #141A28) + un acento.
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Neutros (tinte frío de la paleta) */
  --bg: #F3F4F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --surface-3: #EEF0F4;
  --line: #E2E5EB;
  --line-strong: #CBD0D9;
  --text: #141A28;
  --text-2: #4A5263;
  --text-3: #687082;

  /* Marca y barra lateral */
  --ink: #141A28;
  --ink-2: #222B38;
  --ink-3: #4A5263;
  --ink-fg: #EEEEEE;
  --ink-muted: #9BA0AE;

  /* Acento (acciones y foco) */
  --accent: #2F5BD3;
  --accent-hover: #2449B0;
  --accent-soft: #EBF0FD;
  --accent-text: #2449B0;
  --on-accent: #FFFFFF;

  /* Semánticos */
  --ok: #157347;   --ok-soft: #E5F4EC;
  --warn: #9A5800; --warn-soft: #FEF2DC; --warn-line: #F1C27A;
  --bad: #BF2B2B;  --bad-soft: #FCEBEB;
  --note: #8A5A00; --note-soft: #FFF8E8; --note-line: #EBCB86;

  /* Tipografía */
  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;   /* 12 */
  --fs-sm: 0.8125rem; /* 13 */
  --fs-md: 0.875rem;  /* 14 */
  --fs-lg: 1rem;      /* 16 */
  --fs-xl: 1.125rem;  /* 18 */
  --fs-2xl: 1.375rem; /* 22 */
  --fs-3xl: 1.75rem;  /* 28 */

  /* Espaciado (base 4 px) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  /* Forma y profundidad */
  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(20, 26, 40, 0.05), 0 1px 1px rgba(20, 26, 40, 0.03);
  --shadow-2: 0 12px 32px rgba(20, 26, 40, 0.14), 0 2px 6px rgba(20, 26, 40, 0.06);
  --ring: 0 0 0 3px rgba(47, 91, 211, 0.28);

  --sidebar-w: 260px;
  --topbar-h: 60px;
  --content-max: 1360px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D111B;
    --surface: #141A28;
    --surface-2: #181F2E;
    --surface-3: #1F2737;
    --line: #262F40;
    --line-strong: #364052;
    --text: #EEEEEE;
    --text-2: #B7BCC7;
    --text-3: #8C93A2;
    --ink: #0A0E17;
    --ink-2: #171E2C;
    --accent: #7C9CFF;
    --accent-hover: #9BB3FF;
    --accent-soft: rgba(124, 156, 255, 0.14);
    --accent-text: #A7BCFF;
    --on-accent: #0D111B;
    --ok: #4CC38A;   --ok-soft: rgba(76, 195, 138, 0.13);
    --warn: #E8A33D; --warn-soft: rgba(232, 163, 61, 0.13); --warn-line: rgba(232, 163, 61, 0.45);
    --bad: #F07A72;  --bad-soft: rgba(240, 122, 114, 0.14);
    --note: #E7B758; --note-soft: rgba(231, 183, 88, 0.09); --note-line: rgba(231, 183, 88, 0.4);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-2: 0 16px 40px rgba(0, 0, 0, 0.5);
    --ring: 0 0 0 3px rgba(124, 156, 255, 0.35);
    color-scheme: dark;
  }
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: var(--fs-md); line-height: 1.5; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; color: var(--text); font-weight: 600; letter-spacing: -0.012em; text-wrap: balance; }
h1 { font-size: var(--fs-3xl); line-height: 1.2; }
h2 { font-size: var(--fs-xl); line-height: 1.3; }
h3 { font-size: var(--fs-lg); }
p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--s4); top: -60px; background: var(--surface); padding: var(--s2) var(--s4); border-radius: var(--r-sm); box-shadow: var(--shadow-2); z-index: 100; }
.skip-link:focus { top: var(--s3); }

/* Utilidades de texto */
.muted { color: var(--text-2); }
.hint { color: var(--text-3); font-size: var(--fs-sm); }
.hint .icon { width: 15px; height: 15px; margin-right: 2px; }
.eyebrow { display: block; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.eyebrow.mono { text-transform: none; letter-spacing: 0; font-family: var(--mono); font-weight: 500; }
.eyebrow-gap { margin-top: var(--s4); }
.mono { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.big { font-size: var(--fs-xl); }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 200px; }
.break { overflow-wrap: anywhere; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }
.truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.optional { color: var(--text-3); font-weight: 400; }
.link { font-weight: 500; font-size: var(--fs-sm); }

/* 3. Estructura ------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s4);
  background: var(--ink); color: var(--ink-fg); padding: var(--s5) var(--s4) var(--s4); overflow-y: auto; z-index: 40;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: 0 var(--s1); }
.icon-btn.sidebar-close { display: none; color: var(--ink-muted); }
.brand { display: flex; align-items: center; gap: var(--s3); color: inherit; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; grid-template-columns: repeat(4, 1fr); width: 30px; height: 30px; border-radius: 8px; overflow: hidden; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); }
.brand-mark i:nth-child(1) { background: #EEEEEE; }
.brand-mark i:nth-child(2) { background: #9BA0AE; }
.brand-mark i:nth-child(3) { background: #4A5263; }
.brand-mark i:nth-child(4) { background: #222B38; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text strong { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em; }
.brand-text small { font-size: var(--fs-xs); color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-cta { margin-bottom: var(--s3); }
.nav-section { margin: var(--s5) var(--s3) var(--s2); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); opacity: 0.8; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s3); border-radius: var(--r-sm);
  color: #C9CDD5; font-weight: 500; font-size: var(--fs-md);
}
.nav-item .icon { color: var(--ink-muted); }
.nav-item:hover { background: var(--ink-2); color: var(--ink-fg); text-decoration: none; }
.nav-item.is-active { background: var(--ink-2); color: #FFFFFF; }
.nav-item.is-active::before { content: ""; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #7C9CFF; }
.nav-item.is-active .icon { color: #FFFFFF; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { font-family: var(--mono); font-size: var(--fs-xs); color: var(--ink-muted); }
.nav-count.is-bad { color: #FFFFFF; background: #C0392B; border-radius: var(--r-pill); padding: 0 7px; }
.sidebar-foot { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-user { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar-user strong { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user small { font-size: var(--fs-xs); color: var(--ink-muted); }
.sidebar .avatar { background: var(--ink-2); color: var(--ink-fg); border-color: rgba(255, 255, 255, 0.12); }
.scrim { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s8); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.icon-btn.nav-toggle { display: none; }
.topbar-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; visibility: hidden; }
.topbar-actions { display: flex; align-items: center; gap: var(--s2); }
.content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--s8) var(--s8) var(--s12); display: flex; flex-direction: column; gap: var(--s6); }
.content:focus { outline: none; }

/* 4. Componentes ----------------------------------------------------------- */

/* Botones */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-line: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 38px; padding: 0 var(--s4);
  border-radius: var(--r-sm); border: 1px solid var(--btn-line); background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: var(--fs-md); line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-line: var(--accent); box-shadow: 0 1px 2px rgba(20, 26, 40, .14); }
.btn-primary:hover { --btn-bg: var(--accent-hover); --btn-line: var(--accent-hover); }
.btn-secondary { box-shadow: var(--shadow-1); }
.btn-secondary:hover { --btn-bg: var(--surface-2); --btn-line: var(--text-3); }
.btn-quiet { --btn-bg: transparent; --btn-line: transparent; --btn-fg: var(--text-2); }
.btn-quiet:hover { --btn-bg: var(--surface-3); --btn-fg: var(--text); }
.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--bad); --btn-line: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn-danger:hover { --btn-bg: var(--bad-soft); }
.btn.is-armed { --btn-bg: var(--bad); --btn-fg: #FFFFFF; --btn-line: var(--bad); }
.btn-sm { min-height: 32px; padding: 0 var(--s3); font-size: var(--fs-sm); }
.btn-lg { min-height: 46px; padding: 0 var(--s6); font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn.is-busy { opacity: .75; pointer-events: none; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r-sm);
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.sidebar .icon-btn:hover { background: var(--ink-2); color: var(--ink-fg); }
.back-link { display: inline-flex; align-items: center; gap: var(--s2); align-self: flex-start; padding: 6px 10px 6px 6px; margin: calc(var(--s2) * -1) 0 calc(var(--s2) * -1) -6px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 600; }
.back-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.inline-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }

/* Insignias */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; border: 1px solid transparent; line-height: 1;
}
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-note { background: var(--note-soft); color: var(--note); border-color: var(--note-line); }
.badge .dot, .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.badges { display: flex; flex-wrap: wrap; gap: var(--s2); }
.prio { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; }
.prio i { width: 8px; height: 8px; border-radius: 2px; background: var(--text-3); }
.prio-bad i { background: var(--bad); }
.prio-warn i { background: #E8A33D; }
.prio-neutral i { background: var(--line-strong); }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
fieldset.card { margin: 0; padding: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); padding: var(--s5) var(--s6) 0; }
.card-head h2 { font-size: var(--fs-lg); display: flex; align-items: center; gap: var(--s2); }
.card-head h2 .icon { color: var(--text-3); }
.card-head .muted { margin-top: var(--s1); font-size: var(--fs-sm); max-width: 68ch; }
.card-legend { float: left; width: 100%; padding: var(--s5) var(--s6) 0; font-size: var(--fs-lg); font-weight: 600; }
.card-legend + * { clear: both; }
.card-body { padding: var(--s5) var(--s6); }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s3); padding: var(--s4) var(--s6); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-foot .hint:first-child { margin-right: auto; }
.stack { display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }
.stack-sm { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.narrow { max-width: 560px; }

/* Encabezado de página */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4) var(--s6); }
.page-head-text { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; max-width: 820px; }
.page-head-text > p { color: var(--text-2); font-size: var(--fs-lg); max-width: 72ch; }
.page-head h1 { overflow-wrap: anywhere; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.page-actions form { display: contents; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
.section-head .muted { margin-top: var(--s1); }

/* Formularios */
.form { display: flex; flex-direction: column; gap: var(--s5); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; margin: 0; padding: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s4); }
.field-row > .grow { grid-column: span 2; }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--text); display: inline-flex; align-items: center; gap: 6px; padding: 0; }
.label .icon { width: 16px; height: 16px; color: var(--text-3); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s; min-width: 0;
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input-lg { min-height: 48px; font-size: var(--fs-lg); }
.input-readonly { display: flex; align-items: center; background: var(--surface-2); color: var(--text-2); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon { display: inline-flex; align-items: center; gap: 6px; padding: 0 var(--s3); border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; }
.input-addon:hover { background: var(--surface-3); color: var(--text); }
.input-addon .icon { width: 16px; height: 16px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s2); }
.form-actions-end { padding-top: 0; }
.form-note { display: flex; gap: var(--s2); color: var(--text-3); font-size: var(--fs-sm); }
.form-note .icon { width: 16px; height: 16px; margin-top: 2px; }
.checks { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.check { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r); cursor: pointer; background: var(--surface); }
.check:hover { border-color: var(--line-strong); }
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check span { display: flex; flex-direction: column; gap: 2px; }
.check small { color: var(--text-3); font-size: var(--fs-sm); }
.check-inline { border: 0; padding: 0; align-items: center; background: transparent; font-size: var(--fs-sm); font-weight: 500; }
.check-inline input { margin: 0; }
.subsection { border: 0; margin: 0; padding: var(--s4) 0 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s3); }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-body { display: flex; flex-direction: column; gap: 4px; padding: var(--s3) var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); transition: border-color .15s, box-shadow .15s, background-color .15s; height: 100%; }
.choice-body small { color: var(--text-3); font-size: var(--fs-sm); }
.choice:hover .choice-body { border-color: var(--text-3); }
.choice input:checked + .choice-body { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.choice input:focus-visible + .choice-body { box-shadow: var(--ring); }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: var(--s6) var(--s4); border: 1.5px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); text-align: center; color: var(--text-2); cursor: pointer; transition: border-color .15s, background-color .15s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone .icon { width: 22px; height: 22px; color: var(--text-3); }
.dropzone small { color: var(--text-3); font-size: var(--fs-xs); }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.file-list li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill); background: var(--surface-3); font-size: var(--fs-sm); max-width: 100%; overflow-wrap: anywhere; }
.inline-form { display: flex; gap: var(--s2); justify-content: stretch; }
.inline-form .input { flex: 1; }
.search-box { position: relative; display: flex; align-items: center; min-width: 0; }
.search-box .input { padding-left: 38px; }
.search-icon { position: absolute; left: 12px; width: 17px; height: 17px; color: var(--text-3); pointer-events: none; }
.search-box.grow, .grow { flex: 1 1 260px; }
.input-date .input { width: auto; }

/* Avisos */
.flash-stack { display: flex; flex-direction: column; gap: var(--s2); }
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r); border: 1px solid; font-size: var(--fs-md); }
.alert .icon { margin-top: 1px; }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--text); }
.alert-ok > .icon { color: var(--ok); }
.alert-bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.alert-bad > .icon { color: var(--bad); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn-line); }
.alert-warn > .icon { color: var(--warn); }
.alert-info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.alert-info > .icon { color: var(--accent-text); }
.alert.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity .3s, transform .3s; }

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s3); }
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; box-shadow: var(--shadow-1); }
.kpi-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.25; }
.kpi-sub { font-size: var(--fs-xs); color: var(--text-3); overflow-wrap: anywhere; }
.kpi-ok .kpi-value { color: var(--ok); }
.kpi-warn .kpi-value { color: var(--warn); }
.kpi-bad .kpi-value { color: var(--bad); }
.kpi-warn { border-color: var(--warn-line); }
.kpi-bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }

/* Barra de filtros */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.toolbar .select { width: auto; min-width: 170px; }
.toolbar-plain { align-items: flex-end; gap: var(--s3); }
.toolbar-plain .field { flex: 0 1 200px; }
.segmented { display: inline-flex; padding: 3px; border-radius: var(--r); background: var(--surface-3); gap: 2px; }
.segmented a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 7px; color: var(--text-2); font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.count { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }
.chip:hover { border-color: var(--text-3); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.chip-static { cursor: default; }

/* Tablas */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.table-flush { border: 0; border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); box-shadow: none; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-md); }
.table th { position: sticky; top: 0; text-align: left; padding: 11px 16px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.num { text-align: right; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.table tr.row-warn td:first-child { box-shadow: inset 3px 0 0 #E8A33D; }
.cell-subject { max-width: 420px; }
.cell-subject small { display: block; margin-top: 2px; color: var(--text-3); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link { color: var(--text); }
.table-note { color: var(--text-3); font-size: var(--fs-sm); }
.table-history td { font-size: var(--fs-sm); }

/* SLA y barras */
.sla { display: inline-flex; flex-direction: column; gap: 4px; min-width: 130px; }
.sla-label { font-size: var(--fs-sm); font-weight: 600; }
.sla small { font-size: var(--fs-xs); color: var(--text-3); }
.sla-ok .sla-label { color: var(--ok); }
.sla-warn .sla-label { color: var(--warn); }
.sla-bad .sla-label { color: var(--bad); }
.bar { position: relative; display: block; height: 5px; border-radius: var(--r-pill); background: var(--surface-3); overflow: visible; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--text-3); transition: width .9s linear; }
.sla-ok .bar-fill, .bar-ok .bar-fill { background: var(--ok); }
.sla-warn .bar-fill, .bar-warn .bar-fill { background: #E8A33D; }
.sla-bad .bar-fill, .bar-bad .bar-fill { background: var(--bad); }
.bar-lg { height: 8px; }
.bar-xl { height: 12px; }
.bar-mark { position: absolute; left: 70%; top: -4px; bottom: -4px; width: 2px; border-radius: 2px; background: var(--text-3); opacity: .7; }
.bar-scale { position: relative; height: 18px; font-size: var(--fs-xs); color: var(--text-3); }
.bar-scale span { position: absolute; top: 0; }
.bar-scale span:first-child { left: 0; }
.bar-scale span:nth-child(2) { left: 70%; transform: translateX(-50%); white-space: nowrap; }
.bar-scale span:last-child { right: 0; }
.pw-0{width:0}.pw-5{width:5%}.pw-10{width:10%}.pw-15{width:15%}.pw-20{width:20%}.pw-25{width:25%}.pw-30{width:30%}.pw-35{width:35%}.pw-40{width:40%}.pw-45{width:45%}.pw-50{width:50%}.pw-55{width:55%}.pw-60{width:60%}.pw-65{width:65%}.pw-70{width:70%}.pw-75{width:75%}.pw-80{width:80%}.pw-85{width:85%}.pw-90{width:90%}.pw-95{width:95%}.pw-100{width:100%}
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.meter { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); }
.meter-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); font-weight: 600; font-size: var(--fs-sm); }
.meter-sub { font-size: var(--fs-xs); color: var(--text-3); }

/* KPI de tiempo */
.time-kpi { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s5); }
.time-kpi.tone-warn { border-color: var(--warn-line); }
.time-kpi.tone-bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: linear-gradient(var(--bad-soft), var(--bad-soft)), var(--surface); }
.time-kpi-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2); }
.time-kpi-nums { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) var(--s3); }
.time-kpi-nums > div { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); color: var(--text-3); min-width: 0; }
.time-kpi-nums .num { text-align: left; font-family: var(--mono); font-size: var(--fs-xl); font-weight: 500; color: var(--text); letter-spacing: -0.02em; }
.tone-ok .tone-text { color: var(--ok) !important; }
.tone-warn .tone-text { color: var(--warn) !important; }
.tone-bad .tone-text { color: var(--bad) !important; }

/* Estado vacío */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); padding: var(--s10) var(--s6); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.empty-icon { width: 30px; height: 30px; color: var(--text-3); margin-bottom: var(--s1); }
.empty-title { font-weight: 600; font-size: var(--fs-lg); }
.empty-text { color: var(--text-2); max-width: 46ch; }
.empty-actions { margin-top: var(--s3); display: flex; gap: var(--s2); }

/* Avatares y personas */
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 700; flex: none; border: 1px solid var(--line); letter-spacing: .02em; }
.avatar-sm { width: 28px; height: 28px; font-size: 0.6875rem; }
.avatar-lg { width: 52px; height: 52px; font-size: var(--fs-lg); }
.person { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.person > span { display: flex; flex-direction: column; min-width: 0; }
.person small { color: var(--text-3); font-size: var(--fs-xs); overflow-wrap: anywhere; }
.person:hover { text-decoration: none; }
.person-head { flex-direction: row; align-items: center; gap: var(--s4); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4) var(--s6); margin: 0; }
.facts div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.facts .span { grid-column: 1 / -1; }
.facts dt { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* Menú de cuenta y alertas */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-trigger { display: flex; align-items: center; gap: var(--s2); padding: 4px 8px 4px 4px; border-radius: var(--r-pill); cursor: pointer; }
.menu-trigger:hover, .menu[open] .menu-trigger { background: var(--surface-3); }
.menu-name { font-weight: 600; font-size: var(--fs-sm); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-caret { width: 16px; height: 16px; color: var(--text-3); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); width: 250px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-2); z-index: 50; }
.menu-who { display: flex; flex-direction: column; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; min-width: 0; }
.menu-who small { color: var(--text-3); overflow-wrap: anywhere; }
.menu-item { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 9px 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); font-weight: 500; text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item .icon { width: 17px; height: 17px; color: var(--text-3); }
.bell-count { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--bad); color: #FFFFFF; font-size: 0.6875rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--bg); }

/* Botón de ayuda que pulsa cuando el problema tiene guía */
.help-btn { position: relative; --btn-fg: var(--text-2); }
.help-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: #E8A33D; color: #141A28; font-size: var(--fs-xs); font-weight: 700; }
.help-tip { position: absolute; top: calc(100% + 10px); right: 0; width: max-content; max-width: min(300px, calc(100vw - 32px)); padding: 10px 12px; border-radius: var(--r); background: var(--text); color: var(--bg); font-size: var(--fs-sm); font-weight: 500; line-height: 1.4; white-space: normal; text-align: left; box-shadow: var(--shadow-2); pointer-events: none; z-index: 45; }
.help-tip::before { content: ""; position: absolute; top: -5px; right: 22px; width: 10px; height: 10px; background: var(--text); transform: rotate(45deg); }
.help-btn.is-pulsing { --btn-bg: var(--warn-soft); --btn-line: #E8A33D; --btn-fg: var(--text); animation: help-pulse 1.8s ease-out infinite; }
@keyframes help-pulse { 0% { box-shadow: 0 0 0 0 rgba(232, 163, 61, .6); } 70% { box-shadow: 0 0 0 12px rgba(232, 163, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(232, 163, 61, 0); } }

/* Pestañas */
.tabs { display: flex; gap: var(--s1); padding: var(--s2) var(--s4) 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: var(--s2); padding: 12px 12px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: transparent; color: var(--text-2); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab .icon { width: 17px; height: 17px; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: var(--s4); background: rgba(10, 14, 23, .55); backdrop-filter: blur(2px); }
.modal-card { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; gap: var(--s4); padding: var(--s6); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-2); }
.modal-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.modal-icon.tone-ok { background: var(--ok-soft); color: var(--ok); }
.modal-icon .icon { width: 22px; height: 22px; stroke-width: 2.2; }
.modal-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3) var(--s4); margin: 0; padding: var(--s4) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.modal-facts div { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0; }
.modal-facts dt { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }
.modal-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.modal-reason { display: flex; flex-direction: column; gap: 4px; white-space: pre-wrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; }

/* 5. Pantallas ------------------------------------------------------------- */

/* Acceso */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 0.9fr) minmax(0, 1.1fr); }
.auth-panel { display: flex; flex-direction: column; justify-content: space-between; gap: var(--s8); padding: var(--s10); background: var(--ink); color: var(--ink-fg); }
.auth-panel .brand-text small { color: var(--ink-muted); }
.brand-lg .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
.brand-lg .brand-text strong { font-size: var(--fs-lg); }
.auth-panel-copy { display: flex; flex-direction: column; gap: var(--s6); max-width: 420px; }
.auth-panel-title { font-size: 1.875rem; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; text-wrap: balance; }
.auth-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); color: #C9CDD5; }
.auth-points li { display: flex; align-items: center; gap: var(--s3); }
.auth-points .icon { color: #7C9CFF; }
.auth-panel-foot { font-size: var(--fs-sm); color: var(--ink-muted); }
.auth-main { display: grid; place-items: center; padding: var(--s8) var(--s4); }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--s6); }
.brand-compact { display: none; }
.auth-head { display: flex; flex-direction: column; gap: var(--s2); }
.auth-head h1 { font-size: var(--fs-2xl); }
.auth-head p { color: var(--text-2); }

/* Portal: centro de ayuda */
.help-center { overflow: visible; }
.draft-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px dashed var(--line-strong); border-radius: var(--r); background: var(--surface-2); }
.draft-bar .icon { color: var(--text-3); margin-right: 6px; }
.kb-list { list-style: none; margin: var(--s2) 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.kb-list li + li { border-top: 1px solid var(--line); }
.kb-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); color: var(--text); }
.kb-row:hover { background: var(--surface-2); text-decoration: none; }
.kb-row-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--accent-soft); color: var(--accent-text); flex: none; }
.kb-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.kb-row-text small { color: var(--text-3); font-size: var(--fs-sm); }
.help-none { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2); color: var(--text-2); padding: var(--s3) 0; }

/* Portal: solicitudes */
.request-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.request-card { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s4) var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); box-shadow: var(--shadow-1); transition: border-color .15s, box-shadow .15s; }
.request-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); text-decoration: none; }
.request-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.request-title { font-weight: 600; font-size: var(--fs-lg); overflow-wrap: anywhere; }
.request-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-3); font-size: var(--fs-sm); }
.request-side { display: flex; align-items: center; gap: var(--s3); flex: none; }
.request-chevron { color: var(--text-3); }
.new-reply { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--accent-text); white-space: nowrap; }
.progress-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); counter-reset: s; }
.progress-steps li { position: relative; display: flex; align-items: center; gap: var(--s2); padding-top: var(--s3); border-top: 3px solid var(--line); color: var(--text-3); font-weight: 600; font-size: var(--fs-sm); }
.progress-steps li.is-done { border-top-color: var(--accent); color: var(--text); }
.step-dot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); font-size: var(--fs-xs); }
.is-done .step-dot { background: var(--accent); color: var(--on-accent); }
.step-dot .icon { width: 13px; height: 13px; stroke-width: 2.5; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s5); align-items: start; }
.attachments { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.attachments a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font-size: var(--fs-sm); max-width: 100%; }
.attachments a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachments small { color: var(--text-3); }
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s4); }
.msg { display: flex; gap: var(--s3); align-items: flex-start; max-width: 88%; }
.msg-mine { flex-direction: row-reverse; align-self: flex-end; }
.msg-bubble { display: flex; flex-direction: column; gap: 4px; padding: var(--s3) var(--s4); border-radius: 4px var(--r) var(--r) var(--r); background: var(--surface-3); min-width: 0; }
.msg-mine .msg-bubble { border-radius: var(--r) 4px var(--r) var(--r); background: var(--accent-soft); }
.msg-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--fs-xs); color: var(--text-3); }
.msg-meta strong { color: var(--text); font-size: var(--fs-sm); }
.reply { flex-direction: column; align-items: stretch; gap: var(--s2); }
.reply .form-actions { margin-top: var(--s1); }
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s5); align-items: start; }
.feedback-card { position: sticky; top: calc(var(--topbar-h) + var(--s4)); }
.feedback-card form { display: block; }
.kb-article h1 { font-size: var(--fs-2xl); }
.kb-section { display: flex; flex-direction: column; gap: var(--s2); max-width: 72ch; }
.kb-section > p { color: var(--text-2); font-size: var(--fs-lg); }
.kb-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: var(--s3); }
.kb-steps li { position: relative; padding-left: 38px; counter-increment: step; line-height: 1.55; }
.kb-steps li::before { content: counter(step); position: absolute; left: 0; top: -1px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-family: var(--mono); font-size: var(--fs-xs); font-weight: 500; }
.internal-box { padding: var(--s3) var(--s4); border: 1px solid var(--note-line); border-radius: var(--r); background: var(--note-soft); }

/* Sugerencias de la base de conocimiento */
.suggest-host { display: flex; flex-direction: column; gap: var(--s3); }
.suggest-host:empty { display: none; }
.suggest { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line)); border-radius: var(--r); background: var(--accent-soft); }
.suggest-warn { border-color: var(--warn-line); background: var(--warn-soft); }
.suggest-title { display: flex; align-items: center; gap: var(--s2); font-weight: 600; }
.suggest-title .icon { color: var(--accent-text); }
.suggest-warn .suggest-title .icon { color: var(--warn); }
.kb-disclosure { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.kb-disclosure + .kb-disclosure { margin-top: var(--s2); }
.kb-disclosure > summary { display: flex; align-items: center; gap: var(--s2); padding: var(--s3); cursor: pointer; list-style: none; font-weight: 600; }
.kb-disclosure > summary::-webkit-details-marker { display: none; }
.kb-disclosure > summary > span:first-child { flex: 1; min-width: 0; }
.disclosure-caret { width: 16px; height: 16px; color: var(--text-3); transition: transform .15s; }
.kb-disclosure[open] .disclosure-caret { transform: rotate(180deg); }
.kb-disclosure-body { display: flex; flex-direction: column; gap: var(--s3); padding: 0 var(--s3) var(--s3); }
.dup-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dup-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--line); }
.dup-row:first-child { border-top: 0; }
.dup-text { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dup-text small { font-size: var(--fs-xs); }
.suggest-panel .card-body { display: flex; flex-direction: column; gap: var(--s3); }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.link-list li { display: flex; flex-direction: column; gap: 2px; }
.linked { padding-bottom: 0; }

/* Consola: detalle de ticket */
.ticket-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--s5); align-items: start; }
.ticket-aside { position: sticky; top: calc(var(--topbar-h) + var(--s4)); max-height: calc(100vh - var(--topbar-h) - var(--s8)); overflow-y: auto; }
.form-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s4); }
.form-sections .card-body { padding-top: var(--s4); }
.form-sections .field-row { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.prio-out { display: flex; align-items: center; min-height: 40px; }
.composers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.composer { display: flex; flex-direction: column; gap: var(--s2); }
.composer-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2); }
.composer-internal .textarea { background: var(--note-soft); border-color: var(--note-line); }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.activity-item { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.activity-item.is-internal { background: var(--note-soft); border-color: var(--note-line); }
.activity-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.activity-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: var(--fs-xs); color: var(--text-3); }
.activity-meta strong { color: var(--text); font-size: var(--fs-sm); }

/* Alertas */
.notif-list { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.notif-list li + li { border-top: 1px solid var(--line); }
.notif { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); color: var(--text); }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.is-unread { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--accent); }
.notif-dot.tone-warn { background: #E8A33D; }
.notif-dot.tone-bad { background: var(--bad); }
.notif-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.notif-text small { color: var(--text-3); font-size: var(--fs-xs); }
.notif:not(.is-unread) .notif-text { color: var(--text-2); }
.notif-chevron { color: var(--text-3); }

/* Ajustes */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
.howto { border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3) var(--s4); background: var(--surface-2); }
.howto summary { cursor: pointer; font-weight: 600; }
.howto ol { margin: var(--s3) 0 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: var(--s2); color: var(--text-2); }
.plain-list { list-style: none; margin: 0; display: flex; flex-direction: column; gap: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.plain-list li:last-child { border-bottom: 0; }
.wrap-actions { justify-content: flex-start; }
.export-status { font-size: var(--fs-sm); color: var(--text-2); }
.flash-target { animation: target-flash 1.6s ease-out; }
@keyframes target-flash { 0% { box-shadow: 0 0 0 3px #E8A33D; } 100% { box-shadow: var(--shadow-1); } }
.export-status.is-ok { color: var(--ok); }
.export-status.is-bad { color: var(--bad); }
.error-page { margin-bottom: var(--s2); }

/* 6. Responsive ------------------------------------------------------------ */

/* ---------- App y avisos (PWA) ---------- */
.app-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.app-step .card-head h2, .app-grid .card-head h2 { display: flex; align-items: center; gap: var(--s2); }
.step-num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #FFFFFF; font-size: var(--fs-sm); font-weight: 700; flex: none; }
.howto-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.howto-steps li { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.howto-icon { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); color: var(--accent-text); flex: none; }
.howto-icon .icon { width: 20px; height: 20px; }
.howto-appicon { width: 36px; height: 36px; border-radius: 9px; flex: none; }
.plain-steps { margin: var(--s3) 0 0; padding-left: var(--s5); display: flex; flex-direction: column; gap: var(--s1); font-size: var(--fs-md); color: var(--text-2); }
.notify-types { list-style: none; margin: 0; display: flex; flex-direction: column; gap: var(--s3); }
.notify-types li { display: flex; gap: var(--s3); align-items: flex-start; }
.notify-types strong { display: block; font-weight: 600; }
.notify-types small { display: block; color: var(--text-2); font-size: var(--fs-sm); }
.dot-tone { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--accent); }
.dot-tone.tone-warn { background: var(--warn); } .dot-tone.tone-bad { background: var(--bad); } .dot-tone.tone-ok { background: var(--ok); }
.device-list { list-style: none; margin: 0; padding: 0; }
.device-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s6); }
.device-list li + li { border-top: 1px solid var(--line); }
.device-main { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); min-width: 0; }
.device-main small { flex-basis: 100%; color: var(--text-3); font-size: var(--fs-sm); }
.install-banner { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s4); background: var(--ink); color: #FFFFFF; border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.install-banner[hidden] { display: none; }
.install-banner .install-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.install-banner small { color: #C3C8D2; font-size: var(--fs-sm); }
.install-banner .icon-btn { color: #C3C8D2; }
.offline { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s4); padding: var(--s8) var(--s5); text-align: center; }
.offline img { border-radius: 18px; }
.offline p { max-width: 34ch; color: var(--text-2); }
/* Dentro de la app instalada, respetar la muesca y la barra de inicio del teléfono. */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .content { padding-bottom: calc(var(--s8) + env(safe-area-inset-bottom)); }
  .sidebar { padding-top: env(safe-area-inset-top); }
}

@media (max-width: 1279px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ticket-layout { grid-template-columns: minmax(0, 1fr) 320px; }
}

/* Tableta: la barra lateral se vuelve un panel que se abre con el botón de menú */
@media (max-width: 1023px) {
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100%; transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
  .nav-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-2); transition: transform .22s ease; }
  .icon-btn.sidebar-close { display: inline-grid; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10, 14, 23, .5); z-index: 35; }
  .nav-item.is-active::before { left: -16px; }
  .icon-btn.nav-toggle { display: inline-grid; }
  .topbar { padding: 0 var(--s4); }
  .topbar-title { visibility: visible; }
  .content { padding: var(--s6) var(--s5) var(--s10); }
  .ticket-layout, .detail-grid, .article-layout, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .ticket-aside, .feedback-card { position: static; max-height: none; overflow: visible; }
  .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-panel { display: none; }
  .brand-compact { display: flex; }
  .auth-main { align-items: start; padding-top: var(--s12); }
}

/* Teléfono: tablas en tarjetas, una columna, botones a todo el ancho */
@media (max-width: 719px) {
  h1 { font-size: var(--fs-2xl); }
  .content { padding: var(--s5) var(--s4) var(--s10); gap: var(--s5); }
  .topbar { gap: var(--s1); }
  .help-btn-label, .menu-name, .menu-caret { display: none; }
  .help-btn { padding: 0 10px; }
  .page-head { align-items: stretch; }
  .page-head-text > p { font-size: var(--fs-md); }
  .page-actions { width: 100%; }
  .page-actions > .btn, .page-actions > form { flex: 1 1 auto; }
  .page-actions form .btn { width: 100%; }
  .kpis, .kpis-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .kpi { padding: var(--s3); }
  .kpi-value { font-size: var(--fs-xl); }
  .meters, .composers, .form-sections, .choice-grid { grid-template-columns: minmax(0, 1fr); }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .field-row > .grow { grid-column: auto; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .select, .toolbar .search-box, .input-date .input, .toolbar-plain .field { width: 100%; flex: 1 1 auto; min-width: 0; }
  .segmented { align-self: stretch; }
  .segmented a { flex: 1; justify-content: center; }
  .card-head, .card-body { padding-left: var(--s4); padding-right: var(--s4); }
  .card-legend { padding-left: var(--s4); padding-right: var(--s4); }
  .card-foot { padding: var(--s3) var(--s4); }
  .card-foot .btn { flex: 1 1 auto; }
  .card-foot .hint:first-child { flex-basis: 100%; }

  /* Tablas → tarjetas apiladas con la etiqueta de cada dato */
  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .table-flush { border-top: 1px solid var(--line); padding: var(--s3); }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table tbody { display: flex; flex-direction: column; gap: var(--s2); }
  .table tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s2) var(--s4); box-shadow: var(--shadow-1); }
  .table tr.row-bad { border-left: 3px solid var(--bad); }
  .table tr.row-warn { border-left: 3px solid #E8A33D; }
  .table tr.row-bad td:first-child, .table tr.row-warn td:first-child { box-shadow: none; }
  .table td { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--s3); align-items: center; padding: 7px 0; border: 0; text-align: left; }
  .table td + td { border-top: 1px dashed var(--line); }
  .table td::before { content: attr(data-label); font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
  .table td.num { text-align: left; }
  .table tbody tr:hover td { background: transparent; }
  .cell-subject { max-width: none; }
  .cell-subject .truncate { white-space: normal; }
  .wrap { min-width: 0; }
  .sla { min-width: 0; }
  .table td.hide-sm { display: none; }
  .cell-subject small { white-space: normal; }

  .request-card { align-items: flex-start; padding: var(--s4); }
  .request-side { flex-direction: column; align-items: flex-end; gap: var(--s2); }
  .request-chevron { display: none; }
  .msg { max-width: 100%; }
  .time-kpi-nums .num { font-size: var(--fs-lg); }
  .person-head { align-items: flex-start; }
  .modal-facts { grid-template-columns: minmax(0, 1fr); }
  .inline-form { flex-direction: column; }
  .kb-row-cat { display: none; }
  .progress-steps li { font-size: var(--fs-xs); }
  .help-tip { right: -56px; }
  .help-tip::before { right: 78px; }
}

@media (max-width: 380px) {
  .kpis, .kpis-4 { grid-template-columns: minmax(0, 1fr); }
  .request-card { flex-direction: column; }
  .request-side { flex-direction: row; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .help-btn.is-pulsing { box-shadow: 0 0 0 3px rgba(232, 163, 61, .6); }
}
