/* Quimera Contabilidad — estética Grotesk Editorial V4 (fiel a ordendeldia)
   Display = Space Grotesk · Body = Inter · Mono = JetBrains Mono
   negro + verde Quimera */

@font-face {
  font-family: 'Space Grotesk';
  src: url('fonts/spacegrotesk.woff2') format('woff2');
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('fonts/jetbrainsmono.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:        #0b0f0b;
  --bg2:       #0d130d;
  --card:      #111a11;
  --card2:     #162216;
  --line:      #223122;
  --line2:     #2c3f2c;
  --text:      #eef4ee;
  --muted:     #a9c2af;
  --faint:     #7d907f;
  --green:     #45d883;
  --green-dim: #23a862;
  --yellow:    #ffcc3f;
  --red:       #ff5c5c;
  --blue:      #6fc7ff;
  --orange:    #ffaa44;
  --accent:    #45d883;
  --radius:    16px;
  --shadow:    0 8px 30px rgba(0,0,0,.35);
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Mono', monospace;
}

::selection { background: rgba(69,216,131,.22); color: var(--text); }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #0f1a0f 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font: inherit; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; outline: none; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--green-dim); box-shadow: 0 0 0 3px rgba(69,216,131,.12); }
textarea { resize: vertical; min-height: 72px; }
[hidden] { display: none !important; }
a { color: var(--green); text-decoration: none; }

/* ===== headings con Space Grotesk ===== */
h1, h2, h3, h4, .login-logo, .kpi-val, .tab-label { font-family: var(--font-display); letter-spacing: -.01em; }

/* ===== números tabulares con JetBrains Mono ===== */
.mono, .monto, .badge-num, .kpi-val, .tabla-monto, .corr-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- LOGIN ---------- */
.login-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
}
.login-box {
  width: 100%; max-width: 360px; text-align: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 40px 28px 32px; box-shadow: var(--shadow);
}
.login-logo {
  font-weight: 700; font-size: 32px; letter-spacing: -.5px;
  color: var(--text); margin-bottom: 6px;
}
.login-logo .dot { color: var(--green); }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 28px; }
.login-box input[type=password] {
  text-align: center; letter-spacing: 4px; font-size: 20px;
  margin-bottom: 14px;
}
.login-btn {
  width: 100%; padding: 14px; font-size: 15px; font-weight: 700;
  background: var(--green); color: #062012; border-radius: 12px;
  border: none; font-family: var(--font-display);
}
.login-btn:hover { background: #58e896; }
.login-btn:active { transform: translateY(1px); }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin: 12px 0 0; }

/* ---------- LAYOUT PRINCIPAL ---------- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 54px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 100;
}
.topbar-logo { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.topbar-logo .dot { color: var(--green); }
.topbar-sub { font-size: 12px; color: var(--muted); }
.topbar-spacer { flex: 1; }
.logout-btn {
  font-size: 13px; color: var(--muted); background: none; border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 12px;
}
.logout-btn:hover { border-color: var(--red); color: var(--red); }

/* Tabs */
.tabs-bar {
  display: flex; gap: 2px; padding: 10px 16px 0;
  background: var(--bg); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  background: none; color: var(--muted); border-radius: 10px 10px 0 0;
  padding: 8px 16px; font-size: 14px; font-weight: 500; white-space: nowrap;
  border: 1px solid transparent; border-bottom: none; transition: .12s;
}
.tab-btn:hover { color: var(--text); background: var(--card2); }
.tab-btn.active {
  color: var(--green); background: var(--card);
  border-color: var(--line); border-bottom-color: var(--card);
  font-weight: 700;
}

/* Contenido */
.tab-content { flex: 1; padding: 20px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ---------- KPIs ---------- */
.kpis-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px;
}
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.kpi-val { font-size: 24px; font-weight: 700; color: var(--green); line-height: 1.1; }
.kpi-val.warn { color: var(--yellow); }
.kpi-val.bad  { color: var(--red); }
.kpi-sub { font-size: 11px; color: var(--faint); margin-top: 4px; }

/* ---------- CARDS / PANEL ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px;
}
.panel-title {
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
  margin: 0 0 16px; color: var(--text);
}
.panel-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.panel-row + .panel-row { margin-top: 12px; }

/* ---------- TABLAS ---------- */
.tabla-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--card2); color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; padding: 10px 14px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(69,216,131,.04); }
.tabla-monto { text-align: right; }

/* ---------- BADGES de estado ---------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; letter-spacing: .03em;
  font-family: var(--font-mono);
}
.badge-cobrado, .badge-pagado { background: rgba(69,216,131,.15); color: var(--green); }
.badge-pendiente { background: rgba(255,204,63,.15); color: var(--yellow); }
.badge-atrasado  { background: rgba(255,92,92,.15);  color: var(--red); }
.badge-borrador  { background: rgba(160,160,160,.12); color: var(--muted); }
.badge-emitida   { background: rgba(111,199,255,.15); color: var(--blue); }
.badge-anulada   { background: rgba(255,92,92,.1);   color: var(--faint); text-decoration: line-through; }

/* ---------- BOTONES ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .12s; border: none; font-family: inherit;
}
.btn-primary  { background: var(--green); color: #062012; }
.btn-primary:hover { background: #58e896; }
.btn-secondary { background: var(--card2); color: var(--text); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--green-dim); }
.btn-danger   { background: rgba(255,92,92,.15); color: var(--red); border: 1px solid rgba(255,92,92,.3); }
.btn-danger:hover { background: rgba(255,92,92,.25); }
.btn-ghost    { background: none; color: var(--muted); padding: 6px 10px; }
.btn-ghost:hover { color: var(--text); }
.btn-sm       { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-group    { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---------- MODALES ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--card); border: 1px solid var(--line2); border-radius: 18px;
  padding: 28px 24px; max-width: 520px; width: 100%; max-height: 92vh;
  overflow-y: auto; box-shadow: var(--shadow);
}
.modal-title { font-family: var(--font-display); font-weight: 700; font-size: 18px; margin: 0 0 20px; }
.modal-footer { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---------- GRÁFICO DE BARRAS CSS ---------- */
.chart-wrap { margin: 16px 0; }
.chart-labels { display: flex; gap: 4px; justify-content: flex-start; margin-bottom: 4px; }
.chart-label { font-size: 10px; color: var(--faint); flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bars { display: flex; gap: 4px; align-items: flex-end; height: 80px; }
.chart-bar-group { flex: 1; display: flex; gap: 2px; align-items: flex-end; }
.chart-bar {
  flex: 1; border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s;
}
.bar-ing  { background: var(--green); opacity: .85; }
.bar-eg   { background: var(--red);   opacity: .70; }
.chart-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.chart-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* ---------- FILTROS ---------- */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filtros input, .filtros select { width: auto; font-size: 14px; padding: 7px 12px; }
.filtros label { font-size: 13px; color: var(--muted); }

/* ---------- PRÓXIMOS COBROS ---------- */
.cobros-list { display: flex; flex-direction: column; gap: 8px; }
.cobro-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px;
}
.cobro-nombre { flex: 1; font-weight: 600; }
.cobro-fecha { font-family: var(--font-mono); font-size: 13px; color: var(--yellow); }
.cobro-monto { font-family: var(--font-mono); font-size: 14px; color: var(--green); font-weight: 600; }

/* ---------- ESTADO DE CUENTA CLIENTE ---------- */
.cuenta-saldo {
  font-family: var(--font-mono); font-size: 22px; font-weight: 700;
  color: var(--green);
}
.cuenta-saldo.deudor { color: var(--red); }

/* ---------- FACTURA LÍNEAS ---------- */
.lineas-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 12px 0; }
.lineas-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.lineas-table td { padding: 7px 8px; border-bottom: 1px solid var(--line2); }
.lineas-table input { padding: 6px 8px; font-size: 14px; }
.lineas-total {
  text-align: right; font-family: var(--font-mono); font-size: 18px; font-weight: 700;
  color: var(--green); padding: 10px 0;
}
.btn-add-linea { font-size: 13px; color: var(--green-dim); background: none; border: 1px dashed var(--green-dim); border-radius: 8px; padding: 6px 14px; }
.btn-add-linea:hover { background: rgba(69,216,131,.08); }
.btn-rm-linea { color: var(--red); background: none; padding: 4px 8px; border-radius: 6px; }
.btn-rm-linea:hover { background: rgba(255,92,92,.12); }

/* ---------- TOOLTIP ---------- */
.tooltip-wrap { position: relative; display: inline-block; }
.tooltip-tip {
  display: none; position: absolute; bottom: 120%; left: 50%; transform: translateX(-50%);
  background: #1c2c1c; border: 1px solid var(--line2); border-radius: 8px;
  padding: 6px 12px; font-size: 12px; color: var(--muted); white-space: nowrap; z-index: 300;
}
.tooltip-wrap:hover .tooltip-tip { display: block; }

/* ---------- EMPTY STATE ---------- */
.empty { text-align: center; color: var(--faint); padding: 48px 16px; font-size: 14px; }
.empty-ico { font-size: 32px; margin-bottom: 10px; }

/* ---------- TOAST / NOTIFICACIÓN ---------- */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 500; }
.toast {
  background: var(--card2); border: 1px solid var(--line2); border-radius: 10px;
  padding: 12px 18px; font-size: 14px; max-width: 320px; box-shadow: var(--shadow);
  animation: slideIn .2s ease;
}
.toast.ok    { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- SELECTOR DE MES ---------- */
.mes-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.mes-nav input[type=month] { width: auto; padding: 8px 12px; font-family: var(--font-mono); }
.mes-label { font-family: var(--font-display); font-size: 20px; font-weight: 700; }

/* ---------- PLANILLA ---------- */
.planilla-card {
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; display: flex; align-items: center; gap: 14px;
}
.planilla-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--green-dim);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 15px; color: #062012;
  flex-shrink: 0;
}
.planilla-info { flex: 1; }
.planilla-nombre { font-weight: 700; font-size: 15px; }
.planilla-rol { font-size: 12px; color: var(--muted); }
.planilla-sueldo { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--green); }

/* ---------- MOBILE ---------- */
@media (max-width: 640px) {
  .topbar { padding: 0 12px; }
  .tabs-bar { padding: 8px 10px 0; }
  .tab-btn { padding: 7px 11px; font-size: 13px; }
  .tab-content { padding: 12px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .kpis-grid { grid-template-columns: 1fr 1fr; }
  .modal { padding: 20px 16px; }
}
