/* ─── FACTURAS DASHBOARD ────────────────────────────────────────── */

.facturas-page { background: #F1F5F9; min-height: 100vh; }

/* ─── HEADER ──────────────────────────────────────────────────────── */
.dash-header {
  background: var(--primary);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,.06);
}
.dash-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dash-header .logo { color: white; font-size: .9rem; }
.dash-header-right { display: flex; align-items: center; gap: 12px; }
.header-phone {
  font-size: .8rem;
  color: rgba(255,255,255,.5);
  font-weight: 500;
}
.btn-outline-sm {
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.7);
  padding: 6px 14px;
  border-radius: 100px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 160ms, color 160ms;
}
.btn-outline-sm:hover { border-color: rgba(255,255,255,.5); color: white; }

/* ─── LOOKUP ──────────────────────────────────────────────────────── */
.lookup-section {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
}
.lookup-card {
  background: white;
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: fadeUp .5s var(--ease) both;
}
.lookup-card h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -.025em;
  margin-bottom: 8px;
}
.lookup-card p {
  font-size: .875rem;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.6;
}
.lookup-card .phone-wrap {
  background: #F8FAFC;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  cursor: text;
}
.lookup-card .phone-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--border-focus);
}
.lookup-card .phone-prefix {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .9rem;
  color: var(--text-2);
  font-weight: 500;
  padding-right: 10px;
  border-right: 1.5px solid var(--border);
  flex-shrink: 0;
}
.lookup-card input {
  background: transparent;
  border: none;
  outline: none;
  padding: 13px 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: .95rem;
  color: var(--text);
  width: 100%;
}
.lookup-card input::placeholder { color: #B0BAC6; }

/* ─── STATS BAR ───────────────────────────────────────────────────── */
.stats-bar {
  background: var(--primary);
  padding: 0;
}
.stats-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 28px 4px 0;
  flex: 1;
  min-width: 120px;
}
.stat-item.accent .stat-value { color: var(--accent); }
.stat-value {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: white;
  letter-spacing: -.02em;
}
.stat-label {
  font-size: .72rem;
  color: rgba(255,255,255,.45);
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.stat-divider {
  width: 1px;
  height: 36px;
  background: rgba(255,255,255,.1);
  margin-right: 28px;
  flex-shrink: 0;
}

/* ─── TOOLBAR ────────────────────────────────────────────────────── */
.toolbar {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  transition: border-color 160ms, box-shadow 160ms;
}
.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--border-focus);
}
.search-wrap input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Space Grotesk', sans-serif;
  font-size: .875rem;
  color: var(--text);
}
.search-wrap input::placeholder { color: #B0BAC6; }

.sort-tabs { display: flex; gap: 6px; flex-shrink: 0; }
.sort-btn {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: .8rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 160ms var(--ease);
  white-space: nowrap;
}
.sort-btn:hover { border-color: var(--primary); color: var(--primary); }
.sort-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ─── GRID ───────────────────────────────────────────────────────── */
.facturas-grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 64px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* ─── FACTURA CARD ───────────────────────────────────────────────── */
.factura-card {
  background: white;
  border-radius: var(--r);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 200ms var(--ease), box-shadow 200ms var(--ease);
  animation: fadeUp .4s var(--ease) both;
}
.factura-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-img-wrap {
  position: relative;
  height: 160px;
  background: #F1F5F9;
  overflow: hidden;
}
.card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms var(--ease);
}
.factura-card:hover .card-thumb { transform: scale(1.03); }

.card-img-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  background: rgba(0,0,0,.55);
  border: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(.85);
  transition: opacity 160ms, transform 160ms var(--ease-spring);
  backdrop-filter: blur(4px);
}
.factura-card:hover .card-img-btn { opacity: 1; transform: scale(1); }
.card-img-btn:hover { background: rgba(0,0,0,.75); }

.card-no-img {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.card-img-wrap.no-image .card-thumb { display: none; }
.card-img-wrap.no-image .card-no-img { display: flex; }
.card-img-wrap.no-image .card-img-btn { display: none; }

.card-body { padding: 16px; }

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.card-proveedor {
  font-weight: 700;
  font-size: .95rem;
  color: var(--primary);
  letter-spacing: -.01em;
  line-height: 1.3;
  flex: 1;
}
.card-fecha {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.card-numero {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.card-amounts {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #F8FAFC;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.amount-item { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.amount-label { font-size: .65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.amount-val { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.amount-dot { color: #CBD5E1; font-size: .8rem; flex-shrink: 0; }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.card-concepto {
  font-size: .78rem;
  color: var(--muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-total {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  letter-spacing: -.02em;
  white-space: nowrap;
}

/* ─── EMPTY & LOADING ─────────────────────────────────────────────── */
.empty-state {
  max-width: 1100px;
  margin: 60px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.7;
}
.grid-loading {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.skeleton-card {
  height: 280px;
  background: white;
  border-radius: var(--r);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.6) 50%, transparent 100%);
  animation: shimmer 1.4s ease infinite;
  background-size: 200% 100%;
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ─── LIGHTBOX ────────────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn .2s ease both;
  cursor: zoom-out;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--r-sm);
  box-shadow: 0 32px 64px rgba(0,0,0,.6);
  cursor: default;
  animation: scaleIn .25s var(--ease-spring) both;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,.12);
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 160ms;
}
.lightbox-close:hover { background: rgba(255,255,255,.22); }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .stats-inner { gap: 0; }
  .stat-item { min-width: 80px; padding-right: 0; }
  .stat-divider { display: none; }
  .stat-value { font-size: 1rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .sort-tabs { overflow-x: auto; padding-bottom: 4px; }
  .facturas-grid { grid-template-columns: 1fr; }
  .grid-loading { grid-template-columns: 1fr; }
}
