:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar-bg: #101828;
  --sidebar-text: #94a3b8;
  --sidebar-active: #1e293b;
  --bg-app: #f4f6f9;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: .6rem;
}

* { box-sizing: border-box; }
body {
  background: var(--bg-app);
  font-family: 'Segoe UI', Roboto, -apple-system, sans-serif;
  color: #1e293b;
}

.app-wrapper { display: flex; min-height: 100vh; }

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .2s ease;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar.collapsed { width: 74px; }
.sidebar.collapsed .brand-text, .sidebar.collapsed .link-text { display: none; }

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1rem; color: #fff; font-weight: 700; font-size: 1.05rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  white-space: nowrap; overflow: hidden;
}
.sidebar-nav { padding: .6rem; display: flex; flex-direction: column; gap: .15rem; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .8rem;
  color: var(--sidebar-text); padding: .6rem .8rem; border-radius: var(--radius);
  font-size: .89rem; white-space: nowrap; overflow: hidden;
}
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--primary); color: #fff; }
.sidebar-nav .material-icons { font-size: 20px; }

/* ---------- MAIN ---------- */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: .7rem 1.2rem; position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 1.15rem; font-weight: 600; margin: 0; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: .8rem; }
.badge-rol {
  background: #eef2ff; color: var(--primary); font-size: .75rem;
  font-weight: 600; padding: .3rem .65rem; border-radius: 999px;
}
.btn-icon {
  background: transparent; border: none; color: #475569;
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: #f1f5f9; }
.page-content { padding: 1.4rem; }

/* ---------- CARDS / KPIs ---------- */
.kpi-card {
  background: #fff; border-radius: var(--radius); padding: 1.1rem 1.3rem;
  border: 1px solid var(--border); display: flex; align-items: center; gap: 1rem;
  height: 100%;
}
.kpi-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff;
}
.kpi-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.kpi-label { font-size: .78rem; color: #64748b; }

.card-panel {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem;
}

/* ---------- TABLAS ---------- */
.table thead th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .03em;
  color: #64748b; border-bottom-width: 1px; white-space: nowrap;
}
.table td { vertical-align: middle; font-size: .87rem; }

.badge-estado { font-size: .72rem; padding: .35rem .6rem; border-radius: 999px; font-weight: 600; }
.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-proceso { background: #dbeafe; color: #1e40af; }
.badge-espera { background: #fee2e2; color: #991b1b; }
.badge-finalizado { background: #dcfce7; color: #166534; }
.badge-entregado { background: #e0e7ff; color: #3730a3; }
.badge-cancelado { background: #f1f5f9; color: #475569; }
.badge-pagado { background: #dcfce7; color: #166534; }
.badge-parcial { background: #fef3c7; color: #92400e; }

/* ---------- LOGIN ---------- */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #101828 0%, #1e3a8a 100%);
  padding: 1rem;
}
.login-card {
  background: #fff; border-radius: 1rem; padding: 2.2rem; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 1.2rem; }
.login-logo .material-icons { font-size: 46px; color: var(--primary); }

/* ---------- Utilidades ---------- */
.stock-bajo { color: var(--danger); font-weight: 700; }
.firma-canvas { border: 1px dashed #94a3b8; border-radius: .5rem; touch-action: none; background:#fff; }
.foto-thumb { width: 90px; height: 90px; object-fit: cover; border-radius: .5rem; border: 1px solid var(--border); }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: -260px; z-index: 1000; box-shadow: 0 0 30px rgba(0,0,0,.3); }
  .sidebar.mobile-open { left: 0; }
  .page-title { font-size: 1rem; }
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-content { width: 100%; }
  .page-content { padding: 0; }
}
