/* ==========================================================================
   Prime Gestión — Sistema de diseño
   Tema oscuro, acento configurable (--accent), scrollbars finas y movimiento suave.
   ========================================================================== */

:root {
  --bg: #0E0E0E;
  --panel: #141414;
  --card: #191919;
  --card-hover: #212121;
  --input: #1C1C1C;
  --border: #2A2A2A;
  --accent: #3BBFAD;
  --accent-dark: #2A9080;
  --accent-soft: rgba(59, 191, 173, .12);
  --gold: #C8A96E;
  --text: #EEEEEE;
  --muted: #888888;
  --dim: #444444;
  --red: #E0584A;
  --green: #27AE60;
  --warn: #E67E22;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
::selection { background: var(--accent); color: #0E0E0E; }

/* ── Scrollbars modernas (cápsula fina) ───────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: #323232 transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #323232; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
  transition: background .2s;
}
*::-webkit-scrollbar-thumb:hover { background: #4E4E4E; background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-thumb:active { background: var(--accent); background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-corner { background: transparent; }

/* ── Animaciones ──────────────────────────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn  { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes spin   { to { transform: rotate(360deg); } }
.anim-in { animation: fadeUp .35s var(--ease) both; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
#app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 0 22px; height: 58px;
  background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--text); }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand img { height: 30px; width: auto; border-radius: 6px; }
.topbar .spacer { flex: 1; }
.main { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 24px 24px 60px; animation: fadeIn .3s var(--ease) both; }
.page-title { font-size: 24px; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 22px; }

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 900px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } .main { padding: 16px 14px 50px; } }
.mt { margin-top: 14px; } .mb { margin-bottom: 14px; } .mt-lg { margin-top: 26px; }
.muted { color: var(--muted); } .accent { color: var(--accent); } .gold { color: var(--gold); }
.red { color: var(--red); } .green { color: var(--green); } .warn { color: var(--warn); }
.small { font-size: 12px; } .tiny { font-size: 11px; } .bold { font-weight: 700; }
.mono { font-family: var(--mono); }
.right { text-align: right; } .center { text-align: center; }
.hidden { display: none !important; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  transition: border-color .25s var(--ease), background .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
}
.card.hover:hover { background: var(--card-hover); border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); cursor: pointer; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }

.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.kpi .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }

/* ── Botones ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 13px; line-height: 1;
  padding: 10px 16px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #0E0E0E; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s, box-shadow .2s, opacity .2s, border-color .2s;
}
.btn:hover { background: var(--accent-dark); color: #fff; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(59,191,173,.18); text-decoration: none; }
.btn:active { transform: translateY(0) scale(.98); }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }
.btn.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn.ghost:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.btn.danger { background: transparent; color: var(--red); border-color: rgba(224,88,74,.4); }
.btn.danger:hover { background: var(--red); color: #fff; border-color: var(--red); box-shadow: none; }
.btn.gold { background: var(--gold); color: #1a1408; }
.btn.gold:hover { background: #b8985e; color: #fff; box-shadow: none; }
.btn.sm { padding: 7px 12px; font-size: 12px; }
.btn.lg { padding: 13px 26px; font-size: 14px; }
.btn.icon { padding: 8px 10px; }
.btn .spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

/* ── Formularios ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label, .label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field .help { font-size: 11px; color: var(--dim); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input[type=tel], input[type=url], input[type=search], input[type=month], select, textarea, .input {
  width: 100%; font: inherit; color: var(--text); background: var(--input);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: #5a5a5a; }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' fill='none' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
input[type=color] { width: 44px; height: 34px; padding: 2px; background: var(--input); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.searchbox { position: relative; }
.searchbox input { padding-left: 34px; }
.searchbox::before { content: "🔍"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: .6; }

/* Anular el fondo azul claro del autocompletado nativo del navegador */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #161616 inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text) !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* ── Tablas ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; background: var(--panel); text-align: left; padding: 11px 14px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid #222; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--card-hover); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Badges / chips ───────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #262626; color: var(--muted); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.green  { background: rgba(39,174,96,.14); color: var(--green); }
.badge.red    { background: rgba(224,88,74,.14); color: var(--red); }
.badge.warn   { background: rgba(230,126,34,.14); color: var(--warn); }
.badge.gold   { background: rgba(200,169,110,.15); color: var(--gold); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.green { background: var(--green); } .dot.red { background: var(--red); } .dot.warn { background: var(--warn); } .dot.accent { background: var(--accent); }

/* ── Tabs de módulo + frase explicativa ───────────────────────────────────── */
.tabbar { display: flex; gap: 4px; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--border); padding: 0 22px; }
.tab {
  position: relative; padding: 14px 18px; background: none; border: 0; color: var(--muted);
  font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: color .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); }
.tab::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 2px; background: var(--accent); border-radius: 2px; transform: scaleX(0); transition: transform .3s var(--ease); }
.tab.active::after { transform: scaleX(1); }
.tab-hint {
  display: flex; gap: 10px; align-items: flex-start; margin: 18px 0 18px;
  padding: 11px 16px; border-radius: var(--radius-sm); background: var(--accent-soft);
  border: 1px solid rgba(59,191,173,.25); color: #bfe9e3; font-size: 13px;
}
.tab-hint::before { content: "💡"; }
.tab-content { animation: fadeUp .35s var(--ease) both; }

/* ── Modales ──────────────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(3px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fadeIn .2s both; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: popIn .28s var(--ease) both; }
.modal.wide { max-width: 920px; } .modal.xl { max-width: 1200px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; }
.modal-x { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; padding: 0 4px; transition: color .2s; }
.modal-x:hover { color: var(--text); }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toasts ───────────────────────────────────────────────────────────────── */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast { min-width: 240px; max-width: 420px; padding: 12px 16px; border-radius: 10px; background: #202020; border: 1px solid var(--border); border-left: 3px solid var(--accent); box-shadow: var(--shadow); animation: popIn .3s var(--ease) both; font-size: 13px; }
.toast.error { border-left-color: var(--red); } .toast.warn { border-left-color: var(--warn); } .toast.success { border-left-color: var(--green); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .3s var(--ease); }

/* ── Estados ──────────────────────────────────────────────────────────────── */
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .ico { font-size: 34px; margin-bottom: 8px; opacity: .7; }
.spinner { width: 26px; height: 26px; border: 3px solid #2a2a2a; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
.skeleton { background: linear-gradient(90deg, #1c1c1c 25%, #242424 50%, #1c1c1c 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ── Pantallas de acceso / splash ─────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 500px at 50% -10%, rgba(59,191,173,.08), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; animation: popIn .45s var(--ease) both; }
.auth-card .logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-card .logo img { height: 58px; }
.auth-card .logo h1 { font-size: 26px; }

.module-card { display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.module-card .num { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1; }
.module-card .tag { color: var(--accent); font-size: 12px; font-weight: 600; }
.module-card .desc { color: var(--muted); font-size: 13px; margin: 8px 0 14px; flex: 1; }
.tasks-strip { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 26px; }

/* ── Utilidades varias ────────────────────────────────────────────────────── */
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.pill-tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.pill-tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 600; font-size: 12px; padding: 7px 14px; border-radius: 999px; cursor: pointer; transition: all .2s; }
.pill-tabs button.active { background: var(--accent); color: #0E0E0E; }
.progress { height: 8px; background: #262626; border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s var(--ease); }
details > summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.pre { white-space: pre-wrap; word-wrap: break-word; }

/* ── Campos obligatorios y foco de diagnóstico / redirección ──────────────── */
.badge-required {
  background: rgba(235, 160, 50, 0.16);
  color: #EBA032;
  border: 1px solid rgba(235, 160, 50, 0.45);
  font-weight: 700;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  vertical-align: middle;
}

.field-required-missing {
  border-color: #EBA032 !important;
  background: rgba(235, 160, 50, 0.05) !important;
  box-shadow: 0 0 0 1px rgba(235, 160, 50, 0.3) !important;
}

.field-required-missing:focus {
  border-color: #EBA032 !important;
  box-shadow: 0 0 0 3px rgba(235, 160, 50, 0.35) !important;
}

@keyframes highlightPulseOrange {
  0% {
    box-shadow: 0 0 0 0 rgba(235, 160, 50, 0.8), 0 0 0 1px #EBA032;
    border-color: #EBA032;
    background: rgba(235, 160, 50, 0.12);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(235, 160, 50, 0.45), 0 0 25px rgba(235, 160, 50, 0.5);
    border-color: #FFAE42;
    background: rgba(235, 160, 50, 0.2);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(235, 160, 50, 0), 0 0 0 1px #EBA032;
    border-color: #EBA032;
    background: rgba(235, 160, 50, 0.12);
  }
}

.highlight-target-orange {
  animation: highlightPulseOrange 1.4s ease-in-out infinite !important;
  border-color: #EBA032 !important;
  scroll-margin: 140px;
}

.focus-callout-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #EBA032;
  color: #0E0E0E;
  font-weight: 700;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  animation: fadeUp .3s ease-out both;
  box-shadow: 0 4px 12px rgba(235, 160, 50, 0.4);
}

/* ── Pie de aplicación y contacto ────────────────────────────────────────── */
.app-footer {
  margin-top: auto;
  padding: 16px 200px 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(14, 14, 14, 0.9);
}
.app-footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.app-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color .2s;
}
.app-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Botón flotante y Chat de Soporte (abajo a la derecha) ───────────────── */
.support-fab-btn {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #2A9080 100%);
  color: #0E0E0E;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  box-shadow: 0 6px 24px rgba(59, 191, 173, 0.35);
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  user-select: none;
}
.support-fab-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 30px rgba(59, 191, 173, 0.5);
}
.support-fab-btn:active {
  transform: translateY(0);
}

.support-window {
  position: fixed;
  bottom: 74px;
  right: 22px;
  z-index: 1000;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: #161616;
  border: 1px solid #333;
  border-radius: 16px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn .25s var(--ease) both;
}

.support-head {
  padding: 12px 16px;
  background: #1C1C1C;
  border-bottom: 1px solid #282828;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.support-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.support-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}
.support-msg.bot {
  align-self: flex-start;
  background: #222222;
  color: var(--text);
  border-bottom-left-radius: 2px;
  border: 1px solid #2E2E2E;
}
.support-msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #0E0E0E;
  font-weight: 500;
  border-bottom-right-radius: 2px;
}

.support-input-wrap {
  padding: 10px 14px;
  background: #1C1C1C;
  border-top: 1px solid #282828;
  display: flex;
  align-items: center;
  gap: 8px;
}
.support-input-wrap input {
  flex: 1;
  background: #141414;
  border: 1px solid #2C2C2C;
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.support-input-wrap input:focus {
  border-color: var(--accent);
}

.support-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.support-chip {
  background: #252525;
  border: 1px solid #333;
  color: #bbb;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  display: inline-block;
}
.support-chip:hover {
  background: var(--accent);
  color: #0E0E0E;
  border-color: var(--accent);
}

.support-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}
.support-typing span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: typingBounce 1s infinite alternate;
}
.support-typing span:nth-child(2) { animation-delay: .2s; }
.support-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes typingBounce {
  0% { transform: translateY(0); opacity: 0.4; }
  100% { transform: translateY(-4px); opacity: 1; }
}

@media print {
  body { background: #fff; color: #000; }
}
