/* ===== CSS VARIABLES — Desguaces González Brand ===== */
:root {
  /* ── Marca corporativa ── */
  --brand-yellow:       #F5A800;
  --brand-yellow-dark:  #D4900A;
  --brand-yellow-light: #FEF5DC;
  --brand-charcoal:     #3B3B3B;
  --brand-charcoal-dark:#1C1C1C;

  /* ── UI principal ── */
  --primary:      #F5A800;
  --primary-dark: #D4900A;
  --primary-light:#FEF5DC;
  --secondary:    #3B3B3B;
  --cta:          #F5A800;
  --cta-dark:     #D4900A;
  --cta-light:    #FEF5DC;

  /* ── Estado ── */
  --success:       #059669;
  --success-light: #d1fae5;
  --warning:       #d97706;
  --warning-light: #fef3c7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --info:          #2563eb;
  --info-light:    #dbeafe;

  /* ── Layout ── */
  --bg:          #F7F6F3;
  --bg-card:     #ffffff;
  --sidebar-bg:  #1C1C1C;
  --sidebar-text:#9A9A9A;
  --sidebar-active: #F5A800;
  --sidebar-hover:  #2E2E2E;
  --text-primary:   #1A1A1A;
  --text-secondary: #555555;
  --text-muted:     #9A9A9A;
  --border:         #E5E4E0;
  --border-focus:   #F5A800;

  /* ── Sombras ── */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.03);

  --radius:    10px;
  --radius-lg: 16px;
  --sidebar-w: 264px;
  --transition: 0.18s ease;
}

/* ===== DARK MODE ===== */
body.dark {
  --primary:      #F5A800;
  --primary-dark: #D4900A;
  --primary-light: rgba(245,168,0,.15);
  --cta:      #F5A800;
  --cta-dark: #D4900A;
  --cta-light: rgba(245,168,0,.15);
  --success-light: rgba(5,150,105,.2);
  --warning-light: rgba(217,119,6,.2);
  --danger-light:  rgba(220,38,38,.2);
  --info-light:    rgba(37,99,235,.2);
  --bg:          #111111;
  --bg-card:     #1E1E1E;
  --sidebar-bg:  #0A0A0A;
  --sidebar-text:#6A6A6A;
  --sidebar-hover:#1A1A1A;
  --text-primary:  #F0EFE8;
  --text-secondary:#9A9A9A;
  --text-muted:    #555555;
  --border:        #333333;
  --border-focus:  #F5A800;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.5);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.6);
}
body.dark input[type="text"],
body.dark input[type="number"],
body.dark input[type="email"],
body.dark input[type="tel"],
body.dark input[type="date"],
body.dark select,
body.dark textarea {
  background: #0f172a;
  color: #f1f5f9;
  border-color: #334155;
}
body.dark input:focus, body.dark select:focus, body.dark textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
body.dark .search-bar { background: #1e293b; border-color: #334155; }
body.dark .search-bar input { color: #f1f5f9; }
body.dark .filter-tab { background: #1e293b; border-color: #334155; color: #94a3b8; }
body.dark .filter-tab:hover { border-color: #3b82f6; color: #3b82f6; }
body.dark .filter-tab.active { background: #3b82f6; color: white; border-color: #3b82f6; }
body.dark thead th { background: #0f172a; }
body.dark tbody tr:hover td { background: #273549; }
body.dark .btn-secondary { background: #1e293b; color: #f1f5f9; border-color: #334155; }
body.dark .btn-secondary:hover { background: #334155; }
body.dark .btn-ghost { color: #94a3b8; }
body.dark .btn-ghost:hover { background: #334155; color: #f1f5f9; }
body.dark .page-btn { background: #1e293b; border-color: #334155; color: #f1f5f9; }
body.dark .page-btn:hover:not(:disabled) { border-color: #3b82f6; color: #3b82f6; }
body.dark .ref-code { background: rgba(59,130,246,.15); color: #93c5fd; }
body.dark .img-upload-zone { border-color: #334155; }
body.dark .img-upload-zone:hover { background: rgba(59,130,246,.1); border-color: #3b82f6; }
body.dark .modal { background: #1e293b; }
body.dark .modal-header { border-color: #334155; }
body.dark .modal-footer { border-color: #334155; }
body.dark .confirm-dialog { background: #1e293b; }
body.dark .topbar { background: #1e293b; border-color: #334155; }
body.dark .kpi-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.4); }

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.06);
  color: var(--sidebar-text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,.12); color: #f1f5f9; }
.theme-toggle svg { width: 18px; height: 18px; }

/* Transition suave al cambiar tema */
body, body * {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.15s ease;
}
/* Excluir transiciones en animaciones propias */
.toast, .modal-overlay, .modal, .sidebar { transition: unset; }
.toast { animation: slideIn .25s ease forwards; }
.modal-overlay { transition: opacity 0.2s ease; }
.modal { transition: transform 0.2s ease; }
.sidebar { transition: transform var(--transition); }

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Fira Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

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

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo-img-wrap {
  background: #ffffff;
  border-radius: 10px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}
.sidebar-logo-img {
  width: 140px;
  height: auto;
  display: block;
}
.logo-sub {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.35);
  text-align: center;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}
.nav-section-label {
  font-size: 10px; font-weight: 600;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 8px 8px 6px;
  margin-top: 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 14px; font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #f1f5f9; }
.nav-item.active {
  background: var(--brand-yellow);
  color: #1A1A1A;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(245,168,0,.35);
}
.nav-item.active svg { color: #1A1A1A; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  font-size: 11px; font-weight: 600;
  padding: 1px 8px;
  border-radius: 20px;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.25); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info strong { font-size: 13px; color: #f1f5f9; display: block; truncate: ellipsis; }
.sidebar-user-info span { font-size: 11px; color: var(--sidebar-text); }

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

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 64px;
  display: flex; align-items: center;
  position: sticky; top: 0;
  z-index: 40;
  gap: 16px;
}
.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 22px; font-weight: 800; color: var(--text-primary); font-family: 'Barlow Condensed', sans-serif; letter-spacing: .02em; text-transform: uppercase; }
.topbar-title p { font-size: 13px; color: var(--text-secondary); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-content { padding: 28px; flex: 1; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 20px 24px 0;
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 700; }
.card-header p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.card-body { padding: 20px 24px 24px; }

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: default;
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-icon.blue { background: var(--primary-light); color: var(--primary); }
.kpi-icon.green { background: var(--success-light); color: var(--success); }
.kpi-icon.purple { background: #ede9fe; color: var(--secondary); }
.kpi-icon.orange { background: var(--warning-light); color: var(--warning); }
.kpi-change {
  font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 20px;
}
.kpi-change.up { background: var(--success-light); color: var(--success); }
.kpi-change.down { background: var(--danger-light); color: var(--danger); }
.kpi-change.neutral { background: var(--border); color: var(--text-secondary); }
.kpi-value { font-size: 28px; font-weight: 800; color: var(--brand-charcoal); line-height: 1.1; font-family: 'Barlow Condensed', sans-serif; letter-spacing: -.01em; }
body.dark .kpi-value { color: var(--text-primary); }
.kpi-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ===== DASHBOARD GRID ===== */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
}
.dash-full { grid-column: 1 / -1; }

/* ===== CHARTS ===== */
.chart-container { position: relative; height: 240px; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #f1f5f9; color: var(--text-secondary); }
.badge-purple { background: #ede9fe; color: var(--secondary); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-secondary { background: var(--bg); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-cta { background: var(--brand-yellow); color: #1A1A1A; font-weight: 700; }
.btn-cta:hover:not(:disabled) { background: var(--brand-yellow-dark); box-shadow: 0 4px 14px rgba(245,168,0,.4); color: #1A1A1A; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text-primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
label .required { color: var(--danger); margin-left: 2px; }
input[type="text"], input[type="number"], input[type="email"],
input[type="tel"], input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-primary);
  background: white;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }
.input-with-icon { position: relative; }
.input-with-icon svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.input-with-icon input { padding-left: 38px; }

/* ===== SEARCH BAR ===== */
.search-bar {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.search-bar svg { color: var(--text-muted); width: 18px; height: 18px; flex-shrink: 0; }
.search-bar input {
  border: none; background: transparent; outline: none;
  font-size: 14px; color: var(--text-primary); width: 100%; padding: 0;
  box-shadow: none;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  transform: translateY(12px) scale(.98);
  transition: transform 0.2s ease;
}
.modal-overlay.open .modal { transform: none; }
.modal-lg { max-width: 780px; }
.modal-sm { max-width: 420px; }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-shrink: 0;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-header p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  flex-shrink: 0;
}

/* ===== IMAGE UPLOAD ===== */
.img-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.img-upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.img-upload-zone input[type="file"] { display: none; }
.img-preview-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.img-preview-item {
  width: 80px; height: 80px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  border: 2px solid var(--border);
}
.img-preview-item img { width: 100%; height: 100%; object-fit: cover; }
.img-preview-item .img-remove {
  position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.6); color: white;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 12px; line-height: 1;
}

/* ===== PILL FILTER TABS ===== */
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: white;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); }
.filter-tab.active {
  background: var(--primary); color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 0;
  gap: 12px;
}
.pagination-info { font-size: 13px; color: var(--text-secondary); }
.pagination-btns { display: flex; gap: 6px; }
.page-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  color: var(--text-primary);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}
.empty-state svg { width: 56px; height: 56px; color: var(--text-muted); margin: 0 auto 16px; display: block; }
.empty-state .mascot-img {
  width: 120px; height: 120px;
  object-fit: contain;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(245,168,0,.18));
}
.empty-state h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.empty-state p { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }

/* ===== TOAST NOTIFICATIONS ===== */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--sidebar-bg);
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  min-width: 260px;
  animation: slideIn .25s ease forwards;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
@keyframes slideIn {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== DETAIL VIEW ===== */
.detail-field { margin-bottom: 12px; }
.detail-field label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; display: block; }
.detail-field .value { font-size: 15px; color: var(--text-primary); font-weight: 500; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.detail-img-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-img { width: 100px; height: 80px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); cursor: zoom-in; }
.mov-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.mov-item:last-child { border-bottom: none; }
.mov-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.mov-dot.entrada { background: var(--success); }
.mov-dot.salida { background: var(--danger); }
.mov-info { flex: 1; }
.mov-info strong { font-size: 13px; font-weight: 600; display: block; }
.mov-info span { font-size: 12px; color: var(--text-secondary); }
.mov-qty { font-size: 13px; font-weight: 700; }

/* ===== RESPONSIVE ===== */
.mobile-menu-btn { display: none; }
.bottom-nav      { display: none; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 49;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ── 1100px — tablet landscape ── */
@media (max-width: 1100px) {
  .kpi-grid  { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}

/* ── 768px — tablet portrait / mobile ── */
@media (max-width: 768px) {
  /* Sidebar */
  .sidebar            { transform: translateX(-100%); }
  .sidebar.open       { transform: translateX(0); box-shadow: 8px 0 32px rgba(0,0,0,.45); }
  .main               { margin-left: 0; }
  .mobile-menu-btn    { display: flex; }

  /* Topbar */
  .topbar             { padding: 0 12px; gap: 8px; height: 52px; }
  .topbar-title h1    { font-size: 16px; }
  .topbar-title p     { display: none; }
  .topbar-actions     { gap: 6px; }
  .btn-label          { display: none; }

  /* Page content — deja espacio al bottom nav */
  .page-content { padding: 14px 14px calc(64px + env(safe-area-inset-bottom, 8px)); }

  /* KPI */
  .kpi-grid { grid-template-columns: 1fr 1fr; }

  /* Bottom nav visible */
  .bottom-nav { display: flex; }

  /* Modals → bottom sheet */
  .modal-overlay  { align-items: flex-end; padding: 0; }
  .modal          {
    border-radius: 20px 20px 0 0;
    max-width: 100% !important;
    max-height: 90vh;
    transform: translateY(100%) scale(1);
    transition: transform 0.35s cubic-bezier(.32,.72,0,1);
  }
  .modal-overlay.open .modal  { transform: translateY(0) scale(1); }
  .confirm-dialog {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    width: 100%;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(.32,.72,0,1);
  }
  .modal-overlay.open .confirm-dialog { transform: translateY(0); }

  /* Forms */
  .form-row.cols-2,
  .form-row.cols-3 { grid-template-columns: 1fr; }

  /* Filter tabs — scroll horizontal */
  .filter-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .filter-tabs::-webkit-scrollbar { display: none; }
  .filter-tab { flex-shrink: 0; }

  /* Login — full-screen en móvil */
  .login-screen  { justify-content: stretch; align-items: stretch; padding: 0; }
  .login-card    {
    border-radius: 0;
    min-height: 100dvh;
    max-width: 100%;
    padding: 48px 28px 32px;
    display: flex; flex-direction: column; justify-content: center;
  }
  .login-logo { width: 200px; }
}

/* ── 640px — ocultar columnas no esenciales ── */
@media (max-width: 640px) {
  .hide-xs { display: none !important; }

  /* Topbar title aún más compacto */
  .topbar-title h1 { font-size: 14px; }

  /* Action buttons de tabla: targets táctiles cómodos */
  .btn-icon.btn-sm { min-width: 36px; min-height: 36px; padding: 7px; }
}

/* ── 400px — pantallas muy pequeñas ── */
@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .page-content { padding: 10px 10px calc(64px + env(safe-area-inset-bottom, 8px)); }
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: 48;
  background: var(--sidebar-bg);
  border-top: 1px solid rgba(255,255,255,.07);
  padding-bottom: env(safe-area-inset-bottom, 0);
  flex-direction: row;
}
.bnav-item {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 4px 10px;
  gap: 3px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  transition: color .18s;
  min-height: 52px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.bnav-item svg       { width: 22px; height: 22px; flex-shrink: 0; }
.bnav-item:active    { opacity: .65; }
.bnav-item.active    { color: var(--brand-yellow); }
.bnav-badge {
  position: absolute; top: 6px; right: calc(50% - 22px);
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700; line-height: 16px; height: 16px;
  border-radius: 10px; padding: 0 5px; min-width: 16px;
  text-align: center;
}

/* ===== MISC ===== */
.text-right { text-align: right; }
.font-mono { font-family: 'Fira Code', monospace; }
.ref-code { font-family: 'Fira Code', 'Courier New', monospace; background: var(--brand-yellow-light); padding: 2px 7px; border-radius: 4px; font-size: 12px; color: var(--brand-charcoal); font-weight: 700; letter-spacing: .04em; border: 1px solid rgba(245,168,0,.3); }
.price-value { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-4 { margin-bottom: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overlay-close { position: fixed; inset: 0; z-index: 49; display: none; }
.overlay-close.active { display: block; }
.section { display: none; }
.section.active { display: block; }
.img-lightbox {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
  display: none;
}
.img-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }
.img-lightbox.open { display: flex; }

/* Confirm dialog */
.confirm-dialog {
  background: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: scale(.95);
  transition: transform .2s;
}
.modal-overlay.open .confirm-dialog { transform: scale(1); }
.confirm-icon {
  width: 56px; height: 56px;
  background: var(--danger-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.confirm-icon svg { color: var(--danger); width: 28px; height: 28px; }

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--brand-charcoal-dark);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 32px 80px rgba(0,0,0,.65);
  animation: loginSlideUp .35s ease;
}
@keyframes loginSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.login-logo {
  display: block;
  width: 280px;
  height: auto;
  margin: 0 auto 20px;
}
.login-tagline {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  color: var(--brand-yellow);
  margin: 0 0 24px;
}
.login-divider {
  border: none;
  border-top: 1px solid #E5E7EB;
  margin: 0 0 24px;
}
.login-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--brand-charcoal);
  margin: 0 0 6px;
}
.login-subtitle {
  font-size: 13px;
  color: #6B7280;
  margin: 0 0 28px;
}
.login-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}
.login-input {
  width: 100%;
  padding: 13px 16px;
  border: 2px solid #E5E7EB;
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
  color: #1A1A1A;
}
.login-input:focus {
  border-color: var(--brand-yellow);
  box-shadow: 0 0 0 3px rgba(245,168,0,.18);
}
.login-error {
  margin: 8px 0 0;
  font-size: 13px;
  color: #DC2626;
  font-weight: 600;
}
.login-btn {
  width: 100%;
  margin-top: 24px;
  padding: 14px 20px;
  font-size: 15px;
  border-radius: 10px;
  letter-spacing: .02em;
}
.login-footer {
  margin-top: 24px;
  font-size: 12px;
  color: rgba(255,255,255,.28);
}
@keyframes loginShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}
.login-input.shake {
  animation: loginShake .4s ease;
  border-color: #DC2626 !important;
  box-shadow: 0 0 0 3px rgba(220,38,38,.15) !important;
}
