:root{
  --primary:#8e5576;
  --primary-dark:#633b53;
  --soft:#f7edf3;
  --bg:#faf9f8;
  --card:#fff;
  --text:#292529;
  --muted:#777078;
  --border:#ebe5e8;
  --success:#4d8a68;
  --warning:#c68b37;
  --danger:#b85c64;
  --shadow:0 8px 25px rgba(53,38,48,.07);
  --radius:18px;
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
button,input,select{font:inherit}
button{cursor:pointer;border:0}
.app-shell{display:flex;min-height:100vh}
.sidebar{width:245px;background:#fff;border-right:1px solid var(--border);padding:22px 16px;display:flex;flex-direction:column;position:fixed;inset:0 auto 0 0;z-index:20}
.brand{display:flex;gap:11px;align-items:center;padding:5px 9px 28px}
.brand-mark {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f4dce9;
  font-size: 36px;
}
.brand strong{display:block;letter-spacing:1.5px;font-size:14px}
.brand span{display:block;color:var(--muted);font-size:9px;margin-top:2px}
nav{display:grid;gap:6px}
.nav-item{background:transparent;color:#6c646a;text-align:left;padding:12px 13px;border-radius:12px;display:flex;gap:12px;align-items:center}
.nav-item:hover,.nav-item.active{background:var(--soft);color:var(--primary-dark);font-weight:700}
.sidebar-footer{margin-top:auto;color:#aaa;font-size:11px;text-align:center}
.main{margin-left:245px;width:calc(100% - 245px);padding:0 30px 40px}
.topbar{height:86px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--border)}
.topbar h1{font-size:24px;margin:0 0 2px}
.topbar p{margin:0;color:var(--muted);font-size:13px}
.top-actions{display:flex;gap:8px}
.view-container{padding-top:26px;max-width:1250px;margin:auto}
.grid{display:grid;gap:18px}
.stats-grid{grid-template-columns:repeat(4,1fr)}
.two-col{grid-template-columns:1.5fr 1fr}
.card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);padding:20px}
.stat-card{position:relative;min-height:125px}
.stat-icon{width:42px;height:42px;border-radius:13px;background:var(--soft);display:grid;place-items:center;margin-bottom:12px}
.stat-label{color:var(--muted);font-size:12px}
.stat-value{font-size:25px;font-weight:800;margin-top:4px}
.stat-extra{font-size:11px;color:var(--muted);margin-top:7px}
.section-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px}
.section-head h2,.card h2{font-size:16px;margin:0}
.quick-grid{grid-template-columns:repeat(4,1fr)}
.quick-btn{padding:18px;border-radius:16px;background:#fff;border:1px solid var(--border);text-align:left;box-shadow:var(--shadow)}
.quick-btn:hover{transform:translateY(-1px);border-color:#dbc4d1}
.quick-btn b{display:block;margin-top:8px}
.quick-btn span{font-size:12px;color:var(--muted)}
.table-wrap{overflow:auto}
table{width:100%;border-collapse:collapse;font-size:13px}
th{text-align:left;color:var(--muted);font-weight:600;background:#fcfafb}
th,td{padding:12px 10px;border-bottom:1px solid var(--border);white-space:nowrap}
.product-cell{display:flex;gap:10px;align-items:center}
.product-img{width:40px;height:40px;border-radius:11px;object-fit:cover;background:var(--soft)}
.badge{display:inline-flex;padding:5px 9px;border-radius:999px;font-size:10px;font-weight:700}
.badge.success{background:#eaf5ee;color:var(--success)}
.badge.warning{background:#fff3df;color:#a36c1e}
.badge.danger{background:#fdebed;color:var(--danger)}
.badge.info{background:#eee9f5;color:var(--primary-dark)}
.primary-btn,.secondary-btn,.danger-btn{padding:10px 14px;border-radius:11px;font-weight:700}
.primary-btn{background:var(--primary);color:white}
.primary-btn:hover{background:var(--primary-dark)}
.secondary-btn{background:#fff;border:1px solid var(--border);color:var(--text)}
.danger-btn{background:#fff0f1;color:var(--danger)}
.filters{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:18px}
.input,.select{width:100%;border:1px solid var(--border);background:#fff;border-radius:11px;padding:11px 12px;outline:none}
.input:focus,.select:focus{border-color:#c59db5;box-shadow:0 0 0 3px var(--soft)}
.search-box{min-width:240px;flex:1}
.form-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:13px}
.field label{display:block;font-size:11px;color:var(--muted);margin-bottom:6px}
.field.full{grid-column:1/-1}
.modal-backdrop{position:fixed;inset:0;background:rgba(30,20,28,.4);display:grid;place-items:center;z-index:100;padding:15px}
.modal{background:#fff;width:min(680px,100%);max-height:90vh;overflow:auto;border-radius:20px;padding:22px;box-shadow:0 20px 60px rgba(0,0,0,.18)}
.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}
.modal-head h2{margin:0;font-size:18px}
.close-btn{background:#f4f1f3;border-radius:10px;width:34px;height:34px}
.modal-actions{display:flex;justify-content:flex-end;gap:9px;margin-top:20px}
.empty{padding:35px;text-align:center;color:var(--muted)}
.hero{background:linear-gradient(135deg,#fff,#fbf2f7);border:1px solid var(--border);border-radius:22px;padding:25px;margin-bottom:20px}
.hero h2{margin:0 0 6px;font-size:22px}
.hero p{color:var(--muted);margin:0}
.product-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:14px}
.product-card{background:#fff;border:1px solid var(--border);border-radius:16px;overflow:hidden}
.product-card img{width:100%;height:145px;object-fit:cover;background:var(--soft)}
.product-card .pc-body{padding:12px}
.product-card h3{font-size:13px;margin:0 0 4px}
.price{font-weight:800;margin:8px 0}
.small{font-size:11px;color:var(--muted)}
.row{display:flex;align-items:center;gap:9px}
.space{justify-content:space-between}
.mt{margin-top:18px}
.text-success{color:var(--success)}
.text-danger{color:var(--danger)}
.text-muted{color:var(--muted)}
.list{display:grid;gap:8px}
.list-item{display:flex;justify-content:space-between;gap:10px;padding:11px 0;border-bottom:1px solid var(--border)}
.kpi{font-size:30px;font-weight:800}
.bar{height:8px;background:#eee9ec;border-radius:99px;overflow:hidden}
.bar i{display:block;height:100%;background:var(--primary);border-radius:99px}
.mobile-only,.bottom-nav{display:none}
.toast{position:fixed;right:22px;bottom:22px;background:#30282e;color:#fff;padding:12px 16px;border-radius:12px;z-index:200;box-shadow:var(--shadow);font-size:13px}
@media(max-width:1000px){
  .stats-grid{grid-template-columns:repeat(2,1fr)}
  .quick-grid{grid-template-columns:repeat(2,1fr)}
  .product-grid{grid-template-columns:repeat(3,1fr)}
}
@media(max-width:760px){
  .sidebar{display:none}
  .sidebar.open{display:flex;width:245px;box-shadow:10px 0 35px rgba(0,0,0,.12)}
  .main{margin-left:0;width:100%;padding:0 15px 90px}
  .topbar{height:72px}
  .mobile-only{display:inline-grid}
  .topbar h1{font-size:19px}
  .top-actions .secondary-btn{display:none}
  .stats-grid{grid-template-columns:repeat(2,1fr);gap:10px}
  .stat-card{padding:15px;min-height:110px}
  .stat-value{font-size:20px}
  .two-col{grid-template-columns:1fr}
  .quick-grid{grid-template-columns:repeat(2,1fr);gap:10px}
  .product-grid{grid-template-columns:repeat(2,1fr)}
  .product-card img{height:120px}
  .bottom-nav{display:grid;position:fixed;bottom:0;left:0;right:0;height:68px;background:#fff;border-top:1px solid var(--border);grid-template-columns:repeat(5,1fr);z-index:30}
  .bottom-nav button{background:#fff;color:#777;font-size:18px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px}
  .bottom-nav button span{font-size:9px}
  .bottom-nav button.active{color:var(--primary);font-weight:800}
  .form-grid{grid-template-columns:1fr}
  .field.full{grid-column:auto}
}
/* =========================
   MENÚ LATERAL RETRÁCTIL
   ========================= */

.sidebar {
  position: relative;
  transition: width 0.25s ease;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-text {
  min-width: 0;
  transition: opacity 0.2s ease;
}

.sidebar-toggle {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* Menú contraído */

.sidebar.collapsed {
  width: 82px;
}

.sidebar.collapsed .brand {
  justify-content: center;
}

.sidebar.collapsed .brand-text {
  display: none;
}

.sidebar.collapsed .sidebar-toggle {
  position: absolute;
  right: -42px;
  top: 8px;
  background: var(--card);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar.collapsed .nav-item span {
  display: none;
}

.sidebar.collapsed .sidebar-footer {
  display: none;
}

/* Ajuste de espacio entre menú y contenido */
.app-shell {
  gap: 0 !important;
}

.main {
  margin-left: 0 !important;
}

.app-shell {
  width: 100%;
  max-width: none;
  gap: 0 !important;
}

.main {
  width: 100%;
  min-width: 0;
  margin-left: 0 !important;
}

.sidebar {
  flex-shrink: 0;
}
/* =========================================
   COMPROBANTE ESSENZA
   ========================================= */

.receipt-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.invoice-card {
  background-color: #ffffff;
  width: 100%;
  max-width: 650px;
  padding: 40px 30px;
  color: #5c3e38;
  font-family: 'Montserrat', sans-serif;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 25px;
}

.brand-title {
  font-size: 42px;
  font-weight: 300;
  letter-spacing: 4px;
  color: #b07c72;
  line-height: 1;
}

.brand-subtitle {
  font-size: 13px;
  letter-spacing: 3px;
  color: #6d4c41;
  margin-top: 5px;
  text-align: center;
}

.logo-container {
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.info-section {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 14px;
  color: #5c3e38;
  line-height: 1.5;
}

.client-info h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 5px;
  letter-spacing: 1px;
}

.receipt-info {
  text-align: right;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 25px;
}

.invoice-table th,
.invoice-table td {
  border: 1.5px solid #8c5b51;
  text-align: center;
  padding: 10px 6px;
  font-size: 13px;
}

.invoice-table th {
  background-color: #f2d2cd;
  color: #5c3e38;
  font-weight: 700;
}

.invoice-table td.desc {
  text-align: center;
}

.empty-row td {
  height: 35px;
}

.footer-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 15px;
}

.observaciones h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

.observaciones p {
  font-size: 14px;
  color: #6d4c41;
  margin-bottom: 12px;
}

.check-icon {
  width: 32px;
  height: 32px;
  background-color: #4cd964;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

.totals {
  text-align: right;
  font-size: 15px;
  color: #5c3e38;
}

.totals .subtotal {
  margin-bottom: 15px;
}

.totals .total-border {
  border-top: 2px solid #8c5b51;
  padding-top: 8px;
  font-weight: 700;
  font-size: 16px;
}

.thank-you {
  text-align: right;
  font-family: 'Great Vibes', cursive;
  font-size: 48px;
  color: #5c3e38;
  margin-top: 25px;
}

/* =========================================
   REPORTES
   ========================================= */

.stats-grid {
  display: grid;
  gap: 18px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.btn {
  padding: 10px 14px;
  border-radius: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.view-content {
  width: 100%;
}

.muted {
  color: var(--muted);
}

@media (min-width: 1001px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 1000px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 15px;
  }
}

/* =========================================
   FORMULARIOS DE REPORTES
   ========================================= */

.report-form {
  display: grid;
  gap: 16px;
}

.report-form .form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.report-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.report-form label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.report-form input,
.report-form select,
.report-form textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.report-form input:focus,
.report-form select:focus,
.report-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(142, 85, 118, .10);
}

.report-form textarea {
  min-height: 90px;
  resize: vertical;
}

.report-form button {
  justify-self: start;
  padding: 11px 16px;
  border: none;
  border-radius: 11px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s ease, transform .1s ease;
}

.report-form button:hover {
  background: var(--primary-dark);
}

.report-form button:active {
  transform: translateY(1px);
}

/* Movimiento de dinero */

.movimiento-form {
  display: grid;
  gap: 16px;
}

.movimiento-tipos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.movimiento-tipo {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  font-weight: 700;
  text-align: center;
}

/* Gastos */

.gasto-form {
  display: grid;
  gap: 16px;
}

/* Responsive */

@media (max-width: 760px) {
  .report-form .form-row {
    grid-template-columns: 1fr;
  }

  .movimiento-tipos {
    grid-template-columns: 1fr;
  }

  .report-form button {
    width: 100%;
  }
}

/* =========================================
   FORMULARIOS DE REPORTES
   ========================================= */

.card label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.card input,
.card select,
.card textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.card input:focus,
.card select:focus,
.card textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(142, 85, 118, .10);
}

.card input::placeholder {
  color: #aaa;
}

/* Botones de Reportes */

.card .btn {
  border: none;
  padding: 11px 16px;
  border-radius: 11px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease, transform .1s ease;
}

.card .btn-primary {
  background: var(--primary);
  color: #fff;
}

.card .btn-primary:hover {
  background: var(--primary-dark);
}

.card .btn-primary:active {
  transform: translateY(1px);
}

/* =========================================
   FORMULARIOS DE GASTOS Y MOVIMIENTOS
   ========================================= */

.card > div[style*="grid-template-columns"] {
  width: 100%;
}

.card > div[style*="grid-template-columns"] > div {
  min-width: 0;
}

/* =========================================
   SELECT DE MOVIMIENTO
   ========================================= */

#reporteMovimientoTipo {
  cursor: pointer;
}

/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-width: 600px) {
  .card input,
  .card select,
  .card textarea {
    font-size: 16px;
  }

  .card .btn {
    width: 100%;
  }
}

