/* ===== Sincavent · estilos (autocontenidos, sin dependencias externas) ===== */
:root {
  --bg: #0f172a;
  --bg-2: #111c33;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --primary-50: #eff6ff;
  --success: #16a34a;
  --success-50: #f0fdf4;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warning: #d97706;
  --warning-50: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--surface-2);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout app ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform .2s ease;
}
.brand {
  padding: 20px 20px 16px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-logo { width: 34px; height: 34px; flex: none; border-radius: 9px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand small { font-size: 11px; font-weight: 500; color: #64748b; letter-spacing: .5px; text-transform: uppercase; }
/* Marca con logo de empresa (menú lateral) */
.brand-emp { flex-direction: column; align-items: stretch; gap: 8px; }
.brand-logo-full { width: 100%; max-height: 66px; object-fit: contain; background: #fff; border-radius: 10px; padding: 8px 10px; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.brand-sub { font-size: 10px; font-weight: 600; color: #64748b; letter-spacing: 1px; text-transform: uppercase; text-align: right; }
.nav { flex: 1; padding: 8px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin: 2px 0;
  border-radius: 8px; color: #cbd5e1; font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a .ic { width: 20px; text-align: center; font-size: 16px; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar-foot .user { color: #e2e8f0; font-weight: 600; }
.sidebar-foot .role { color: #64748b; font-size: 12px; text-transform: capitalize; }
.sidebar-foot a { color: #94a3b8; }

.main { flex: 1; margin-left: 240px; min-width: 0; }
.topbar {
  display: none;
  align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--bg); color: #fff;
  position: sticky; top: 0; z-index: 30;
}
.topbar .brand { padding: 0; font-size: 18px; }
.hamburger { background: none; border: none; color: #fff; font-size: 22px; cursor: pointer; }
.content { padding: 24px; max-width: 1200px; margin: 0 auto; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat .value.money { color: var(--primary); }
.stat .foot { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.green .value { color: var(--success); }
.stat.amber .value { color: var(--warning); }
.stat.purple .value { color: #7c3aed; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; }
thead th { background: var(--surface-2); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; cursor: pointer; background: var(--surface-2); color: var(--text);
  text-decoration: none; transition: background .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-50); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 14px 20px; font-size: 16px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--success-50); color: var(--success); }
.badge-low { background: var(--danger-50); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-info { background: var(--primary-50); color: var(--primary); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--danger-50); color: var(--danger); border: 1px solid #fecaca; }
.alert-warn { background: var(--warning-50); color: var(--warning); border: 1px solid #fde68a; }

/* ---------- Toolbar (search/filter) ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 180px; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%); }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 32px; }
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-logo img { width: 46px; height: 46px; border-radius: 12px; box-shadow: var(--shadow); }
.auth-logo .name { font-size: 22px; font-weight: 800; letter-spacing: .3px; color: var(--text); }
.auth-card h1 { margin: 0 0 4px; font-size: 24px; }
.auth-card .tagline { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.auth-card .field { margin-bottom: 14px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--muted); font-size: 14px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 16px; align-items: start; }
.pos-search input { font-size: 16px; padding: 14px; }
.pos-results { margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 62vh; overflow-y: auto; }
.prod-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s; }
.prod-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.prod-card .pn { font-weight: 600; font-size: 14px; line-height: 1.3; }
.prod-card .pp { color: var(--primary); font-weight: 700; margin-top: 6px; }
.prod-card .ps { color: var(--muted); font-size: 12px; margin-top: 2px; }
.prod-card.agotado { opacity: .5; cursor: not-allowed; }

.cart { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.cart h3 { margin: 0; padding: 16px; border-bottom: 1px solid var(--border); font-size: 16px; }
.cart-items { flex: 1; overflow-y: auto; padding: 8px 16px; }
.cart-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--surface-2); }
.cart-row .ci-name { flex: 1; font-size: 14px; }
.cart-row .ci-name small { display: block; color: var(--muted); }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 26px; height: 26px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; font-weight: 700; }
.qty span { min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.ci-sub { min-width: 64px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ci-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; }
.cart-foot { border-top: 1px solid var(--border); padding: 16px; }
.cart-line { display: flex; justify-content: space-between; margin-bottom: 8px; }
.cart-total { font-size: 22px; font-weight: 700; }
.cart-empty { color: var(--muted); text-align: center; padding: 30px 10px; }

/* Filas de la compra (cantidad + costo editables) */
.compra-row { padding: 10px 0; border-bottom: 1px solid var(--surface-2); }
.compra-row .cr-name { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.compra-row .cr-inputs { display: flex; align-items: flex-end; gap: 8px; }
.compra-row .cr-inputs label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; flex: 1; }
.compra-row .cr-inputs input { padding: 6px 8px; font-size: 14px; }
.compra-row .cr-inputs .ci-del { align-self: center; }

/* ---------- Logo de empresa ---------- */
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 120px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; margin-bottom: 14px; padding: 12px; }
.logo-preview img { max-width: 100%; max-height: 140px; object-fit: contain; }
.logo-placeholder { color: var(--muted); font-size: 14px; }
.recibo-logo { text-align: center; margin-bottom: 10px; }
.recibo-logo img { max-height: 80px; max-width: 200px; object-fit: contain; }

/* ---------- Recibo ---------- */
.recibo { max-width: 400px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.recibo h2 { text-align: center; margin: 0 0 4px; }
.recibo .r-emp { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.recibo table { margin: 14px 0; }
.recibo td, .recibo th { padding: 6px 4px; font-size: 14px; }
.recibo .r-tot { border-top: 2px dashed var(--border); padding-top: 12px; margin-top: 12px; }
.recibo .r-line { display: flex; justify-content: space-between; margin: 4px 0; }
.recibo .r-line.big { font-size: 20px; font-weight: 700; }
.print-actions { max-width: 400px; margin: 16px auto; display: flex; gap: 12px; }

/* ---------- Gráficas (sin librerías, solo CSS) ---------- */
/* Barras verticales: ventas por día */
.vchart { display: flex; align-items: flex-end; gap: 4px; height: 200px; padding-top: 10px; }
.vcol { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.vbar { width: 72%; max-width: 34px; background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%); border-radius: 4px 4px 0 0; min-height: 3px; transition: opacity .15s; }
.vbar:hover { opacity: .82; }
.vlbl { font-size: 10px; color: var(--muted); margin-top: 6px; white-space: nowrap; }

/* Barras horizontales: top productos */
.hbar { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.hbar-name { width: 130px; flex: none; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { flex: 1; background: var(--surface-2); border-radius: 6px; height: 20px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%); border-radius: 6px; min-width: 3px; }
.hbar-val { flex: none; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .pos { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .content { padding: 16px; }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .backdrop.show { display: block; }
}

@media print {
  .sidebar, .topbar, .print-actions, .page-head .btn, .toolbar { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .recibo { border: none; box-shadow: none; }
  .card, .table-wrap { break-inside: avoid; }
  /* Conservar los colores de las gráficas al imprimir/guardar como PDF */
  .vbar, .hbar-fill, .stat .value { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
