/* ── Variables ──────────────────────────────────────────────── */
:root {
  --brand-dark:   #0f2d52;
  --brand-mid:    #1a4a8a;
  --brand-light:  #e8f0fb;
  --sidebar-w:    220px;
  --topbar-h:     56px;
  --border:       #dee2e6;
  --text-muted:   #6c757d;
  --success-soft: #d1e7dd;
  --danger-soft:  #f8d7da;
}

/* ── Reset / Base ───────────────────────────────────────────── */
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f5f7fa;
  color: #212529;
  font-size: 0.925rem;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}
.navbar-brand .brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  margin-right: 8px;
  font-size: 0.95rem;
}
.navbar .nav-link {
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.navbar .nav-link:hover,
.navbar .nav-link.active {
  background: rgba(255,255,255,0.12);
}

/* ── Page header ────────────────────────────────────────────── */
.page-header {
  padding: 1.25rem 0 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin: 0;
}
.page-header .breadcrumb {
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
}

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 1.1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: 0 3px 8px rgba(0,0,0,.08); }
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-card .stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--brand-dark);
}
.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ── Tabla de facturas ──────────────────────────────────────── */
.table-facturas {
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.table-facturas .table {
  margin-bottom: 0;
}
.table-facturas .table th {
  background: #f8f9fb;
  border-bottom: 2px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 0.65rem 0.85rem;
  white-space: nowrap;
}
.table-facturas .table td {
  padding: 0.65rem 0.85rem;
  vertical-align: middle;
  border-color: #f0f0f0;
}
.table-facturas .table tbody tr {
  cursor: pointer;
  transition: background .1s;
}
.table-facturas .table tbody tr:hover {
  background: var(--brand-light);
}
.num-factura {
  font-family: 'Courier New', monospace;
  font-weight: 600;
  color: var(--brand-mid);
  font-size: 0.9rem;
}
.importe {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}
.importe-total {
  font-weight: 700;
  color: var(--brand-dark);
}

/* ── Estado badges ──────────────────────────────────────────── */
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3em 0.65em;
  letter-spacing: .02em;
}

/* ── Filtros ────────────────────────────────────────────────── */
.filtros-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.03);
}

/* ── Formulario de factura ──────────────────────────────────── */
.form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
  overflow: hidden;
}
.form-card-header {
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.form-card-body { padding: 1.25rem; }

/* ── Tabla de líneas ────────────────────────────────────────── */
.tabla-lineas-wrap {
  overflow-x: auto;
}
.tabla-lineas {
  min-width: 860px;
}
.tabla-lineas th {
  background: #f8f9fb;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 0.55rem 0.6rem;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
.tabla-lineas td {
  padding: 0.45rem 0.5rem;
  vertical-align: middle;
}
.tabla-lineas .fila-linea td { border-color: #f0f2f5; }
.tabla-lineas .fila-linea:hover td { background: #fafbff; }
.num-linea-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--brand-light);
  color: var(--brand-mid);
  font-size: 0.75rem;
  font-weight: 700;
}
.col-desc { min-width: 200px; }
.col-num  { width: 90px; }
.col-iva  { width: 115px; }
.col-dto  { width: 80px; }
.col-imp  { width: 105px; }
.col-act  { width: 46px; }

/* ── Resumen de totales ─────────────────────────────────────── */
.resumen-totales {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.resumen-totales table { margin-bottom: 0; }
.resumen-totales td { padding: 0.45rem 1rem; }
.resumen-totales .total-final {
  background: var(--brand-dark);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
}
.resumen-totales .total-final td { padding: 0.7rem 1rem; }
.desglose-label { color: var(--text-muted); font-size: 0.85rem; }

/* ── Detalle de factura ─────────────────────────────────────── */
.factura-header-card {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 100%);
  color: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
}
.factura-header-card .num-factura-big {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  letter-spacing: -0.02em;
}
.factura-header-card .empresa-nombre {
  font-size: 1.1rem;
  font-weight: 600;
  opacity: .95;
}
.factura-header-card .dato-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .65;
}
.factura-header-card .dato-valor {
  font-size: 0.92rem;
  font-weight: 500;
}
.total-grande {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ── Acciones de estado ─────────────────────────────────────── */
.btn-estado {
  font-size: 0.8rem;
  padding: 0.35rem 0.85rem;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { border-radius: 8px; font-size: 0.88rem; }

/* ── Botón añadir línea ─────────────────────────────────────── */
.btn-agregar-linea {
  border: 2px dashed #c0cfe0;
  color: var(--brand-mid);
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.5rem 1.2rem;
  transition: all .15s;
}
.btn-agregar-linea:hover {
  border-color: var(--brand-mid);
  background: var(--brand-light);
  color: var(--brand-dark);
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: .35;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 767px) {
  .stat-card .stat-value { font-size: 1.1rem; }
  .factura-header-card { padding: 1rem 1.1rem; }
  .total-grande { font-size: 1.4rem; }
}
