/* ============================================================
   CRÉDITOS CM — Rediseño visual
   Estilo: Financial dark luxury · Syne + Manrope + JetBrains Mono
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@500;600;700;800&family=Manrope:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #080c14;
  --bg2:         #0d1320;
  --bg3:         #141c2e;
  --bg4:         #1a2238;
  --border:      #1e2d47;
  --border2:     #2a3f60;
  --text:        #e2e8f5;
  --text2:       #7a8fad;
  --text3:       #3d5070;
  --accent:      #3b82f6;
  --accent2:     #2563eb;
  --accent-glow: rgba(59,130,246,.18);
  --green:       #22d3a4;
  --green-bg:    rgba(34,211,164,.1);
  --red:         #f66;
  --red-bg:      rgba(255,102,102,.1);
  --amber:       #fbbf24;
  --amber-bg:    rgba(251,191,36,.1);
  --purple:      #a78bfa;
  --purple-bg:   rgba(167,139,250,.1);
  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 2px 8px rgba(0,0,0,.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.6);
  --font:        'Manrope', sans-serif;
  --font-display:'Syne', sans-serif;
  --mono:        'JetBrains Mono', monospace;
  --sidebar-w:   248px;
  --topbar-h:    58px;
  --sidebar-gradient: linear-gradient(180deg, #0d1320 0%, #080c18 100%);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; transition: color .15s; }
a:hover { color: #60a5fa; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Layout ────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  grid-row: 1 / 3;
  background: var(--sidebar-gradient);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Scrollbar del sidebar */
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 11px;
}

.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 16px; font-weight: 800; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(59,130,246,.35);
}

.logo-text {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}
.logo-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 16px 12px; }

.nav-section { margin-bottom: 24px; }
.nav-section-label {
  font-size: 9.5px; font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 0 10px 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  cursor: pointer;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,.04);
  color: var(--text);
}
.nav-item.active {
  background: rgba(59,130,246,.12);
  color: #93c5fd;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: linear-gradient(180deg, #3b82f6, #6366f1);
  border-radius: 0 2px 2px 0;
}
.nav-item .icon { width: 17px; height: 17px; opacity: .55; flex-shrink: 0; transition: opacity .15s; }
.nav-item:hover .icon { opacity: .85; }
.nav-item.active .icon { opacity: 1; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  transition: background .15s;
  cursor: pointer;
}
.user-chip:hover { background: rgba(255,255,255,.04); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59,130,246,.3);
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-role { font-size: 11px; color: var(--text3); }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  background: rgba(8,12,20,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 600;
  letter-spacing: -.01em;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ── Main ──────────────────────────────────────────────────── */
.main { padding: 28px; overflow: visible; min-width: 0; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  overflow: visible;
  transition: border-color .2s;
}
.card:hover { border-color: var(--border2); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.card-title {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 600;
  letter-spacing: -.01em;
}

/* ── Stat cards ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .15s;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent);
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-1px); }

.stat-label {
  font-size: 11px; font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 24px; font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
}
.stat-sub { font-size: 12px; color: var(--text2); margin-top: 6px; }

.stat-green { border-left: 2px solid var(--green); }
.stat-red   { border-left: 2px solid var(--red); }
.stat-amber { border-left: 2px solid var(--amber); }
.stat-blue  { border-left: 2px solid var(--accent); }

/* Glow sutil en stat cards coloreadas */

/* ── Tablas ────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody td { padding: 12px 14px; color: var(--text); vertical-align: middle; }
td.mono  { font-family: var(--mono); font-size: 12.5px; }
td.right { text-align: right; }
td.muted { color: var(--text2); }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

/* ── Score bar ─────────────────────────────────────────────── */
.score-wrap { display: flex; align-items: center; gap: 10px; }
.score-bar  { flex: 1; height: 4px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #3b82f6, #22d3a4); transition: width .5s cubic-bezier(.4,0,.2,1); }
.score-num  { font-family: var(--mono); font-size: 12.5px; min-width: 36px; text-align: right; }

/* ── Formularios ───────────────────────────────────────────── */
.form-grid   { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-full   { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text2); letter-spacing: .01em; }

input[type="text"], input[type="number"], input[type="email"],
input[type="date"], input[type="password"], input[type="tel"],
select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
input::placeholder, textarea::placeholder { color: var(--text3); }
select option { background: var(--bg3); }
textarea { resize: vertical; min-height: 80px; }
input[readonly], select[disabled] { opacity: .5; cursor: not-allowed; }

.field-hint  { font-size: 11.5px; color: var(--text3); }
.field-error { font-size: 11.5px; color: var(--red); }

/* ── Botones ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; border: none; outline: none;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: .01em;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(59,130,246,.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #60a5fa 0%, #6366f1 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(59,130,246,.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg4);
  border-color: var(--border2);
}

.btn-danger  { background: var(--red-bg); color: var(--red); border: 1px solid rgba(255,102,102,.2); }
.btn-danger:hover { background: rgba(255,102,102,.18); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,211,164,.2); }
.btn-success:hover { background: rgba(34,211,164,.18); }
.btn-sm      { padding: 6px 12px; font-size: 12.5px; }
.btn-icon    { padding: 7px; }

/* ── Alertas flash ─────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 9px; font-size: 13.5px;
  margin-bottom: 18px; border: 1px solid;
  font-weight: 500;
}
.alert-success { background: var(--green-bg); color: var(--green); border-color: rgba(34,211,164,.2); }
.alert-error   { background: var(--red-bg);   color: var(--red);   border-color: rgba(255,102,102,.2); }
.alert-info    { background: rgba(59,130,246,.08); color: #93c5fd; border-color: rgba(59,130,246,.2); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border-color: rgba(251,191,36,.2); }

/* ── Scoring panel ─────────────────────────────────────────── */
.scoring-panel {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.scoring-components { display: grid; gap: 10px; margin-top: 12px; }
.sc-row   { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.sc-label { width: 200px; color: var(--text2); flex-shrink: 0; }
.sc-bar   { flex: 1; height: 3px; background: var(--bg); border-radius: 2px; overflow: hidden; }
.sc-fill  { height: 100%; border-radius: 2px; background: linear-gradient(90deg, #3b82f6, #6366f1); }
.sc-val   { width: 40px; text-align: right; font-family: var(--mono); font-size: 12px; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  overflow-x: auto;
}
.tabs::-webkit-scrollbar { height: 0; }

.tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  color: var(--text3); background: transparent;
  border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: color .15s, border-color .15s;
  margin-bottom: -1px;
  white-space: nowrap;
  letter-spacing: .01em;
}
.tab-btn:hover  { color: var(--text2); }
.tab-btn.active { color: #93c5fd; border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Calc box ──────────────────────────────────────────────── */
.calc-box {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.calc-row  { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13.5px; }
.calc-row + .calc-row { border-top: 1px solid var(--border); }
.calc-key  { color: var(--text2); }
.calc-val  { font-family: var(--mono); font-weight: 500; }
.calc-total .calc-key { color: var(--text); font-weight: 600; }
.calc-total .calc-val { color: #60a5fa; font-size: 18px; font-family: var(--font-display); }

/* ── Paginación ────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: flex-end; margin-top: 16px; }
.page-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; font-size: 12.5px; font-weight: 600;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); cursor: pointer; transition: all .12s;
}
.page-btn:hover   { background: var(--bg4); border-color: var(--border2); color: var(--text); }
.page-btn.active  { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 8px rgba(59,130,246,.3); }
.page-btn.disabled{ opacity: .3; pointer-events: none; }

/* ── Buscador ──────────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 13px;
  transition: border-color .2s, box-shadow .2s;
}
.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.search-bar input {
  background: transparent; border: none; outline: none;
  color: var(--text); font-size: 13.5px; flex: 1; padding: 0;
}
.search-icon { color: var(--text3); flex-shrink: 0; }

/* ── Anticipo box ──────────────────────────────────────────── */
.anticipo-box {
  border: 1px solid rgba(59,130,246,.3);
  background: rgba(59,130,246,.05);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 12px; margin-top: 16px;
}
.anticipo-box .ab-label { font-size: 10.5px; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 4px; font-weight: 600; }
.anticipo-box .ab-val   { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.anticipo-box .ab-val.green  { color: var(--green); }
.anticipo-box .ab-val.amber  { color: var(--amber); }
.anticipo-box .ab-val.accent { color: #60a5fa; }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state { text-align: center; padding: 52px 24px; color: var(--text3); }
.empty-state svg { margin: 0 auto 16px; opacity: .25; }
.empty-state p   { font-size: 14.5px; }

/* ── Login ─────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 40%, rgba(59,130,246,.08) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(99,102,241,.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(34,211,164,.04) 0%, transparent 60%);
}
.login-box {
  width: 100%; max-width: 375px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 18px; padding: 38px 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 30px; }
.login-logo .logo-mark {
  width: 50px; height: 50px; border-radius: 14px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 22px; color: #fff; font-weight: 800;
  box-shadow: 0 6px 20px rgba(59,130,246,.35);
}
.login-logo h1 { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.login-logo p  { font-size: 13px; color: var(--text3); }

/* ── Utilidades ────────────────────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-16        { margin-bottom: 16px; }
.mb-24        { margin-bottom: 24px; }
.text-muted   { color: var(--text2); }
.text-small   { font-size: 12.5px; }
.text-mono    { font-family: var(--mono); }
.text-right   { text-align: right; }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-amber   { color: var(--amber); }
.text-accent  { color: #60a5fa; }
.w-full       { width: 100%; }
.divider      { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .anticipo-box { grid-template-columns: 1fr; }
  .form-grid-3 { grid-template-columns: 1fr; }
}

/* ── Animaciones ───────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.main > * { animation: fadeUp .22s cubic-bezier(.4,0,.2,1) forwards; }
.main > *:nth-child(2) { animation-delay: .04s; }
.main > *:nth-child(3) { animation-delay: .08s; }
.main > *:nth-child(4) { animation-delay: .12s; }

.fade-in { animation: fadeIn .2s ease forwards; }

/* ── Z-index fixes ─────────────────────────────────────────── */
.table-wrapper { position: relative; z-index: 0; }
#q-dropdown, #q-clientes-drop { z-index: 99999 !important; }
.search-bar { position: relative; z-index: 20; }
