/* ═══════════════════════════════════════════════
   MOTOR'OILS — Aveo Inventory System
   style.css
   ═══════════════════════════════════════════════ */

/* ── TOKENS ── */
:root {
  --bg:        #0F172A;
  --surface:   #1E293B;
  --surface2:  #273447;
  --border:    #2D3F55;
  --orange:    #FF6D00;
  --orange2:   #FF8F00;
  --blue:      #1565C0;
  --blue2:     #1976D2;
  --blue3:     #42A5F5;
  --text:      #E5E7EB;
  --muted:     #64748B;
  --green:     #00A550;
  --red:       #D32F2F;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
  --transition: .15s ease;
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
img { display: block; max-width: 100%; }

/* ── BACKGROUND GRID ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(21,101,192,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(21,101,192,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* ══════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════ */
.flex-row    { display: flex; flex-direction: row; }
.flex-col    { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.full-width { width: 100%; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.gap-lg { gap: 16px; }
.gap-xl { gap: 24px; }
.hidden  { display: none !important; }
.visible { display: block !important; }
.overflow-hidden { overflow: hidden; }
.sticky-top { position: sticky; top: 0; z-index: 50; }
.text-muted { color: var(--muted); }
.text-orange { color: var(--orange); }
.text-blue   { color: var(--blue3); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.font-mono { font-family: 'DM Mono', monospace; }
.font-condensed { font-family: 'Barlow Condensed', sans-serif; }
.uppercase { text-transform: uppercase; }
.bold { font-weight: 700; }
.nowrap { white-space: nowrap; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.relative { position: relative; }
.overflow-y-auto { overflow-y: auto; }
.min-width-0 { min-width: 0; }

/* ── LABEL UTILITY ── */
.label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 5px;
  display: block;
}

/* ══════════════════════════════════════
   HEADER
   ══════════════════════════════════════ */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,23,42,.96);
  backdrop-filter: blur(20px);
  border-bottom: 2px solid var(--orange);
  display: flex;
  align-items: stretch;
  height: 58px;
  min-width: 0;
}

/* Brand */
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px 0 14px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--orange);
  white-space: nowrap;
}
.brand-sub {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--blue3);
  white-space: nowrap;
}

/* Nav tabs */
.nav-center {
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-center::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition), background var(--transition);
}
.nav-tab.active {
  background: rgba(255,109,0,.1);
  color: var(--orange);
  border: 1px solid rgba(255,109,0,.25);
}
.nav-tab:hover:not(.active) { color: var(--text); }

/* Header right */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}
.online-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  background: rgba(0,165,80,.08);
  border: 1px solid rgba(0,165,80,.25);
  font-size: 10px;
  font-weight: 700;
  color: var(--green);
  white-space: nowrap;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.online-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* Sucursal selector */
.suc-selector { display: flex; gap: 4px; flex-wrap: wrap; }
.suc-btn {
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  transition: all var(--transition);
  white-space: nowrap;
}
.suc-btn.active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.suc-btn:hover:not(.active) {
  border-color: var(--orange);
  color: var(--orange);
}

/* ══════════════════════════════════════
   DIA BANNER
   ══════════════════════════════════════ */
#dia-banner {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 7px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
  z-index: 1;
}
.dia-badge {
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.dia-badge.abierto {
  background: rgba(0,165,80,.1);
  border: 1px solid rgba(0,165,80,.25);
  color: var(--green);
}
.dia-badge.cerrado {
  background: rgba(211,47,47,.08);
  border: 1px solid rgba(211,47,47,.2);
  color: var(--red);
}
.dia-clock {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  color: var(--orange);
}
.dia-fecha { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ══════════════════════════════════════
   MAIN / PAGES
   ══════════════════════════════════════ */
#app-main {
  max-width: 1340px;
  margin: 0 auto;
  padding: 18px;
  position: relative;
  z-index: 1;
}
.page { display: none; }
.page.active { display: block; }

/* ══════════════════════════════════════
   STATS
   ══════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 2px 0 0 2px;
}
.stat-card.orange::before { background: var(--orange); }
.stat-card.blue::before   { background: var(--blue); }
.stat-card.orange2::before{ background: var(--orange2); }

.stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 5px;
}
.stat-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
}
.stat-card.orange  .stat-value { color: var(--orange); }
.stat-card.blue    .stat-value { color: var(--blue3); }
.stat-card.orange2 .stat-value { color: var(--orange2); }

/* ══════════════════════════════════════
   TREE / CATEGORIAS
   ══════════════════════════════════════ */
.tree-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.tree-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
}
.tree-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tree-sep { color: var(--border); margin: 0 2px; }
.tree-chip {
  padding: 4px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  transition: all var(--transition);
}
.tree-chip.active { border-color: var(--orange); color: var(--orange); background: rgba(255,109,0,.07); }
.tree-chip:hover  { border-color: var(--orange); color: var(--orange); }

/* ══════════════════════════════════════
   TOOLBAR
   ══════════════════════════════════════ */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.search-box {
  flex: 1;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 13px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.search-box:focus { border-color: var(--orange); }
.search-box::placeholder { color: var(--muted); }

.form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.form-select:focus { border-color: var(--orange); }

/* ══════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════ */
.btn {
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  min-height: 38px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-orange { background: var(--orange); color: #fff; }
.btn-orange:hover:not(:disabled) { background: var(--orange2); }

.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover:not(:disabled) { background: var(--blue2); }

.btn-green { background: var(--green); color: #fff; }
.btn-green:hover:not(:disabled) { filter: brightness(1.1); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); }

.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: var(--radius-sm); min-height: 32px; }
.btn-full { width: 100%; justify-content: center; }

/* ══════════════════════════════════════
   PRODUCT CARDS
   ══════════════════════════════════════ */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition), transform var(--transition);
  cursor: pointer;
}
.product-card:hover { border-color: var(--orange); transform: translateY(-2px); }

.card-img {
  width: 100%;
  height: 140px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  font-size: 13px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 11px; }

.card-hier {
  font-size: 9px;
  color: var(--muted);
  margin-bottom: 3px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.card-hier .hi { color: var(--blue3); }

.card-code {
  font-family: 'DM Mono', monospace;
  font-size: 9px;
  color: var(--blue3);
  background: rgba(66,165,245,.08);
  border: 1px solid rgba(66,165,245,.15);
  padding: 1px 6px;
  border-radius: 3px;
  display: inline-block;
  margin-bottom: 5px;
}
.card-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 4px;
  line-height: 1.2;
}
.card-badges { display: flex; gap: 3px; flex-wrap: wrap; margin-bottom: 7px; }
.suc-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--orange);
  border: 1px solid rgba(255,109,0,.3);
  background: rgba(255,109,0,.06);
}
.card-prices { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 6px; }
.price-stack { display: flex; flex-direction: column; gap: 1px; }
.price-base  { font-size: 10px; color: var(--muted); }
.price-venta { font-family: 'Barlow Condensed', sans-serif; font-size: 17px; font-weight: 900; color: var(--orange); line-height: 1; }
.price-gain  { font-size: 10px; color: var(--blue3); font-weight: 600; }

.stock-label { font-family: 'Barlow Condensed', sans-serif; font-size: 12px; font-weight: 700; }
.st-ok  { color: var(--green); }
.st-low { color: var(--orange2); }
.st-out { color: var(--red); }

.card-actions { display: flex; gap: 4px; margin-top: 7px; }

/* ══════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════ */
.empty-state { text-align: center; padding: 56px 20px; }
.empty-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 5px;
}
.empty-sub { color: var(--muted); font-size: 12px; }

/* ══════════════════════════════════════
   MODAL
   ══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-overlay.open .modal { transform: scale(1); }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  overflow-y: auto;
  transform: scale(.96);
  transition: transform .2s;
}
.modal-lg { max-width: 820px; }

.modal-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 1;
  border-top: 2px solid var(--orange);
}
.modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--orange);
}
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { border-color: var(--red); color: var(--red); }
.modal-body   { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 7px; justify-content: flex-end; }

/* ══════════════════════════════════════
   FORM ELEMENTS
   ══════════════════════════════════════ */
.form-group { margin-bottom: 13px; }

.form-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus { border-color: var(--orange); }
.form-input.mono  { font-family: 'DM Mono', monospace; }

.form-row  { display: grid; grid-template-columns: 1fr 1fr;       gap: 10px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr;   gap: 9px; }

.section-sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.section-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--orange);
  margin-bottom: 10px;
}

/* Photo upload */
.photo-upload {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition);
  position: relative;
  background: var(--surface2);
}
.photo-upload:hover { border-color: var(--orange); }
.photo-upload input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.photo-hint    { font-size: 12px; color: var(--muted); }
.photo-preview { width: 100%; max-height: 140px; object-fit: cover; border-radius: var(--radius-sm); margin-top: 7px; }

/* Price box */
.price-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px;
}
.price-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.price-result-val {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 20px;
  font-weight: 900;
  color: var(--blue3);
}

/* Stock grid */
.stock-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stock-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color var(--transition);
}
.stock-item:focus-within { border-color: var(--orange); }
.stock-item-label {
  font-size: 9px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
}
.stock-item-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--orange);
}
.stock-item input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition);
}
.stock-item input:focus { border-color: var(--orange); }

/* ══════════════════════════════════════
   VENTAS
   ══════════════════════════════════════ */
.venta-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}
.venta-sidebar { position: sticky; top: 120px; }

.venta-search-results {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 4px;
  display: none;
}
.search-result-item {
  padding: 9px 12px;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface); }
.sri-name { font-family: 'Barlow Condensed', sans-serif; font-size: 14px; font-weight: 700; }
.sri-sub  { font-size: 11px; color: var(--muted); }
.sri-price { font-family: 'Barlow Condensed', sans-serif; font-size: 15px; font-weight: 800; color: var(--orange); }

.cart-builder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
}
.cart-empty { text-align: center; padding: 22px; color: var(--muted); font-size: 13px; }
.cart-items { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; margin-bottom: 8px; }
.cart-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.cart-item-name { font-family: 'Barlow Condensed', sans-serif; font-size: 14px; font-weight: 700; }
.cart-item-sub  { font-size: 11px; color: var(--muted); }
.cart-item-qty input {
  width: 54px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  color: var(--orange);
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  text-align: center;
  outline: none;
}
.cart-item-qty input:focus { border-color: var(--orange); }
.cart-item-total { font-family: 'Barlow Condensed', sans-serif; font-size: 15px; font-weight: 800; color: var(--orange); min-width: 80px; text-align: right; }

.venta-totals {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--orange);
  border-radius: var(--radius-md);
  padding: 14px;
}
.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.totals-row.main { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 10px; }
.totals-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.totals-value { font-family: 'Barlow Condensed', sans-serif; font-size: 15px; font-weight: 800; }
.totals-value.big    { font-size: 22px; color: var(--orange); }
.totals-value.blue   { color: var(--blue3); }
.totals-value.muted  { color: var(--muted); }

/* ══════════════════════════════════════
   HISTORIAL
   ══════════════════════════════════════ */
.hist-tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.hist-tab {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  transition: all var(--transition);
}
.hist-tab.active {
  background: rgba(21,101,192,.12);
  color: var(--blue3);
  border-color: rgba(21,101,192,.3);
}
.hist-tab:hover:not(.active) { color: var(--text); }

.ventas-list, .dias-list { display: flex; flex-direction: column; gap: 7px; }

.venta-card, .dia-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}
.venta-card { border-left: 3px solid var(--orange); }
.dia-card   { border-left: 3px solid var(--blue); }
.venta-card:hover { border-color: var(--orange); transform: translateX(2px); }
.dia-card:hover   { border-color: var(--blue2); transform: translateX(2px); }

.card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.card-date { font-size: 11px; color: var(--muted); font-weight: 600; }
.card-suc-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  background: rgba(255,109,0,.08);
  color: var(--orange);
  border: 1px solid rgba(255,109,0,.2);
  text-transform: uppercase;
}
.card-nums { display: flex; gap: 16px; align-items: baseline; }
.card-total { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; font-weight: 900; color: var(--orange); }
.card-gain  { font-family: 'Barlow Condensed', sans-serif; font-size: 15px; font-weight: 800; color: var(--blue3); }
.card-info  { font-family: 'Barlow Condensed', sans-serif; font-size: 13px; color: var(--muted); }

.dia-estado {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.dia-estado.abierto { background: rgba(0,165,80,.08); color: var(--green); border: 1px solid rgba(0,165,80,.2); }
.dia-estado.cerrado { background: rgba(21,101,192,.08); color: var(--blue3); border: 1px solid rgba(21,101,192,.2); }

/* ══════════════════════════════════════
   DETAIL VIEWS
   ══════════════════════════════════════ */
.detail-img {
  width: 100%;
  height: 190px;
  border-radius: var(--radius-md);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  font-size: 14px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}
.detail-img img { width: 100%; height: 100%; object-fit: cover; }
.detail-hier { font-size: 11px; color: var(--muted); margin-bottom: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.detail-code {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--blue3);
  background: rgba(66,165,245,.08);
  border: 1px solid rgba(66,165,245,.15);
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 7px;
}
.detail-name { font-family: 'Barlow Condensed', sans-serif; font-size: 24px; font-weight: 900; margin-bottom: 12px; }
.detail-desc { font-size: 13px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }

.price-boxes { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.price-box-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
}
.pbi-label { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 3px; font-weight: 700; }
.pbi-value { font-family: 'Barlow Condensed', sans-serif; font-size: 19px; font-weight: 900; }
.pbi-value.orange { color: var(--orange); }
.pbi-value.blue   { color: var(--blue3); }
.pbi-value.muted  { color: var(--muted); }

/* ══════════════════════════════════════
   STOCK TABLE
   ══════════════════════════════════════ */
.stock-table { width: 100%; border-collapse: collapse; }
.stock-table th {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  padding: 6px 9px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-weight: 700;
}
.stock-table td { padding: 8px 9px; border-bottom: 1px solid var(--border); font-size: 13px; }
.stock-table tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: .5px;
  text-transform: uppercase;
}
.tag-ok  { background: rgba(0,165,80,.1);  color: var(--green); }
.tag-low { background: rgba(255,143,0,.1); color: var(--orange2); }
.tag-out { background: rgba(211,47,47,.1); color: var(--red); }

/* ══════════════════════════════════════
   CONFIG PAGE
   ══════════════════════════════════════ */
.config-section { max-width: 580px; display: flex; flex-direction: column; gap: 20px; }
.suc-manager { display: flex; flex-direction: column; gap: 8px; }
.suc-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.suc-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.suc-name-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  outline: none;
}
.suc-name-input:focus { border-color: var(--orange); }
.suc-color-input {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 2px;
  background: var(--bg);
  cursor: pointer;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--orange);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.about-logo { width: 56px; height: 56px; object-fit: contain; flex-shrink: 0; }
.about-name { font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 900; color: var(--orange); }
.about-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ══════════════════════════════════════
   TOAST
   ══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 999;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: .5px;
  text-transform: uppercase;
  transform: translateY(80px);
  opacity: 0;
  transition: all .25s;
  max-width: 300px;
  border-left: 3px solid var(--orange);
  box-shadow: var(--shadow);
}
.toast.show   { transform: translateY(0); opacity: 1; }
.toast.err    { border-left-color: var(--red); }
.toast.ok     { border-left-color: var(--green); }

/* ══════════════════════════════════════
   LOADING SCREEN
   ══════════════════════════════════════ */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.loading-logo { width: 90px; animation: float 2.5s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}
.loading-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--orange);
}
.loading-sub { font-size: 10px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; }
.loader-bar  { width: 180px; height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.loader-bar::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--blue3));
  animation: load 1.2s ease-in-out infinite;
}
@keyframes load {
  0%   { transform: translateX(-150%); }
  100% { transform: translateX(400%); }
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 1200px) {
  .venta-grid { grid-template-columns: 1fr 300px; }
}

@media (max-width: 900px) {
  .venta-grid { grid-template-columns: 1fr; }
  .venta-sidebar { position: static; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .price-boxes { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  #app-header { flex-wrap: nowrap; height: auto; min-height: 58px; }
  .header-brand { padding: 0 10px; }
  .brand-name { font-size: 15px; }
  .brand-sub  { display: none; }
  .nav-center { padding: 0 6px; gap: 1px; }
  .nav-tab    { padding: 5px 10px; font-size: 12px; }
  .header-right .suc-selector { display: none; }

  #app-main { padding: 12px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row3 { grid-template-columns: 1fr; }
  .price-boxes { grid-template-columns: 1fr 1fr; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

  .modal { max-height: 96vh; border-radius: var(--radius-md); }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 10px 14px; }

  /* Sucursal selector en banner de dia en mobile */
  .mobile-suc-row {
    display: flex;
    padding: 6px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 5px;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 20px; }
  .products-grid { grid-template-columns: 1fr 1fr; }
  .card-img { height: 110px; }
  .hist-tabs { flex-wrap: wrap; }
  .btn { min-height: 42px; padding: 9px 14px; }
}

/* ══════════════════════════════════════
   AUTH — LOGIN SCREEN
   ══════════════════════════════════════ */
#loginScreen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#loginScreen.hidden { display: none; }
#appRoot.hidden { display: none; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--orange);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  display: block;
  width: 70px;
  margin: 0 auto 12px;
}
.login-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 26px;
  font-weight: 900;
  color: var(--orange);
  text-align: center;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.login-sub {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 28px;
}
.login-error {
  background: rgba(211,47,47,.1);
  border: 1px solid rgba(211,47,47,.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--red);
  margin-bottom: 12px;
  min-height: 0;
}
.login-error:empty { display: none; }

/* User info in header */
#userInfo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

/* ── NUEVO USUARIO MODAL ── */
.modal-overlay#nuevoUsuarioModal .modal { max-width: 460px; }

/* ── USERS PANEL ── */
#usersPanel { display: flex; flex-direction: column; gap: 8px; }

/* ══════════════════════════════════════
   DESCUENTOS — chips en venta
   ══════════════════════════════════════ */
.desc-chip {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
}
.desc-chip:hover  { border-color: var(--green); color: var(--green); }
.desc-chip.active {
  background: rgba(0,165,80,.12);
  border-color: var(--green);
  color: var(--green);
}

/* ══════════════════════════════════════
   EGRESOS — historial card
   ══════════════════════════════════════ */
.egreso-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

/* ══════════════════════════════════════
   VENTA TOTALS — pago/vuelto
   ══════════════════════════════════════ */
.pago-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-top: 10px;
}
.pago-input {
  width: 110px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  text-align: right;
  outline: none;
  transition: border-color var(--transition);
}
.pago-input:focus { border-color: var(--orange); }

/* ══════════════════════════════════════
   CONFIG — descuentos list
   ══════════════════════════════════════ */
#descuentosConfig .suc-row {
  flex-wrap: wrap;
  gap: 6px;
}

/* ══════════════════════════════════════
   HISTORIAL — egresos tab total
   ══════════════════════════════════════ */
#egresosTotalDisplay {
  min-width: 80px;
  text-align: right;
}

/* ══════════════════════════════════════
   HIST TABS — 3 tabs
   ══════════════════════════════════════ */
.hist-tabs { flex-wrap: wrap; }

/* ══════════════════════════════════════
   VENTA SIDEBAR — responsive ajustes
   ══════════════════════════════════════ */
@media (max-width: 900px) {
  .venta-grid { grid-template-columns: 1fr; }
  .venta-sidebar { position: static; }
  #descuentosContainer { gap: 4px; }
}

@media (max-width: 480px) {
  .desc-chip { font-size: 11px; padding: 3px 9px; }
  .pago-input { width: 90px; font-size: 13px; }
  .totals-value.big { font-size: 20px; }
}

/* ══════════════════════════════════════
   CLIENTE BOX en ventas
   ══════════════════════════════════════ */
.cliente-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 10px;
}

/* ══════════════════════════════════════
   HISTORIAL — agrupacion por dia
   ══════════════════════════════════════ */
.day-group {
  margin-bottom: 18px;
}
.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.day-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 16px;
  font-weight: 800;
  text-transform: capitalize;
  color: var(--text);
}
.day-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.day-totals { text-align: right; }
.day-total-main {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 18px;
  font-weight: 900;
  color: var(--orange);
}
.day-total-sub { font-size: 11px; color: var(--blue3); }
.day-items {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  margin-left: 6px;
}

/* ══════════════════════════════════════
   INFO GRID en detalles
   ══════════════════════════════════════ */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--surface2);
  border-radius: var(--radius-md);
  padding: 14px;
}
.info-lbl {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}
.info-val { font-weight: 700; font-size: 13px; }

/* ══════════════════════════════════════
   DIA GRID en historial
   ══════════════════════════════════════ */
.dia-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.dia-grid-lbl {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 2px;
}
.dia-grid-val {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 800;
}

/* Tabla totales row */
.tt-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.tt-main { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }

/* Mobile fixes */
@media (max-width: 480px) {
  .info-grid { grid-template-columns: 1fr; }
  .dia-grid { grid-template-columns: 1fr 1fr; }
  .day-header { padding: 8px 10px; flex-wrap: wrap; gap: 6px; }
  .day-total-main { font-size: 16px; }
}
