/* ================================================================
   ERP CONEXVA — Design tokens + componentes compartidos
   ================================================================ */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --rule: #e5e7eb;
  --rule-soft: #f3f4f6;

  --accent: #2563eb;        /* azul CTA */
  --accent-soft: #dbeafe;
  --accent-ink: #1d4ed8;

  --green: #059669;
  --green-soft: #d1fae5;
  --green-soft-2: #ecfdf5;

  --amber: #d97706;
  --amber-soft: #fef3c7;
  --amber-soft-2: #fffbeb;

  --red: #dc2626;
  --red-soft: #fee2e2;

  --orange: #ea580c;
  --orange-soft: #ffedd5;

  --gold: #b45309;
  --purple: #7c3aed;
  --slate: #475569;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.06);
  --shadow-lg: 0 10px 30px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.mono { font-family: 'IBM Plex Mono', ui-monospace, Menlo, monospace; }

/* ---------- Tipografía ---------- */
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; margin: 0; color: var(--ink); }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }
.display { font-weight: 700; letter-spacing: -0.02em; }
.caption {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
}
.num { font-family: 'IBM Plex Mono', ui-monospace, monospace; text-align: right; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border: 1px solid transparent;
  background: var(--accent); color: white;
  font-family: inherit; font-size: 13px; font-weight: 500;
  border-radius: var(--r-md); cursor: pointer;
  transition: background 0.12s, transform 0.04s, box-shadow 0.12s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.ghost {
  background: transparent; color: var(--ink-soft); border-color: var(--rule);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn.soft:hover { background: #c7dbfd; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b91c1c; }
.btn.warn { background: var(--orange-soft); color: var(--orange); border-color: #fdd3b0; }
.btn.warn:hover { background: #fed3b0; }
.btn.green { background: var(--green); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.xs { padding: 4px 8px; font-size: 11px; border-radius: var(--r-sm); }
.btn.icon { padding: 6px 8px; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.02em;
  background: var(--rule-soft); color: var(--ink-soft);
  white-space: nowrap;
}
.chip.green, .chip.facturado { background: var(--green-soft); color: var(--green); }
.chip.amber, .chip.proyeccion, .chip.proyectado { background: var(--amber-soft); color: var(--amber); }
.chip.red, .chip.gastos { background: var(--red-soft); color: var(--red); }
.chip.blue, .chip.facturacion { background: var(--accent-soft); color: var(--accent-ink); }
.chip.purple, .chip.fxf { background: #ede9fe; color: var(--purple); }
.chip.slate, .chip.virtual { background: #e2e8f0; color: var(--slate); }
.chip.ka, .chip.gold { background: #fef3c7; color: var(--gold); }
.chip.terminado { background: #e2e8f0; color: var(--slate); }
.chip.administrador { background: #ede9fe; color: var(--purple); }
.chip.usuario { background: var(--accent-soft); color: var(--accent-ink); }
.chip.inactivo { background: var(--rule-soft); color: var(--muted); }
.chip.mes-actual { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; padding: 4px 10px; font-size: 11px; border-radius: 999px; }
.chip.dot::before { content: '●'; font-size: 8px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card.padded { padding: 20px 24px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px; font-weight: 500; color: var(--ink-soft);
}
.input, select, textarea, input[type=text], input[type=password], input[type=number], input[type=date], input[type=email] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  background: var(--surface);
  font: inherit;
  color: var(--ink);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus, select:focus, textarea:focus,
input[type=text]:focus, input[type=password]:focus, input[type=number]:focus, input[type=date]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 64px; }
select { cursor: pointer; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; color: var(--ink-soft); }

/* ---------- Tabla ---------- */
table.data {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface);
  font-size: 13px;
}
table.data thead th {
  text-align: left; padding: 12px 14px;
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
}
table.data tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--rule-soft);
  color: var(--ink);
}
table.data tbody tr:hover td { background: var(--surface-2); cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tfoot td {
  padding: 12px 14px; background: var(--surface-2);
  font-weight: 600; border-top: 1px solid var(--rule);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  padding: 12px 16px; background: var(--ink); color: white;
  border-radius: var(--r-md); font-size: 13px;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(12px); transition: all 0.22s;
  /* CRITICO: cuando esta oculto (sin .show) no debe interceptar clicks.
     Posicionado bottom-right donde puede estar el boton SI/NO/Marcar
     completada — sin pointer-events:none los botones son inutilizables
     despues de que el toast se haya mostrado una vez. */
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(17,24,39,0.45); z-index: 99;
  display: none; opacity: 0; transition: opacity 0.22s;
}
.drawer-backdrop.open { display: block; opacity: 1; }
.drawer {
  /* 980px (antes 720px): la matriz semanal de 7 columnas (Mes + 5 Sem + Total)
     no respiraba a 720; las celdas Sem quedaban tan angostas que números como
     "55500" o "1575.45" se cortaban y el botón "Facturar" no se leía completo.
     Sigue limitado a 96vw para pantallas chicas / tablets. */
  position: fixed; top: 0; right: 0; width: min(980px, 96vw); height: 100vh;
  background: var(--bg); z-index: 100; transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(.4,0,.2,1); overflow-y: auto;
  box-shadow: -10px 0 30px rgba(17,24,39,0.1);
}
.drawer.open { transform: translateX(0); }
.drawer > header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 22px 28px; border-bottom: 1px solid var(--rule); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.drawer > header .meta { font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }
.drawer > header h2 { font-size: 20px; }
.drawer > header .close {
  background: transparent; border: 1px solid var(--rule); color: var(--muted);
  cursor: pointer; font-size: 16px; width: 32px; height: 32px; border-radius: var(--r-sm);
}
.drawer > header .close:hover { color: var(--ink); border-color: var(--ink-soft); }
.drawer .body { padding: 24px 28px; }
.drawer section {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg);
  padding: 20px 22px; margin-bottom: 18px;
}
.drawer section > h3 {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); margin-bottom: 14px;
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; }
.row.gap-sm { gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.loading { color: var(--muted); font-style: italic; padding: 24px; text-align: center; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.info-grid .cell .l { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.08em; font-weight: 500; }
.info-grid .cell .v { font-size: 14px; color: var(--ink); margin-top: 4px; }

/* Scrollbar sutil */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

@media (max-width: 720px) {
  .info-grid { grid-template-columns: 1fr; }
}
