/* ═══════════════════════════════════════════════════════
   PriceWise — Stylesheet
   Estética: dark industrial con acentos neón cian
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:       #0d1218;          /* antes #0a0a0c — un pelín más claro y azulado */
  --surface:  #18202a;          /* más claridad para que las cards resalten */
  --surface2: #222d3a;          /* segundo nivel también más claro */
  --border:   #2d3a4a;          /* borde más visible */
  --border2:  #3a4859;

  /* Acentos principales (vuelta a cian) */
  --cian:     #00d4c8;
  --cian2:    #00ffee;
  --amber:    #f5a623;
  --red:      #ff4d6d;
  --green:    #39d98a;
  --purple:   #9b6dff;
  --text:     #e8e4ee;
  --muted:    #7d8a9c;          /* texto secundario más legible */
  --r:        12px;
  --sidebar:  248px;
  --header:   1.6rem;
  --shadow-soft: rgba(0, 0, 0, 0.3);
  --shadow-strong: rgba(0, 0, 0, 0.6);

  /* Bordes suaves y fondos elevados para tarjetas (look "premium") */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --bg-elevated:   #232f3d;
  --cian-10: rgba(0, 212, 200, 0.1);
  --cian-25: rgba(0, 212, 200, 0.25);
  --amber-12: rgba(245, 166, 35, 0.12);
  --amber-30: rgba(245, 166, 35, 0.3);
  --red-10: rgba(255, 77, 109, 0.1);
  --red-30: rgba(255, 77, 109, 0.3);
  --green-10: rgba(57, 217, 138, 0.1);
  --green-30: rgba(57, 217, 138, 0.3);

  /* Variables del rediseño Toyota que ya NO usamos — quedan como aliases */
  --toyota-red:    #00d4c8;
  --toyota-red-h:  #00ffee;
  --toyota-silver: #c0c5cc;
  --hybrid-green:  #39d98a;
  --carbon:        #18202a;

}



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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

/* ═══════════ AUTH ═══════════ */

.auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0,212,200,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(155,109,255,0.05) 0%, transparent 50%);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 40px 80px var(--shadow-strong);
  animation: slideUp 0.4s cubic-bezier(0.16,1,0.3,1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
}

.logo-icon {
  font-size: 1.6rem;
  color: var(--cian);
  filter: drop-shadow(0 0 8px var(--cian));
}

.logo-text {
  font-family: 'Clash Display', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-tabs {
  display: flex; gap: 0;
  background: var(--surface2);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1; padding: 8px;
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; transition: all 0.2s;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px var(--shadow-soft);
}

.auth-error {
  background: rgba(255,77,109,0.1);
  border: 1px solid rgba(255,77,109,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--red);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.auth-hint {
  text-align: center; margin-top: 16px;
  color: var(--muted); font-size: 0.85rem;
}
.auth-hint a {
  color: var(--cian); cursor: pointer;
  text-decoration: underline;
}

/* ═══════════ LAYOUT ═══════════ */

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

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav {
  flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 10px 12px;
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  border-radius: 8px; font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; text-align: left;
  transition: all 0.2s; position: relative;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: rgba(0,212,200,0.08);
  color: var(--cian);
  border: 1px solid rgba(0,212,200,0.15);
}

/* ── Grupos de navegación colapsables ── */
.nav-group {
  margin-bottom: 4px;
}
.nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 8px;
  transition: all 0.2s;
}
.nav-group-header:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-group-arrow {
  transition: transform 0.2s;
  font-size: 0.7rem;
}
.nav-group.collapsed .nav-group-arrow {
  transform: rotate(-90deg);
}
.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 8px;
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.nav-group.collapsed .nav-group-items {
  max-height: 0;
}

.nav-icon { font-size: 1rem; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.72rem; font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 12px;
}

.plan-badge {
  display: inline-block;
  background: rgba(0,212,200,0.1);
  color: var(--cian);
  border: 1px solid rgba(0,212,200,0.25);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.7rem; font-weight: 600;
  letter-spacing: 0.08em;
  width: fit-content;
}

.user-info {
  display: flex; align-items: center; gap: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--cian);
  color: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}

.user-name { font-size: 0.85rem; font-weight: 500; }
.user-company { font-size: 0.75rem; color: var(--muted); }

.btn-logout {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); padding: 7px;
  border-radius: 8px; cursor: pointer;
  font-size: 0.8rem; transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ─── MAIN ─── */
.main-content {
  margin-left: var(--sidebar);
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
}

/* ─── VIEWS ─── */
.view { display: none; padding: 36px 40px; animation: fadeIn 0.25s ease; }
.view.active { display: block; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.view-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.view-header h1 {
  font-family: 'Clash Display', sans-serif;
  font-size: var(--header);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ═══════════ COMPONENTS ═══════════ */

/* Buttons */
.btn-primary {
  background: var(--cian);
  color: var(--bg);
  border: none; border-radius: 8px;
  padding: 10px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.btn-primary:hover {
  background: var(--cian2);
  box-shadow: 0 4px 20px rgba(0,212,200,0.35);
  transform: translateY(-1px);
}
.btn-primary.full { width: 100%; padding: 13px; }

.btn-secondary {
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); border-radius: 8px;
  padding: 10px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem; cursor: pointer; transition: all 0.2s;
}
.btn-secondary:hover { border-color: var(--cian); color: var(--cian); }

.btn-icon {
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  padding: 4px 8px; font-size: 1rem;
  transition: color 0.2s;
}
.btn-icon:hover { color: var(--red); }

.btn-link {
  background: none; border: none;
  color: var(--cian); cursor: pointer;
  font-size: 0.88rem; padding: 8px 0;
  font-family: 'DM Sans', sans-serif;
}

.btn-group { display: flex; gap: 10px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; margin-bottom: 6px;
  font-size: 0.82rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 10px 14px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 8px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none; border-color: var(--cian);
  box-shadow: 0 0 0 3px rgba(0,212,200,0.1);
}
.form-group select { cursor: pointer; }

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

/* Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r);
  padding: 24px;
  margin-bottom: 20px;
}
.panel-header {
  font-weight: 600; font-size: 0.95rem;
  margin-bottom: 16px; color: var(--text);
}
.panel-hint { color: var(--muted); font-size: 0.88rem; margin-bottom: 16px; }

/* Paneles con acento de color (info destacada, avisos, zonas de riesgo) */
.panel.tone-cian  { border-color: var(--cian-25); }
.panel.tone-amber { border-color: var(--amber-30); }
.panel.tone-red   { border-color: var(--red-30); }
.panel.tone-green { border-color: var(--green-30); }
.panel.tone-cian  > .panel-header { color: var(--cian); }
.panel.tone-amber > .panel-header { color: var(--amber); }
.panel.tone-red   > .panel-header { color: var(--red); }
.panel.tone-green > .panel-header { color: var(--green); }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px; margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r);
  padding: 20px; position: relative; overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border2); }
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
}
.stat-card::before        { background: var(--border2); }
.stat-card.accent::before { background: var(--cian); }
.stat-card.warn::before   { background: var(--amber); }
.stat-card.green::before  { background: var(--green); }

.stat-num {
  font-family: 'Clash Display', sans-serif;
  font-size: 2.2rem; font-weight: 700; line-height: 1;
  margin-bottom: 6px;
}
.stat-card.accent .stat-num { color: var(--cian); }
.stat-card.warn   .stat-num { color: var(--amber); }
.stat-card.green  .stat-num { color: var(--green); }
.stat-label { color: var(--muted); font-size: 0.8rem; }

/* Dashboard grid */
.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}

/* Lists grid */
.lists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.list-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r);
  padding: 20px;
  transition: all 0.2s;
  cursor: pointer;
}
.list-card.status-pending_review {
  border: 1px solid var(--amber);
  border-left: 4px solid var(--amber);
  background: color-mix(in srgb, var(--amber) 6%, var(--surface));
}
.list-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.list-card-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
}

.list-card-name { font-weight: 600; font-size: 1rem; }
.list-card-type {
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--muted);
  text-transform: uppercase;
  flex-shrink: 0;
}

.list-card-meta {
  display: flex; gap: 16px;
  color: var(--muted); font-size: 0.82rem; margin-bottom: 14px;
}

.list-card-actions { display: flex; gap: 8px; }

.status-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%; margin-right: 6px;
  vertical-align: middle;
}
.status-ready    .status-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-processing .status-dot { background: var(--amber); animation: pulse 1s infinite; }
.status-error    .status-dot { background: var(--red); }
.status-pending_review .status-dot { background: var(--amber); }

@keyframes pulse {
  0%, 100% { opacity: 1; } 50% { opacity: 0.3; }
}

/* Search */
.search-bar-big {
  display: flex; gap: 12px; margin-bottom: 24px;
}
.search-bar-big input {
  flex: 1; padding: 13px 18px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r); color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 0.95rem;
}
.search-bar-big input:focus {
  outline: none; border-color: var(--cian);
  box-shadow: 0 0 0 3px rgba(0,212,200,0.1);
}

/* Compare tabs */
.compare-tabs {
  display: flex; gap: 4px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  width: fit-content;
}
.ctab {
  background: transparent; border: none;
  padding: 8px 20px; border-radius: 8px;
  color: var(--muted); cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem; transition: all 0.2s;
}
.ctab.active {
  background: var(--cian-10);
  color: var(--cian);
  border: 1px solid var(--cian-25);
}
.ctab-panel { display: none; }
.ctab-panel.active { display: block; }

/* Search result card */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 8px;
  transition: all 0.2s;
  overflow: hidden;
}
.result-card:hover { border-color: var(--border2); }
.result-card.result-parecido { opacity: 0.6; }
.result-card.result-parecido .result-price { font-weight: 500; }
.result-card.best {
  border-color: rgba(57,217,138,0.35);
  background: rgba(57,217,138,0.04);
}

.result-card-inner {
  display: flex; align-items: center;
  padding: 14px 18px; gap: 16px;
}

.result-supplier {
  font-weight: 600; min-width: 140px;
  font-size: 0.9rem;
}

.result-name { flex: 1; color: var(--muted); font-size: 0.88rem; }

.result-code {
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--muted);
}

.result-brand {
  font-size: 0.78rem; color: var(--purple);
  background: rgba(155,109,255,0.1);
  border: 1px solid rgba(155,109,255,0.2);
  padding: 2px 8px; border-radius: 4px;
}

.result-price {
  font-family: 'Clash Display', sans-serif;
  font-size: 1.1rem; font-weight: 600;
  min-width: 90px; text-align: right;
}
.result-price.cheapest { color: var(--green); }
.result-price.expensive { color: var(--muted); }

.result-score {
  font-size: 0.72rem; color: var(--muted);
  min-width: 50px; text-align: right;
}

/* Alert card */
.alert-card {
  background: rgba(245,166,35,0.08);
  border: 1px solid rgba(245,166,35,0.3);
  border-radius: var(--r);
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 12px;
}

.alert-icon { font-size: 1.3rem; flex-shrink: 0; }
.alert-content { flex: 1; }
.alert-title { font-weight: 600; color: var(--amber); margin-bottom: 4px; }
.alert-detail { font-size: 0.83rem; color: var(--muted); }

/* Summary bar */
.summary-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
  display: flex; gap: 32px; align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.summary-stat { text-align: center; }
.summary-val { font-weight: 700; font-size: 1.1rem; }
.summary-val.green { color: var(--green); }
.summary-val.red   { color: var(--red); }
.summary-key { font-size: 0.75rem; color: var(--muted); }

/* Orders */
.order-filters {
  display: flex; gap: 8px; margin-bottom: 20px;
}
.filter-btn {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 16px;
  color: var(--muted); cursor: pointer; font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif; transition: all 0.2s;
}
.filter-btn.active { border-color: var(--cian); color: var(--cian); }
.filter-btn:hover  { border-color: var(--border2); color: var(--text); }

.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 12px;
  overflow: hidden;
}

.order-card-header {
  display: flex; align-items: center;
  padding: 14px 18px; gap: 16px;
  cursor: pointer;
  transition: background 0.2s;
}
.order-card-header:hover { background: var(--surface2); }

.order-ref { font-weight: 600; font-size: 0.95rem; }
.order-supplier { color: var(--muted); font-size: 0.85rem; }
.order-status-badge {
  margin-left: auto;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase;
}
.status-ordered   { background: rgba(0,212,200,0.1);  color: var(--cian);  border: 1px solid rgba(0,212,200,0.3); }
.status-invoiced  { background: rgba(245,166,35,0.1); color: var(--amber); border: 1px solid rgba(245,166,35,0.3); }
.status-received  { background: rgba(57,217,138,0.1); color: var(--green); border: 1px solid rgba(57,217,138,0.3); }
.status-cancelled { background: rgba(255,77,109,0.1); color: var(--red);   border: 1px solid rgba(255,77,109,0.3); }

.order-items-list {
  border-top: 1px solid var(--border);
  padding: 12px 18px;
  display: none;
}
.order-items-list.expanded { display: block; }

.order-item-line {
  display: flex; gap: 16px; align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.order-item-line:last-child { border-bottom: none; }

.order-actions { display: flex; gap: 8px; margin-top: 12px; }

/* Keywords */
.keyword-add {
  display: flex; gap: 10px; margin-bottom: 16px;
}
.keyword-add input { flex: 1; }

.kw-chips {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.kw-chip {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.85rem;
  display: flex; align-items: center; gap: 8px;
  animation: chipIn 0.2s ease;
}
@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
.kw-chip button {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-size: 0.9rem; line-height: 1;
}
.kw-chip button:hover { color: var(--red); }

/* Team */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 10px;
  min-height: 68px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.team-card:hover {
  border-color: var(--cian);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(236, 58, 58, 0.25);
}
.team-avatar {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--cian) 0%, #009b94 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
  color: white;
  flex-shrink: 0;
}
.team-info {
  min-width: 0;
  overflow: hidden;
}
.team-info strong {
  display: block;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-info span {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.role-badge {
  font-size: 0.7rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.team-card .btn-icon {
  border: 1px solid var(--border);
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.team-card .btn-icon:hover {
  background: rgba(255,77,109,0.1);
  border-color: var(--red);
  color: var(--red);
  transform: scale(1.06);
}

/* Responsive — pantallas chicas */
@media (max-width: 640px) {
  .team-card {
    grid-template-columns: 40px 1fr auto;
    grid-template-areas:
      "avatar info delete"
      ".      role role";
    gap: 10px;
    padding: 12px 14px;
  }
  .team-avatar { grid-area: avatar; }
  .team-info { grid-area: info; }
  .role-badge { grid-area: role; justify-self: start; margin-top: 4px; }
  .team-card .btn-icon { grid-area: delete; }
}

/* Checkbox grid (multi-lista) */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px; margin-bottom: 16px;
}
.check-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  cursor: pointer; transition: all 0.2s;
}
.check-item input[type="checkbox"] { accent-color: var(--cian); cursor: pointer; }
.check-item:hover { border-color: var(--cian); }

/* Multi compare table */
.compare-table-wrap { overflow-x: auto; margin-top: 20px; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: left; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
tbody tr:hover { background: var(--surface2); }
tbody td {
  padding: 11px 14px; font-size: 0.88rem;
  vertical-align: middle;
}
.td-cheapest { color: var(--green); font-weight: 600; }
.td-savings  { color: var(--amber); font-weight: 500; }
.td-na       { color: var(--border2); }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--r);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--cian);
  background: rgba(0,212,200,0.04);
}
.drop-icon { font-size: 2rem; display: block; margin-bottom: 10px; }
.drop-zone p { color: var(--muted); font-size: 0.88rem; }
.drop-zone p.hint { font-size: 0.78rem; margin-top: 4px; }
.selected-file {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px; padding: 10px 14px;
  font-size: 0.88rem;
  display: flex; align-items: center; gap: 8px;
}

/* Progress */
.progress-bar {
  height: 4px; background: var(--surface2);
  border-radius: 2px; overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill {
  height: 100%; width: 0%;
  background: var(--cian);
  transition: width 0.3s ease;
}

/* Order item row (modal) */
.order-item-row {
  display: grid;
  grid-template-columns: 100px 1fr 100px 60px 90px 30px;
  gap: 8px; margin-bottom: 8px;
}
.order-item-row input {
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem;
}
.order-item-row input:focus {
  outline: none; border-color: var(--cian);
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 32px;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 40px 80px rgba(0,0,0,0.5);
  animation: slideUp 0.3s cubic-bezier(0.16,1,0.3,1);
}
.modal.modal-lg { max-width: 780px; }

.modal-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.modal-header h2 {
  font-family: 'Clash Display', sans-serif;
  font-size: 1.2rem;
}
.modal-header button {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  font-size: 1.2rem; transition: color 0.2s;
}
.modal-header button:hover { color: var(--red); }

.modal-footer {
  display: flex; gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.88rem;
  z-index: 9999;
  opacity: 0;
  transform: translateY(16px);
  transition: all 0.3s ease;
  pointer-events: none;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-color: rgba(57,217,138,0.4); color: var(--green); }
.toast.error   { border-color: rgba(255,77,109,0.4); color: var(--red); }
.toast.warning { border-color: rgba(245,166,35,0.4); color: var(--amber); }

/* Misc */
.mt { margin-top: 16px; }
.empty-state {
  text-align: center; color: var(--muted);
  padding: 48px; font-size: 0.9rem;
}
.list-placeholder { color: var(--muted); font-size: 0.88rem; padding: 8px 0; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-item span:last-child, .sidebar-footer .user-info div,
  .plan-badge { display: none; }
  .main-content { margin-left: 60px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .view { padding: 20px; }
}

@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .order-item-row { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .result-card-inner { flex-wrap: wrap; }
  .view-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}

/* ═══════════ SHOPPING LIST ═══════════ */

.shopping-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  margin-bottom: 24px;
}

.shopping-search-panel { display: flex; flex-direction: column; gap: 16px; }

.search-results-dropdown {
  margin-top: 12px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-result-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.search-result-item:hover {
  border-color: var(--cian);
  background: rgba(0,212,200,0.05);
  transform: translateX(2px);
}

.search-result-code {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--cian);
  font-weight: 600;
}
.search-result-desc {
  font-size: 0.85rem;
  color: var(--text);
  margin: 4px 0 6px;
}
.search-result-meta {
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.shopping-cart {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 500px;
  overflow-y: auto;
}

.cart-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  animation: chipIn 0.2s ease;
}

.cart-item-info { min-width: 0; }
.cart-item-code { font-family: monospace; font-size: 0.78rem; color: var(--cian); font-weight: 600; }
.cart-item-desc { font-size: 0.8rem; color: var(--muted); margin-top: 2px;
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cart-qty-input {
  width: 50px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  text-align: center;
}

.empty-cart {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 24px 8px;
  font-style: italic;
}

.shopping-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.supplier-breakdown-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cian);
  border-radius: var(--r);
  padding: 16px 20px;
}
.sb-supplier { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.sb-stat { font-size: 0.82rem; color: var(--muted); }
.sb-total { color: var(--green); font-weight: 600; font-size: 1.1rem; margin-top: 6px; }

.not-found-section {
  background: rgba(255,77,109,0.06);
  border: 1px solid rgba(255,77,109,0.25);
  border-radius: var(--r);
  padding: 16px 20px;
  margin-top: 16px;
}
.not-found-section h3 { color: var(--red); margin-bottom: 10px; font-size: 0.95rem; }
.not-found-item {
  font-family: monospace;
  font-size: 0.85rem;
  padding: 4px 0;
  color: var(--text);
}

@media (max-width: 900px) {
  .shopping-layout { grid-template-columns: 1fr; }
}

/* ═══════════ MEJORAS LISTA DE COMPRA ═══════════ */

.search-result-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.search-result-main { flex: 1; min-width: 0; }

.search-result-price {
  color: var(--green);
  font-weight: 600;
}

.btn-add-cart {
  background: var(--cian);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-add-cart:hover {
  background: var(--cian2);
  transform: scale(1.05);
}

.search-result-item.highlighted {
  border-color: var(--cian);
  background: rgba(0,212,200,0.08);
  transform: translateX(4px);
}

.search-empty-msg {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 12px;
  text-align: center;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px dashed var(--border);
}

/* Animación de flash verde al agregar al carrito */
.cart-item.flash-added {
  animation: flashGreen 0.8s ease;
}

@keyframes flashGreen {
  0%   { background: var(--surface2); }
  30%  { background: rgba(57,217,138,0.3); border-color: var(--green); transform: scale(1.03); }
  100% { background: var(--surface2); }
}

#shoppingSearchResults {
  display: flex;
  flex-direction: column;
}

/* Hacer el scroll del carrito más visible */
.shopping-cart::-webkit-scrollbar { width: 6px; }
.shopping-cart::-webkit-scrollbar-track { background: var(--bg); }
.shopping-cart::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ═══════════ MARCAS PREFERIDAS ═══════════ */

.cart-item-brands {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
}

.pref-brand-chip {
  background: rgba(245,166,35,0.12);
  border: 1px solid rgba(245,166,35,0.35);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--amber);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pref-brand-chip button {
  background: none;
  border: none;
  color: var(--amber);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0;
}
.pref-brand-chip button:hover { color: var(--red); }

.btn-add-pref-brand {
  background: var(--surface);
  border: 1px dashed var(--border2);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.15s;
}
.btn-add-pref-brand:hover {
  border-color: var(--amber);
  color: var(--amber);
}

.brand-picker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.brand-pick-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.brand-pick-btn:hover {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(245,166,35,0.06);
}

.td-preferred {
  background: rgba(245,166,35,0.08);
  border-left: 2px solid var(--amber);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════
   REDISEÑO TOYOTA — Animaciones y componentes mejorados
   ═══════════════════════════════════════════════════════ */

/* ─── TIPOGRAFÍA ─── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Bebas+Neue&display=swap');

body {
  font-family: 'Inter', 'DM Sans', sans-serif;
  background:
    radial-gradient(ellipse at top left, rgba(235,10,30,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(12,192,120,0.03) 0%, transparent 50%),
    var(--bg);
}

.view-header h1,
.auth-logo .logo-text {
  font-family: 'Bebas Neue', 'Clash Display', sans-serif;
  letter-spacing: 0.02em;
}

.logo-icon {
  color: var(--toyota-red);
  filter: drop-shadow(0 0 12px rgba(235,10,30,0.5));
}

/* ─── BOTONES CON EFECTO PRESS ─── */
.btn-primary,
.btn-secondary,
.btn-add-cart,
.btn-add-pref-brand,
.btn-add-direct {
  position: relative;
  overflow: hidden;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--toyota-red) 0%, #C20A1A 100%);
  color: white;
  box-shadow:
    0 2px 0 rgba(0,0,0,0.4),
    0 4px 14px rgba(235,10,30,0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--toyota-red-h) 0%, var(--toyota-red) 100%);
  transform: translateY(-2px);
  box-shadow:
    0 4px 0 rgba(0,0,0,0.4),
    0 8px 24px rgba(235,10,30,0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    0 1px 0 rgba(0,0,0,0.4),
    0 2px 8px rgba(235,10,30,0.3);
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s, height 0.4s;
  pointer-events: none;
}

.btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

.btn-secondary {
  background: var(--surface2);
  border: 1px solid var(--border2);
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  border-color: var(--toyota-red);
  color: var(--toyota-red);
  transform: translateY(-1px);
}

/* ─── CARDS CON EFECTO LIFT ─── */
.list-card,
.stat-card,
.team-card,
.supplier-breakdown-card,
.panel {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.list-card::before,
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(235,10,30,0.04), transparent);
  transition: left 0.6s;
  pointer-events: none;
}

.list-card:hover,
.stat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(235,10,30,0.4);
  box-shadow:
    0 8px 24px rgba(0,0,0,0.5),
    0 0 0 1px rgba(235,10,30,0.1) inset;
}

.list-card:hover::before,
.stat-card:hover::before {
  left: 100%;
}

/* ─── SIDEBAR MEJORADA ─── */
.nav-item {
  position: relative;
  transition: all 0.25s ease;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 70%;
  background: var(--toyota-red);
  border-radius: 0 3px 3px 0;
  transition: transform 0.2s ease;
}

.nav-item:hover {
  background: rgba(235,10,30,0.06);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(235,10,30,0.12) 0%, rgba(235,10,30,0.02) 100%);
  color: var(--toyota-red);
  border-color: transparent;
}

.nav-item.active::before {
  transform: translateY(-50%) scaleY(1);
}

/* ─── PLAN BADGE ─── */
.plan-badge {
  background: linear-gradient(135deg, var(--toyota-red) 0%, #C20A1A 100%);
  color: white;
  border: none;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(235,10,30,0.25);
}

.user-avatar {
  background: linear-gradient(135deg, var(--toyota-red) 0%, #B30815 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(235,10,30,0.3);
}

/* ─── SPINNER MEJORADO (estilo speedometer) ─── */
.spinner {
  width: 56px;
  height: 56px;
  border: 3px solid var(--border);
  border-top-color: var(--toyota-red);
  border-right-color: var(--toyota-red);
  border-radius: 50%;
  position: relative;
  animation: spinFast 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.spinner::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 2px solid var(--border);
  border-bottom-color: var(--toyota-silver);
  border-radius: 50%;
  animation: spinSlow 1.4s linear infinite reverse;
}

@keyframes spinFast {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes spinSlow {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ─── VIEW HEADER REDISEÑADO ─── */
.view-header h1 {
  font-size: 2.2rem;
  text-transform: uppercase;
  position: relative;
  padding-bottom: 6px;
}

.view-header h1::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  width: 40px;
  height: 3px;
  background: var(--toyota-red);
  border-radius: 2px;
}

/* ─── CARDS DE COMPARACIÓN (rediseño limpio) ─── */
.product-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--carbon) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: all 0.25s ease;
}

.product-card:hover {
  border-color: rgba(235,10,30,0.3);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.product-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.product-card-code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(235,10,30,0.08);
  color: var(--toyota-red);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid rgba(235,10,30,0.2);
  white-space: nowrap;
}

.product-card-name {
  font-size: 0.98rem;
  font-weight: 600;
  flex: 1;
  line-height: 1.4;
}

.product-card-qty {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.product-pref-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(244,161,28,0.1);
  border: 1px solid rgba(244,161,28,0.3);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  color: var(--amber);
  margin-top: 4px;
}

/* Grid de marcas (filas por marca dentro de cada producto) */
.brand-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.brand-row.is-preferred {
  background: linear-gradient(90deg, rgba(244,161,28,0.08), var(--surface2));
  border-color: rgba(244,161,28,0.35);
}

.brand-row.is-winner {
  background: linear-gradient(90deg, rgba(12,192,120,0.07), var(--surface2));
  border-color: rgba(12,192,120,0.35);
  box-shadow: 0 2px 8px rgba(12,192,120,0.1);
}

.brand-row.is-preferred.is-winner {
  background: linear-gradient(90deg, rgba(244,161,28,0.12), rgba(235,10,30,0.06));
  border-color: var(--amber);
  box-shadow: 0 2px 12px rgba(244,161,28,0.2);
}

.brand-row-label {
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--purple);
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-row.is-preferred .brand-row-label {
  color: var(--amber);
}

.brand-row-suppliers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.supplier-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 110px;
  position: relative;
  transition: all 0.2s ease;
}

.supplier-pill.is-cheapest {
  border-color: var(--hybrid-green);
  background: rgba(12,192,120,0.06);
}

.supplier-pill.is-cheapest .supplier-pill-name {
  color: var(--hybrid-green);
  font-weight: 700;
}

.supplier-pill-name {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.supplier-pill-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.supplier-pill.is-cheapest .supplier-pill-price {
  color: var(--hybrid-green);
}

/* Botón hover "Agregar a pre-pedido" */
.supplier-pill .add-to-preorder-btn {
  position: absolute;
  top: 50%;
  right: -42px;
  transform: translateY(-50%);
  background: var(--toyota-red);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(235,10,30,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.supplier-pill:hover .add-to-preorder-btn {
  opacity: 1;
  visibility: visible;
  right: -42px;
  animation: bounceIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.supplier-pill .add-to-preorder-btn:hover {
  transform: translateY(-50%) scale(1.1);
  background: var(--toyota-red-h);
}

@keyframes bounceIn {
  0%   { transform: translateY(-50%) scale(0); }
  60%  { transform: translateY(-50%) scale(1.15); }
  100% { transform: translateY(-50%) scale(1); }
}

.brand-row-winner-tag {
  font-size: 0.7rem;
  background: var(--hybrid-green);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ─── PRE-PEDIDOS — VISTA NUEVA ─── */
.preorders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.preorder-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--carbon) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.preorder-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--toyota-red);
}

.preorder-card:hover {
  transform: translateY(-6px);
  border-color: var(--toyota-red);
  box-shadow:
    0 12px 32px rgba(0,0,0,0.5),
    0 0 0 1px rgba(235,10,30,0.2) inset;
}

.preorder-supplier-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  color: var(--text);
}

.preorder-stats {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.preorder-stat-label {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.preorder-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 1.1rem;
}

.preorder-stat-value.green {
  color: var(--hybrid-green);
}

.preorder-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.preorder-empty-icon {
  font-size: 3rem;
  margin-bottom: 14px;
  opacity: 0.4;
}

/* Detail view del pre-pedido */
.preorder-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-top: 16px;
}

.preorder-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}

.preorder-detail-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.8rem;
  letter-spacing: 0.04em;
}

.preorder-detail-total {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.4rem;
  color: var(--hybrid-green);
  font-weight: 700;
}

.btn-clear-preorder {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 8px;
  padding: 8px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
}

.btn-clear-preorder:hover {
  background: var(--red);
  color: white;
  box-shadow: 0 4px 12px rgba(255,77,109,0.4);
}

.preorder-item-row {
  display: grid;
  grid-template-columns: 110px 1fr 80px 90px 90px 30px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--surface2);
  transition: background 0.2s ease;
}

.preorder-item-row:hover {
  background: var(--carbon);
}

.preorder-item-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: var(--toyota-red);
  font-weight: 600;
}

.preorder-item-brand {
  display: inline-block;
  background: rgba(155,109,255,0.1);
  color: var(--purple);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.preorder-item-qty-input {
  width: 60px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  text-align: center;
  color: var(--text);
  font-family: 'Inter', sans-serif;
}

.preorder-item-qty-input:focus {
  outline: none;
  border-color: var(--toyota-red);
}

.preorder-item-price,
.preorder-item-subtotal {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  text-align: right;
}

.preorder-item-subtotal {
  color: var(--hybrid-green);
}

/* Animación entrada items */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.preorder-item-row,
.product-card {
  animation: slideInRight 0.3s ease backwards;
}

/* Toast mejorado */
.toast {
  border-radius: 12px;
  border: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-weight: 500;
}

.toast.success {
  background: linear-gradient(135deg, rgba(12,192,120,0.15), rgba(12,192,120,0.05));
  border-left: 4px solid var(--hybrid-green);
  color: var(--hybrid-green);
}

/* Botón flotante "Ver pre-pedidos" */
.preorder-floating-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: linear-gradient(135deg, var(--toyota-red), #C20A1A);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(235,10,30,0.4);
  transition: all 0.25s ease;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preorder-floating-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 32px rgba(235,10,30,0.6);
}

.preorder-floating-badge {
  background: white;
  color: var(--toyota-red);
  border-radius: 50%;
  min-width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.78rem;
}

/* ═══════════ PEDIDOS CONFIRMADOS ═══════════ */

.confirmed-orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.confirmed-order-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--carbon) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.confirmed-order-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.confirmed-order-card.status-pending::before  { background: var(--cian); }
.confirmed-order-card.status-received::before { background: var(--green); }
.confirmed-order-card.status-cancelled::before{ background: var(--red); }

.confirmed-order-card:hover {
  transform: translateY(-4px);
  border-color: var(--cian);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}

.confirmed-order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.confirmed-order-supplier {
  font-family: 'Bebas Neue', 'Inter', sans-serif;
  font-size: 1.45rem;
  letter-spacing: 0.03em;
}

.confirmed-order-status-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.status-pending  .confirmed-order-status-badge { background: rgba(0,212,200,0.15);  color: var(--cian); }
.status-received .confirmed-order-status-badge { background: rgba(57,217,138,0.15); color: var(--green); }
.status-cancelled .confirmed-order-status-badge{ background: rgba(255,77,109,0.15); color: var(--red); }

.confirmed-order-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--surface2);
  border-radius: 10px;
  margin-bottom: 12px;
}

.confirmed-order-meta-item {
  display: flex;
  flex-direction: column;
}

.confirmed-order-meta-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.confirmed-order-meta-value {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-weight: 700;
  font-size: 0.92rem;
}

.confirmed-order-meta-value.green { color: var(--green); }
.confirmed-order-meta-value.amber { color: var(--amber); }
.confirmed-order-meta-value.red   { color: var(--red); }

.days-countdown {
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  margin-top: 4px;
}

.days-countdown.urgent {
  background: rgba(255,77,109,0.1);
  color: var(--red);
  border: 1px solid rgba(255,77,109,0.3);
  animation: pulseRed 2s ease-in-out infinite;
}

.days-countdown.warning {
  background: rgba(245,166,35,0.1);
  color: var(--amber);
  border: 1px solid rgba(245,166,35,0.3);
}

.days-countdown.safe {
  background: rgba(57,217,138,0.08);
  color: var(--green);
  border: 1px solid rgba(57,217,138,0.25);
}

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,77,109,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(255,77,109,0); }
}

/* Botón "Realizar pedido" en preorder cards */
.btn-confirm-order {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  background: linear-gradient(135deg, var(--cian) 0%, #009b94 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.25s ease;
}

.btn-confirm-order:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,212,200,0.4);
}

/* Modal de confirmación */
.confirm-checklist {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
}

.confirm-item-row {
  display: grid;
  grid-template-columns: 32px 100px 1fr 70px 100px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.confirm-item-row:last-child { border-bottom: none; }

.confirm-item-row.received {
  background: rgba(57,217,138,0.05);
}

.confirm-item-row.not-received {
  background: rgba(255,77,109,0.04);
  opacity: 0.55;
}

.confirm-item-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--green);
}

/* Advertencia de duplicado */
.duplicate-warning {
  background: rgba(245,166,35,0.08);
  border: 1px solid rgba(245,166,35,0.4);
  border-radius: 12px;
  padding: 18px;
  margin: 16px 0;
}

.duplicate-warning h3 {
  color: var(--amber);
  margin: 0 0 10px;
  font-size: 1rem;
}

.duplicate-warning-list {
  margin: 10px 0;
  font-size: 0.88rem;
}

.duplicate-warning-list-item {
  background: var(--surface2);
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* Mejora del hover en supplier-pill (mejora 4) */
.supplier-pill {
  cursor: pointer;
}

.supplier-pill:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: var(--cian);
  background: linear-gradient(135deg, rgba(0,212,200,0.06) 0%, var(--surface2) 100%);
  box-shadow: 0 4px 16px rgba(0,212,200,0.15);
}

.supplier-pill:active {
  transform: translateY(0) scale(0.98);
}

.supplier-pill .add-hint {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--cian);
  color: var(--bg);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 10;
}

.supplier-pill:hover .add-hint {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Quitar el botón flotante "+" — ahora toda la pill es el botón */
.supplier-pill .add-to-preorder-btn {
  display: none !important;
}

/* ═══════════ PRESUPUESTOS ═══════════ */

.quote-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--carbon) 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  overflow: hidden;
}

.quote-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--cian), var(--green));
}

.quote-card:hover {
  transform: translateY(-4px);
  border-color: var(--cian);
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}

.quote-card-name {
  font-family: 'Bebas Neue', 'Inter', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.quote-card-desc {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.quote-card-stats {
  display: flex;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.quote-card-stat {
  display: flex;
  flex-direction: column;
}

.quote-card-stat-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quote-card-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--green);
}

/* Editor de plantilla */
.quote-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-top: 20px;
}

.quote-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.quote-editor-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.7rem;
}

.quote-item-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
}

.quote-item-row {
  display: grid;
  grid-template-columns: 32px 1fr 110px 50px;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.quote-item-row input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
}

.quote-item-row input:focus {
  outline: none;
  border-color: var(--cian);
}

.quote-brands-section {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.quote-brand-row {
  display: grid;
  grid-template-columns: 22px 1fr 120px 60px 30px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.quote-brand-row input[type="radio"] {
  cursor: pointer;
  accent-color: var(--amber);
}

.btn-mini {
  background: transparent;
  border: 1px dashed var(--border2);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

.btn-mini:hover {
  border-color: var(--cian);
  color: var(--cian);
}

/* Vista "Usar plantilla" */
.quote-use-row {
  display: grid;
  grid-template-columns: 32px 1fr 140px 110px 90px 90px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  transition: all 0.2s ease;
}

.quote-use-row.disabled {
  opacity: 0.5;
  background: rgba(255,77,109,0.03);
}

.quote-use-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--green);
}

.quote-use-row select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
}

.quote-use-row select:focus {
  outline: none;
  border-color: var(--cian);
}

.quote-use-row .price-display {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: right;
}

.quote-use-row .price-usd { color: var(--text); }
.quote-use-row .price-bcv { color: var(--cian); }

.bcv-info-banner {
  background: rgba(0,212,200,0.08);
  border: 1px solid rgba(0,212,200,0.3);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.bcv-info-banner .factor-display {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--cian);
}

.quote-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(135deg, rgba(0,212,200,0.08), rgba(57,217,138,0.05));
  border: 1px solid var(--cian);
  border-radius: 12px;
  margin-top: 16px;
}

.quote-total-block {
  text-align: center;
}

.quote-total-label {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.quote-total-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 1.6rem;
}

.quote-total-amount.usd { color: var(--text); }
.quote-total-amount.bcv { color: var(--cian); }

/* ═══════════ SIDEBAR COMPACTO ═══════════ */

.sidebar nav,
.sidebar-nav {
  gap: 1px !important;
}

.nav-item {
  padding: 8px 14px !important;
  font-size: 0.85rem !important;
  border-radius: 8px !important;
  min-height: unset !important;
  margin-bottom: 1px;
}

.nav-icon {
  font-size: 1rem !important;
  margin-right: 8px !important;
}

.nav-badge {
  font-size: 0.7rem !important;
  padding: 2px 6px !important;
  margin-left: auto !important;
}

/* Avatar y datos del usuario más compactos */
.user-section,
.user-info-block {
  padding: 10px 14px !important;
}

.user-name {
  font-size: 0.88rem !important;
}

.user-company {
  font-size: 0.74rem !important;
}

.user-avatar {
  width: 32px !important;
  height: 32px !important;
  font-size: 0.9rem !important;
}

.plan-badge {
  padding: 3px 8px !important;
  font-size: 0.7rem !important;
}

/* Si la sidebar tiene scroll, hacerla invisible pero funcional */
.sidebar {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

/* ═══════════ BARRA DE BÚSQUEDA — PRESUPUESTOS ═══════════ */
.quote-search-bar {
  width: 100%;
  margin: 0 0 20px 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.quote-search-bar input {
  width: 100%;
  padding: 9px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.quote-search-bar input::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.quote-search-bar input:focus {
  outline: none;
  border-color: var(--cian);
  box-shadow: 0 0 0 3px rgba(0,212,200,0.12);
}

/* ══════════════════════════════════════════════════════════════════ */
/* HUB OVERLAY — Pantalla de selección de módulo                       */
/* ══════════════════════════════════════════════════════════════════ */

.hub-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--bg) 0%, #0a1620 100%);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.hub-container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hub-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Clash Display', sans-serif;
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--text);
}

.hub-logo .logo-icon {
  color: var(--cian);
  font-size: 1.7rem;
}

.hub-logo .logo-text {
  letter-spacing: -0.02em;
}

.hub-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--muted);
}

.btn-logout-mini {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}

.btn-logout-mini:hover {
  border-color: #ff4757;
  color: #ff4757;
}

.hub-welcome {
  text-align: center;
  padding: 8px 0;
}

.hub-welcome h1 {
  font-family: 'Clash Display', sans-serif;
  font-weight: 600;
  font-size: 2.2rem;
  margin: 0 0 8px 0;
  color: var(--text);
  letter-spacing: -0.02em;
}

.hub-welcome p {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

.hub-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hub-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: 'DM Sans', sans-serif;
  text-align: left;
  width: 100%;
  color: var(--text);
}

.hub-card-active:hover {
  border-color: var(--cian);
  background: var(--surface2);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 212, 200, 0.12);
}

.hub-card-active:hover .hub-card-arrow {
  color: var(--cian);
  transform: translateX(4px);
}

.hub-card-icon {
  font-size: 2.4rem;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border-radius: 12px;
}
.hub-card-icon.icon-teal   { background: var(--cian-10);  border: 1px solid var(--cian-25); }
.hub-card-icon.icon-orange { background: var(--amber-12); border: 1px solid var(--amber-30); }
.hub-card-icon.icon-blue   { background: rgba(77,171,247,0.1); border: 1px solid rgba(77,171,247,0.3); }
.hub-card-icon.icon-red    { background: var(--red-10);   border: 1px solid var(--red-30); }

.hub-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hub-card-title {
  font-family: 'Clash Display', sans-serif;
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.hub-card-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.hub-card-arrow {
  font-size: 1.4rem;
  color: var(--muted);
  flex-shrink: 0;
  transition: all 0.25s ease;
  font-weight: 400;
}

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

.hub-card-disabled .hub-card-arrow {
  font-size: 0.78rem;
  font-style: italic;
}

/* Botón "Volver a Suite" en el sidebar */
.btn-back-to-hub {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.btn-back-to-hub:hover {
  border-color: var(--cian);
  color: var(--cian);
  background: var(--surface2);
}

/* Responsive móvil */
@media (max-width: 640px) {
  .hub-welcome h1 { font-size: 1.7rem; }
  .hub-card { padding: 18px 18px; gap: 14px; }
  .hub-card-icon { width: 48px; height: 48px; font-size: 2rem; }
  .hub-card-title { font-size: 1.1rem; }
  .hub-card-desc { font-size: 0.8rem; }
}

/* Fix: view del placeholder de Ventas — sin animación, opacity directa */
#view-sales-placeholder.active {
  opacity: 1 !important;
  animation: none !important;
}

/* ══════════════════════════════════════════════════════════════════ */
/* MÓDULO VENTAS — Estilos del salesApp                                */
/* ══════════════════════════════════════════════════════════════════ */

/* Contenedor principal — mismo layout que #app */
#salesApp {
  min-height: 100vh;
  display: flex;
}

/* Sidebar de Ventas — hereda casi todo de .sidebar, pero acento distinto */
.sidebar-sales .logo-icon {
  color: var(--cian);
  filter: drop-shadow(0 0 12px rgba(0, 212, 200, 0.5));
}

.sidebar-sales .nav-item.active {
  background: rgba(0, 212, 200, 0.1);
  color: var(--cian);
  border-left: 3px solid var(--cian);
}

/* Vistas del módulo Ventas */
.sales-view {
  display: none;
  padding: 36px 40px;
  animation: fadeIn 0.25s ease;
}

.sales-view.active {
  display: block;
}

/* Grid de datos generales (vendedor / cliente) */
.sale-header-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px 20px;
}

.sale-header-grid .form-group {
  margin: 0;
}

.sale-header-grid select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
}

.sale-header-grid select:focus {
  border-color: var(--cian);
  outline: none;
}

/* Header de la tabla de items */
.sale-items-header,
.sale-payments-header {
  display: grid;
  gap: 8px;
  padding: 10px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}

.sale-items-header {
  grid-template-columns: 130px 1fr 120px 60px 90px 90px 90px 40px;
}

.sale-payments-header {
  grid-template-columns: 180px 130px 1fr 40px;
}

/* Fila de item o pago */
.sale-item-row,
.sale-payment-row {
  display: grid;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.sale-item-row {
  grid-template-columns: 130px 1fr 120px 60px 90px 90px 90px 40px;
}

.sale-payment-row {
  grid-template-columns: 180px 130px 1fr 40px;
}

.sale-item-row input,
.sale-item-row select,
.sale-payment-row input,
.sale-payment-row select {
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  width: 100%;
}

.sale-item-row input:focus,
.sale-item-row select:focus,
.sale-payment-row input:focus,
.sale-payment-row select:focus {
  border-color: var(--cian);
  outline: none;
}

.sale-item-row input[type="number"],
.sale-payment-row input[type="number"] {
  text-align: right;
}

/* Rol Comprador (limitado): ocultar columna de costo en Registrar Venta */
.role-buyer-basic .sale-items-header,
.role-buyer-basic .sale-item-row {
  grid-template-columns: 130px 1fr 120px 60px 90px 90px 40px;
}
.role-buyer-basic .col-costo,
.role-buyer-basic .item-cost,
.role-buyer-basic .sf-cost {
  display: none;
}

/* Campos de las filas de venta/pago con su etiqueta: en escritorio la
   etiqueta no se ve (ya está el encabezado de la tabla); en celular sí. */
.sale-item-row .sf,
.sale-payment-row .sf {
  display: block;
  margin: 0;
  min-width: 0;
}
.sale-item-row .sf-label,
.sale-payment-row .sf-label {
  display: none;
}


.sale-item-subtotal {
  text-align: right;
  color: var(--cian);
  font-weight: 500;
  padding: 8px 4px;
  font-size: 0.9rem;
}

/* Botón X para quitar fila */
.btn-remove-row {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-remove-row:hover {
  border-color: #ff4757;
  color: #ff4757;
}

/* Panel-header con botón */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-mini {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--cian);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}

.btn-mini:hover {
  border-color: var(--cian);
  background: rgba(0, 212, 200, 0.1);
}

/* Totales */
.sale-totals {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

.sale-total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
}

.sale-total-row.sale-margin {
  color: #4ade80;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.sale-total-big {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--cian);
  font-family: 'Clash Display', sans-serif;
}

/* Resumen de pagos */
.sale-payment-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  font-size: 0.9rem;
}

.sale-payment-summary #salePaymentsTotal {
  color: var(--cian);
  font-weight: 600;
  font-size: 1.1rem;
}

.sale-payment-balance-ok {
  color: #4ade80;
  font-size: 0.82rem;
}

.sale-payment-balance-err {
  color: #ff4757;
  font-size: 0.82rem;
}

/* Autocompletado de código */
.code-autocomplete {
  position: absolute;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 240px;
  overflow-y: auto;
  min-width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.code-autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.code-autocomplete-item:hover,
.code-autocomplete-item.selected {
  background: var(--surface2);
}

.code-autocomplete-code {
  color: var(--cian);
  font-weight: 500;
}

.code-autocomplete-desc {
  color: var(--text);
  font-size: 0.82rem;
  margin-top: 2px;
}

.code-autocomplete-meta {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 2px;
}

/* Fix para el placeholder de Ventas cuando cargue por primera vez */
#view-sales-placeholder.active,
#sales-view-register.active,
#sales-view-list.active,
#sales-view-customers.active {
  opacity: 1 !important;
  animation: fadeIn 0.25s ease !important;
}

/* Rol Comprador (limitado): ocultar tarjetas y columnas de costo/margen en Métricas */
.role-buyer-basic #metricTotalCost,
.role-buyer-basic #metricTotalCost + .metric-label,
.role-buyer-basic .metric-card:has(#metricTotalCost),
.role-buyer-basic .metric-card:has(#metricMarginUsd),
.role-buyer-basic .metric-card:has(#metricMarginPercent) {
  display: none;
}

/* Responsive tabla de items en pantallas chicas */
@media (max-width: 1200px) {
  .sale-items-header,
  .sale-item-row {
    grid-template-columns: 110px 1fr 100px 55px 80px 80px 80px 36px;
    font-size: 0.78rem;
  }
  .role-buyer-basic .sale-items-header,
  .role-buyer-basic .sale-item-row {
    grid-template-columns: 110px 1fr 100px 55px 80px 80px 36px;
  }
}

/* Widget de tasa del día en sidebar de Ventas */
.sales-rate-widget {
  margin: 16px 20px;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}

.sales-rate-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.sales-rate-value {
  font-family: 'Clash Display', sans-serif;
  font-size: 1.05rem;
  color: var(--cian);
  font-weight: 600;
}

/* Fila de pago con moneda VES: mostrar equivalente USD al lado */
.pay-usd-preview {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 4px 8px;
  white-space: nowrap;
}

.pay-usd-preview.pay-usd-ok {
  color: #4ade80;
}

/* Ocultar flechas de incremento/decremento en inputs numéricos */
input[type="number"] {
  -moz-appearance: textfield; /* Firefox */
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none; /* Chrome, Edge, Safari */
  margin: 0;
}

/* ── Listado de ventas ── */
.sales-filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 12px;
  color: var(--muted);
}
.filter-group input,
.filter-group select {
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--cian);
  box-shadow: 0 0 0 3px var(--cian-10);
}

.sales-table {
  width: 100%;
  border-collapse: collapse;
}
.sales-table th {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.sales-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.sales-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}
.sales-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.paid      { background: rgba(34,197,94,0.15);  color: #22c55e; }
.status-badge.partial   { background: rgba(234,179,8,0.15);  color: #eab308; }
.status-badge.credit    { background: rgba(249,115,22,0.15); color: #f97316; }
.status-badge.cancelled { background: rgba(239,68,68,0.15);  color: #ef4444; }
/* ── Modal detalle ── */
.sale-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.sale-detail-modal {
  background: var(--bg-panel, #161616);
  border-radius: 10px;
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}
.sale-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-panel, #161616);
}
.btn-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.sale-detail-body { padding: 20px; }
.sale-detail-section { margin-bottom: 18px; }
.sale-detail-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.sale-detail-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.sale-detail-items-table td { padding: 6px 4px; }
.sale-detail-totals {
  display: flex;
  justify-content: space-between;
  padding-top: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  font-weight: 600;
}

.date-picker-wrapper {
  position: relative;
}
.date-picker-input {
  cursor: pointer;
  background: var(--bg-input, #1a1a1a);
}
.date-picker-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1100;
  background: var(--bg-panel, #161616);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.date-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.date-picker-title { font-weight: 600; font-size: 14px; }
.date-picker-nav {
  background: none;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
}
.date-picker-nav:hover { background: rgba(255,255,255,0.08); }
.date-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.date-picker-day {
  text-align: center;
  padding: 6px 0;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}
.date-picker-day:hover:not(.empty) { background: rgba(255,255,255,0.08); }
.date-picker-day.today { border: 1px solid var(--accent, #06b6d4); }
.date-picker-day.selected { background: var(--accent, #06b6d4); color: #fff; }
.date-picker-day.empty { cursor: default; }

.metrics-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.metric-card {
  position: relative;
  flex: 1;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--cian-25);
}
.metric-card-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1rem;
  background: var(--cian-10);
  border: 1px solid var(--cian-25);
  color: var(--cian);
}
.metric-card.warn .metric-card-icon {
  background: var(--amber-12);
  border-color: var(--amber-30);
  color: var(--amber);
}
.metric-card.danger .metric-card-icon {
  background: var(--red-10);
  border-color: var(--red-30);
  color: var(--red);
}
.metric-card.green .metric-card-icon {
  background: var(--green-10);
  border-color: var(--green-30);
  color: var(--green);
}
.metric-card.wide {
  flex-basis: 100%;
}
.metric-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-right: 40px;
}
.metric-value {
  font-family: 'Clash Display', sans-serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}
.metric-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ── Tarjetas de alerta del home (agotados / créditos / cuentas por pagar) ── */
.home-alert {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r);
  padding: 18px 20px 18px 24px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.home-alert::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--muted);
}
.home-alert.is-danger::before  { background: var(--red); }
.home-alert.is-warning::before { background: var(--amber); }
.home-alert.is-ok::before      { background: var(--green); }
.home-alert.is-clickable { cursor: pointer; }
.home-alert.is-clickable:hover {
  transform: translateY(-1px);
  border-color: var(--border2);
}
.home-alert-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}
.home-alert-body { flex: 1; min-width: 0; }
.home-alert-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 2px;
}
.home-alert.is-danger .home-alert-title  { color: var(--red); }
.home-alert.is-warning .home-alert-title { color: var(--amber); }
.home-alert.is-ok .home-alert-title      { color: var(--green); }
.home-alert-value {
  font-family: 'Clash Display', sans-serif;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.15;
}
.home-alert-hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 2px;
}
.home-alert-arrow {
  color: var(--muted);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ── Tarjeta con gradiente para métricas destacadas (ej. Capital dormido) ── */
.capital-card {
  background: linear-gradient(135deg, var(--bg-elevated), var(--surface));
  border: 1px solid var(--amber-30);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
}
.capital-card-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 1.3rem;
  background: var(--amber-12);
  border: 1px solid var(--amber-30);
  color: var(--amber);
}
.capital-card-body { flex: 1; min-width: 0; }
.capital-card-label {
  font-weight: 600;
  color: var(--amber);
  margin-bottom: 6px;
}
.capital-card-value {
  font-family: 'Clash Display', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}
.capital-card-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.inventory-row-review {
  background: rgba(234, 179, 8, 0.08);
}
.inventory-row-review input {
  border-color: #eab308 !important;
}

.inv-field-locked {
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--text) !important;
  padding: 4px 6px !important;
  cursor: default;
}
.inv-field-unlocked {
  background: var(--bg-input, #1a1a1a) !important;
  border: 1px solid var(--cian) !important;
  color: var(--text) !important;
  cursor: text;
}

/* Descripción del inventario: se ve completa (envuelve y crece con el texto) */
textarea.inv-edit-desc {
  width: 240px;
  max-width: 100%;
  min-height: 40px;
  font: inherit;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  field-sizing: content;   /* Chromium: alto automático según contenido */
  resize: vertical;
}
textarea.inv-edit-desc.inv-field-locked {
  resize: none;
  overflow: hidden;
}
#inventoryReadonlyBody td[data-label="Descripción"],
#inventoryListBody td {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.branch-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.branch-result-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface2);
  margin-bottom: 8px;
  border-left: 4px solid;
}

.agotado-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 340px;
  background: var(--surface);
  border: 1px solid #ef4444;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 2000;
  animation: slideUp 0.3s ease;
}
.agotado-toast + .agotado-toast {
  margin-bottom: 100px; /* apilar si hay varios */
}

/* ── Recorrido guiado (tour) ── */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 3000;
  pointer-events: auto;
}

.tour-spotlight {
  position: fixed;
  border-radius: 8px;
  box-shadow: 0 0 0 4px var(--cian), 0 0 0 9999px rgba(0, 0, 0, 0.65);
  z-index: 3001;
  pointer-events: none;
  transition: all 0.3s ease;
}

.tour-tooltip {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--cian);
  border-radius: 10px;
  padding: 18px;
  width: 320px;
  z-index: 3002;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.tour-tooltip h4 {
  margin: 0 0 8px 0;
  color: var(--cian);
  font-size: 1rem;
}

.tour-tooltip p {
  margin: 0 0 14px 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
}

.tour-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.tour-progress {
  font-size: 0.78rem;
  color: var(--muted);
}

.btn-tour-help {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s;
}

.btn-tour-help:hover {
  border-color: var(--cian);
  color: var(--cian);
}

/* ═══════════════════════════════════════════════════════════
   ADAPTACIÓN A PANTALLAS PEQUEÑAS Y LAPTOPS
   ═══════════════════════════════════════════════════════════ */

/* Las tablas anchas se desplazan horizontalmente DENTRO de su panel,
   en vez de empujar toda la página y cortar los botones de la derecha */
.panel {
  overflow-x: auto;
}

.sales-table {
  min-width: 100%;
}

/* Barra de desplazamiento visible pero discreta */
.panel::-webkit-scrollbar {
  height: 8px;
}
.panel::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 4px;
}
.panel::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Laptops (1366px y similares) ── */
@media (max-width: 1440px) {
  /* Menos aire alrededor: gana espacio útil sin sacrificar legibilidad */
  .view,
  .sales-view {
    padding: 24px 24px;
  }

  .panel {
    padding: 18px;
  }

  /* Tarjetas de métricas: que quepan más por fila */
  .metrics-cards {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  /* Tablas: un poco más compactas */
  .sales-table th,
  .sales-table td {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  /* Campos editables dentro de tablas (Inventario, revisión de carga) */
  .sales-table input[type="text"],
  .sales-table input[type="number"] {
    padding: 5px 7px;
    font-size: 0.82rem;
  }
}

/* ── Laptops pequeñas / tablets horizontales ── */
@media (max-width: 1200px) {
  /* Barra lateral compacta antes de los 900px, para ganar ancho útil */
  .sidebar {
    width: 190px;
  }
  .main-content {
    margin-left: 190px;
  }

  .view,
  .sales-view {
    padding: 20px 18px;
  }

  /* Formularios de 2-3 columnas pasan a 2 */
  .panel > div[style*="grid-template-columns:1fr 1fr 1fr"],
  .panel > div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ── Tablets y móviles ── */
@media (max-width: 900px) {
  /* Los formularios en cuadrícula pasan a una sola columna */
  .panel div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .metrics-cards {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  /* Filas de filtros y botones se acomodan en varias líneas */
  .sales-filters {
    flex-wrap: wrap;
  }

  .view-header {
    flex-wrap: wrap;
    gap: 10px;
  }
}

/* ── Móviles ── */
@media (max-width: 640px) {
  .view,
  .sales-view {
    padding: 16px 12px;
  }

  .panel {
    padding: 14px;
  }

  .metrics-cards {
    grid-template-columns: 1fr 1fr;
  }

  .metric-value {
    font-size: 1.3rem;
  }

  /* Modales a pantalla casi completa */
  .modal,
  .sale-detail-modal {
    max-width: 95vw !important;
    margin: 10px;
  }
}

/* ═══════════════════════════════════════════════════════════
   MÓVIL: menú desplegable y tablas como tarjetas
   ═══════════════════════════════════════════════════════════ */

/* Botón de menú (solo visible en móvil) */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1200;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Fondo oscuro al abrir el menú */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1050;
}

@media (max-width: 860px) {
  .mobile-menu-btn { display: flex; }
  .sidebar-backdrop.open { display: block; }

  /* El menú se sale de pantalla y entra al abrirlo */
  .sidebar,
  .sidebar-sales {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1100;
    width: 265px;
  }

  .sidebar.open,
  .sidebar-sales.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  /* El contenido ocupa todo el ancho */
  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding-top: 56px;  /* espacio para el botón de menú */
  }

  .view,
  .sales-view {
    padding: 14px 12px;
  }

  /* Tarjetas del Hub en una columna */
  .hub-grid {
    grid-template-columns: 1fr;
  }

  /* Métricas de dos en dos */
  .metrics-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-value { font-size: 1.25rem; }
  .metric-label { font-size: 0.72rem; }

  /* Encabezados más compactos */
  .view-header h1 {
    font-size: 1.25rem;
  }

  /* Modales casi a pantalla completa */
  .modal,
  .sale-detail-modal {
    max-width: 96vw !important;
    max-height: 90vh;
    margin: 8px;
  }

  /* Campos a 16px: evita que el móvil haga zoom al enfocarlos */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Botones más altos, para el dedo */
  .btn-primary, .btn-secondary {
    padding: 12px 16px;
    min-height: 44px;
  }
}

/* ── Tablas como tarjetas en móvil ──
   Cada fila se convierte en un bloque con etiqueta + valor.
   Requiere que el HTML tenga data-label en cada celda. */
@media (max-width: 640px) {
  .sales-table.stack-mobile thead {
    display: none;
  }

  .sales-table.stack-mobile,
  .sales-table.stack-mobile tbody,
  .sales-table.stack-mobile tr,
  .sales-table.stack-mobile td {
    display: block;
    width: 100%;
  }

  .sales-table.stack-mobile tr {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
  }

  .sales-table.stack-mobile td {
    border: none;
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: right;
  }

  .sales-table.stack-mobile td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    text-align: left;
    flex-shrink: 0;
  }

  /* Celdas sin etiqueta (botones) ocupan todo el ancho */
  .sales-table.stack-mobile td:not([data-label]) {
    justify-content: flex-end;
    padding-top: 10px;
  }
}

@media (max-width: 640px) {
  .branch-result-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

@media (max-width: 640px) {
  /* Gráficos de barras: desplazables si no caben */
  #expenseTrendChart {
    overflow-x: auto;
    min-width: 100%;
  }
  #expenseTrendChart > div {
    min-width: 55px;
  }
}
/* ═══════════════════════════════════════════════════════
   Pruebas finales 1 — componentes nuevos
   ═══════════════════════════════════════════════════════ */

/* Caja flotante "Cargando…" */
.pw-loading-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: none; align-items: center; justify-content: center;
  background: rgba(13, 18, 24, 0.55);
  backdrop-filter: blur(2px);
}
.pw-loading-box {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 18px 24px; max-width: min(420px, 90vw);
  box-shadow: 0 12px 40px var(--shadow-strong);
  color: var(--text); font-size: 0.95rem;
}
.pw-spinner, .btn-spinner {
  display: inline-block; border-radius: 50%;
  border: 3px solid var(--cian-25); border-top-color: var(--cian);
  animation: pwSpin 0.8s linear infinite; flex-shrink: 0;
}
.pw-spinner { width: 28px; height: 28px; }
.btn-spinner { width: 14px; height: 14px; border-width: 2px; vertical-align: -2px; }
@keyframes pwSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pw-spinner, .btn-spinner { animation-duration: 2s; } }

/* Paginador */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-top: 14px;
}
.pager:empty { display: none; }
.pager-info { color: var(--muted); font-size: 0.85rem; }
.pager-btns { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.pager-btn {
  min-width: 34px; padding: 5px 10px; border-radius: 6px; cursor: pointer;
  background: var(--surface2); border: 1px solid var(--border2); color: var(--text);
  font-family: inherit; font-size: 0.82rem;
}
.pager-btn:hover:not(:disabled) { border-color: var(--cian); color: var(--cian); }
.pager-btn:disabled { opacity: 0.4; cursor: default; }
.pager-btn.is-current { background: var(--cian-10); border-color: var(--cian); color: var(--cian); font-weight: 700; }
.pager-gap { color: var(--muted); padding: 0 4px; }

/* Login en dos pasos */
.login-email-chip {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 14px; font-size: 0.9rem; word-break: break-all;
}
.login-email-chip a { color: var(--cian); cursor: pointer; white-space: nowrap; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.6; cursor: wait; }

/* Configuración: WhatsApp e interruptores */
.wa-loading { color: var(--muted); display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.wa-autorefresh { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.feature-toggle {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 12px 0; border-top: 1px solid var(--border); cursor: pointer;
}
.feature-toggle:first-child { border-top: none; }
.feature-toggle-text { display: flex; flex-direction: column; gap: 4px; }
.feature-toggle-text span { color: var(--muted); font-size: 0.84rem; line-height: 1.5; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-slider {
  position: absolute; inset: 0; border-radius: 26px; transition: background .2s;
  background: var(--surface2); border: 1px solid var(--border2);
}
.switch-slider::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px;
  border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s;
}
.switch input:checked + .switch-slider { background: var(--cian-25); border-color: var(--cian); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); background: var(--cian); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--cian); outline-offset: 2px; }
.switch input:disabled + .switch-slider { opacity: 0.5; }

/* Mis Listas */
.nav-badge-warn { background: var(--amber) !important; color: #1a1a1a !important; }
.list-pending-banner {
  font-size: 0.82rem; font-weight: 600; color: var(--amber);
  background: var(--amber-12); border: 1px solid var(--amber-30);
  border-radius: 8px; padding: 6px 10px; margin-bottom: 10px;
}
.list-card-activated { font-size: 0.78rem; color: var(--muted); margin: -4px 0 10px; min-height: 1em; }

/* Registrar venta: código vinculado a Inventario o inexistente */
.sale-item-row.is-linked .item-code { border-color: var(--green-30); }
.sale-item-row.is-invalid .item-code { border-color: var(--amber); background: var(--amber-12); }
.code-autocomplete-empty { padding: 10px 12px; color: var(--amber); font-size: 0.85rem; }

/* Comparador: marca preferida */
.pref-missing-note {
  margin-top: 8px; font-size: 0.8rem; color: var(--amber);
  background: var(--amber-12); border-radius: 6px; padding: 6px 10px;
}
.brand-row-other-tag {
  font-size: 0.72rem; color: var(--muted); border: 1px dashed var(--border2);
  border-radius: 20px; padding: 3px 10px; white-space: nowrap;
}

/* Pedido manual (asistente) */
.order-wiz-steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.order-wiz-step {
  font-size: 0.8rem; padding: 4px 12px; border-radius: 20px;
  border: 1px solid var(--border2); color: var(--muted);
}
.order-wiz-step.is-active { border-color: var(--cian); color: var(--cian); background: var(--cian-10); font-weight: 600; }
.order-wiz-step.is-done { color: var(--green); border-color: var(--green-30); }
.order-wiz-search {
  width: 100%; padding: 9px 14px; margin-bottom: 12px;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 8px;
  color: var(--text); font-family: inherit;
}
.order-wiz-table { max-height: 50vh; overflow: auto; }
.order-wiz-add { display: flex; gap: 6px; align-items: center; }
.order-wiz-add input, .order-wiz-num {
  width: 70px; padding: 5px 8px; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 6px; color: var(--text); font-family: inherit;
}
.order-wiz-num { width: 90px; }
.order-wiz-table tr.is-in-cart td { background: var(--green-10); }
.order-wiz-cartbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  margin-top: 14px; padding: 10px 14px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border2); font-weight: 600;
}
.order-wiz-total { text-align: right; margin-top: 12px; font-size: 1.05rem; }
.order-wiz-total strong { color: var(--cian); font-size: 1.25rem; }

/* Registro de actividad */
.audit-row { cursor: pointer; }
.audit-row:hover td, .audit-row:focus td { background: var(--surface2); }
.audit-row:focus { outline: 1px solid var(--cian); }
.audit-open-hint { color: var(--cian); font-size: 0.78rem; margin-left: 6px; white-space: nowrap; }
.audit-detail-head { margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; }
.audit-detail-head p { color: var(--muted); margin-top: 4px; }
.audit-sub { margin: 16px 0 8px; font-size: 0.95rem; }
.audit-diff-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin-top: 8px; }
.audit-diff-table th, .audit-diff-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.audit-diff-table th { color: var(--muted); font-weight: 600; }
.audit-diff-table tr.is-changed td { background: var(--amber-12); }
.audit-diff-table em { color: var(--muted); }
.audit-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.audit-no-detail { color: var(--muted); font-style: italic; margin-top: 10px; }

@media (max-width: 640px) {
  .order-wiz-add { flex-direction: column; align-items: stretch; }
  .order-wiz-add input { width: 100%; }
  .pager { justify-content: center; }
}

/* ─── Inventario: aviso de búsqueda aproximada ─── */
.inv-aprox-note {
  margin: 0 0 12px; padding: 10px 14px;
  background: var(--amber-12); border: 1px solid var(--amber-30);
  border-radius: 8px; color: var(--amber); font-size: 0.86rem;
}

/* ─── Bot de ventas (sección oculta de Administrador) ─── */
.bot-private-note { color: var(--muted); font-size: 0.84rem; margin: -6px 0 18px; }
.bot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.bot-grid > .panel { margin-bottom: 20px; }
#admin-view-bot .filter-group { margin-bottom: 14px; }
#admin-view-bot .filter-group input,
#admin-view-bot .filter-group select,
#admin-view-bot .filter-group textarea { width: 100%; }
#admin-view-bot .filter-group textarea {
  padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); resize: vertical;
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem; line-height: 1.4;
}
#admin-view-bot .filter-group textarea:focus { outline: none; border-color: var(--cian); box-shadow: 0 0 0 3px var(--cian-10); }
.bot-field-hint { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 4px; line-height: 1.4; }
p.bot-field-hint { margin: 0 0 14px; }
.bot-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.bot-search-form, .bot-inline-form {
  display: grid; gap: 12px; align-items: end; margin-bottom: 14px;
}
.bot-search-form { grid-template-columns: 2fr 1.2fr 0.7fr 0.9fr auto; }
.bot-inline-form { grid-template-columns: 1fr 1fr auto; }
.bot-search-form .filter-group, .bot-inline-form .filter-group { margin-bottom: 0 !important; }
.bot-search-form .btn-primary, .bot-inline-form .btn-primary { height: 40px; white-space: nowrap; }

.bot-search-summary { color: var(--muted); font-size: 0.86rem; margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.bot-search-summary strong { color: var(--text); font-weight: 600; }
.bot-table-wrap { overflow-x: auto; }
.bot-cell-desc { min-width: 220px; }
.bot-cell-code { font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; white-space: nowrap; }
.bot-cell-sub { color: var(--muted); font-size: 0.76rem; margin-top: 3px; }
.bot-tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.74rem;
  font-weight: 600; white-space: nowrap; margin: 1px 4px 1px 0;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
}
.bot-tag.ok   { background: var(--green-10); color: var(--green); border-color: var(--green-30); }
.bot-tag.warn { background: var(--amber-12); color: var(--amber); border-color: var(--amber-30); }
.bot-tag.bad  { background: var(--red-10);   color: var(--red);   border-color: var(--red-30); }
.bot-empty { color: var(--muted); text-align: center; padding: 20px; }

.bot-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.bot-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px;
  border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); font-size: 0.84rem;
}
.bot-chip .eq { color: var(--muted); }
.bot-chip button {
  background: none; border: none; color: var(--muted); cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%; font-size: 0.9rem; line-height: 1;
}
.bot-chip button:hover, .bot-chip button:focus-visible { background: var(--red-10); color: var(--red); outline: none; }
.bot-chip.fabrica { padding-right: 12px; }
.bot-details { margin-top: 14px; }
.bot-details summary { cursor: pointer; color: var(--muted); font-size: 0.86rem; }
.bot-details[open] summary { margin-bottom: 10px; }

.bot-key-new {
  margin: 0 0 14px; padding: 14px; border-radius: 10px;
  background: var(--green-10); border: 1px solid var(--green-30);
}
.bot-key-new p { font-size: 0.86rem; margin-bottom: 8px; }
.bot-key-new .bot-key-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bot-key-new code {
  flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; padding: 8px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); font-family: 'JetBrains Mono', monospace; font-size: 0.8rem;
}

@media (max-width: 900px) {
  .bot-grid { grid-template-columns: 1fr; }
  .bot-search-form { grid-template-columns: 1fr 1fr; }
  .bot-search-form .bot-search-q { grid-column: 1 / -1; }
  .bot-inline-form { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .bot-search-form { grid-template-columns: 1fr; }
}

/* Vista previa del mensaje del bot (estilo chat) */
.bot-preview {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px;
  margin: 6px 0 18px; padding: 16px; border-radius: 12px;
  background: var(--surface2); border: 1px solid var(--border);
}
.bot-preview-chat { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.bot-preview-head { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
.bot-bubble {
  max-width: 92%; padding: 10px 12px; border-radius: 12px; font-size: 0.9rem; line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.bot-bubble-in  { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; }
.bot-bubble-out { align-self: flex-end; background: var(--green-10); border: 1px solid var(--green-30); border-top-right-radius: 4px; }
.bot-bubble strong { font-weight: 700; }
.bot-preview-side { min-width: 0; }
.bot-preview-tipo { font-weight: 600; margin-bottom: 8px; }
.bot-preview-acciones { margin: 0 0 12px 18px; color: var(--text); font-size: 0.86rem; line-height: 1.5; }
.bot-preview-acciones:empty { display: none; }
@media (max-width: 900px) {
  .bot-preview { grid-template-columns: 1fr; }
  .bot-search-form { grid-template-columns: 1fr 1fr; }
}
.bot-variante td { border-top-color: transparent; }
.bot-variante .bot-cell-code { color: var(--muted); }

/* Nomenclaturas de vehículos */
.bot-nom-form {
  display: grid; gap: 10px 12px; align-items: end; margin-bottom: 14px;
  grid-template-columns: 1.2fr 1.2fr 1.1fr 0.7fr 0.7fr 0.9fr 0.9fr auto auto;
}
.bot-nom-form .filter-group { margin-bottom: 0 !important; }
.bot-nom-form .btn-primary { height: 40px; white-space: nowrap; }
.bot-check { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--muted); height: 40px; white-space: nowrap; }
.bot-check input { width: 16px; height: 16px; }
@media (max-width: 1200px) { .bot-nom-form { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .bot-nom-form { grid-template-columns: 1fr 1fr; } }

/* Sección de productos agotados: nota de cuándo salen de la lista */
.agotados-nota { color: var(--muted); font-size: 0.82rem; margin: 0 0 8px; }

/* ── Espera del comparador (10 s) ── */
.cmp-espera {
  margin-top: 24px; padding: 32px 20px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.cmp-espera-icono { position: relative; width: 96px; height: 72px; margin: 0 auto 14px; }
.cmp-espera-hoja {
  position: absolute; top: 8px; width: 40px; height: 52px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--border2);
  box-shadow: 0 4px 12px var(--shadow-soft);
  animation: cmp-barajar 1.8s ease-in-out infinite;
}
.cmp-espera-hoja::before, .cmp-espera-hoja::after {
  content: ""; position: absolute; left: 7px; right: 7px; height: 4px; border-radius: 2px; background: var(--cian-25);
}
.cmp-espera-hoja::before { top: 12px; }
.cmp-espera-hoja::after  { top: 22px; right: 14px; }
.cmp-espera-hoja:nth-child(1) { left: 6px;  transform: rotate(-10deg); animation-delay: 0s; }
.cmp-espera-hoja:nth-child(2) { left: 28px; z-index: 1; animation-delay: .3s; }
.cmp-espera-hoja:nth-child(3) { left: 50px; transform: rotate(10deg); animation-delay: .6s; }
.cmp-espera-lupa {
  position: absolute; right: -6px; bottom: -6px; z-index: 2; font-size: 30px;
  filter: drop-shadow(0 0 8px var(--cian-25));
  animation: cmp-lupa 2.4s ease-in-out infinite;
}
@keyframes cmp-barajar { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
@keyframes cmp-lupa {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-34px, -10px) rotate(-12deg); }
  50% { transform: translate(-62px, 2px) rotate(0deg); }
  75% { transform: translate(-30px, 8px) rotate(10deg); }
}
.cmp-espera-titulo { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.cmp-espera-paso { margin: 6px 0 16px; min-height: 1.4em; color: var(--cian); font-size: 0.92rem; }
.cmp-espera-barra {
  max-width: 420px; height: 8px; margin: 0 auto; overflow: hidden;
  background: var(--surface2); border-radius: 999px;
}
.cmp-espera-progreso {
  width: 0; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--cian), var(--cian2));
  box-shadow: 0 0 12px var(--cian-25);
  transition-property: width; transition-timing-function: cubic-bezier(.4, .1, .3, 1);
}
.cmp-espera-listas { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 16px; }
.cmp-espera-chip {
  font-size: 0.75rem; padding: 3px 10px; border-radius: 999px;
  color: var(--muted); border: 1px solid var(--border); transition: all .3s;
}
.cmp-espera-chip.is-lista { color: var(--cian); border-color: var(--cian-25); background: var(--cian-10); }
.cmp-espera-chip.is-lista::before { content: "✓ "; }
@media (prefers-reduced-motion: reduce) {
  .cmp-espera-hoja, .cmp-espera-lupa { animation: none; }
}

/* ── Pedido manual: ventana más ancha, sin barras a la vista y sin arrastrar a un lado ── */
.modal.modal-lg.order-wizard { max-width: min(1080px, 96vw); padding: 24px 28px; }
.order-wizard, .order-wiz-table {
  scrollbar-width: thin;                     /* Firefox: fina y casi invisible */
  scrollbar-color: transparent transparent;
}
.order-wizard:hover, .order-wiz-table:hover { scrollbar-color: var(--border2) transparent; }
.order-wizard::-webkit-scrollbar, .order-wiz-table::-webkit-scrollbar { width: 6px; height: 6px; }
.order-wizard::-webkit-scrollbar-track, .order-wiz-table::-webkit-scrollbar-track { background: transparent; }
.order-wizard::-webkit-scrollbar-thumb, .order-wiz-table::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.order-wizard:hover::-webkit-scrollbar-thumb, .order-wiz-table:hover::-webkit-scrollbar-thumb { background: var(--border2); }
.order-wiz-table { overflow-x: hidden; margin-top: 8px; }
.order-wiz-grid { table-layout: fixed; width: 100%; }
.order-wiz-grid col.c-code  { width: 17%; }
.order-wiz-grid col.c-brand { width: 13%; }
.order-wiz-grid col.c-price { width: 10%; }
.order-wiz-grid col.c-qty   { width: 150px; }
.order-wiz-grid col.c-num   { width: 96px; }
.order-wiz-grid col.c-sub   { width: 11%; }
.order-wiz-grid col.c-del   { width: 44px; }
.order-wiz-grid th, .order-wiz-grid td { padding: 8px 10px; }
.order-wiz-grid thead th { position: sticky; top: 0; z-index: 1; }
/* El texto largo se parte en varias líneas en vez de empujar la tabla a un lado */
.order-wiz-grid td { white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }
.order-wiz-grid td:first-child { font-size: 0.76rem; }
.order-wiz-grid .order-wiz-add { gap: 4px; }
.order-wiz-grid .order-wiz-add input { width: 52px; }
.order-wiz-grid .order-wiz-num { width: 100%; }
.order-wiz-grid .btn-mini { white-space: nowrap; }
/* En el celular cada producto es una tarjeta: código y precio arriba, el nombre
   completo en el medio, marca y cantidad abajo (nada se corta ni se arrastra) */
@media (max-width: 640px) {
  .modal.modal-lg.order-wizard { padding: 18px 12px; }
  .order-wiz-grid, .order-wiz-grid tbody { display: block; }
  .order-wiz-grid colgroup, .order-wiz-grid thead { display: none; }
  .order-wiz-grid tr {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px;
    padding: 10px 6px; border-bottom: 1px solid var(--border);
  }
  .order-wiz-grid td { display: block; padding: 0; border: none; font-size: 0.86rem; }
  .order-wiz-grid td[colspan] { grid-column: 1 / -1; }
  /* Paso 2: código | precio · nombre · marca | cantidad */
  #orderWizItemsBody td:nth-child(1) { grid-area: 1 / 1; }
  #orderWizItemsBody td:nth-child(4) { grid-area: 1 / 2; text-align: right; }
  #orderWizItemsBody td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; font-weight: 500; }
  #orderWizItemsBody td:nth-child(3) { grid-area: 3 / 1; align-self: center; }
  #orderWizItemsBody td:nth-child(5) { grid-area: 3 / 2; }
  #orderWizItemsBody .order-wiz-add { flex-direction: row; align-items: center; }
  #orderWizItemsBody .order-wiz-add input { width: 56px; }
  #orderWizItemsBody tr.is-in-cart { background: var(--green-10); border-radius: 8px; }
  #orderWizItemsBody tr.is-in-cart td { background: none; }
  /* Paso 3: código | quitar · nombre · marca | subtotal · cantidad | precio */
  #orderWizSummaryBody tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  #orderWizSummaryBody td:nth-child(1) { grid-area: 1 / 1 / 2 / 3; }
  #orderWizSummaryBody td:nth-child(7) { grid-area: 1 / 3; }
  #orderWizSummaryBody td:nth-child(2) { grid-area: 2 / 1 / 3 / 4; font-weight: 500; }
  #orderWizSummaryBody td:nth-child(3) { grid-area: 3 / 1 / 4 / 3; }
  #orderWizSummaryBody td:nth-child(6) { grid-area: 3 / 3; text-align: right; font-weight: 600; }
  #orderWizSummaryBody td:nth-child(4) { grid-area: 4 / 1; }
  #orderWizSummaryBody td:nth-child(5) { grid-area: 4 / 2 / 5 / 4; }
  #orderWizSummaryBody td:nth-child(4)::before { content: "Cant."; display: block; color: var(--muted); font-size: 0.72rem; }
  #orderWizSummaryBody td:nth-child(5)::before { content: "Precio u."; display: block; color: var(--muted); font-size: 0.72rem; }
}

/* Cuentas por Pagar: barra con buscador y filtro de estado */
.debts-toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.debts-toolbar .panel-header { margin-right: auto !important; align-self: center; }
.debts-search { flex: 1 1 260px; max-width: 380px; margin-bottom: 0 !important; }
.debts-search input { width: 100%; }

/* ── Confirmación antes de registrar mercancía ── */
.confirm-overlay { z-index: 900; }
.confirm-modal { max-width: 460px; text-align: center; padding: 28px 28px 22px; }
.confirm-icono {
  width: 56px; height: 56px; margin: 0 auto 10px; display: grid; place-items: center;
  font-size: 28px; border-radius: 50%; background: var(--cian-10); border: 1px solid var(--cian-25);
}
.confirm-modal h2 { font-family: 'Clash Display', sans-serif; font-size: 1.2rem; margin: 0 0 4px; }
.confirm-intro { color: var(--muted); font-size: 0.88rem; margin: 0 0 12px; }
.confirm-resumen {
  margin: 0; padding: 4px 14px; text-align: left; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border);
}
.confirm-resumen > div {
  display: flex; justify-content: space-between; gap: 16px; padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.confirm-resumen > div:last-child { border-bottom: none; }
.confirm-resumen dt { color: var(--muted); font-size: 0.86rem; }
.confirm-resumen dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.confirm-aviso {
  margin: 12px 0 0; padding: 8px 12px; border-radius: 8px; text-align: left; font-size: 0.85rem;
  background: var(--amber-12); border: 1px solid var(--amber-30); color: var(--amber);
}
.confirm-pregunta { margin: 14px 0 0; font-weight: 600; }
.confirm-modal .modal-footer { justify-content: center; margin-top: 18px; padding-top: 16px; }

/* ── Ventas: separar por estado (botones rápidos) ── */
.sales-status-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.status-chip {
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 0.82rem;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
  transition: background .15s, color .15s, border-color .15s;
}
.status-chip:hover { color: var(--text); border-color: var(--border2); }
.status-chip:focus-visible { outline: 2px solid var(--cian); outline-offset: 2px; }
.status-chip.is-active { background: var(--cian-10); color: var(--cian); border-color: var(--cian-25); font-weight: 600; }

/* ── Perfil del cliente: sus ventas ── */
.cliente-ventas-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cliente-ventas-total { color: var(--muted); font-weight: 500; margin-left: 6px; }
.cliente-venta-fila { cursor: pointer; }
.cliente-venta-fila:focus-visible { outline: 2px solid var(--cian); outline-offset: -2px; }

/* ═══════════════════════════════════════════════════════
   MODO CLARO (botón ☀️/🌙 junto a "Salir"; se recuerda en este navegador)
   Mismos colores de marca, oscurecidos lo justo para leerse sobre blanco.
   ═══════════════════════════════════════════════════════ */
html[data-theme="light"] {
  color-scheme: light;
  --bg:       #f3f6f9;
  --surface:  #ffffff;
  --surface2: #eef2f6;
  --border:   #d8e0e8;
  --border2:  #c5d0dc;
  --cian:     #00968e;
  --cian2:    #00b5ab;
  --amber:    #b8730a;
  --red:      #d92f4f;
  --green:    #18965a;
  --purple:   #7446d6;
  --text:     #17212c;
  --muted:    #5b6878;
  --shadow-soft:   rgba(23, 33, 44, 0.08);
  --shadow-strong: rgba(23, 33, 44, 0.18);
  --border-subtle: rgba(23, 33, 44, 0.07);
  --bg-elevated:   #ffffff;
  --bg-panel:      #ffffff;
  --bg-input:      #f6f8fb;
  --cian-10: rgba(0, 150, 142, 0.09);
  --cian-25: rgba(0, 150, 142, 0.28);
  --amber-12: rgba(184, 115, 10, 0.1);
  --amber-30: rgba(184, 115, 10, 0.32);
  --red-10: rgba(217, 47, 79, 0.08);
  --red-30: rgba(217, 47, 79, 0.3);
  --green-10: rgba(24, 150, 90, 0.09);
  --green-30: rgba(24, 150, 90, 0.3);
  --toyota-red:    #00968e;
  --toyota-red-h:  #00b5ab;
  --toyota-silver: #5b6878;
  --hybrid-green:  #18965a;
  --carbon:        #ffffff;
}
html[data-theme="light"] body { background: var(--bg); color: var(--text); }
html[data-theme="light"] .hub-overlay { background: linear-gradient(135deg, #f3f6f9 0%, #e3edf3 100%); }
html[data-theme="light"] .sales-table tbody tr:hover,
html[data-theme="light"] .date-picker-nav:hover,
html[data-theme="light"] .date-picker-day:hover:not(.empty) { background: rgba(23, 33, 44, 0.05); }
html[data-theme="light"] .pw-loading-overlay { background: rgba(243, 246, 249, 0.6); }
html[data-theme="light"] .modal-overlay,
html[data-theme="light"] .sale-detail-overlay { background: rgba(23, 33, 44, 0.45); }
html[data-theme="light"] .modal,
html[data-theme="light"] .panel { box-shadow: 0 1px 3px var(--shadow-soft); }
html[data-theme="light"] .status-badge.paid      { color: #15803d; background: rgba(21, 128, 61, 0.1); }
html[data-theme="light"] .status-badge.partial   { color: #a16207; background: rgba(161, 98, 7, 0.1); }
html[data-theme="light"] .status-badge.credit    { color: #c2410c; background: rgba(194, 65, 12, 0.1); }
html[data-theme="light"] .status-badge.cancelled { color: #b91c1c; background: rgba(185, 28, 28, 0.08); }
/* Colores escritos directo en el HTML que sobre blanco casi no se leen */
html[data-theme="light"] [style*="color:#39d98a"], html[data-theme="light"] [style*="color: #39d98a"],
html[data-theme="light"] [style*="color:#22c55e"] { color: #15803d !important; }
html[data-theme="light"] [style*="color:#f5a623"], html[data-theme="light"] [style*="color: #f5a623"],
html[data-theme="light"] [style*="color:#eab308"] { color: #a16207 !important; }
html[data-theme="light"] [style*="color:#ff4d6d"] { color: #c81e45 !important; }
html[data-theme="light"] [style*="background:rgba(13,18,24"] { background: rgba(243, 246, 249, 0.97) !important; }
html[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c5d0dc; }

/* Botón para cambiar de modo: junto a "Salir", nunca encima del contenido */
.btn-tema {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; cursor: pointer; font: inherit; font-size: 0.8rem;
  padding: 6px 10px; transition: border-color .2s, color .2s, background .2s;
}
.btn-tema:hover { border-color: var(--cian); color: var(--cian); }
.btn-tema:focus-visible { outline: 2px solid var(--cian); outline-offset: 2px; }
.btn-tema .tema-icono { font-size: 0.95rem; line-height: 1; }
.sidebar-footer .footer-acciones { display: flex; gap: 8px; }
.sidebar-footer .footer-acciones .btn-logout { flex: 1; }
.sidebar-footer .footer-acciones .btn-tema { padding: 7px 10px; }
@media (max-width: 600px) {
  .hub-user .btn-tema .tema-texto { display: none; }   /* en el celular, solo el ícono */
}

/* Va al final del archivo para ganarle a la regla de 1200px de las filas de venta. */
/* Celular: cada producto y cada pago es una tarjeta con etiquetas, sin
   desplazar la tabla hacia los lados. */
@media (max-width: 640px) {
  .sale-items-header,
  .sale-payments-header {
    display: none;
  }
  .sale-item-row,
  .role-buyer-basic .sale-item-row {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-areas:
      "code  code  code  brand brand del"
      "desc  desc  desc  desc  desc  desc"
      "qty   qty   price price cost  cost"
      "sub   sub   sub   sub   sub   sub";
    gap: 6px 8px;
    padding: 12px;
    font-size: 0.85rem;
  }
  .role-buyer-basic .sale-item-row {
    grid-template-areas:
      "code  code  code  brand brand del"
      "desc  desc  desc  desc  desc  desc"
      "qty   qty   qty   price price price"
      "sub   sub   sub   sub   sub   sub";
  }
  .sale-item-row .sf-code  { grid-area: code; }
  .sale-item-row .sf-desc  { grid-area: desc; }
  .sale-item-row .sf-brand { grid-area: brand; }
  .sale-item-row .sf-qty   { grid-area: qty; }
  .sale-item-row .sf-price { grid-area: price; }
  .sale-item-row .sf-cost  { grid-area: cost; }
  .sale-item-row .sale-item-subtotal { grid-area: sub; padding: 2px 4px; }
  .sale-item-row .sale-item-subtotal::before { content: "Subtotal: "; color: var(--muted); font-weight: 400; }
  .sale-item-row .btn-remove-row { grid-area: del; justify-self: end; }
  .sale-item-row .sf-label,
  .sale-payment-row .sf-label {
    display: block;
    font-size: 0.7rem;
    color: var(--muted);
    margin-bottom: 2px;
  }
  .sale-item-row input,
  .sale-payment-row input,
  .sale-payment-row select {
    font-size: 16px;  /* evita que el celular haga zoom al escribir */
  }
  .sale-payment-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "method method method del"
      "amount amount ref    ref"
      "days   days   .      .";
    gap: 6px 8px;
    padding: 12px;
  }
  .sale-payment-row .pay-method      { grid-area: method; }
  .sale-payment-row .sf-amount       { grid-area: amount; }
  .sale-payment-row .sf-ref          { grid-area: ref; }
  .sale-payment-row .pay-credit-days { grid-area: days; width: 100% !important; }
  .sale-payment-row .btn-remove-row  { grid-area: del; justify-self: end; }
}

/* "Administrador" es el título más largo de los módulos y en pantallas
   medianas (barra lateral angosta) se cortaba: "Administrac…". */
@media (max-width: 1200px) {
  #adminApp .sidebar-logo { padding-left: 14px; padding-right: 14px; }
  #adminApp .logo-text { font-size: 1.05rem; white-space: nowrap; }
}
