/* =====================================================================
 * SmallKnife · Sistema de diseño
 * Un solo CSS para todo el sitio. Todo se apoya en variables, así el
 * tema "retro" (opcional para admin/soporte) solo cambia la paleta.
 * ===================================================================== */

/* ---------- 1. Variables (tema claro, por defecto) ---------- */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e8edf5;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff6ff;
  --primary-contrast: #ffffff;

  --success: #059669;  --success-50: #ecfdf5;
  --warning: #d97706;  --warning-50: #fffbeb;
  --danger:  #dc2626;  --danger-50:  #fef2f2;
  --info:    #0284c7;  --info-50:    #f0f9ff;
  --violet:  #7c3aed;  --violet-50:  #f5f3ff;

  --role-admin: #7c3aed; --role-soporte: #059669; --role-cliente: #2563eb;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px rgba(37, 99, 235, .25);

  --header-h: 64px;
  --container: 1200px;
  --transition: .18s ease;
  color-scheme: light;
}

/* ---------- 2. Tema retro (opcional, solo admin/soporte) ---------- */
[data-theme="retro"] {
  --font: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --bg: #050805;
  --surface: #0a110a;
  --surface-2: #0e180e;
  --surface-3: #132313;
  --text: #b9ffc8;
  --text-2: #7ee59a;
  --muted: #5fae74;
  --border: #1d3a24;
  --border-strong: #2c5a37;
  --primary: #33ff66;
  --primary-600: #22dd55;
  --primary-50: #0f2414;
  --primary-contrast: #031006;
  --success: #33ff66; --success-50: #0f2414;
  --warning: #ffd23f; --warning-50: #221c06;
  --danger:  #ff5f56; --danger-50:  #2a0d0b;
  --info:    #4fd1ff; --info-50:    #06202a;
  --violet:  #c792ff; --violet-50:  #1b1028;
  --role-admin: #c792ff; --role-soporte: #33ff66; --role-cliente: #4fd1ff;
  --radius-sm: 2px; --radius: 3px; --radius-lg: 4px;
  --shadow-sm: none; --shadow: none; --shadow-lg: 0 0 0 1px var(--border-strong);
  --ring: 0 0 0 2px rgba(51, 255, 102, .45);
  color-scheme: dark;
}
[data-theme="retro"] body { text-shadow: 0 0 6px rgba(51, 255, 102, .18); }
[data-theme="retro"] .btn-primary { text-shadow: none; }

/* ---------- 3. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
img, svg, video, canvas { max-width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; color: var(--text); }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.85rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 700; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, kbd, pre { font-family: var(--font-mono); font-size: .88em; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; word-break: break-all; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; overflow: auto; white-space: pre-wrap; }
::selection { background: var(--primary); color: var(--primary-contrast); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .xs { font-size: .76rem; }
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; } .text-center { text-align: center; }
.nowrap { white-space: nowrap; } .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-0 { margin-top: 0 } .mb-0 { margin-bottom: 0 } .mt { margin-top: 16px } .mb { margin-bottom: 16px }
.hidden { display: none !important; }

/* ---------- 4. Estructura de la app ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50; height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header .inner { max-width: var(--container); margin: 0 auto; height: 100%; padding: 0 20px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12rem; color: var(--text); letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--primary); color: var(--primary-contrast); font-size: 15px; }
.brand span b { color: var(--primary); font-weight: 800; }

.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: .92rem; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--primary-50); color: var(--primary); }
.nav a .count { background: var(--danger); color: #fff; font-size: .7rem; padding: 0 6px; border-radius: 10px; font-weight: 800; }

.header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-size: 17px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.user-menu { position: relative; }
.user-trigger { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); font: inherit; }
.user-trigger:hover { border-color: var(--border-strong); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--primary); color: var(--primary-contrast); display: grid; place-items: center; font-weight: 800; font-size: .8rem; flex-shrink: 0; }
.avatar-lg { width: 88px; height: 88px; font-size: 1.8rem; }
.user-trigger .who { text-align: left; line-height: 1.15; padding-right: 4px; }
.user-trigger .who b { display: block; font-size: .86rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; }
.dropdown.open { display: block; animation: pop .14s ease; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; color: var(--text); font: inherit; font-size: .92rem; background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.dropdown .danger { color: var(--danger); }
.dropdown .head { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.menu-toggle { display: none; }
.mobile-nav { display: none; }

.app-main { max-width: var(--container); margin: 0 auto; padding: 28px 20px 60px; }
.app-main.narrow { max-width: 820px; }
.app-main.wide { max-width: 1400px; }
.app-footer { max-width: var(--container); margin: 0 auto; padding: 18px 20px 30px; color: var(--muted); font-size: .82rem; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; border-top: 1px solid var(--border); }
.app-footer a { color: var(--muted); }

/* Encabezado de página con botón Volver */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head .titles { min-width: 0; }
.page-head h1 { margin: 2px 0 4px; }
.page-head p { margin: 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.back-link:hover { color: var(--primary); text-decoration: none; }

/* ---------- 5. Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 18px; }
.grid > .card, .row > .card, .stats > .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.flat { box-shadow: none; }
.card.tint { background: var(--surface-2); }
.card.pad-0 { padding: 0; overflow: hidden; }
.section { margin-bottom: 30px; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); }
.section-title::before { content: ""; width: 4px; height: 16px; border-radius: 4px; background: var(--accent, var(--primary)); }
.section-title small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted); font-size: .8rem; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; min-height: 42px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: .92rem; font-weight: 650; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition); }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: var(--primary-contrast); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); background: var(--danger); color: #fff; }
.btn-outline-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn-outline-danger:hover { background: var(--danger-50); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; min-height: 34px; font-size: .84rem; border-radius: 8px; }
.btn-lg { padding: 13px 22px; min-height: 50px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: 38px; min-height: 38px; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-size: .82rem; font-weight: 650; color: var(--text-2); }
.hint { font-size: .78rem; color: var(--muted); }
.input, .select, .textarea,
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel],
input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; min-height: 42px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem;
  transition: border-color var(--transition), box-shadow var(--transition); }
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }
.check { display: flex; align-items: center; gap: 10px; font-size: .92rem; cursor: pointer; }
.input-group { position: relative; display: flex; }
.input-group input { padding-right: 46px; }
.input-group .addon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }

/* Interruptor */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 24px; cursor: pointer; transition: var(--transition); }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: var(--transition); box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Avisos */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; border: 1px solid; font-size: .92rem; margin-bottom: 16px; }
.alert i { margin-top: 3px; }
.alert-success { background: var(--success-50); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--success); }
.alert-danger, .alert-error { background: var(--danger-50); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.alert-warning { background: var(--warning-50); border-color: color-mix(in srgb, var(--warning) 35%, transparent); color: var(--warning); }
.alert-info { background: var(--info-50); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info); }
.alert > div { color: var(--text); }

/* Etiquetas */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; line-height: 1.3; }
.badge-success { background: var(--success-50); color: var(--success); }
.badge-warning { background: var(--warning-50); color: var(--warning); }
.badge-danger  { background: var(--danger-50);  color: var(--danger); }
.badge-info    { background: var(--info-50);    color: var(--info); }
.badge-primary { background: var(--primary-50); color: var(--primary); }
.badge-violet  { background: var(--violet-50);  color: var(--violet); }
.badge-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; vertical-align: middle; }
.stat > .xs { display: block; margin-top: 2px; }
.pill-count { background: var(--danger); color: #fff; font-size: .7rem; font-weight: 800; padding: 1px 7px; border-radius: 999px; }
.role-badge { font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 999px; color: #fff; }
.role-admin { background: var(--role-admin); } .role-soporte { background: var(--role-soporte); } .role-cliente { background: var(--role-cliente); }
[data-theme="retro"] .role-badge, [data-theme="retro"] .pill-count { color: #031006; }

/* Indicadores */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; color: var(--text); display: block; box-shadow: var(--shadow-sm); transition: border-color var(--transition), transform var(--transition); }
a.stat:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); color: var(--text); }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; }
.stat.is-alert .value { color: var(--danger); }
.stat .delta { font-size: .78rem; font-weight: 700; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); }

/* Tarjetas de acceso (panel) */
.tile { display: flex; gap: 14px; align-items: flex-start; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow-sm); transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition); }
a.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent, var(--primary)) 45%, var(--border)); text-decoration: none; color: var(--text); }
.tile .ico, .ico-badge { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; font-size: 18px;
  color: var(--accent, var(--primary)); background: color-mix(in srgb, var(--accent, var(--primary)) 12%, var(--surface)); }
.tile h3 { margin: 0 0 3px; display: flex; align-items: center; gap: 8px; font-size: .98rem; }
.tile p { margin: 0; font-size: .86rem; color: var(--muted); line-height: 1.45; }
.tile.disabled { opacity: .55; cursor: not-allowed; }
.accent-blue { --accent: #2563eb; } .accent-green { --accent: #059669; } .accent-violet { --accent: #7c3aed; }
.accent-amber { --accent: #d97706; } .accent-pink { --accent: #db2777; } .accent-cyan { --accent: #0891b2; }
[data-theme="retro"] [class*="accent-"] { --accent: var(--primary); }

/* Tablas: en móvil se convierten en tarjetas (usar data-label en cada <td>) */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
.table tr.clickable { cursor: pointer; }
.table .cell-main b { display: block; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* Pestañas y filtros */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 11px 14px; color: var(--muted); font-weight: 650; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: .84rem; white-space: nowrap; }
.chip:hover { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented a, .segmented button { padding: 6px 12px; border-radius: 8px; color: var(--text-2); font-weight: 650; font-size: .85rem; border: 0; background: none; cursor: pointer; font-family: inherit; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Estado vacío */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty i { font-size: 34px; margin-bottom: 10px; color: var(--border-strong); display: block; }
.empty h3 { color: var(--text); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; background: rgba(15, 23, 42, .55); backdrop-filter: blur(3px); }
.modal.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; animation: pop .16s ease; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* Copiar / código */
.copy-box { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 6px 6px 6px 12px; }
.copy-box code, .copy-box input { flex: 1; min-width: 0; background: none; border: 0; padding: 0; min-height: 0; font-family: var(--font-mono); font-size: .84rem; box-shadow: none; }

/* Notificación flotante */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--text); color: var(--surface); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .9rem; font-weight: 600; animation: pop .16s ease; }
[data-theme="retro"] .toast { background: var(--primary); color: #031006; }

/* Detalles desplegables */
details.card > summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; transition: transform var(--transition); }
details.card[open] > summary::before { transform: rotate(90deg); }
details.card[open] > summary { margin-bottom: 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--danger-50); }

/* ---------- 6b. Chat de tickets (cliente y soporte) ---------- */
.chat-layout { display: grid; grid-template-columns: 350px minmax(0, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; height: calc(100vh - var(--header-h) - 150px); min-height: 540px; box-shadow: var(--shadow-sm); }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-list .list-head { padding: 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.chat-list .items { overflow-y: auto; flex: 1; }
.ticket-item { display: block; width: 100%; text-align: left; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--border); background: none; cursor: pointer; color: var(--text); font: inherit; border-left: 3px solid transparent; }
.ticket-item:hover { background: var(--surface-2); }
.ticket-item.active { background: var(--primary-50); border-left-color: var(--primary); }
.ticket-item .t-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.ticket-item .t-subj { font-size: .88rem; color: var(--text-2); margin-top: 3px; }
.ticket-item .t-meta { font-size: .74rem; color: var(--muted); margin-top: 3px; display: flex; justify-content: space-between; gap: 8px; }
.ticket-item.unread .t-subj { color: var(--text); font-weight: 700; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); display: inline-block; margin-left: 6px; vertical-align: middle; }
.chat-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { padding: 12px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chat-head .titles { flex: 1; min-width: 0; }
.chat-head h3 { margin: 0; font-size: 1rem; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 20px 18px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.chat-foot { padding: 12px 14px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-foot form { display: flex; gap: 8px; align-items: flex-end; }
.chat-foot textarea { min-height: 44px; max-height: 160px; resize: none; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 30px; }
.chat-empty i { font-size: 40px; display: block; margin-bottom: 12px; color: var(--border-strong); }
.bubble { max-width: min(78%, 640px); padding: 10px 14px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--border); font-size: .93rem; line-height: 1.5; overflow-wrap: anywhere; }
.bubble.mine { margin-left: auto; border-radius: 16px 16px 4px 16px; background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.bubble.mine a { color: inherit; text-decoration: underline; }
.bubble.system { max-width: 100%; border-radius: 12px; background: var(--warning-50); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.bubble .meta { display: block; font-size: .72rem; font-weight: 700; opacity: .75; margin-bottom: 3px; }
.bubble img { display: block; max-width: 240px; max-height: 240px; border-radius: 10px; margin-top: 8px; cursor: zoom-in; }
.bubble .file { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-weight: 600; }
.chat-closed { text-align: center; color: var(--muted); font-weight: 600; padding: 6px; }
.lightbox { position: fixed; inset: 0; z-index: 150; background: rgba(0, 0, 0, .85); display: none; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.chat-back { display: none; }
@media (max-width: 860px) {
  .chat-layout { grid-template-columns: 1fr; height: calc(100dvh - var(--header-h) - 130px); min-height: 460px; }
  .chat-pane { display: none; }
  .chat-layout.chat-active .chat-list { display: none; }
  .chat-layout.chat-active .chat-pane { display: flex; }
  .chat-back { display: inline-grid; }
  body:has(.chat-layout.chat-active) .page-head,
  body:has(.chat-layout.chat-active) .app-footer { display: none; }
  .chat-layout.chat-active { height: calc(100dvh - var(--header-h) - 36px); }
  .bubble { max-width: 88%; }
}

/* ---------- 6. Pantallas de acceso (login, registro…) ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--violet) 12%, transparent), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 34px 30px; }
.auth-card.wide { max-width: 620px; }
.auth-card .brand { justify-content: center; margin-bottom: 22px; font-size: 1.25rem; }
.auth-card h1 { font-size: 1.45rem; text-align: center; margin-bottom: 6px; }
.auth-card .lead { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: .94rem; }
.auth-foot { text-align: center; margin-top: 20px; font-size: .9rem; color: var(--muted); }
.auth-status { text-align: center; }
.auth-status .big-icon { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 16px; font-size: 28px; }
.big-icon.ok { background: var(--success-50); color: var(--success); }
.big-icon.err { background: var(--danger-50); color: var(--danger); }
.big-icon.info { background: var(--info-50); color: var(--info); }
.code-input { text-align: center; font-family: var(--font-mono); font-size: 1.7rem !important; letter-spacing: .5em; padding-left: .5em !important; }

/* Requisitos de contraseña */
.pw-meter { height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.pw-meter span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .25s, background .25s; }
.reqs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 12px; margin: 10px 0 0; padding: 0; list-style: none; font-size: .8rem; color: var(--muted); }
.reqs li::before { content: "○ "; }
.reqs li.ok { color: var(--success); }
.reqs li.ok::before { content: "✓ "; }

/* ---------- 7. Responsive ---------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav a { padding: 8px 9px; }
  .nav a .lbl-long { display: none; }
}
@media (max-width: 860px) {
  .nav { display: none; }
  .menu-toggle { display: inline-grid; }
  .user-trigger .who { display: none; }
  .mobile-nav { display: none; position: fixed; inset: var(--header-h) 0 0 0; z-index: 49; background: var(--surface); padding: 12px 16px 30px; overflow-y: auto; border-top: 1px solid var(--border); }
  .mobile-nav.open { display: block; animation: pop .14s ease; }
  .mobile-nav a { display: flex; align-items: center; gap: 12px; padding: 14px 12px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: 1rem; }
  .mobile-nav a:hover, .mobile-nav a.active { background: var(--surface-2); text-decoration: none; }
  .mobile-nav a i { width: 22px; text-align: center; color: var(--muted); }
  .mobile-nav .group { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 16px 12px 6px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .app-header .inner { padding: 0 12px; gap: 8px; }
  .app-main { padding: 18px 14px 50px; }
  .grid-2, .grid-3, .grid-4, .form-row { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: var(--radius); }
  .page-head { align-items: stretch; }
  .page-head .actions, .page-head .actions .btn { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat .value { font-size: 1.35rem; }
  .auth-card { padding: 26px 18px; border-radius: 16px; }
  .reqs { grid-template-columns: 1fr 1fr; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { max-height: 92vh; border-radius: 18px 18px 0 0; }
  .toast-wrap { left: 14px; right: 14px; }

  /* Tablas → tarjetas */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 4px; margin-bottom: 10px; background: var(--surface); }
  .table.responsive td { border: 0; padding: 7px 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; flex-shrink: 0; }
  .table.responsive td[data-label=""]::before, .table.responsive td:not([data-label])::before { display: none; }
  .table.responsive td.cell-main { display: block; text-align: left; padding-top: 10px; }
  .table.responsive .actions { justify-content: flex-start; }
  .card.pad-0 .table.responsive { padding: 10px; }
  .hide-sm { display: none !important; }
  .section-title { flex-wrap: wrap; row-gap: 2px; }
  .section-title small { flex-basis: 100%; padding-left: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media print { .app-header, .app-footer, .mobile-nav, .btn, .back-link { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

/* =====================================================================
 * CRM de desarrollo: clientes, proyectos y línea de tiempo
 * ===================================================================== */
:root { --vis-cliente: var(--primary); --vis-equipo: var(--warning); --vis-privado: #db2777; }
.text-danger { color: var(--danger) !important; } .text-warning { color: var(--warning); }
.mt-s { margin-top: 10px; }
.grow { flex: 1; min-width: 0; }
.nowrap-row { flex-wrap: nowrap; }
.clamp-1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.avatar-xs { width: 24px; height: 24px; font-size: .62rem; }
.muted-avatar { background: var(--surface-3); color: var(--muted); }

/* Diseño principal + columna lateral */
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; align-items: start; }
.layout-side > aside .card + .card { margin-top: 0; }
.layout-side.wide-side { grid-template-columns: minmax(0, 1fr) 360px; }

/* Datos en pares */
.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* Contactos */
.contact { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.contact:first-of-type { border-top: 0; padding-top: 0; }
.add-box { margin-top: 12px; border-top: 1px dashed var(--border-strong); padding-top: 12px; }
.add-box summary { cursor: pointer; font-weight: 700; color: var(--primary); list-style: none; }
.add-box summary::-webkit-details-marker { display: none; }
.note-private { border-color: color-mix(in srgb, var(--vis-privado) 35%, var(--border)); background: color-mix(in srgb, var(--vis-privado) 4%, var(--surface)); }
.note-private h3 { color: var(--vis-privado); }

/* Tarjetas de proyecto */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.project-list { display: grid; gap: 12px; }
.project-card { display: flex; flex-direction: column; gap: 10px; color: var(--text); transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); margin-top: 0 !important; }
.project-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.project-card h3 { margin: 0; font-size: 1.05rem; line-height: 1.3; }
.project-card .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .82rem; color: var(--text-2); }
.project-card .foot { margin-top: auto; flex-wrap: nowrap; }
.project-card.has-pending { border-color: color-mix(in srgb, var(--warning) 55%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 14%, transparent); }
.project-card .people { display: inline-flex; }
.project-card .people .tester { margin-left: -6px; }
.project-card .people .avatar { border: 2px solid var(--surface); }
.envs { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.env-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; }
.env-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.env-chip.env-produccion { background: var(--success-50); color: var(--success); }
.env-chip.env-demo { background: var(--violet-50); color: var(--violet); }

/* Barra de progreso */
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); border-radius: inherit; transition: width .4s ease; }
.progress.lg { height: 8px; margin-bottom: 18px; }

/* Etapas (stepper) */
.stages-card { margin-bottom: 22px; }
.stepper { list-style: none; margin: 0; padding: 0 0 2px; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; scroll-snap-type: x proximity; }
.stepper::-webkit-scrollbar { display: none; }
.step { scroll-snap-align: center; }
.step { position: relative; flex: 1 0 104px; }
.step::after { content: ""; position: absolute; top: 15px; left: calc(50% + 18px); right: calc(-50% + 18px); height: 2px; background: var(--border); }
.step:last-child::after { display: none; }
.step.st-hecho::after, .step.st-omitido::after { background: var(--success); }
.step-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; background: none; border: 0; padding: 0 2px; font: inherit; color: var(--text-2); cursor: default; text-align: center; }
.step .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 800; background: var(--surface); border: 2px solid var(--border-strong); color: var(--muted); position: relative; z-index: 1; transition: box-shadow var(--transition); }
.step .lbl { font-size: .76rem; font-weight: 650; line-height: 1.25; }
.step .lbl small { display: block; font-weight: 500; color: var(--muted); font-size: .7rem; }
.step.st-hecho .dot { background: var(--success); border-color: var(--success); color: #fff; }
.step.st-en_curso .dot { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }
.step.st-en_curso .dot i { animation: spin 2.4s linear infinite; }
.step.st-en_curso .lbl { color: var(--primary); font-weight: 800; }
.step.st-omitido .dot { background: var(--surface-3); border-style: dashed; }
.step.st-omitido .lbl { text-decoration: line-through; color: var(--muted); }
.step-btn { cursor: pointer; border-radius: 10px; padding: 4px 2px 6px; transition: background var(--transition); }
.step-btn:hover { background: var(--surface-2); }
.step-btn:hover .dot { box-shadow: var(--ring); }
.step-count { position: absolute; top: -6px; right: -8px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--violet); color: #fff; font-size: .64rem; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface); }
.stage-status { display: flex; width: 100%; }
.stage-status form { flex: 1; }
.stage-status button { width: 100%; }
.stage-status button[disabled] { cursor: default; }
.stage-items { list-style: none; margin: 0 0 12px; padding: 0; }
.stage-items li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-left: 3px solid var(--vis-cliente); background: var(--surface-2); border-radius: 0 8px 8px 0; margin-bottom: 6px; flex-wrap: wrap; font-size: .9rem; }
.stage-items li.vis-equipo { border-left-color: var(--vis-equipo); }
.stage-items li.vis-privado { border-left-color: var(--vis-privado); }
.stage-items li a { font-weight: 650; color: var(--text); flex: 1; min-width: 40%; }
.stage-add { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.stage-add .field { margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Visibilidad */
.vis-tag { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.vis-tag.vis-cliente { color: var(--vis-cliente); background: color-mix(in srgb, var(--vis-cliente) 10%, transparent); }
.vis-tag.vis-equipo  { color: var(--vis-equipo);  background: color-mix(in srgb, var(--vis-equipo) 12%, transparent); }
.vis-tag.vis-privado { color: var(--vis-privado); background: color-mix(in srgb, var(--vis-privado) 10%, transparent); }
.vis-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.vis-opt { position: relative; cursor: pointer; }
.vis-opt input { position: absolute; opacity: 0; }
.vis-opt span { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; font-size: .9rem; transition: var(--transition); }
.vis-opt small { color: var(--muted); font-size: .76rem; }
.vis-opt input:focus-visible + span { box-shadow: var(--ring); }
.vis-opt.vis-cliente input:checked + span { border-color: var(--vis-cliente); background: color-mix(in srgb, var(--vis-cliente) 7%, transparent); }
.vis-opt.vis-equipo input:checked + span  { border-color: var(--vis-equipo);  background: color-mix(in srgb, var(--vis-equipo) 8%, transparent); }
.vis-opt.vis-privado input:checked + span { border-color: var(--vis-privado); background: color-mix(in srgb, var(--vis-privado) 7%, transparent); }
.client-only { display: grid; gap: 10px; padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--vis-cliente) 6%, transparent); }
.client-only[hidden], .client-only [hidden] { display: none; }
.seg-opt { cursor: pointer; }
.seg-opt span { display: block; padding: 6px 14px; border-radius: 8px; font-weight: 650; font-size: .88rem; color: var(--text-2); }
.seg-opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* Línea de tiempo */
.composer { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; padding: 14px 16px; }
.composer textarea { min-height: 46px; resize: vertical; }
.file-btn { cursor: pointer; max-width: 60%; overflow: hidden; }
.file-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-left: 50px; margin-bottom: 14px; }
.tl-item[hidden] { display: none; }
.tl-dot { position: absolute; left: 0; top: 10px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-2); font-size: .85rem; z-index: 1; }
.tl-body { padding: 14px 16px; border-left: 3px solid var(--vis-cliente); margin: 0 !important; }
.tl-item.vis-equipo .tl-body { border-left-color: var(--vis-equipo); }
.tl-item.vis-privado .tl-body { border-left-color: var(--vis-privado); background: color-mix(in srgb, var(--vis-privado) 3%, var(--surface)); }
.tl-item.vis-privado .tl-dot { border-color: var(--vis-privado); color: var(--vis-privado); }
.tl-item.vis-equipo .tl-dot { border-color: var(--vis-equipo); color: var(--vis-equipo); }
.tl-item.kind-hito .tl-dot { background: var(--success-50); border-color: var(--success); color: var(--success); }
.tl-item.kind-hito .tl-body { padding: 10px 16px; }
.tl-item.kind-comentario .tl-dot { background: var(--primary-50); border-color: var(--primary); color: var(--primary); }
.tl-item.kind-propuesta .tl-dot, .tl-item.kind-presupuesto .tl-dot, .tl-item.kind-orden_trabajo .tl-dot { background: var(--warning-50); }
.tl-ticket .tl-body { border-left-color: var(--border-strong); background: var(--surface-2); }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .8rem; }
.tl-kind { font-weight: 800; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; font-size: .72rem; }
.tl-date { margin-left: auto; color: var(--muted); }
.tl-menu .dropdown { min-width: 170px; }
.tl-menu .icon-btn { width: 28px; height: 28px; }
.tl-title { display: block; margin: 6px 0 0; font-size: 1rem; font-weight: 700; color: var(--text); }
a.tl-title:hover { color: var(--primary); }
.tl-text { margin-top: 6px; font-size: .93rem; line-height: 1.55; color: var(--text); overflow-wrap: anywhere; }
.tl-author { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .78rem; color: var(--muted); }
.tl-item.flash .tl-body { animation: flash 2.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 30%, transparent); } 100% { box-shadow: none; } }
.files { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.files li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font-size: .85rem; max-width: 100%; }
.files li a { display: inline-flex; gap: 6px; align-items: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .icon-btn { width: 22px; height: 22px; }
.approval { margin-top: 12px; padding: 12px 14px; border-radius: 10px; font-size: .9rem; border: 1px solid; }
.approval.ap-pendiente { background: var(--warning-50); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.approval.ap-aceptado  { background: var(--success-50); border-color: color-mix(in srgb, var(--success) 35%, transparent); color: var(--success); }
.approval.ap-rechazado { background: var(--danger-50); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.approval .tl-text { color: var(--text); }
.approval textarea { background: var(--surface); }

/* Entornos y listas cortas */
.env { padding: 12px 0; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.env:first-of-type { border-top: 0; padding-top: 0; }
.env-name { font-size: .95rem; }
.env-url { display: block; color: var(--text-2); }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); color: var(--text); font-size: .9rem; }
.mini-row:first-of-type { border-top: 0; }
.mini-row:hover { text-decoration: none; color: var(--primary); }
.stage-edit { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; counter-reset: st; }
.stage-edit li { display: flex; gap: 6px; align-items: center; counter-increment: st; }
.stage-edit li::before { content: counter(st); width: 22px; color: var(--muted); font-weight: 700; font-size: .8rem; text-align: right; }
.stage-edit input[type=text], .stage-edit input:not([type]) { flex: 1; }

/* Actividad reciente (panel) */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); align-items: flex-start; }
.activity li:first-child { border-top: 0; padding-top: 0; }
.activity .ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex-shrink: 0; font-size: .85rem; }
.activity a { color: var(--text); font-weight: 650; }
.activity .xs { display: block; }

[data-theme="retro"] { --vis-privado: #ff6ad5; }

/* Menú superior: con muchas secciones se compacta antes de pasar al menú móvil */
@media (max-width: 1600px) { .user-trigger .who { display: none; } }
@media (max-width: 1480px) {
  .nav a { padding: 9px 11px; }
  .nav a .nav-lbl { display: none; }
  .nav a.active .nav-lbl { display: inline; }
}
@media (max-width: 1024px) {
  .layout-side, .layout-side.wide-side { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tl-item { padding-left: 0; }
  .timeline::before, .tl-dot { display: none; }
  .composer > .avatar { display: none; }
  .step { flex-basis: 84px; }
  .clamp-1 { max-width: 30ch; }
}
.modal-body .label { display: block; margin-bottom: 8px; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 14px 16px; }
.filters .field { margin: 0; }
.activity .act-day { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 0 4px; border-top: 0; }
@media (max-width: 640px) { .filters { grid-template-columns: 1fr 1fr; } }
.big-num { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.steps { padding-left: 20px; display: grid; gap: 8px; margin: 0 0 10px; }

/* Monitor de servicios */
.mon-overview { margin-bottom: 18px; }
.mon-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.mon-kpis { display: flex; gap: 28px; flex-wrap: wrap; }
.mon-kpis > div { display: flex; align-items: baseline; gap: 6px; }
.mon-big { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--success); }
.mon-big.muted { color: var(--muted); }
#healthChart { width: 100%; height: 120px; display: block; margin-bottom: 8px; }
.mon-group { margin-bottom: 14px; overflow: hidden; }
.mon-gtitle { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0; padding: 12px 18px 8px; }
.mon-list { list-style: none; margin: 0; padding: 0; }
.mon-list li { display: grid; grid-template-columns: 12px minmax(0, 1fr) minmax(120px, 240px) 52px 86px; align-items: center; gap: 14px; padding: 10px 18px; border-top: 1px solid var(--border); }
.mon-list li[hidden] { display: none; }
.mon-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.mon-list li[data-state="ok"] .mon-dot { background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent); }
.mon-list li[data-state="warn"] .mon-dot { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 22%, transparent); }
.mon-list li[data-state="bad"] .mon-dot { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 10%, transparent); } }
.mon-name { min-width: 0; display: flex; flex-direction: column; }
.mon-name a { font-weight: 650; color: var(--text); }
.mon-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon-spark { width: 100%; height: 30px; }
.mon-up { text-align: right; font-variant-numeric: tabular-nums; }
.mon-state { font-size: .78rem; font-weight: 700; text-align: right; color: var(--muted); }
li[data-state="ok"] .mon-state { color: var(--success); } li[data-state="warn"] .mon-state { color: var(--warning); } li[data-state="bad"] .mon-state { color: var(--danger); }
.mon-links .row { gap: 8px; }
@media (max-width: 720px) {
  .mon-list li { grid-template-columns: 12px minmax(0, 1fr) 76px; row-gap: 6px; }
  .mon-spark { grid-column: 2 / 4; grid-row: 2; }
  .mon-up { display: none; }
}
@media (max-width: 720px) { .mon-state { grid-column: 3; grid-row: 1; } }

/* Diagnóstico */
.diag-form { margin-bottom: 18px; padding: 14px 16px; }
.diag-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.diag-kpi { display: flex; flex-direction: column; gap: 4px; border-left: 4px solid var(--muted); margin: 0 !important; }
.diag-kpi.st-ok { border-left-color: var(--success); } .diag-kpi.st-warn { border-left-color: var(--warning); } .diag-kpi.st-bad { border-left-color: var(--danger); }
.diag-list { list-style: none; margin: 0; padding: 0; }
.diag-list li { display: grid; grid-template-columns: 18px 150px minmax(0, 1fr); gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); align-items: start; font-size: .9rem; }
.diag-list li:first-child { border-top: 0; }
.diag-list li > i { margin-top: 3px; }
.diag-list .dl-k { color: var(--text-2); font-weight: 600; }
.diag-list .dl-v { overflow-wrap: anywhere; }
.diag-list.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); column-gap: 24px; }
.diag-list.cols li:nth-child(2) { border-top: 0; }
.text-success { color: var(--success); }
@media (max-width: 640px) { .diag-list li { grid-template-columns: 18px 1fr; } .diag-list .dl-v { grid-column: 2; } }
.mon-big.text-warning { color: var(--warning); } .mon-big.text-danger { color: var(--danger); }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* Ficha de cliente: árbol de sitios y proyectos */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree > li { padding: 10px 0; border-top: 1px solid var(--border); }
.tree > li:first-child { border-top: 0; padding-top: 0; }
.tree ul { margin: 6px 0 0 8px; padding-left: 16px; border-left: 2px solid var(--border); }
.tree ul li { padding: 4px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tree a { color: var(--text); }
.site-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.site-row { margin: 0 !important; display: flex; flex-direction: column; }
.site-projects { margin-top: 12px; padding-top: 8px; border-top: 1px dashed var(--border); flex: 1; }
.pad-row { padding: 12px 18px; }
.tabs .pill-count { background: var(--surface-3); color: var(--text-2); }
.scope-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.scope-list > .hint { grid-column: 1 / -1; margin: 0; }
.scope-client { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.scope-projects { display: grid; gap: 4px; margin: 6px 0 0 24px; }
.scope-list[hidden] { display: none; }
.imp-bar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 8px 16px; background: #7c3aed; color: #fff; font-size: .88rem; }
.imp-bar .btn { background: #fff; color: #5b21b6; border-color: #fff; }
.site-badges:empty { display: none; }

/* Documentos del proyecto (vista cliente): lista sin línea de tiempo */
.timeline.doc-list::before { display: none; }
.timeline.doc-list .tl-item { padding-left: 0; }
.timeline.doc-list .tl-dot { display: none; }

/* Campanita de notificaciones */
.notif-btn { position: relative; }
.notif-count { position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; line-height: 17px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.notif-count[hidden] { display: none; }
.notif.has-new .notif-btn i { animation: notif-ring 1.2s ease 1; transform-origin: 50% 0; }
@keyframes notif-ring { 0%,100% { transform: none; } 20% { transform: rotate(14deg); } 40% { transform: rotate(-12deg); } 60% { transform: rotate(8deg); } 80% { transform: rotate(-4deg); } }
.notif-dd { width: 340px; max-width: calc(100vw - 24px); }
.notif-list { max-height: 360px; overflow-y: auto; scrollbar-width: thin; }
.notif-empty { padding: 10px 12px; margin: 0; }
.dropdown a.notif-item { align-items: flex-start; }
.notif-item .grow { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-item b { display: block; font-size: .9rem; }
.notif-item .unread-dot { margin: 7px 0 0; flex: none; }
.chat-head [hidden] { display: none !important; }
.chip-deleted { color: var(--danger); }

/* Prospectos */
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 60ch; }
.prospect-filters { gap: 8px; flex-wrap: wrap; }
.prospect-filters select { width: auto; min-height: 38px; }
.prospect-table tr.is-closed td { opacity: .6; }
.prospect-status select { min-height: 32px; padding: 3px 28px 3px 10px; font-size: .82rem; font-weight: 600; border-radius: 999px; width: auto; }
.prospect-status .st-contactado { color: var(--info); border-color: var(--info); }
.prospect-status .st-interesado { color: var(--violet); border-color: var(--violet); }
.prospect-status .st-propuesta  { color: var(--warning); border-color: var(--warning); }
.prospect-status .st-ganado     { color: var(--success); border-color: var(--success); background: var(--success-50); }
.prospect-status .st-descartado { color: var(--danger); border-color: var(--danger); }
.prospect-issues { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.prospect-issues li::marker { color: var(--warning); }

/* Inicio: accesos rápidos */
.ta-right { text-align: right; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.quick-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius, 14px); background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s, transform .15s; }
.quick-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: 0 6px 18px rgba(15, 23, 42, .06); transform: translateY(-1px); }
.quick-card .grow { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.quick-card b { font-size: 1rem; }
.qc-icon { flex: none; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.1rem; }
.qc-violet { background: var(--violet-50); color: var(--violet); }
.qc-blue   { background: var(--primary-50, var(--info-50)); color: var(--primary); }

/* Prospectos: contacto */
.contact-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn-wa:hover { background: #1ebe5b; border-color: #1ebe5b; color: #fff; }
.issue-picks { display: grid; gap: 6px; max-height: 190px; overflow-y: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2, var(--bg)); }
.issue-picks .check { font-size: .86rem; align-items: flex-start; }
.contact-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.contact-log li { display: flex; gap: 12px; align-items: flex-start; }
.contact-log li.is-failed { opacity: .75; }
.cl-icon { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--muted); }
.cl-icon.ch-email { background: var(--info-50); color: var(--info); }
.cl-icon.ch-whatsapp { background: #e7f9ee; color: #1ebe5b; }
.cl-icon.ch-visita { background: var(--violet-50); color: var(--violet); }
.cl-icon.ch-llamada { background: var(--warning-50); color: var(--warning); }
.contact-log .grow { min-width: 0; }
.cl-body summary { cursor: pointer; color: var(--primary); }
.cl-body > div { margin-top: 6px; padding: 10px 12px; background: var(--bg); border-radius: 10px; white-space: normal; }
.mt-xs { margin-top: 4px; }
/* Modales largos: el pie con los botones siempre a la vista */
.modal-box[data-compose], #tplModal .modal-box, #entryModal .modal-box, #newTicketModal .modal-box { display: flex; flex-direction: column; overflow: hidden; }
.modal-box[data-compose] .modal-body, #tplModal .modal-body, #entryModal .modal-body, #newTicketModal .modal-body { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-box[data-compose] .modal-foot, #tplModal .modal-foot, #entryModal .modal-foot, #newTicketModal .modal-foot { flex: none; flex-wrap: wrap; }

/* Campañas */
.camp-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1100px) { .camp-layout { grid-template-columns: 1fr; } }
.camp-frame-wrap { padding: 14px; background: #eef2f7; border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; justify-content: center; margin-top: 12px; }
#campFrame { width: 600px; max-width: 100%; height: 760px; border: 0; background: #eef2f7; transition: width .2s; }
.camp-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.camp-rcpts { max-height: 460px; overflow-y: auto; }

/* Contable */
.fin-big { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin: 2px 0 4px; }
.fin-table tr.is-void td, .mini-row.is-void, tr.is-void td { opacity: .5; }
tr.is-void td:not(:last-child) { text-decoration: line-through; text-decoration-color: rgba(100,116,139,.5); }
.fin-kind { display: inline-block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 1px 7px; border-radius: 999px; margin-right: 4px; vertical-align: 1px; }
.fk-cargo { background: var(--warning-50); color: var(--warning); }
.fk-pago { background: var(--success-50); color: var(--success); }
.fk-credito { background: var(--info-50); color: var(--info); }
.stat.stat-danger .value { color: var(--danger); }
.text-success { color: var(--success); }
/* Los títulos de columna siguen la alineación de sus datos */
.table th.ta-right, .table td.ta-right { text-align: right; }
.table th.ta-center, .table td.ta-center { text-align: center; }
.fund-tag { color: var(--violet); font-weight: 600; }
.fund-card { border-left: 4px solid var(--violet); }

/* Facturación ARCA */
.arca-test.ok { border-left: 4px solid var(--success); } .arca-test.ok h3 { color: var(--success); }
.arca-test.bad { border-left: 4px solid var(--danger); } .arca-test.bad h3 { color: var(--danger); }
.arca-steps ol { padding-left: 20px; margin: 0; display: grid; gap: 8px; }
.arca-mode { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 14px; line-height: 1.35; }
.arca-mode > i { font-size: 18px; margin-top: 2px; }
.arca-mode-test { background: var(--warning-50); border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent); color: var(--warning); }
.arca-mode-real { background: var(--success-50); border: 1px solid color-mix(in srgb, var(--success) 45%, transparent); color: var(--success); }
.arca-form .btn.btn-warning { background: #d97706; border-color: #d97706; color: #fff; }
.arca-mode[hidden] { display: none; }
/* Selector compacto de visibilidad (nota rápida del proyecto) */
.vis-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; gap: 2px; background: var(--surface); }
.vis-seg label { cursor: pointer; position: relative; }
.vis-seg input { position: absolute; opacity: 0; pointer-events: none; }
.vis-seg span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--muted); transition: var(--transition); }
.vis-seg input:focus-visible + span { box-shadow: var(--ring); }
.vis-seg .vis-cliente input:checked + span { color: var(--vis-cliente); background: color-mix(in srgb, var(--vis-cliente) 12%, transparent); }
.vis-seg .vis-equipo input:checked + span  { color: var(--vis-equipo);  background: color-mix(in srgb, var(--vis-equipo) 12%, transparent); }
.vis-seg .vis-privado input:checked + span { color: var(--vis-privado); background: color-mix(in srgb, var(--vis-privado) 12%, transparent); }
.composer:has(.vis-privado input:checked) textarea { border-color: color-mix(in srgb, var(--vis-privado) 40%, var(--border)); }
.composer:has(.vis-cliente input:checked) textarea { border-color: color-mix(in srgb, var(--vis-cliente) 45%, var(--border)); }
/* Insignia de usuario interno (equipo o prueba) */
.badge-internal { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); border: 1px dashed color-mix(in srgb, var(--warning) 55%, transparent); vertical-align: middle; font-weight: 700; }
/* Modal «Nueva entrada» compacto */
.entry-top { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); gap: 0 14px; align-items: start; }
@media (max-width: 720px) { .entry-top { grid-template-columns: 1fr 1fr; } .entry-top > .field:first-child { grid-column: 1 / -1; } }
.vis-seg-lg { display: flex; width: max-content; max-width: 100%; }
.vis-seg-lg span { padding: 9px 13px; font-size: .88rem; }
.vis-desc { display: block; margin-top: 4px; }
.entry-client { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 10px 14px; margin: -4px 0 14px; border-radius: 10px; background: color-mix(in srgb, var(--vis-cliente) 7%, transparent); border: 1px solid color-mix(in srgb, var(--vis-cliente) 25%, transparent); }
.entry-client[hidden] { display: none; }
.entry-client .approval-opt[hidden] { display: none; }
.page-home { color: var(--primary); font-size: .85em; margin-right: 2px; }
/* Ayuda memoria */
.help-tip { color: var(--muted); font-size: .85em; cursor: help; margin-left: 2px; }
.help-tip:hover, .help-tip:focus { color: var(--primary); outline: none; }
.memo-tip { font-size: .8rem; color: var(--muted); margin: -6px 0 14px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); }
.memo-tip > .fa-lightbulb { color: var(--warning); margin-right: 2px; }
#ntForm [data-nt-client-only][hidden] { display: none; }
