:root {
  --cafe: #6B3A2A;
  --cafe-dark: #4A2419;
  --cafe-light: #9B5A3F;
  --verde: #2D5016;
  --verde-light: #3D6B1E;
  --dorado: #C8860A;
  --crema: #FBF7F0;
  --crema-dark: #EDE3D0;
  --texto: #1A1A1A;
  --texto-suave: #6B6B6B;
  --blanco: #FFFFFF;
  --error: #C0392B;
  --exito: #27AE60;
  --borde: #DDD3C0;
  --sombra: 0 2px 12px rgba(0,0,0,0.10);
  --sombra-lg: 0 4px 24px rgba(0,0,0,0.15);
  --radio: 14px;
  --radio-sm: 8px;
  --nav-h: 68px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--crema);
  color: var(--texto);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ===== TOP HEADER ===== */
.app-header {
  background: var(--cafe);
  color: var(--blanco);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--sombra);
}

.app-header .logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.app-header .logo-sub {
  font-size: 0.72rem;
  opacity: 0.8;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.app-header .user-badge {
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ===== MAIN CONTENT ===== */
.page-content {
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 16px);
  min-height: calc(100vh - 60px);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--blanco);
  border-top: 1px solid var(--borde);
  display: flex;
  z-index: 200;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--texto-suave);
  font-size: 0.68rem;
  font-weight: 500;
  padding: 8px 4px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item svg { width: 24px; height: 24px; }

.nav-item.active {
  color: var(--cafe);
}

.nav-item.active svg { stroke: var(--cafe); }

.nav-item.nav-main {
  color: var(--blanco);
}

.nav-item.nav-main .nav-circle {
  width: 52px;
  height: 52px;
  background: var(--cafe);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -18px;
  box-shadow: var(--sombra-lg);
  border: 3px solid var(--crema);
}

.nav-item.nav-main svg { width: 26px; height: 26px; stroke: var(--blanco); }
.nav-item.nav-main span { color: var(--cafe); }

/* ===== CARDS ===== */
.card {
  background: var(--blanco);
  border-radius: var(--radio);
  padding: 18px;
  box-shadow: var(--sombra);
  margin-bottom: 14px;
}

.card-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--texto-suave);
  margin-bottom: 10px;
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--blanco);
  border-radius: var(--radio);
  padding: 16px;
  box-shadow: var(--sombra);
  text-align: center;
}

.stat-card.accent { background: var(--cafe); color: var(--blanco); }
.stat-card.green { background: var(--verde); color: var(--blanco); }

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card:not(.accent):not(.green) .stat-value { color: var(--cafe); }
.stat-card:not(.accent):not(.green) .stat-label { color: var(--texto-suave); }

/* ===== META BAR ===== */
.meta-bar-wrap { margin: 4px 0 8px; }
.meta-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--texto-suave);
  margin-bottom: 6px;
}
.meta-bar-bg {
  background: var(--crema-dark);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}
.meta-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cafe), var(--dorado));
  border-radius: 99px;
  transition: width 0.6s ease;
}
.meta-pct {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cafe);
  text-align: right;
  margin-top: 4px;
}

/* ===== INVENTORY GRID ===== */
.inv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.inv-item {
  background: var(--crema);
  border: 1.5px solid var(--borde);
  border-radius: var(--radio-sm);
  padding: 14px 12px;
  text-align: center;
}

.inv-item.low { border-color: #E67E22; background: #FEF9F0; }
.inv-item.empty { border-color: var(--error); background: #FEF0EF; }

.inv-qty { font-size: 2rem; font-weight: 800; color: var(--cafe); line-height: 1; }
.inv-item.low .inv-qty { color: #E67E22; }
.inv-item.empty .inv-qty { color: var(--error); }
.inv-name { font-size: 0.78rem; color: var(--texto-suave); margin-top: 4px; line-height: 1.3; }
.inv-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  margin-top: 4px;
  background: var(--crema-dark);
  color: var(--texto-suave);
}
.inv-item.empty .inv-badge { background: var(--error); color: #fff; }
.inv-item.low .inv-badge { background: #E67E22; color: #fff; }

/* ===== SALE LIST ===== */
.sale-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--borde);
}
.sale-item:last-child { border-bottom: none; }

.sale-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--crema-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--cafe);
  flex-shrink: 0;
}

.sale-info { flex: 1; min-width: 0; }
.sale-client { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sale-detail { font-size: 0.78rem; color: var(--texto-suave); margin-top: 2px; }
.sale-channel { font-size: 0.7rem; color: var(--texto-suave); }

.sale-amount {
  text-align: right;
  flex-shrink: 0;
}
.sale-price { font-weight: 700; font-size: 0.92rem; color: var(--cafe); }
.sale-qty { font-size: 0.75rem; color: var(--texto-suave); }
.sale-date { font-size: 0.7rem; color: var(--texto-suave); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--texto-suave);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--borde);
  border-radius: var(--radio-sm);
  font-size: 1rem;
  background: var(--blanco);
  color: var(--texto);
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--cafe);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B3A2A' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* ===== PRODUCT SELECTOR ===== */
.product-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.product-card {
  border: 2px solid var(--borde);
  border-radius: var(--radio-sm);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--blanco);
  -webkit-tap-highlight-color: transparent;
}

.product-card.selected {
  border-color: var(--cafe);
  background: #FDF4EE;
}

.product-card .p-price {
  font-size: 1rem;
  font-weight: 800;
  color: var(--cafe);
}

.product-card .p-name {
  font-size: 0.78rem;
  color: var(--texto-suave);
  margin-top: 3px;
  line-height: 1.3;
}

.product-card .p-badge {
  display: inline-block;
  font-size: 0.65rem;
  background: var(--crema-dark);
  color: var(--texto-suave);
  padding: 2px 7px;
  border-radius: 99px;
  margin-top: 5px;
  font-weight: 600;
}

.product-card.selected .p-badge {
  background: var(--cafe);
  color: var(--blanco);
}

/* ===== QUANTITY CONTROL ===== */
.qty-control {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--borde);
  border-radius: var(--radio-sm);
  overflow: hidden;
}

.qty-btn {
  width: 52px;
  height: 52px;
  border: none;
  background: var(--crema-dark);
  font-size: 1.5rem;
  color: var(--cafe);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  font-weight: 600;
}

.qty-btn:active { background: var(--borde); }

.qty-display {
  flex: 1;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--texto);
  background: var(--blanco);
  padding: 10px;
  border: none;
  outline: none;
}

/* ===== CHIP SELECTORS ===== */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 14px;
  border: 1.5px solid var(--borde);
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  background: var(--blanco);
  color: var(--texto-suave);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.chip.selected {
  border-color: var(--cafe);
  background: var(--cafe);
  color: var(--blanco);
  font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radio-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.3px;
}

.btn:active { transform: scale(0.98); opacity: 0.9; }

.btn-primary { background: var(--cafe); color: var(--blanco); }
.btn-success { background: var(--verde); color: var(--blanco); }
.btn-outline {
  background: transparent;
  border: 2px solid var(--cafe);
  color: var(--cafe);
}
.btn-danger { background: var(--error); color: var(--blanco); }
.btn-sm {
  width: auto;
  padding: 8px 16px;
  font-size: 0.85rem;
  display: inline-block;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--cafe-dark) 0%, var(--cafe) 50%, var(--cafe-light) 100%);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
  color: var(--blanco);
}

.login-logo .brand-name {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.login-logo .brand-tagline {
  font-size: 0.82rem;
  opacity: 0.8;
  margin-top: 6px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.login-icon {
  width: 80px;
  height: 80px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 2.5rem;
}

.login-card {
  background: var(--blanco);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--sombra-lg);
}

.login-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--texto);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 0.85rem;
  color: var(--texto-suave);
  margin-bottom: 24px;
}

.error-msg {
  background: #FDECEA;
  color: var(--error);
  border-radius: var(--radio-sm);
  padding: 12px 14px;
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: none;
}

/* ===== BADGES / TAGS ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-cafe { background: #F5EAE0; color: var(--cafe); }
.badge-green { background: #E5F0DC; color: var(--verde); }
.badge-gold { background: #FEF3D7; color: #8B5E00; }
.badge-gray { background: var(--crema-dark); color: var(--texto-suave); }

/* ===== CLIENT ITEM ===== */
.client-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--borde);
  text-decoration: none;
  color: inherit;
}
.client-item:last-child { border-bottom: none; }

.client-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--crema-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--cafe);
  flex-shrink: 0;
}

.client-info { flex: 1; min-width: 0; }
.client-name { font-weight: 600; font-size: 0.95rem; }
.client-detail { font-size: 0.78rem; color: var(--texto-suave); margin-top: 2px; }

.client-stats { text-align: right; }
.client-total { font-weight: 700; font-size: 0.88rem; color: var(--cafe); }
.client-count { font-size: 0.72rem; color: var(--texto-suave); }

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--texto);
}

/* ===== CHANNEL BARS ===== */
.channel-item {
  margin-bottom: 14px;
}
.channel-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 5px;
}
.channel-label span:first-child { font-weight: 600; }
.channel-label span:last-child { color: var(--texto-suave); }
.channel-bar-bg { background: var(--crema-dark); border-radius: 99px; height: 8px; overflow: hidden; }
.channel-bar-fill { height: 100%; border-radius: 99px; background: var(--cafe); }

/* ===== MONTH GRID ===== */
.month-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.month-cell {
  text-align: center;
  padding: 8px 4px;
  border-radius: 6px;
  background: var(--crema-dark);
}
.month-cell.active { background: var(--cafe); color: var(--blanco); }
.month-cell.has-sales { background: var(--crema); border: 1.5px solid var(--borde); }
.month-cell .m-name { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; opacity: 0.8; }
.month-cell .m-val { font-size: 0.78rem; font-weight: 700; margin-top: 2px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  padding: 0;
}
.modal-overlay.hidden { display: none; }

.modal-sheet {
  background: var(--blanco);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--borde);
  border-radius: 99px;
  margin: 0 auto 20px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--texto);
  color: var(--blanco);
  padding: 12px 20px;
  border-radius: 99px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 999;
  box-shadow: var(--sombra-lg);
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--exito); }
.toast.error { background: var(--error); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--texto-suave);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ===== SEARCH ===== */
.search-wrap {
  position: relative;
  margin-bottom: 14px;
}
.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: var(--texto-suave);
}
.search-input {
  width: 100%;
  padding: 13px 16px 13px 44px;
  border: 1.5px solid var(--borde);
  border-radius: var(--radio-sm);
  font-size: 0.95rem;
  background: var(--blanco);
  -webkit-appearance: none;
}
.search-input:focus { outline: none; border-color: var(--cafe); }

/* ===== PAGE TITLE ===== */
.page-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--texto);
  margin-bottom: 4px;
}
.page-subtitle {
  font-size: 0.82rem;
  color: var(--texto-suave);
  margin-bottom: 16px;
}

/* ===== DIVIDER ===== */
.divider {
  border: none;
  border-top: 1px solid var(--borde);
  margin: 16px 0;
}

/* ===== SCROLLABLE TABS ===== */
.tab-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  white-space: nowrap;
  padding: 8px 16px;
  border: 1.5px solid var(--borde);
  border-radius: 99px;
  background: var(--blanco);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--texto-suave);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn.active {
  background: var(--cafe);
  border-color: var(--cafe);
  color: var(--blanco);
}

/* ===== UTILS ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-bold { font-weight: 700; }
.text-cafe { color: var(--cafe); }
.text-muted { color: var(--texto-suave); }
.text-sm { font-size: 0.82rem; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }
.loading { text-align: center; padding: 30px; color: var(--texto-suave); font-size: 0.9rem; }

@media (min-width: 480px) {
  .page-content { max-width: 520px; margin: 0 auto; }
}
