/* ═══════════════════════════════════════════════════════════
   B2YOU — Sistema de diseño
   Paleta: cream #F5F1EB | cognac #6B463F | dark #1A1614
   Tipografía: Playfair Display + DM Sans + DM Mono
   ═══════════════════════════════════════════════════════════ */

/* ── CSS VARIABLES ──────────────────────────────────────── */
:root {
  /* Colores principales */
  --cream:       #F5F1EB;
  --cream-dark:  #EDE8DF;
  --cream-deep:  #E0D9CE;
  --cognac:      #6B463F;
  --cognac-light:#8A5E56;
  --cognac-deep: #4F3029;
  --noir:        #1A1614;
  --noir-soft:   #2C2421;

  /* Tema claro (default) */
  --bg:          var(--cream);
  --bg-card:     #FFFFFF;
  --bg-sidebar:  var(--cognac-deep);
  --bg-hover:    var(--cream-dark);
  --border:      #D8D0C4;
  --border-light:#EBE5DC;
  --text:        #2A1F1B;
  --text-muted:  #7A6A63;
  --text-sidebar:#F0E8E2;
  --accent:      var(--cognac);
  --accent-hover:var(--cognac-light);
  --shadow:      0 2px 12px rgba(107,70,63,0.10);
  --shadow-lg:   0 8px 32px rgba(107,70,63,0.15);

  /* Tipografía */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  /* Layout */
  --sidebar-w:   240px;
  --sidebar-collapsed: 64px;
  --topbar-h:    68px;
  --radius:      10px;
  --radius-sm:   6px;
  --radius-lg:   16px;
  --transition:  0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg:          #1A1614;
  --bg-card:     #231E1B;
  --bg-sidebar:  #120E0C;
  --bg-hover:    #2C2421;
  --border:      #3D3330;
  --border-light:#2C2421;
  --text:        #F0E8E2;
  --text-muted:  #9A8A83;
  --text-sidebar:#E8DDD8;
  --shadow:      0 2px 12px rgba(0,0,0,0.35);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.50);
}

/* ── HIDE NUMBER SPINNERS ─────────────────────────────── */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

/* ── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .logo-2,
.sidebar.collapsed .logo-you { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .logo-b { font-size: 1.5rem; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--cream);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.logo-b { color: #F5F1EB; }
.logo-2 { color: var(--cognac-light); transition: var(--transition); }
.logo-you { color: #F5F1EB; transition: var(--transition); }

.sidebar-toggle {
  color: rgba(255,255,255,0.4);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { color: white; background: rgba(255,255,255,0.1); }
.sidebar.collapsed .sidebar-toggle svg { transform: rotate(180deg); }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(240,232,226,0.65);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,0.10);
  color: var(--cream);
}
.nav-item.active {
  background: rgba(245,241,235,0.15);
  color: var(--cream);
  font-weight: 600;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--cognac-light);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.75;
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-label { transition: var(--transition); }
.nav-separator { height: 1px; background: rgba(255,255,255,0.08); margin: 12px 0; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(240,232,226,0.55);
  font-size: 0.875rem;
  font-weight: 500;
  width: 100%;
  transition: var(--transition);
}
.theme-toggle:hover { background: rgba(255,255,255,0.08); color: var(--cream); }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

.logout-btn { width: 100%; color: rgba(240,232,226,0.55) !important; }
.logout-btn:hover { background: rgba(200,80,60,0.15) !important; color: #F08080 !important; }

/* ── MAIN CONTENT ───────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}
.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background var(--transition), border-color var(--transition);
}

.topbar-left { display: flex; align-items: baseline; gap: 14px; }
.page-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }

.user-badge {
  background: var(--cream-dark);
  color: var(--cognac);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
[data-theme="dark"] .user-badge { background: var(--bg-hover); color: var(--cognac-light); }

/* ── CONTENT AREA ───────────────────────────────────────── */
.content-area {
  flex: 1;
  padding: 28px 32px 40px;
}

/* ── ALERTS (toast overlay) ─────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  right: 24px;
  z-index: 9999;
  min-width: 280px;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.35s ease;
}
@keyframes toastIn { from { opacity:0; transform:translateX(40px) } to { opacity:1; transform:translateX(0) } }

.alert-success { background: #EBF5EB; color: #2D6A2D; border: 1px solid #B8DDB8; }
.alert-error   { background: #FBF0F0; color: #8B2525; border: 1px solid #E8B4B4; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #93C5FD; }
[data-theme="dark"] .alert-success { background: #1A2F1A; color: #8FCC8F; border-color: #2D5A2D; }
[data-theme="dark"] .alert-error   { background: #2F1A1A; color: #CC8F8F; border-color: #5A2D2D; }
[data-theme="dark"] .alert-info    { background: #1A2040; color: #93B5DF; border-color: #2D4A6D; }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
  cursor: pointer;
}

.btn-primary {
  background: var(--cognac);
  color: var(--cream);
  border: none;
}
.btn-primary:hover { background: var(--cognac-light); transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--cognac); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 6px 12px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }

.btn-danger { background: #C0392B; color: white; border: none; }
.btn-danger:hover { background: #A93226; }
.btn-success { background: #15803D; color: white; border: none; }
.btn-success:hover { background: #166534; }

.btn-outline-primary {
  background: transparent;
  color: var(--cognac);
  border: 1.5px solid var(--cognac);
}
.btn-outline-primary:hover { background: var(--cognac); color: var(--cream); }
[data-theme="dark"] .btn-outline-primary { color: var(--cognac-light); border-color: var(--cognac-light); }
[data-theme="dark"] .btn-outline-primary:hover { background: var(--cognac-light); color: #1A1614; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background var(--transition), border-color var(--transition);
}

.card-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 22px; }

/* ── METRIC CARDS ───────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.metric-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--cognac);
  border-radius: var(--radius) var(--radius) 0 0;
}
.metric-card.green::before { background: #4CAF50; }
.metric-card.blue::before  { background: #2196F3; }
.metric-card.amber::before { background: #FF9800; }
.metric-card.red::before   { background: #F44336; }

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.metric-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── TABLES ─────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-hover); }

.table .num {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: right;
}

/* ── BADGES / ESTADOS ───────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-borrador      { background: #F3F4F6; color: #6B7280; }
.badge-confirmada    { background: #EEF2FF; color: #4338CA; }
.badge-produccion    { background: #FFF7ED; color: #C2410C; }
.badge-entregada     { background: #F0FDF4; color: #15803D; }
.badge-entregada-parcial { background: #ECFDF5; color: #059669; }
.badge-cobrada       { background: #F0FDF4; color: #15803D; border: 1px solid #86EFAC; }
.badge-finalizada    { background: #ECFDF5; color: #047857; border: 1px solid #6EE7B7; }
.badge-cancelada     { background: #FEF2F2; color: #DC2626; }
.badge-solicitada    { background: #EFF6FF; color: #2563EB; }
.badge-enviada       { background: #F0F9FF; color: #0369A1; }
.badge-recibida      { background: #F0FDF4; color: #15803D; }
.badge-stock-bajo    { background: #FFF7ED; color: #C2410C; }
.badge-activo        { background: #F0FDF4; color: #15803D; }
.badge-inactivo      { background: #F9FAFB; color: #9CA3AF; }
.badge-mayorista     { background: #EEF2FF; color: #6D28D9; }
.badge-minorista     { background: #FDF4FF; color: #9333EA; }

[data-theme="dark"] .badge-borrador   { background: #374151; color: #9CA3AF; }
[data-theme="dark"] .badge-confirmada { background: #312E81; color: #A5B4FC; }
[data-theme="dark"] .badge-cobrada    { background: #14532D; color: #86EFAC; }
[data-theme="dark"] .badge-finalizada { background: #064E3B; color: #6EE7B7; }
[data-theme="dark"] .badge-cancelada  { background: #7F1D1D; color: #FCA5A5; }

/* ── FORMS ──────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-full { grid-column: 1 / -1; }

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

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.form-control {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.9rem;
  transition: var(--transition);
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--cognac);
  box-shadow: 0 0 0 3px rgba(107,70,63,0.12);
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.6; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: 0.75rem; color: var(--text-muted); }
.form-error { font-size: 0.75rem; color: #DC2626; }

.field-validation-error { color: #DC2626; font-size: 0.78rem; margin-top: 3px; display: block; }

/* ── ITEMS TABLE (para ventas/compras) ──────────────────── */
.items-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 24px;
}
.items-header {
  padding: 14px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.items-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.item-row {
  display: grid;
  grid-template-columns: 1fr 140px 140px auto;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
  align-items: center;
}
.item-row:last-child { border-bottom: none; }

/* ── TOTALS / RESUMEN ───────────────────────────────────── */
.totals-box {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.total-row {
  display: flex;
  gap: 32px;
  font-size: 0.875rem;
}
.total-label { color: var(--text-muted); }
.total-value { font-family: var(--font-mono); font-weight: 600; color: var(--text); min-width: 100px; text-align: right; }
.total-grand { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--cognac); }

/* ── PAGINATION ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}
.page-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  border: 1px solid transparent;
}
.page-btn:hover { background: var(--bg-hover); color: var(--text); }
.page-btn.active { background: var(--cognac); color: white; border-color: var(--cognac); }

/* ── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { opacity: 0.3; margin-bottom: 16px; }
.empty-state h3 { font-family: var(--font-display); margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 0.875rem; }

/* ── FILTERS BAR ────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}
.search-box input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.875rem;
  transition: var(--transition);
}
.search-box input:focus { outline: none; border-color: var(--cognac); box-shadow: 0 0 0 3px rgba(107,70,63,0.1); }
.search-box svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filter-select {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  min-width: 150px;
}
.filter-select:focus { outline: none; border-color: var(--cognac); }

/* ── DETAIL VIEW ────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 22px;
  align-items: start;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.detail-field:last-child { border-bottom: none; }
.detail-field-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.detail-field-value { font-size: 0.9rem; color: var(--text); font-weight: 500; }

/* ── SIDEBAR PANEL (para pagos/entregas) ─────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
}
.panel-body { padding: 16px 18px; }

/* ── TIMELINE ────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 14px;
  padding: 12px 0;
  position: relative;
}
.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px; top: 36px; bottom: 0;
  width: 1px;
  background: var(--border);
}
.timeline-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--cognac);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  position: relative;
  z-index: 1;
}
.timeline-dot.muted { background: var(--bg-hover); color: var(--text-muted); }
.timeline-content { flex: 1; padding-top: 4px; }
.timeline-title { font-weight: 600; font-size: 0.875rem; margin-bottom: 2px; }
.timeline-meta { font-size: 0.75rem; color: var(--text-muted); }
.timeline-amount { font-family: var(--font-mono); font-size: 0.875rem; font-weight: 600; color: var(--cognac); }

/* ── LOGIN PAGE ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cognac-deep);
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(138,94,86,0.3) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(107,70,63,0.2) 0%, transparent 60%);
}
.login-card {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: 52px 48px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}
.login-logo {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--cognac);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}
.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 36px;
}
.login-card .form-control {
  background: white;
}
.login-card .form-label { color: var(--cognac); }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 0.95rem; }

/* ── MONEDA (helpers) ────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: #15803D; }
.text-danger  { color: #DC2626; }
.fw-600 { font-weight: 600; }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar .nav-label, .sidebar .logo-2, .sidebar .logo-you { opacity: 0; width: 0; }
  .main-content { margin-left: var(--sidebar-collapsed); }
  .content-area { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 16px; }
}

/* ═══════════════════════════════════════════════════════════
   EXTENSIÓN CSS — Layout, Views, Components
   ═══════════════════════════════════════════════════════════ */

/* ── SIDEBAR (nuevo layout) ──────────────────────────────── */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 8px;
}
.sidebar-brand-img {
  height: 40px;
  object-fit: contain;
  display: block;
  filter: invert(1);
}
.sidebar-brand-sub { font-size: 0.7rem; color: rgba(240,232,226,0.5); padding-left: 7px; }

.sidebar-section {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(240,232,226,0.35);
  padding: 10px 18px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: rgba(240,232,226,0.75);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 400;
  border-radius: 0;
  transition: all 0.18s ease;
  position: relative;
}
.sidebar-link:hover { background: rgba(255,255,255,0.07); color: var(--cream); }
.sidebar-link.active {
  background: rgba(255,255,255,0.12);
  color: var(--cream);
  font-weight: 600;
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--cognac-light);
  border-radius: 0 3px 3px 0;
}
.sidebar-link .icon {
  font-size: 0.85rem; opacity: 0.8;
  width: 20px; min-width: 20px; text-align: center;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-link .icon svg { display: block; }
.sidebar-link:hover .icon, .sidebar-link.active .icon { opacity: 1; }

.sidebar-nav { flex: 1; overflow-y: auto; padding-bottom: 8px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--cognac-light);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.875rem;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: 0.825rem; font-weight: 600; color: var(--cream); }
.sidebar-user-role { font-size: 0.7rem; color: rgba(240,232,226,0.45); }

/* ── MAIN WRAPPER ────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}
.topbar-subtitle { font-family: var(--font-body); font-size: 0.875rem; color: var(--text-muted); font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ── PAGE CONTENT ────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 28px 32px;
  width: 100%;
  max-width: 1400px;
  min-width: 0;
}

/* ── PAGE ACTIONS BAR (moved from topbar) ───────────────── */
.page-actions-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* ── LOADING OVERLAY ─────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
  z-index: 999;
  display: none;
  align-items: center; justify-content: center;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── BUTTON ADDITIONS ────────────────────────────────────── */
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-topbar { font-size: 0.78rem; background: transparent; border: none; color: var(--text-muted); padding: 6px 12px; }
.btn-topbar:hover { color: var(--text); background: var(--bg-hover); }

/* ── CARD ────────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 22px; overflow: hidden; }
.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; margin: 0; }
.card-body { padding: 22px; }
.card-body.p-0 { padding: 0; }

/* ── METRICS ─────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.metric-card--primary { border-left: 3px solid var(--cognac); }
.metric-card--warning { border-left: 3px solid #C2410C; }
.metric-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.metric-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.metric-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; }
.metric-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ── GRIDS ───────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; margin-bottom: 22px; }

/* ── FILTER BAR ──────────────────────────────────────────── */
.filter-bar { margin-bottom: 18px; }
.filter-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: fit-content; }
.filter-form .form-control { width: auto; }
.form-control-sm { padding: 7px 11px !important; font-size: 0.825rem !important; height: auto !important; }

/* ── TABLE ───────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table thead th { padding: 10px 14px; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-light); color: var(--text); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: var(--bg-hover); }
.table .text-right { text-align: right; }

/* ── BADGE ───────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 100px; font-size: 0.7rem; font-weight: 600; text-transform: capitalize; }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.badge-borrador      { background: #F3F4F6; color: #6B7280; }
.badge-confirmada    { background: #EEF2FF; color: #4338CA; }
.badge-enproduccion  { background: #FFF7ED; color: #C2410C; }
.badge-entregada     { background: #F0FDF4; color: #15803D; }
.badge-cobrada       { background: #F0FDF4; color: #15803D; border: 1px solid #86EFAC; }
.badge-cancelada     { background: #FEF2F2; color: #DC2626; }
.badge-solicitada    { background: #EFF6FF; color: #2563EB; }
.badge-enviada       { background: #F0F9FF; color: #0369A1; }
.badge-recibida      { background: #F0FDF4; color: #15803D; }
.badge-pendiente     { background: #FFF7ED; color: #C2410C; }
.badge-aplicada      { background: #F0FDF4; color: #15803D; }
.badge-anulada       { background: #FEF2F2; color: #DC2626; }
.badge-recibido      { background: #EFF6FF; color: #2563EB; }
.badge-procesando    { background: #FFF7ED; color: #C2410C; }
.badge-success       { background: #F0FDF4; color: #15803D; }
.badge-danger        { background: #FEF2F2; color: #DC2626; }
.badge-warning       { background: #FFF7ED; color: #C2410C; }
.badge-info          { background: #EFF6FF; color: #2563EB; }

/* ── FORM ────────────────────────────────────────────────── */
.form-layout { display: flex; flex-direction: column; gap: 0; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0; }
.form-control { width: 100%; padding: 9px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text); font-size: 0.875rem; font-family: var(--font-body); transition: var(--transition); box-sizing: border-box; }
.form-control:focus { outline: none; border-color: var(--cognac); box-shadow: 0 0 0 3px rgba(107,70,63,0.1); }
.form-row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; margin-bottom: 16px; }
.form-row .form-group { margin-bottom: 0; }
.col-md-3 { grid-column: span 3; }
.col-md-4 { grid-column: span 4; }
.col-md-6 { grid-column: span 6; }
.col-md-8 { grid-column: span 8; }
.col-md-12 { grid-column: span 12; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding-top: 20px; border-top: 1px solid var(--border-light); }
/* Buttons after form-row get spacing and right alignment */
.form-row + .btn,
.form-row + .form-btn-row,
.form-row ~ .btn { margin-top: 16px; }
.form-btn-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.input-group { display: flex; }
.input-prefix { padding: 9px 12px; background: var(--bg-hover); border: 1.5px solid var(--border); border-right: none; border-radius: var(--radius-sm) 0 0 var(--radius-sm); color: var(--text-muted); font-size: 0.875rem; }
.input-group .form-control { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; cursor: pointer; }

/* ── DETAIL LAYOUT ───────────────────────────────────────── */
.cards-flex { display: flex; flex-wrap: wrap; gap: 16px; }
.cards-flex > * { flex: 1 1 calc(50% - 8px); min-width: calc(50% - 8px); max-width: calc(50% - 8px); }
.cards-flex > .full-width { flex: 1 1 100%; min-width: 100%; max-width: 100%; }
.cards-flex > .grid-2 { flex: 1 1 100%; min-width: 100%; max-width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
.cards-flex > style { display: none; }
.detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 22px; margin-bottom: 22px; align-items: start; }
.detail-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; align-items: start; }
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }
.info-item { padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.info-item:nth-last-child(-n+2) { border-bottom: none; }
.info-item dt { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: 3px; }
.info-item dd { font-size: 0.875rem; font-weight: 500; color: var(--text); margin: 0; }
.notes-box { background: var(--bg-hover); border-radius: var(--radius-sm); padding: 12px; font-size: 0.875rem; color: var(--text-muted); margin-top: 12px; font-style: italic; }

/* ── FINANCIAL SUMMARY ───────────────────────────────────── */
.financial-summary { display: flex; flex-direction: column; gap: 0; }
.fin-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border-light); font-size: 0.875rem; }
.fin-row:last-child { border-bottom: none; }
.fin-balance { font-weight: 700; }
.fin-balance--pending .mono { color: #DC2626; }
.fin-balance--ok .mono { color: #15803D; }

/* ── PAYMENT SUMMARY ─────────────────────────────────────── */
.payment-summary { background: var(--bg-hover); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 20px; }
.payment-balance { display: flex; justify-content: space-between; align-items: center; font-size: 0.875rem; }
.payment-balance strong { font-size: 1.4rem; font-family: var(--font-mono); color: var(--cognac); }

/* ── DELIVERY BLOCKS ─────────────────────────────────────── */
.delivery-block { border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.delivery-header { font-size: 0.875rem; margin-bottom: 8px; }
.delivery-items { display: flex; flex-wrap: wrap; gap: 6px; }
.delivery-item-tag { background: var(--bg-hover); padding: 3px 8px; border-radius: 100px; font-size: 0.75rem; }
.entrega-form { border-top: 1px solid var(--border); padding-top: 16px; }
.table-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.table-form-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; font-size: 0.875rem; }
.table-form-row .form-control { max-width: 100px; }

/* ── ITEM ROW (forms) ────────────────────────────────────── */
.item-row { display: grid; grid-template-columns: 1fr 120px 40px; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-light); }
.item-row--3col { grid-template-columns: 1fr 100px 120px 40px; }
.item-row:last-child { border-bottom: none; }

/* ── DANGER ZONE ─────────────────────────────────────────── */
.danger-zone { border: 1px solid #FCA5A5; background: #FEF2F2; border-radius: var(--radius); padding: 20px; margin-bottom: 22px; max-width: 480px; }
.danger-zone h3 { color: #DC2626; font-size: 0.875rem; font-weight: 700; margin: 0 0 14px; text-transform: uppercase; letter-spacing: 0.05em; }
[data-theme="dark"] .danger-zone { background: #2A1F1F; border-color: #5A2D2D; }
[data-theme="dark"] .danger-zone h3 { color: #FCA5A5; }

/* ── QUICK ACTIONS ───────────────────────────────────────── */
.quick-actions { display: flex; flex-direction: column; gap: 8px; }

/* ── SECTION TITLE ───────────────────────────────────────── */
.section-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 16px 0 10px; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 2.5rem; opacity: 0.3; margin-bottom: 12px; }
.empty-state h3 { font-family: var(--font-display); color: var(--text); margin: 0 0 8px; }
.empty-state p { font-size: 0.875rem; margin: 0 0 20px; }

/* ── ROW WARNING ─────────────────────────────────────────── */
.row-warning td { background: #FFFBEB !important; }

/* ── METRIC CARD ICON ────────────────────────────────────── */
.metric-card-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  opacity: 0.13;
  color: currentColor;
  pointer-events: none;
}

/* ── TABLE SCROLL (horizontal en mobile y donde no quepa) ─── */
.card-body.p-0 {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrapper,
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── ALERTS (color variants) ────────────────────────────── */
.alert-success { background: #F0FDF4; color: #15803D; border: 1px solid #86EFAC; }
.alert-danger  { background: #FEF2F2; color: #DC2626; border: 1px solid #FCA5A5; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FCD34D; }
.text-danger { color: #DC2626; font-size: 0.78rem; }
.text-warning { color: #C2410C; }

/* ── LOGIN PAGE ──────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  background: var(--cognac-deep);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-container { width: 100%; max-width: 440px; padding: 20px; }
.login-brand { text-align: center; margin-bottom: 32px; }
.login-logo { font-family: var(--font-display); font-size: 2rem; font-weight: 700; background: rgba(255,255,255,0.15); color: var(--cream); width: 60px; height: 60px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.login-brand-name { font-family: var(--font-display); font-size: 1.5rem; color: var(--cream); font-weight: 700; }
.login-brand-sub { color: rgba(240,232,226,0.5); font-size: 0.8rem; }
.login-card { background: var(--cream); border-radius: var(--radius-lg); padding: 36px 40px; box-shadow: 0 24px 80px rgba(0,0,0,0.5); }
.login-title { font-family: var(--font-display); font-size: 1.5rem; color: var(--cognac-deep); margin: 0 0 24px; }
.login-card .form-control { background: white; }
.login-card .form-label { color: var(--cognac); }

/* ── D-FLEX HELPER ───────────────────────────────────────── */
.d-flex { display: flex; }
.align-items-end { align-items: flex-end; }

/* ── CODE ────────────────────────────────────────────────── */
code { font-family: var(--font-mono); font-size: 0.85em; background: var(--bg-hover); padding: 2px 5px; border-radius: 4px; }

/* ── MOBILE HAMBURGER ─────────────────────────────────────── */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text);
  margin-right: 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.hamburger-btn:hover { background: var(--bg-hover); }
.hamburger-btn svg { display: block; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 768px) {
  .hamburger-btn { display: flex; align-items: center; justify-content: center; }

  .sidebar {
    position: fixed;
    width: var(--sidebar-w);                    /* override the 64px from the first block */
    left: calc(-1 * var(--sidebar-w));          /* fully off-screen when closed */
    top: 0;
    height: 100vh;
    z-index: 100;
    transition: left 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
    overflow: visible;
  }
  .sidebar.open { left: 0; }

  /* Restore nav text that was hidden by the earlier mobile block */
  .sidebar .nav-label,
  .sidebar .logo-2,
  .sidebar .logo-you { opacity: 1; width: auto; overflow: visible; }

  .main-wrapper { margin-left: 0 !important; width: 100%; flex: 1; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }

  /* ── 32: Card/grid layouts collapse to single column ── */
  .detail-layout  { grid-template-columns: 1fr !important; }
  .detail-row-2col { grid-template-columns: 1fr !important; }
  .grid-2         { grid-template-columns: 1fr !important; }
  .detail-grid    { grid-template-columns: 1fr !important; }
  .metrics-grid  { grid-template-columns: repeat(2, 1fr); }

  /* cards-flex: una columna en mobile, excepto KPI/metrics que tienen su propio layout */
  .cards-flex > * { flex: 1 1 100% !important; min-width: 100% !important; max-width: 100% !important; }


  /* All form-row columns go full width on mobile */
  .form-row .col-md-3,
  .form-row .col-md-4,
  .form-row .col-md-6,
  .form-row .col-md-8,
  .form-row .col-md-12 { grid-column: span 12; }
  .form-row .form-group { margin-bottom: 12px; }
  .form-row { gap: 0; }

  /* Topbar actions wrap gracefully */
  .topbar-actions { flex-wrap: wrap; gap: 6px; }

  /* ── Prevent iOS zoom on input focus ── */
  .form-control, select, input, textarea { font-size: 16px !important; }

  /* ── Improve readability on mobile ── */
  .table thead th { font-size: 0.75rem; }
  .sidebar-section { font-size: 0.72rem; }

  /* ── 33: Tables scroll horizontally ── */
  .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card-body .table { min-width: 480px; }
  /* Exception: card-body.p-0 already handled; don't double-apply min-width to tiny tables */
  .card-body.p-0 .table { min-width: 0; }

  /* filter-row and stat-row wrap */
  .filter-row { flex-direction: column; align-items: stretch; }
  .stat-row    { grid-template-columns: repeat(2, 1fr); }

  /* ── Filter form: full width on mobile ── */
  .filter-form { width: 100%; flex-direction: column; align-items: stretch; }
  .filter-form .form-control { width: 100%; }
  .filter-form .btn-group-toggle { width: 100%; }
  .filter-group { width: 100%; }
  .filter-group select,
  .filter-group input { min-width: 0 !important; width: 100% !important; }
  .filter-card .btn { width: 100%; }
}

/* ── CINTURON MATRIX ─────────────────────────────────────── */
.matrix-table th { font-size: 0.78rem; padding: 8px 10px; white-space: nowrap; }
.matrix-table td { padding: 5px 8px; }
.matrix-input {
  width: 90px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  transition: var(--transition);
}
.matrix-input:focus { outline: none; border-color: var(--cognac); background: var(--bg-elevated); }
.matrix-row-label { font-weight: 600; font-size: 0.85rem; white-space: nowrap; padding-right: 14px; }

/* ── VENTA PRECIO LINE ────────────────────────────────────── */
.venta-item-row {
  display: grid;
  grid-template-columns: 1fr 100px 130px 130px 40px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.venta-item-row:last-child { border-bottom: none; }
.price-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 6px 8px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  text-align: right;
}
.subtotal-display {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cognac);
  padding: 6px 8px;
  text-align: right;
}
.venta-totals-bar {
  background: var(--bg-hover);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  margin-top: 12px;
  align-items: center;
}
.venta-total-label { font-size: 0.8rem; color: var(--text-muted); }
.venta-total-value { font-family: var(--font-mono); font-weight: 700; font-size: 1.1rem; color: var(--cognac-deep); }

/* ── CHEQUE STATUS BADGE ──────────────────────────────────── */
.badge-encartera   { background: #E0F2FE; color: #0369A1; }
.badge-depositado  { background: #F0FDF4; color: #15803D; }
.badge-usado       { background: #F3F4F6; color: #374151; }
.badge-rechazado   { background: #FEF2F2; color: #DC2626; }
.badge-anulado     { background: #F9FAFB; color: #9CA3AF; }

/* ═══════════════════════════════════════════════════════════
   NUEVOS MÓDULOS
   ═══════════════════════════════════════════════════════════ */

/* ── NOTIFICATION BELL ────────────────────────────────────── */
.notif-bell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}
.notif-bell:hover { background: var(--bg-hover); color: var(--text); }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  border-radius: 99px;
  background: #DC2626;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* ── PRODUCTION STAGE BADGES ──────────────────────────────── */
.badge-diseno        { background: #F3E8FF; color: #7C3AED; }
.badge-corte         { background: #FEF3C7; color: #D97706; }
.badge-confeccion    { background: #DBEAFE; color: #2563EB; }
.badge-terminado     { background: #D1FAE5; color: #059669; }
.badge-controlcalidad{ background: #E0F2FE; color: #0284C7; }
.badge-completada    { background: #F0FDF4; color: #15803D; }
.badge-cancelada     { background: #FEF2F2; color: #DC2626; }

/* ── PRESUPUESTO STATUS BADGES ────────────────────────────── */
.badge-borrador   { background: #F3F4F6; color: #6B7280; }
.badge-enviado    { background: #DBEAFE; color: #2563EB; }
.badge-aprobado   { background: #D1FAE5; color: #059669; }
.badge-convertido { background: #F0FDF4; color: #15803D; }
.badge-rechazado2 { background: #FEF2F2; color: #DC2626; }
.badge-vencido    { background: #FEF3C7; color: #D97706; }

/* ── NOTA CREDITO BADGES ──────────────────────────────────── */
.badge-pendiente  { background: #FEF3C7; color: #D97706; }
.badge-aplicada   { background: #D1FAE5; color: #059669; }

/* ── PEDIDO ONLINE BADGES ─────────────────────────────────── */
.badge-recibido     { background: #DBEAFE; color: #2563EB; }
.badge-procesando   { background: #FEF3C7; color: #D97706; }
.badge-convertidoav { background: #D1FAE5; color: #059669; }

/* ── INTERACCION BADGES ───────────────────────────────────── */
.badge-llamada  { background: #DBEAFE; color: #2563EB; }
.badge-email    { background: #F3E8FF; color: #7C3AED; }
.badge-visita   { background: #D1FAE5; color: #059669; }
.badge-whatsapp { background: #DCFCE7; color: #16A34A; }
.badge-nota     { background: #F3F4F6; color: #6B7280; }

/* ── CALENDAR GRID ────────────────────────────────────────── */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}
.calendar-nav .month-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  min-width: 200px;
  text-align: center;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.calendar-header {
  background: var(--bg-hover);
  padding: 8px 4px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}
.calendar-day {
  background: var(--bg-card);
  min-height: 80px;
  padding: 6px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.calendar-day:hover { background: var(--bg-hover); }
.calendar-day.other-month { opacity: 0.4; }
.calendar-day.today { background: #FEF3C7; }
.calendar-day-num {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.calendar-events {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.calendar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.calendar-dot.venta    { background: #2563EB; }
.calendar-dot.compra   { background: #D97706; }
.calendar-dot.cheque   { background: #DC2626; }
.calendar-dot.produccion { background: #7C3AED; }

.calendar-detail-panel {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: none;
}
.calendar-detail-panel.active { display: block; }

/* ── TIMELINE (CRM / Actividad) ───────────────────────────── */
.timeline {
  position: relative;
  padding-left: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 16px;
}
.timeline-item::before {
  display: none;
}
.timeline-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.timeline-content {
  font-size: 0.85rem;
}

/* ── PRODUCTION PROGRESS ──────────────────────────────────── */
.etapa-progress {
  display: flex;
  gap: 4px;
  align-items: center;
}
.etapa-step {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: background var(--transition);
}
.etapa-step.active { background: var(--accent); }
.etapa-step.completed { background: #059669; }

/* ── ANOMALY BADGE (Gastos) ───────────────────────────────── */
.badge-anomaly {
  background: #FEF2F2;
  color: #DC2626;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* ── TASK LIST ────────────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.task-item:hover { background: var(--bg-hover); }
.task-item.completed { opacity: 0.5; }
.task-item.completed .task-title { text-decoration: line-through; }
.task-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.task-check:hover { border-color: var(--accent); }
.task-check.done { background: #059669; border-color: #059669; }
.task-title { font-size: 0.85rem; flex: 1; }
.task-due { font-size: 0.7rem; color: var(--text-muted); }
.task-due.overdue { color: #DC2626; font-weight: 600; }

/* ── NOTIFICATION LIST ────────────────────────────────────── */
.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
  align-items: flex-start;
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: #FFFBEB; }
[data-theme="dark"] .notif-item.unread { background: #2A2420; }
.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
}
.notif-icon.cobro    { background: #FEF2F2; color: #DC2626; }
.notif-icon.stock    { background: #FEF3C7; color: #D97706; }
.notif-icon.cheque   { background: #DBEAFE; color: #2563EB; }
.notif-icon.entrega  { background: #F3E8FF; color: #7C3AED; }
.notif-icon.general  { background: #F3F4F6; color: #6B7280; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; }
.notif-msg { font-size: 0.78rem; color: var(--text-muted); }
.notif-time { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; }

/* ── RESPONSIVE CALENDAR ──────────────────────────────────── */
@media (max-width: 768px) {
  .calendar-grid {
    grid-template-columns: repeat(7, minmax(90px, 1fr));
    min-width: 630px;
  }
  .calendar-grid-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .calendar-day { min-height: 50px; padding: 4px; }
  .calendar-day-num { font-size: 0.65rem; }
  .calendar-nav .month-title { font-size: 1rem; min-width: 160px; }
}

/* ── DASHBOARD LAYOUT ────────────────────────────────────── */
.dash-main-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 22px;
  align-items: start;
}
.dash-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  margin-bottom: 22px;
}
.dash-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  animation: chartFadeIn 0.5s ease forwards;
}
.dash-chart-card:nth-child(2) { animation-delay: 0.08s; }
.dash-chart-card:nth-child(3) { animation-delay: 0.16s; }
.dash-chart-card:nth-child(4) { animation-delay: 0.24s; }
@keyframes chartFadeIn {
  to { opacity: 1; transform: translateY(0); }
}
.dash-chart-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.dash-chart-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0;
}
.dash-chart-body {
  padding: 16px;
  position: relative;
  min-height: 200px;
}
.dash-chart-body canvas {
  width: 100% !important;
  height: 200px !important;
}
.period-selector {
  display: flex;
  gap: 4px;
}
.period-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.period-btn:hover { border-color: var(--cognac); color: var(--cognac); }
.period-btn.active { background: var(--cognac); color: white; border-color: var(--cognac); }
.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* metric-card icon position */
.metric-card-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.12;
  color: var(--text);
}

@media (max-width: 1200px) {
  .dash-main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .page-content { padding: 14px; max-width: 100%; }
  .dash-charts-grid { grid-template-columns: 1fr; }
  .dash-main-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { padding: 14px; }
  .metric-value { font-size: 1.5rem; }
  .metric-card-icon svg { width: 30px; height: 30px; }
}

/* ── DASHBOARD HERO ───────────────────────────────────────── */
.dash-hero {
  background: linear-gradient(135deg, var(--cognac-deep) 0%, var(--cognac) 50%, var(--cognac-light) 100%);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #F0E8E2;
  position: relative;
  overflow: hidden;
}
.dash-hero::before {
  content: '';
  position: absolute;
  top: -60%; right: -10%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
  pointer-events: none;
}
.dash-hero-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: white;
  margin: 0 0 4px 0;
}
.dash-hero-sub {
  font-size: 0.85rem;
  color: rgba(240,232,226,0.8);
  margin: 0;
}
.dash-hero-alerts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.dash-alert-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 100px;
  padding: 5px 14px;
  font-size: 0.76rem;
  color: #FDE8E8;
  white-space: nowrap;
  overflow: hidden;
}
.dash-alert-pill svg { flex-shrink: 0; }

/* ── DASHBOARD ACTION BUTTONS ────────────────────────────── */
.dash-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid transparent;
}
.dash-action-btn:hover {
  background: var(--cream-deep);
  border-color: var(--border);
  transform: translateX(2px);
}
.dash-action-btn svg { color: var(--text-muted); flex-shrink: 0; }
.dash-action-btn.dash-action-primary {
  background: var(--cognac);
  color: white;
  font-weight: 600;
}
.dash-action-btn.dash-action-primary:hover {
  background: var(--cognac-light);
  border-color: transparent;
}
.dash-action-btn.dash-action-primary svg { color: rgba(255,255,255,0.8); }
.dash-action-btn.dash-action-danger { color: #dc2626; }
.dash-action-btn.dash-action-danger svg { color: #dc2626; }
.dash-action-count {
  margin-left: auto;
  background: rgba(107,70,63,0.1);
  color: var(--cognac);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  font-family: var(--font-mono);
}

/* ── DASHBOARD CHART TITLE ICON ──────────────────────────── */
.dash-chart-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dash-chart-title .icon {
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .dash-hero { flex-direction: column; align-items: flex-start; padding: 20px; }
  .dash-hero-title { font-size: 1.2rem; }
  .dash-hero-alerts { flex-direction: column; gap: 6px; width: 100%; }
  .dash-alert-pill { max-width: 100%; }
  .dash-alert-pill-text {
    display: block;
    overflow: hidden;
    min-width: 0;
    flex: 1;
  }
  .dash-alert-pill-text-inner {
    display: inline-block;
    white-space: nowrap;
    animation: marquee-scroll 8s linear infinite;
  }
}
@keyframes marquee-scroll {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(0); }
  85%  { transform: translateX(calc(-100% + 200px)); }
  100% { transform: translateX(calc(-100% + 200px)); }
}

[data-theme="dark"] .dash-action-btn { background: var(--bg-hover); }
[data-theme="dark"] .dash-action-btn:hover { background: var(--cream-deep); }
[data-theme="dark"] .dash-action-count { background: rgba(107,70,63,0.25); }

/* ── PAGINATION ────────────────────────────────────────────── */
.pagination-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 0.82rem;
}
.pagination-info { color: var(--text-muted); }
.pagination-buttons { display: flex; gap: 4px; align-items: center; }
.pagination-buttons .btn { min-width: 32px; padding: 4px 8px; font-size: 0.78rem; }
.pagination-dots { color: var(--text-muted); padding: 0 4px; }

/* ── FLUJO DE DOCUMENTOS ─────────────────────────────────── */
.flujo-container {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
}

.flujo-columna {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  justify-content: center;
}

.flujo-nodo {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-card);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 120px;
  font-family: 'Inter', sans-serif;
  position: relative;
}
.flujo-nodo::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dot-color, #FFC107);
}

.flujo-nodo:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  text-decoration: none;
  color: var(--text);
}

.flujo-nodo.flujo-actual {
  border-color: var(--accent);
  background: var(--cream-dark);
  box-shadow: 0 0 0 3px rgba(107,70,63,0.15);
}
[data-theme="dark"] .flujo-nodo.flujo-actual {
  background: var(--bg-hover);
  box-shadow: 0 0 0 3px rgba(107,70,63,0.3);
}

.flujo-tipo {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.flujo-codigo {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
}

.flujo-estado {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.flujo-flecha {
  font-size: 1.4rem;
  color: var(--text-muted);
  flex-shrink: 0;
  line-height: 1;
  align-self: flex-start;
  margin-top: 30px;
}

/* Contenedor de hijos ramificados — agrupados por categoría */
.flujo-hijos {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* Cada categoría: items horizontales */
.flujo-categoria {
  display: flex;
  align-items: center;
  gap: 6px;
}
.flujo-cat-label { display: none; }
.flujo-cat-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.flujo-cat-flecha {
  font-size: 1rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.flujo-cat-indent {
  padding-left: 0;
}
.flujo-cat-item-con-sub {
  display: flex;
  align-items: center;
  gap: 6px;
}
.flujo-cat-sub-pagos {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Sub-hijos (compras apiladas verticalmente dentro de un grupo OP) */
.flujo-sub-hijos {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.flujo-conector-linea {
  flex: 1;
  height: 0;
  border-top: 2px solid var(--text-muted);
  margin-right: -6px;
  margin-top: 11px;
}
.flujo-sub-hijos > .flujo-cat-item-con-sub:first-child .flujo-conector-linea {
  margin-top: -11px;
}
/* Ocultar lineas intermedias (ni primera ni ultima) */
.flujo-sub-hijos > .flujo-cat-item-con-sub:not(:first-child):not(:last-child) .flujo-conector-linea {
  display: none;
}

/* Grupo compras → OP con bracket */
.flujo-grupo-op {
  display: flex;
  align-items: center;
  gap: 0;
}
.flujo-grupo-op-bracket {
  width: 20px;
  align-self: stretch;
  border: 2px solid var(--text-muted);
  border-left: none;
  border-radius: 0 8px 8px 0;
  margin: 35px 0;
  flex-shrink: 0;
}

/* Color-coded left borders per node type */
.flujo-presupuesto { border-left: 3px solid #6B8EC7; }
.flujo-venta { border-left: 3px solid var(--cognac); }
.flujo-nc { border-left: 3px solid #C7736B; }
.flujo-compra { border-left: 3px solid #6BC77A; }
.flujo-op { border-left: 3px solid #C7B46B; }
.flujo-pago { border-left: 3px solid #4CAF50; font-size: 0.8rem; }
.flujo-entrega { border-left: 3px solid #2196F3; font-size: 0.8rem; }

@media (max-width: 640px) {
  .flujo-container { min-width: max-content; }
  .flujo-nodo { min-width: 100px; padding: 8px 10px; }
  .flujo-tipo { font-size: 0.7rem; }
  .flujo-codigo { font-size: 0.85rem; }
  .flujo-estado { font-size: 0.72rem; }
}

/* ── Product Search Autocomplete ──────────────────────── */
.product-search-wrapper {
  position: relative;
}
.product-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
}
.psr-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-light);
}
.psr-item:hover, .psr-item.active {
  background: var(--bg-hover);
}
.psr-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
  white-space: nowrap;
}
.psr-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.psr-stock {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.psr-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Prominent status badge (large) ──────────────────── */
.badge-estado-lg {
  display: inline-block;
  padding: 6px 18px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.badge-estado-lg.badge-borrador   { background: #E3E8EF; color: #4A5568; }
.badge-estado-lg.badge-confirmada { background: #C6F6D5; color: #22543D; }
.badge-estado-lg.badge-enproduccion { background: #FEFCBF; color: #744210; }
.badge-estado-lg.badge-entregadaparcialmente { background: #BEE3F8; color: #2A4365; }
.badge-estado-lg.badge-entregada  { background: #C6F6D5; color: #22543D; }
.badge-estado-lg.badge-cobrada    { background: #9AE6B4; color: #1C4532; }
.badge-estado-lg.badge-finalizada { background: #6EE7B7; color: #064E3B; }
.badge-estado-lg.badge-cancelada  { background: #FED7D7; color: #822727; }
/* Compras */
.badge-estado-lg.badge-solicitada { background: #DBEAFE; color: #1E40AF; }
.badge-estado-lg.badge-enviada    { background: #BAE6FD; color: #0C4A6E; }
.badge-estado-lg.badge-recibidaparcialmente { background: #D1FAE5; color: #065F46; }
.badge-estado-lg.badge-recibida   { background: #A7F3D0; color: #064E3B; }
/* Ordenes Produccion */
.badge-estado-lg.badge-diseno          { background: #EDE9FE; color: #5B21B6; }
.badge-estado-lg.badge-corte           { background: #FEF3C7; color: #92400E; }
.badge-estado-lg.badge-confeccion      { background: #DBEAFE; color: #1E40AF; }
.badge-estado-lg.badge-terminado       { background: #D1FAE5; color: #065F46; }
.badge-estado-lg.badge-controlcalidad  { background: #BAE6FD; color: #0C4A6E; }
.badge-estado-lg.badge-completada      { background: #A7F3D0; color: #064E3B; }

/* ═══════════════════════════════════════════════════════════
   MODERN UI COMPONENTS (2026 Redesign)
   ═══════════════════════════════════════════════════════════ */

/* ── Semantic colors ───────────────────────────────────── */
:root {
  --color-success:    #2D7A4F;
  --color-success-bg: #E8F5ED;
  --color-warning:    #B8860B;
  --color-warning-bg: #FFF8E7;
  --color-danger:     #C0392B;
  --color-danger-bg:  #FDEDED;
  --color-info:       #2E6B8A;
  --color-info-bg:    #EBF5FB;
}
[data-theme="dark"] {
  --color-success:    #6BCB8B;
  --color-success-bg: #1A2F1A;
  --color-warning:    #E0A82E;
  --color-warning-bg: #2A2410;
  --color-danger:     #E57373;
  --color-danger-bg:  #2F1A1A;
  --color-info:       #6BB3D0;
  --color-info-bg:    #1A2530;
}

/* ── CARD HOVER EFFECT ─────────────────────────────────── */
.card { transition: background var(--transition), border-color var(--transition), box-shadow var(--transition); }
.card:hover { box-shadow: var(--shadow); }

/* ── HERO HEADER ───────────────────────────────────────── */
.hero-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.hero-left { display: flex; flex-direction: column; gap: 6px; }
.hero-title {
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 16px;
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.hero-meta .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--border); }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }

/* ── KPI ROW ───────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-row--2 { grid-template-columns: repeat(2, 1fr); }
.kpi-row--3 { grid-template-columns: repeat(3, 1fr); }
.kpi-row--4 { grid-template-columns: repeat(4, 1fr); }
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-width: 0;
  overflow: hidden;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-card--total::before   { background: var(--cognac); }
.kpi-card--paid::before    { background: var(--color-success); }
.kpi-card--balance::before { background: var(--color-warning); }
.kpi-card--profit::before  { background: var(--color-info); }
.kpi-card--danger::before  { background: var(--color-danger); }
.kpi-card--progress::before { background: var(--cognac); }

.kpi-pct {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
}
.kpi-pct--partial { color: var(--cognac); }
.kpi-pct--done { color: var(--color-success); }

.kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi-value.text-success { color: var(--color-success) !important; }
.kpi-value.text-warning { color: var(--color-warning) !important; }
.kpi-value.text-info    { color: var(--color-info) !important; }
.kpi-value.text-danger  { color: var(--color-danger) !important; }

/* ── PROGRESS BARS ─────────────────────────────────────── */
.progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-light);
}
.progress-row:last-child { border-bottom: none; }
.progress-label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); min-width: 90px; }
.progress-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--border-light);
  border-radius: 10px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.5s ease;
}
.progress-bar-fill--delivery { background: var(--color-success); }
.progress-bar-fill--payment  { background: var(--cognac); }
.progress-bar-fill--production { background: var(--color-info); }
.progress-pct {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 40px;
  text-align: right;
}

/* ── MODERN INFO GRID ──────────────────────────────────── */
.info-grid-modern {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0;
}
@media (max-width: 768px) {
  .info-grid-modern { grid-template-columns: 1fr 1fr; }
  .info-grid-modern .info-cell[style*="grid-column"] { grid-column: 1 / -1 !important; }
}
.info-cell {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
}
.info-cell:last-child { border-right: none; }
.info-cell .info-label,
.info-cell-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.info-cell .info-value,
.info-cell-value {
  font-size: 0.925rem;
  font-weight: 500;
  color: var(--text);
}
.info-cell a, .info-cell-value a { color: var(--cognac); text-decoration: none; font-weight: 600; }
.info-cell a:hover, .info-cell-value a:hover { text-decoration: underline; }

/* ── CARD TITLE WITH ICON ──────────────────────────────── */
.card-title .icon,
.card-title-icon {
  width: 20px; height: 20px;
  color: var(--cognac);
  flex-shrink: 0;
  display: inline-flex;
  vertical-align: middle;
}

/* ── FINANCIAL BREAKDOWN ───────────────────────────────── */
.fin-breakdown { padding: 0; }
.fin-breakdown .fin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}
.fin-breakdown .fin-row:last-child { border-bottom: none; }
.fin-breakdown .fin-row .label { color: var(--text-muted); font-weight: 500; }
.fin-breakdown .fin-row .value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.95rem;
}
.fin-row--highlight {
  background: var(--bg);
  padding: 16px 22px !important;
}
.fin-row--highlight .label { color: var(--text) !important; font-weight: 700 !important; }
.fin-row--highlight .value { font-size: 1.1rem !important; color: var(--cognac) !important; }
.tag-est {
  font-size: 0.68rem;
  background: var(--color-warning-bg);
  color: var(--color-warning);
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  font-weight: 600;
}

/* ── QUANTITY PILLS ────────────────────────────────────── */
.qty-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  padding: 3px 10px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
}
.qty-ordered   { background: var(--cream-dark); color: var(--text); }
.qty-delivered  { background: var(--color-success-bg); color: var(--color-success); }
.qty-pending   { background: var(--color-warning-bg); color: var(--color-warning); }
.qty-zero      { background: var(--cream-dark); color: var(--text-muted); }
[data-theme="dark"] .qty-ordered { background: var(--bg-hover); }
[data-theme="dark"] .qty-zero    { background: var(--bg-hover); }

/* ── PRODUCT CELL ──────────────────────────────────────── */
.product-cell { display: flex; align-items: center; gap: 8px; }
.product-cell a { display: flex; flex-direction: column; text-decoration: none; color: inherit; min-width: 0; }
.product-name { font-weight: 600; color: var(--text); }
.product-code { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.product-cell .btn-item-info-detail { flex-shrink: 0; }

/* ── COLOR TAG ─────────────────────────────────────────── */
.color-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--cream-dark);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}
[data-theme="dark"] .color-tag { background: var(--bg-hover); }

/* ── DELIVERY TIMELINE ─────────────────────────────────── */
.delivery-timeline { padding: 20px 22px; }
.delivery-timeline .timeline-item {
  position: relative;
  padding-left: 28px;
  padding-bottom: 20px;
}
.delivery-timeline .timeline-item:last-child { padding-bottom: 0; }
.delivery-timeline .timeline-dot {
  position: absolute;
  left: 1px; top: 16px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--color-success);
  z-index: 1;
}
.delivery-timeline .timeline-item::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 16px;
  bottom: -20px;
  width: 1px;
  background: var(--border);
}
.delivery-timeline .timeline-item:last-child::after { display: none; }
.delivery-timeline .timeline-date {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.delivery-timeline .timeline-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.delivery-timeline .timeline-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.delivery-timeline .timeline-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--cream-dark);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
}
[data-theme="dark"] .delivery-timeline .timeline-tag { background: var(--bg-hover); }

/* ── DELIVERY FORM (modern) ────────────────────────────── */
.delivery-form {
  padding: 22px;
  border-top: 2px solid var(--cognac);
  background: linear-gradient(180deg, rgba(107,70,63,0.03) 0%, transparent 100%);
}
[data-theme="dark"] .delivery-form { background: linear-gradient(180deg, rgba(107,70,63,0.08) 0%, transparent 100%); }
.delivery-form h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.delivery-form-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.delivery-form-row:last-of-type { border-bottom: none; }
.delivery-form-product { flex: 1; font-weight: 500; }
.delivery-form-pending { font-size: 0.82rem; color: var(--text-muted); min-width: 100px; }
.delivery-form .form-input-sm {
  width: 90px;
  text-align: center;
  font-family: var(--font-mono);
}

/* ── PAYMENT ROWS ──────────────────────────────────────── */
.payment-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.payment-row:last-child { border-bottom: none; }
.payment-row:hover { background: var(--bg-hover); }
.payment-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.payment-icon--transfer { background: var(--color-info-bg); color: var(--color-info); }
.payment-icon--cash     { background: var(--color-success-bg); color: var(--color-success); }
.payment-icon--check    { background: var(--color-warning-bg); color: var(--color-warning); }
.payment-icon--card     { background: #F3E8FF; color: #7C3AED; }
.payment-info { flex: 1; }
.payment-method { font-weight: 600; font-size: 0.9rem; }
.payment-date { font-size: 0.78rem; color: var(--text-muted); }
.payment-amount {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-success);
}

/* ── SELLER CARDS ──────────────────────────────────────── */
.seller-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.seller-card:last-child { border-bottom: none; }
.seller-card:hover { background: var(--bg-hover); }
.seller-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--cognac);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.seller-info { flex: 1; min-width: 0; }
.seller-name { font-weight: 700; font-size: 0.95rem; }
.seller-name a { color: inherit; text-decoration: none; }
.seller-name a:hover { color: var(--cognac); }
.seller-type { font-size: 0.78rem; color: var(--text-muted); }
.seller-amounts { display: flex; gap: 24px; text-align: right; }
.seller-stat {}
.seller-stat-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.seller-stat-value { font-family: var(--font-mono); font-weight: 700; font-size: 0.9rem; }

/* ── MODERN NOTES BOX ──────────────────────────────────── */
.notes-box-modern {
  background: var(--bg);
  border-left: 3px solid var(--cognac);
  padding: 14px 18px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 22px 22px;
  font-style: italic;
}

/* ── MODERN DANGER ZONE ────────────────────────────────── */
.danger-zone-modern {
  border: 1px dashed var(--color-danger);
  border-radius: var(--radius-lg);
  padding: 22px;
  background: rgba(192,57,43,0.02);
  margin-bottom: 22px;
}
[data-theme="dark"] .danger-zone-modern { background: rgba(192,57,43,0.06); }
.danger-zone-modern h3 {
  font-size: 0.82rem;
  color: var(--color-danger);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}
.danger-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.danger-row .form-control { flex: 1; }

/* ── BADGE DOT ─────────────────────────────────────────── */
.badge-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── TABLE MODERN (upgraded table) ─────────────────────── */
.table thead th {
  background: var(--bg);
}
.table tbody tr { transition: background var(--transition); }

/* ── RESPONSIVE MODERN ─────────────────────────────────── */
@media (max-width: 1024px) {
  .kpi-row, .kpi-row--3, .kpi-row--4 { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 768px) {
  .hero-header { flex-direction: column; }
  .hero-title { font-size: 1.5rem; }
  .kpi-row, .kpi-row--2, .kpi-row--3, .kpi-row--4 { grid-template-columns: repeat(2, 1fr) !important; }
  .kpi-card { padding: 14px 12px; }
  .kpi-value { font-size: 1.15rem; }
  .kpi-sub { font-size: 0.7rem; }
  .seller-amounts { flex-direction: column; gap: 8px; text-align: left; }
  .danger-row { flex-direction: column; align-items: stretch; }
  .info-cell { border-right: none !important; }
  .info-cell:nth-last-child(-n+2) { border-bottom: 1px solid var(--border-light); }
  .info-cell:last-child { border-bottom: none; }
  .payment-row { flex-wrap: wrap; }

  /* ── Hide non-essential columns on mobile ── */
  .col-hide-mobile { display: none !important; }

  /* ── Products table: enlarge image, code and name on mobile ── */
  .productos-table .col-img { width: 80px !important; min-width: 80px !important; padding: 6px !important; }
  .productos-table .prod-thumb { width: 70px !important; height: 52px !important; border-radius: 6px !important; object-fit: cover !important; }
  .productos-table .col-codigo { min-width: 100px !important; white-space: nowrap; }
  .productos-table .col-nombre { min-width: 200px !important; word-break: break-word; }
  .productos-table .text-right { min-width: 90px !important; white-space: nowrap; }
  /* Items table in ventas/compras: wider product column */
  td .product-cell { min-width: 200px; }
}
@media (max-width: 400px) {
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 10px 8px; }
  .kpi-value { font-size: 1rem; }
  .kpi-label { font-size: 0.68rem; }
  .kpi-sub { font-size: 0.65rem; }
}
