/* ============================================================
   FLORALAB — Design System
   Forest Green Brand Theme | Inter font
   Logo: dark forest green #1B6B3A / white
   ============================================================ */

:root {
  /* ── Floralab Brand Greens ── */
  --brand-50:   #f0f9f4;
  --brand-100:  #d4edde;
  --brand-200:  #a6d9bc;
  --brand-300:  #6fbf95;
  --brand-400:  #44a872;   /* accent claro — hover, links */
  --brand-500:  #1B6B3A;   /* COLOR PRINCIPAL DEL LOGO */
  --brand-600:  #165830;
  --brand-700:  #114525;
  --brand-800:  #0c321b;

  /* ── alias emerald → brand (compatibilidad) ── */
  --green-400:  var(--brand-400);
  --green-500:  var(--brand-500);
  --green-600:  var(--brand-600);
  --emerald-400: #4ab87a;   /* acento brillante, textos highlight */
  --emerald-500: #1B6B3A;   /* = brand-500 */
  --emerald-600: var(--brand-600);

  /* ── Dark backgrounds (tono más cálido/forestal) ── */
  --bg-900:  #080e0b;
  --bg-800:  #0d1510;
  --bg-700:  #121d16;
  --bg-600:  #182519;
  --bg-500:  #1e2f21;
  --surface:  #14201a;
  --surface2: #192619;

  /* ── Borders ── */
  --border:       rgba(27,107,58,.18);
  --border-hover: rgba(68,168,114,.35);

  /* ── Text ── */
  --text-primary:   #edf7f1;
  --text-secondary: #7ec99a;
  --text-muted:     #4a6b57;

  /* ── Layout ── */
  --sidebar-w: 260px;
  --sidebar-collapsed: 72px;
  --topbar-h: 60px;

  /* ── Radii ── */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* ── Shadows ── */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.5);
  --shadow-md:   0 4px 16px rgba(0,0,0,.55);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.65);
  --shadow-glow: 0 0 20px rgba(27,107,58,.22);

  --transition: .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-900);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-800); }
::-webkit-scrollbar-thumb { background: var(--bg-500); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--emerald-600); }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-800);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 72px;
}

.brand { display: flex; align-items: center; gap: 12px; overflow: hidden; }

.brand-logo {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(27,107,58,.4), var(--shadow-glow);
}
.brand-logo svg { display: block; }

/* legacy brand-icon kept for other places */
.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.brand-text { overflow: hidden; }
.brand-name { display: block; font-size: 18px; font-weight: 800; color: var(--text-primary); white-space: nowrap; }
.brand-name span { color: var(--emerald-400); }
.brand-sub { display: block; font-size: 10px; color: var(--text-muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .05em; }

.sidebar-toggle, .topbar-toggle {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover, .topbar-toggle:hover {
  background: var(--bg-600); color: var(--emerald-400);
}

/* Topbar hamburger: only on mobile; Sidebar toggle: only on desktop */
.topbar-toggle { display: none; }
@media (max-width: 768px) {
  .topbar-toggle { display: flex; }
  .sidebar-toggle { display: none; }
}

.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section { margin-bottom: 8px; }

.nav-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 6px 8px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.nav-item i { width: 18px; text-align: center; flex-shrink: 0; font-size: 15px; }

.nav-item:hover {
  background: var(--bg-600);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(16,185,129,.18), rgba(34,197,94,.08));
  color: var(--emerald-400);
  border: 1px solid rgba(52,211,153,.2);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--emerald-400);
  border-radius: 0 2px 2px 0;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-700);
  overflow: hidden;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--emerald-500), var(--green-600));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; overflow: hidden; }
.user-name { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: 11px; color: var(--text-muted); text-transform: capitalize; }

.logout-btn {
  color: var(--text-muted); font-size: 15px; text-decoration: none;
  transition: color var(--transition);
  flex-shrink: 0;
}
.logout-btn:hover { color: #ef4444; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* sin esto el flex crece con su contenido y las tablas no hacen scroll propio */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-800);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }

.badge-role {
  background: linear-gradient(135deg, rgba(16,185,129,.2), rgba(34,197,94,.1));
  border: 1px solid rgba(52,211,153,.25);
  color: var(--emerald-400);
  font-size: 11px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: capitalize;
}

/* ---- Page Content ---- */
.page-content {
  padding: 28px 28px;
  flex: 1;
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.card-title {
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  color: var(--text-primary);
}

.card-title i { color: var(--emerald-400); }

/* ---- KPI Cards ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}

.kpi-card:hover { transform: translateY(-2px); border-color: var(--border-hover); }

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--kpi-color, rgba(16,185,129,.08));
  transform: translate(30%, -30%);
}

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: var(--kpi-color, rgba(16,185,129,.12));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--kpi-text, var(--emerald-400));
  margin-bottom: 12px;
}

.kpi-value { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 4px; }
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--bg-700);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:hover { background: var(--bg-700); }
tbody td { padding: 12px 14px; vertical-align: middle; }

tbody tr:last-child { border-bottom: none; }

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}

.badge-success { background: rgba(34,197,94,.15); color: #4ade80; border: 1px solid rgba(34,197,94,.25); }
.badge-warning { background: rgba(234,179,8,.15);  color: #fbbf24; border: 1px solid rgba(234,179,8,.25); }
.badge-danger  { background: rgba(239,68,68,.15);  color: #f87171; border: 1px solid rgba(239,68,68,.25); }
.badge-info    { background: rgba(59,130,246,.15);  color: #60a5fa; border: 1px solid rgba(59,130,246,.25);}
.badge-muted   { background: rgba(100,116,139,.15); color: #94a3b8; border: 1px solid rgba(100,116,139,.25); }

/* ---- Status indicators ---- */
.status-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.status-dot.ok    { background: rgba(34,197,94,.2); color: #4ade80; }
.status-dot.pending { background: rgba(234,179,8,.2); color: #fbbf24; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff;
  box-shadow: 0 4px 14px rgba(27,107,58,.4);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #247d47, var(--brand-500));
  box-shadow: 0 6px 20px rgba(27,107,58,.55);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-600); color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-500); border-color: var(--border-hover); }

.btn-danger {
  background: rgba(239,68,68,.12); color: #f87171;
  border: 1px solid rgba(239,68,68,.25);
}
.btn-danger:hover { background: rgba(239,68,68,.22); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }

.form-control, .form-select {
  background: var(--bg-700);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-control:focus, .form-select:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}

.form-control::placeholder { color: var(--text-muted); }
select.form-select option { background: var(--bg-700); color: var(--text-primary); }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ---- Toggle switch ---- */
.toggle-switch input { display: none; }
.toggle-switch label {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; font-size: 14px; color: var(--text-primary);
}
.toggle-track {
  width: 42px; height: 24px;
  background: var(--bg-500);
  border-radius: 12px;
  position: relative;
  transition: background var(--transition);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
}
.toggle-switch input:checked + label .toggle-track { background: var(--emerald-500); }
.toggle-switch input:checked + label .toggle-track::after { transform: translateX(18px); }

/* ============================================================
   SEARCHBAR
   ============================================================ */
.searchbar {
  position: relative;
  display: flex; align-items: center;
}
.searchbar i {
  position: absolute; left: 12px;
  color: var(--text-muted); font-size: 14px;
  pointer-events: none;
}
.searchbar input {
  padding-left: 38px;
  background: var(--bg-700);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding-top: 9px; padding-bottom: 9px;
  font-size: 14px; font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  width: 260px;
}
.searchbar input:focus { border-color: var(--emerald-500); }
.searchbar input::placeholder { color: var(--text-muted); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 90%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 18px;
  transition: color var(--transition);
}
.modal-close:hover { color: #f87171; }

/* ============================================================
   PRODUCT CARD (catálogo)
   ============================================================ */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.product-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.product-card-img {
  width: 100%; aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-700);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 36px;
}
.product-card-img img { width: 100%; height: 100%; object-fit: cover; }

.product-card-body { padding: 12px; }
.product-card-code { font-size: 10px; color: var(--text-muted); margin-bottom: 2px; }
.product-card-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.product-card-price { font-size: 15px; font-weight: 800; color: var(--emerald-400); }
.product-card-stock { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   ORDER CART / PREPEDIDO
   ============================================================ */
.cart-summary {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}

.cart-totals { text-align: right; padding-top: 12px; border-top: 1px solid var(--border); }
.cart-totals .line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.cart-totals .total-line { font-size: 17px; font-weight: 800; color: var(--emerald-400); margin-top: 6px; }

/* ---- Steps ---- */
.steps {
  display: flex; gap: 8px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.step {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-muted);
}
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  transition: all var(--transition);
}
.step.active .step-num {
  background: var(--emerald-500); color: #fff;
  box-shadow: 0 0 10px rgba(16,185,129,.4);
}
.step.done .step-num {
  background: rgba(34,197,94,.2); color: var(--green-400);
}
.step.active { color: var(--text-primary); }
.step-sep { height: 1px; width: 28px; background: var(--border); }

/* ============================================================
   ALERTS / TOASTS
   ============================================================ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999; display: flex; flex-direction: column; gap: 10px;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  animation: slideIn .25s ease;
}

.toast.success { border-left: 3px solid var(--emerald-500); }
.toast.error   { border-left: 3px solid #ef4444; }
.toast.info    { border-left: 3px solid #3b82f6; }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  justify-content: flex-end; margin-top: 18px;
}
.page-info { margin-right: auto; font-size: 12.5px; color: var(--text-muted); }
.page-gap  { color: var(--text-muted); padding: 0 2px; }
.page-btn {
  min-width: 34px; padding: 0 8px; height: 34px; border-radius: var(--radius-sm);
  background: var(--bg-700); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); text-decoration: none;
}
.page-btn:hover { background: var(--bg-500); color: var(--text-primary); }
.page-btn.active { background: var(--emerald-500); color: #fff; border-color: var(--emerald-500); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 30% 40%, rgba(16,185,129,.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(34,197,94,.05) 0%, transparent 50%),
              var(--bg-900);
  padding: 24px;
}

.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(16,185,129,.06);
}

.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .icon {
  width: 72px; height: 72px;
  background: #1B6B3A;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  box-shadow: 0 0 0 4px rgba(27,107,58,.25), var(--shadow-glow);
  margin-bottom: 14px;
  overflow: hidden;
}
.login-logo h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.login-logo h1 span { color: var(--emerald-400); }
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-card .form-group { margin-bottom: 16px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-top: 8px; }

.login-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.25);
  color: #f87171;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ============================================================
   IMAGE UPLOAD PREVIEW
   ============================================================ */
.img-upload-wrap {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition);
}
.img-upload-wrap:hover { border-color: var(--emerald-500); }
.img-preview {
  width: 120px; height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin: 8px auto;
  display: block;
}
.img-upload-wrap input { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ---- Mobile overlay backdrop ---- */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
  z-index: 99;
  opacity: 0;
  transition: opacity .25s ease;
}
.sidebar-backdrop.visible {
  display: block;
  opacity: 1;
}

/* ---- Tablet ≤ 1024px ---- */
@media (max-width: 1024px) {
  .page-content { padding: 20px; }
  .kpi-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

  /* Two-column layouts → stack */
  .dashboard-grid,
  .detail-grid,
  .discount-grid {
    grid-template-columns: 1fr !important;
  }

  .card-header {
    flex-wrap: wrap;
  }

  .searchbar input { width: 200px; }
}

/* ---- Mobile ≤ 768px ---- */
@media (max-width: 768px) {
  /* Sidebar slides from left with overlay */
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.4);
  }

  /* Main content fills screen */
  .main-content { margin-left: 0 !important; }

  /* Page content padding */
  .page-content { padding: 14px; }

  /* Topbar */
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-title { font-size: 14px; }

  /* Forms & grids */
  .form-grid { grid-template-columns: 1fr; }

  /* KPI */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .kpi-value { font-size: 22px; }
  .kpi-card { padding: 14px; }
  .kpi-icon { width: 34px; height: 34px; font-size: 15px; margin-bottom: 8px; }

  /* Cards */
  .card { padding: 16px; border-radius: var(--radius-md); }
  .card-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 10px;
  }

  /* Buttons wrap */
  .flex.gap-2, .flex.gap-3, .flex.gap-4 {
    flex-wrap: wrap;
  }

  /* Searchbar */
  .searchbar { width: 100%; }
  .searchbar input { width: 100% !important; }

  /* Products grid (catalog cards) */
  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  /* Tables — force horizontal scroll + minimum widths */
  .table-wrap { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  table { min-width: 600px; }
  thead th { padding: 10px 10px; font-size: 10px; }
  tbody td { padding: 10px 10px; font-size: 12.5px; }

  /* Pagination */
  .pagination { 
    justify-content: center; 
    flex-wrap: wrap;
  }

  /* Buttons */
  .btn { padding: 8px 14px; font-size: 12.5px; }
  .btn-sm { padding: 6px 10px; font-size: 11.5px; }

  /* Steps */
  .steps { gap: 4px; }
  .step { font-size: 11px; }
  .step-num { width: 24px; height: 24px; font-size: 11px; }
  .step-sep { width: 16px; }

  /* Modal */
  .modal { 
    padding: 20px; 
    width: 95%; 
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }

  /* Toast */
  .toast-container { 
    bottom: 12px; right: 12px; left: 12px;
  }
  .toast { 
    min-width: auto; 
    font-size: 12.5px; 
    padding: 10px 14px;
  }

  /* Login page */
  .login-card { 
    padding: 28px 20px; 
    border-radius: var(--radius-lg);
  }
  .login-logo h1 { font-size: 22px; }
  .login-logo .icon { width: 60px; height: 60px; font-size: 24px; }

  /* Cart totals */
  .cart-totals .total-line { font-size: 15px; }

  /* Order filter form adjustments */
  .orders-filter-form {
    flex-direction: column;
    align-items: stretch !important;
    width: 100% !important;
  }
  .orders-filter-form input[type="date"],
  .orders-filter-form input[type="text"] {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Inline grid forms (discount page tipo/valor grid) */
  .discount-form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Image upload */
  .img-preview { width: 90px; height: 90px; }
}

/* ---- Small phones ≤ 480px ---- */
@media (max-width: 480px) {
  html { font-size: 14px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-card { 
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
  }
  .kpi-card::before { display: none; }
  .kpi-icon { margin-bottom: 0; }
  .kpi-value { font-size: 20px; }

  .products-grid { grid-template-columns: 1fr 1fr; }

  .page-content { padding: 10px; }

  .topbar-title { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .badge-role { font-size: 10px; padding: 3px 8px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-emerald { color: var(--emerald-400); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.hidden { display: none !important; }
