/*
 * TrackX — RouteX Design System
 * Light-only, navy sidebar, clean professional look.
 * REGLA: todo color usa CSS var. Cero valores hardcoded.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ══════════════════════════════════════════════════════════════
   CSS VARIABLES — RouteX Palette
   ══════════════════════════════════════════════════════════════ */
:root {
  /* PRIMARY — Azul Navy */
  --primary-50:  #f0f6ff;
  --primary-100: #e0edff;
  --primary-200: #c7deff;
  --primary-300: #a3c9ff;
  --primary-400: #5a96ff;
  --primary-500: #1a5fd9;
  --primary-600: #0d4ab8;
  --primary-700: #0a3d99;
  --primary-800: #08357a;
  --primary-900: #082b57;
  --primary-950: #051d3d;

  /* SECONDARY — Slate */
  --secondary-50:  #f8fafc;
  --secondary-100: #f1f5f9;
  --secondary-200: #e2e8f0;
  --secondary-300: #cbd5e1;
  --secondary-400: #94a3b8;
  --secondary-500: #64748b;
  --secondary-600: #475569;
  --secondary-700: #334155;
  --secondary-800: #1e293b;
  --secondary-900: #0f172a;

  /* SUCCESS */
  --success-50:  #f0fdf4;
  --success-100: #dcfce7;
  --success-500: #22c55e;
  --success-600: #16a34a;
  --success-700: #15803d;

  /* WARNING */
  --warning-50:  #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;

  /* ERROR */
  --error-50:  #fef2f2;
  --error-100: #fee2e2;
  --error-200: #fecaca;
  --error-500: #ef4444;
  --error-600: #dc2626;
  --error-700: #b91c1c;

  /* SPECIAL */
  --green-500: #22c55e;

  /* LAYOUT */
  --sidebar-width: 280px;
  --sidebar-collapsed: 80px;
  --topbar-height: 64px;
  --topbar-height-mobile: 56px;

  /* SEMANTIC */
  --bg-page: var(--secondary-50);
  --bg-card: #ffffff;
  --bg-secondary: var(--secondary-100);
  --bg-tertiary: var(--secondary-50);
  --text-primary: var(--secondary-900);
  --text-secondary: var(--secondary-600);
  --text-muted: var(--secondary-400);
  --border-color: var(--secondary-200);
  --border-subtle: var(--secondary-100);

  /* SHORTHAND ALIASES (used in JS pages) */
  --accent:  #1a5fd9;
  --success: #22c55e;
  --danger:  #ef4444;
  --warning: #f59e0b;
  --info:    #3b82f6;
  --purple:  #7c3aed;
}

/* ══════════════════════════════════════════════════════════════
   RESET
   ══════════════════════════════════════════════════════════════ */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
input, select, textarea, button {
  font-family: inherit; font-size: inherit; outline: none;
}
a { color: var(--primary-500); text-decoration: none; }
a:hover { color: var(--primary-600); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ══════════════════════════════════════════════════════════════
   LAYOUT — App Wrapper
   ══════════════════════════════════════════════════════════════ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  transition: margin-left 0.3s ease;
  min-width: 0;       /* prevent flex child from expanding beyond parent */
  overflow-x: hidden;
}
.main-content-inner {
  padding: 2rem;
  min-width: 0;
  max-width: 100%;
}
body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed);
}

/* ══════════════════════════════════════════════════════════════
   SIDEBAR — Navy Gradient
   ══════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: linear-gradient(to bottom, #082b57, #08357a, #051d3d);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.3s ease;
}
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}

/* Sidebar blobs */
.sidebar::before,
.sidebar::after {
  content: '';
  position: absolute;
  pointer-events: none;
  width: 256px; height: 256px;
  border-radius: 50%;
  opacity: 0.1;
  mix-blend-mode: overlay;
  filter: blur(64px);
}
.sidebar::before {
  top: -60px; left: -60px;
  background: #5a96ff;
}
.sidebar::after {
  bottom: 40px; right: -80px;
  background: #0d4ab8;
}

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
}

/* Logo area */
.sidebar-logo {
  padding: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}
.sidebar-logo-text {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.sidebar-logo-text .logo-route {
  color: #ffffff;
  font-weight: 700;
  font-size: 1.5rem;
}
.sidebar-logo-text .logo-x {
  color: var(--green-500);
  font-weight: 700;
  font-size: 1.5rem;
}
.sidebar-logo .logo-sub {
  color: var(--primary-200);
  font-size: 0.65rem;
  margin-left: 0.5rem;
}
body.sidebar-collapsed .sidebar-logo .logo-sub,
body.sidebar-collapsed .sidebar-logo-text .logo-route {
  display: none;
}
.sidebar-toggle-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 0.5rem;
  color: white;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
  background: rgba(255,255,255,0.2);
}

/* User panel */
.sidebar-user {
  margin: 1rem;
  padding: 1rem;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  border-radius: 0.75rem;
  border: 1px solid rgba(255,255,255,0.2);
  position: relative;
  z-index: 1;
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-user-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.3);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-weight: 600;
  color: white;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  color: var(--primary-100);
  font-size: 0.75rem;
  text-transform: capitalize;
}
.sidebar-user-badge {
  margin-top: 0.75rem;
  background: rgba(255,255,255,0.2);
  color: white;
  border-radius: 0.5rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  border: 1px solid rgba(255,255,255,0.3);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.sidebar-collapsed .sidebar-user-name,
body.sidebar-collapsed .sidebar-user-role,
body.sidebar-collapsed .sidebar-user-badge,
body.sidebar-collapsed .sidebar-user-info > div {
  display: none;
}
body.sidebar-collapsed .sidebar-user {
  padding: 0.5rem;
  display: flex; justify-content: center;
}
body.sidebar-collapsed .sidebar-user-info {
  justify-content: center;
}

/* Navigation sections */
.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
  position: relative;
  z-index: 1;
}
.nav-section {
  margin-bottom: 0.5rem;
}
.nav-section-label {
  color: var(--primary-200);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 1rem 0.375rem;
}
body.sidebar-collapsed .nav-section-label {
  display: none;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  margin: 0.125rem 0.75rem;
  border-radius: 0.5rem;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  white-space: nowrap;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}
.nav-item.active {
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  border-color: rgba(255,255,255,0.3);
}
.nav-item.active::after {
  content: '';
  position: absolute;
  right: -0.75rem;
  top: 50%; transform: translateY(-50%);
  width: 4px; height: 16px;
  background: white;
  border-radius: 2px;
}
.nav-item-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.1);
  border-radius: 0.5rem;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.nav-item-text {
  font-size: 0.875rem;
  font-weight: 500;
}
body.sidebar-collapsed .nav-item-text {
  display: none;
}
body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0.625rem;
  margin: 0.125rem 0.5rem;
}
body.sidebar-collapsed .nav-item.active::after {
  right: -0.5rem;
}

/* Logout button */
.sidebar-logout {
  margin: 0.75rem;
  position: relative;
  z-index: 1;
}
.sidebar-logout .nav-item {
  background: rgba(239,68,68,0.2);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fee2e2;
  margin: 0;
}
.sidebar-logout .nav-item:hover {
  background: #dc2626;
  border-color: #ef4444;
}
.sidebar-logout .nav-item-icon {
  background: rgba(239,68,68,0.2);
}

/* Footer */
.sidebar-footer {
  padding: 1rem;
  text-align: center;
  color: var(--primary-200);
  font-size: 0.75rem;
  position: relative;
  z-index: 1;
}
body.sidebar-collapsed .sidebar-footer {
  display: none;
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}
.sidebar-overlay.show { display: block; }

/* ══════════════════════════════════════════════════════════════
   TOPBAR / HEADER
   ══════════════════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--secondary-200);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  transition: left 0.3s ease;
}
body.sidebar-collapsed .topbar {
  left: var(--sidebar-collapsed);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar-hamburger {
  display: none;
  background: none; border: none;
  color: var(--secondary-700);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
}
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}
.topbar-breadcrumb .bc-home {
  color: var(--secondary-400);
}
.topbar-breadcrumb .bc-sep {
  color: var(--secondary-300);
  font-size: 0.75rem;
}
.topbar-breadcrumb .bc-current {
  color: var(--primary-900);
  font-weight: 600;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Storage indicator */
.storage-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--secondary-600);
}
.storage-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.storage-dot.green { background: var(--success-500); }
.storage-dot.yellow { background: var(--warning-500); }
.storage-dot.red { background: var(--error-500); animation: pulse 2s infinite; }
.storage-bar {
  width: 64px; height: 6px;
  background: var(--secondary-200);
  border-radius: 3px;
  overflow: hidden;
}
.storage-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.storage-bar-fill.green { background: var(--success-500); }
.storage-bar-fill.yellow { background: var(--warning-500); }
.storage-bar-fill.red { background: var(--error-500); }

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE — Split Screen
   ══════════════════════════════════════════════════════════════ */
.login-wrap {
  display: flex;
  min-height: 100vh;
}
.login-form-side {
  flex: 1;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}
.login-form-inner {
  width: 100%;
  max-width: 400px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 2rem;
}
.login-logo .logo-route {
  color: var(--secondary-900);
  font-weight: 700;
  font-size: 1.5rem;
}
.login-logo .logo-x {
  color: var(--green-500);
  font-weight: 700;
  font-size: 1.5rem;
}
.login-title {
  font-weight: 700;
  font-size: 1.875rem;
  color: var(--secondary-900);
  margin-bottom: 0.5rem;
}
.login-subtitle {
  color: var(--secondary-600);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
}
.login-field {
  margin-bottom: 1.25rem;
}
.login-field label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--secondary-700);
  margin-bottom: 0.375rem;
}
.input-group {
  position: relative;
}
.input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%; transform: translateY(-50%);
  color: var(--secondary-400);
  font-size: 1.125rem;
  pointer-events: none;
}
.input-icon-right {
  position: absolute;
  right: 0.75rem;
  top: 50%; transform: translateY(-50%);
  color: var(--secondary-400);
  font-size: 1.125rem;
  cursor: pointer;
  background: none; border: none;
}
.input-icon-right:hover { color: var(--secondary-600); }
.input-group input {
  width: 100%;
  border: 1px solid var(--secondary-300);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group input:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(26,95,217,0.1);
}
.input-group input::placeholder {
  color: var(--secondary-400);
}
.login-error {
  color: var(--error-500);
  font-size: 0.8125rem;
  margin-bottom: 0.75rem;
  min-height: 1.25rem;
}
.btn-login {
  width: 100%;
  background: var(--primary-900);
  color: white;
  border: none;
  border-radius: 0.5rem;
  padding: 0.875rem 1.5rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-login:hover { background: var(--primary-800); }
.btn-login:disabled {
  opacity: 0.6; cursor: not-allowed;
}
.login-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--secondary-400);
  font-size: 0.8125rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--secondary-200);
}
.btn-track-package {
  width: 100%;
  background: white;
  color: var(--secondary-700);
  border: 2px solid var(--secondary-300);
  border-radius: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  font-size: 0.9375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s;
}
.btn-track-package:hover {
  border-color: var(--secondary-400);
  background: var(--secondary-50);
}
.login-footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--secondary-400);
  font-size: 0.75rem;
}

/* Login right panel — hero */
.login-hero-side {
  flex: 1;
  background: linear-gradient(135deg, #082b57, #08357a, #051d3d);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}
.login-hero-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 64px 64px;
  pointer-events: none;
}
.login-hero-blob {
  position: absolute;
  width: 320px; height: 320px;
  border-radius: 50%;
  opacity: 0.15;
  filter: blur(80px);
  pointer-events: none;
  animation: blob 7s infinite ease-in-out;
}
.login-hero-blob:nth-child(1) {
  top: 10%; left: 15%;
  background: #5a96ff;
  animation-delay: 0s;
}
.login-hero-blob:nth-child(2) {
  top: 50%; right: 10%;
  background: #0d4ab8;
  animation-delay: 2s;
}
.login-hero-blob:nth-child(3) {
  bottom: 10%; left: 30%;
  background: #1a5fd9;
  animation-delay: 4s;
}
.login-hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 500px;
}
.login-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 9999px;
  padding: 0.375rem 1rem;
  color: white;
  font-size: 0.875rem;
  margin-bottom: 2rem;
}
.login-hero-title {
  color: white;
  font-weight: 700;
  font-size: 2.5rem;
  line-height: 1.2;
  margin-bottom: 1rem;
}
.login-hero-sub {
  color: var(--primary-100);
  font-size: 1.0625rem;
  line-height: 1.6;
  margin-bottom: 2.5rem;
}
.login-hero-features {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.feature-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.75rem;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
  transition: background 0.2s;
}
.feature-card:hover {
  background: rgba(255,255,255,0.1);
}
.feature-card-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.1);
  border-radius: 0.5rem;
  color: var(--primary-300);
  font-size: 1.25rem;
  flex-shrink: 0;
}
.feature-card-title {
  color: white;
  font-weight: 600;
  font-size: 0.9375rem;
}
.feature-card-desc {
  color: var(--primary-200);
  font-size: 0.8125rem;
}

/* ══════════════════════════════════════════════════════════════
   PAGE CONTENT
   ══════════════════════════════════════════════════════════════ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: .5rem;
}
.page-header h2 {
  font-size: 1.25rem; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; gap: .5rem;
}
.page-header h2 i { color: var(--primary-500); font-size: 1.3rem; }
.page-title {
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--secondary-900);
}
.page-subtitle {
  color: var(--secondary-600);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ══════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  overflow: clip;  /* border-radius without clipping absolutely-positioned children */
}
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}
.card-body {
  padding: 1.5rem;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow .2s;
}
.kpi-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.07); }
/* icon block — generated by kpiCard() as .kpi-card-icon or .kpi-icon */
.kpi-card-icon, .kpi-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.75rem;
  font-size: 1.5rem;
  flex-shrink: 0;
  background: var(--primary-50);
  color: var(--primary-500);
}
.kpi-card-icon.green,  .kpi-icon.green  { background: var(--success-50);  color: var(--success-600); }
.kpi-card-icon.yellow, .kpi-icon.yellow { background: var(--warning-50);  color: var(--warning-600); }
.kpi-card-icon.red,    .kpi-icon.red    { background: var(--error-50);    color: var(--error-600); }
.kpi-card-icon.purple, .kpi-icon.purple { background: #f5f3ff;             color: #7c3aed; }
.kpi-card-icon.blue,   .kpi-icon.blue   { background: var(--primary-50);  color: var(--primary-500); }
/* text block — .kpi-card-top holds label+value when icon is sibling */
.kpi-card-top { flex: 1; }
.kpi-label {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}
.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.kpi-change {
  font-size: 0.75rem;
  margin-top: 0.25rem;
}
.kpi-change.up { color: var(--success-500); }
.kpi-change.down { color: var(--error-500); }

/* ══════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════ */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}
.table-wrap thead th {
  background: var(--secondary-50);
  color: var(--secondary-600);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.table-wrap tbody td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table-wrap tbody tr:last-child td {
  border-bottom: none;
}
.table-wrap tbody tr:hover {
  background: var(--secondary-50);
}
.table-wrap tbody tr { cursor: pointer; transition: background 0.15s; }

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary-900);
  color: white;
  border-color: var(--primary-900);
}
.btn-primary:hover { background: var(--primary-800); border-color: var(--primary-800); }
.btn-outline {
  background: transparent;
  color: var(--secondary-700);
  border-color: var(--secondary-300);
}
.btn-outline:hover {
  background: var(--secondary-50);
  border-color: var(--secondary-400);
}
.btn-ghost {
  background: transparent;
  color: var(--secondary-600);
  border: none;
}
.btn-ghost:hover { background: var(--secondary-100); }
.btn-danger {
  background: var(--error-500);
  color: white;
  border-color: var(--error-500);
}
.btn-danger:hover { background: var(--error-600); border-color: var(--error-600); }
.btn-success {
  background: var(--success-500);
  color: white;
  border-color: var(--success-500);
}
.btn-success:hover { background: var(--success-600); border-color: var(--success-600); }
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}
.btn-full { width: 100%; }

/* Botones de icono en tablas */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: .4rem;
  border: none;
  background: transparent;
  color: var(--secondary-400);
  cursor: pointer;
  transition: background .15s, color .15s;
  font-size: 1.05rem;
  padding: 0;
}
.btn-icon:hover {
  background: var(--secondary-100);
  color: var(--accent);
}
.btn-icon.danger:hover { background: #fee2e2; color: var(--danger); }
td.inline-actions {
  white-space: nowrap;
  padding: .25rem .75rem;
}
tr:hover .btn-icon { color: var(--secondary-500); }

/* ══════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════ */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--secondary-700);
  margin-bottom: 0.375rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
input[type="search"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--secondary-300);
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(26,95,217,0.1);
}
input::placeholder, textarea::placeholder {
  color: var(--secondary-400);
}
textarea { resize: vertical; min-height: 80px; }

/* ══════════════════════════════════════════════════════════════
   BADGES DE ESTADO
   ══════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}
.badge-created     { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-in_transit  { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-en_sucursal { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge-delivered   { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.badge-cancelled   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge-rejected    { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge-pending     { background: #f8fafc; color: #334155; border-color: #cbd5e1; }
.badge-urgente     { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }

/* ══════════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform 0.2s;
}
.modal-overlay.show .modal {
  transform: translateY(0);
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-weight: 600;
  font-size: 1.125rem;
}
.modal-close {
  background: none; border: none;
  color: var(--secondary-400);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.375rem;
}
.modal-close:hover { background: var(--secondary-100); color: var(--secondary-600); }
.modal-body {
  padding: 1.5rem;
}
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ══════════════════════════════════════════════════════════════
   TOASTS
   ══════════════════════════════════════════════════════════════ */
#toasts {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  animation: toast-in 0.3s ease;
  border: 1px solid;
}
.toast.ok {
  background: var(--success-50);
  color: var(--success-700);
  border-color: var(--success-100);
}
.toast.err {
  background: var(--error-50);
  color: var(--error-700);
  border-color: var(--error-100);
}
.toast.warn {
  background: var(--warning-50);
  color: var(--warning-700);
  border-color: var(--warning-100);
}
.toast.info {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-100);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ══════════════════════════════════════════════════════════════
   TRACKING PAGE (public)
   ══════════════════════════════════════════════════════════════ */
.tracking-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}
.tracking-card {
  background: white;
  border-radius: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 600px;
  padding: 2.5rem;
}
.tracking-card-logo {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.tracking-input-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.tracking-input-row .input-group {
  flex: 1;
}
.tracking-input-row .btn-primary {
  flex-shrink: 0;
}

/* Timeline */
.timeline {
  margin-top: 1.5rem;
}
.timeline-item {
  display: flex;
  gap: 1rem;
  padding-bottom: 1.5rem;
  position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 36px;
  bottom: 0;
  width: 2px;
  background: var(--secondary-200);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  z-index: 1;
}
.timeline-dot.blue   { background: #eff6ff; color: #1d4ed8; }
.timeline-dot.yellow { background: #fffbeb; color: #b45309; }
.timeline-dot.purple { background: #f5f3ff; color: #6d28d9; }
.timeline-dot.green  { background: #f0fdf4; color: #15803d; }
.timeline-dot.red    { background: #fef2f2; color: #b91c1c; }
.timeline-dot.gray   { background: #f8fafc; color: #64748b; }
.timeline-content {
  flex: 1;
  padding-top: 0.25rem;
}
.timeline-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}
.timeline-date {
  font-size: 0.75rem;
  color: var(--secondary-400);
  margin-top: 0.125rem;
}
.timeline-note {
  font-size: 0.8125rem;
  color: var(--secondary-500);
  margin-top: 0.25rem;
}

/* ══════════════════════════════════════════════════════════════
   AUTOCOMPLETE
   ══════════════════════════════════════════════════════════════ */
.autocomplete-wrap {
  position: relative;
}
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: white;
  border: 1px solid var(--secondary-200);
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  max-height: 240px;
  overflow-y: auto;
  z-index: 60;
  margin-top: 0.25rem;
  display: none;
}
.autocomplete-dropdown.show { display: block; }
.autocomplete-item {
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: var(--primary-50);
  color: var(--primary-700);
}

/* ══════════════════════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 1rem;
}
.page-btn {
  min-width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--secondary-200);
  border-radius: 0.5rem;
  background: white;
  color: var(--secondary-600);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.page-btn:hover { background: var(--secondary-50); border-color: var(--secondary-300); }
.page-btn.active {
  background: var(--primary-900);
  color: white;
  border-color: var(--primary-900);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════
   FILTER BAR
   ══════════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  margin-bottom: 1rem;
}
.filter-bar input,
.filter-bar select {
  max-width: 220px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

/* ══════════════════════════════════════════════════════════════
   DETAIL PANEL (slide-in)
   ══════════════════════════════════════════════════════════════ */
#detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px;
  max-width: 100%;
  background: white;
  box-shadow: -10px 0 30px rgba(0,0,0,0.15);
  z-index: 80;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#detail-panel.on {
  transform: translateX(0);
}
#detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 79;
}
#detail-overlay.on {
  display: block;
}
.detail-panel-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}
.detail-panel-body {
  padding: 1.5rem;
  flex: 1;
}
.detail-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
}
.detail-section:last-child { border-bottom: none; margin-bottom: 0; }
.detail-section h4 {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 0 0 .75rem;
}
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .3rem 0;
  font-size: .84rem;
}
.detail-row .label {
  flex: 0 0 120px;
  color: var(--text-muted);
  font-size: .78rem;
}
.detail-row .value {
  flex: 1;
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
}
.timeline { display: flex; flex-direction: column; gap: .75rem; }
.timeline-item {
  padding: .6rem .8rem;
  border-radius: .5rem;
  background: var(--bg-secondary);
  border-left: 3px solid var(--border-color);
}
.timeline-item.status-created  { border-color: var(--info); }
.timeline-item.status-in_transit { border-color: var(--warning); }
.timeline-item.status-en_sucursal { border-color: var(--purple); }
.timeline-item.status-delivered { border-color: var(--success); }
.timeline-item.status-cancelled,.timeline-item.status-rejected { border-color: var(--danger); }
.timeline-title { font-size: .82rem; font-weight: 600; color: var(--text-primary); }
.timeline-meta  { font-size: .72rem; color: var(--text-muted); margin-top: .15rem; }
.timeline-note  { font-size: .78rem; color: var(--text-secondary); margin-top: .3rem; font-style: italic; }

/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════════ */
@keyframes blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(30px, -50px) scale(1.1); }
  66%      { transform: translate(-20px, 20px) scale(0.9); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--secondary-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ══════════════════════════════════════════════════════════════
   UTILITY CLASSES
   ══════════════════════════════════════════════════════════════ */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-muted { color: var(--text-secondary); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.p-4 { padding: 1rem; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Mobile first
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .login-hero-side { display: none; }
}

@media (max-width: 768px) {
  :root {
    --topbar-height: var(--topbar-height-mobile);
  }
  .sidebar {
    transform: translateX(-100%);
    z-index: 51;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  body.sidebar-collapsed .sidebar {
    width: var(--sidebar-width);
  }
  .main-content {
    margin-left: 0 !important;
  }
  .topbar {
    left: 0 !important;
  }
  .topbar-hamburger {
    display: block;
  }
  .sidebar-toggle-btn {
    display: none;
  }
  .main-content-inner {
    padding: 1rem;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar input,
  .filter-bar select {
    max-width: 100%;
  }
  #detail-panel {
    width: 100%;
  }
  .login-form-side {
    padding: 1.5rem;
  }
  .tracking-card {
    padding: 1.5rem;
  }
  .tracking-input-row {
    flex-direction: column;
  }
  .table-wrap {
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .pagination {
    flex-wrap: wrap;
  }
}

/* ══════════════════════════════════════════════════════════════
   PAGE SECTIONS (used by JS pages)
   ══════════════════════════════════════════════════════════════ */
.page-section {
  display: none;
}
.page-section.active {
  display: block;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--secondary-400);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}
.empty-state p {
  font-size: 0.9375rem;
}

/* Status indicators */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.active { background: var(--success-500); }
.status-dot.inactive { background: var(--secondary-300); }

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem;
}
.tab-nav-item {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--secondary-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab-nav-item:hover { color: var(--secondary-700); }
.tab-nav-item.active {
  color: var(--primary-700);
  border-bottom-color: var(--primary-500);
}

/* Chip / tag */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--secondary-100);
  color: var(--secondary-600);
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════
   BACKWARD-COMPAT — Legacy class aliases used by api.js/app.js
   ══════════════════════════════════════════════════════════════ */
/* sgs-toast (used by api.js toast()) */
.sgs-toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  animation: toast-in 0.3s ease;
  border: 1px solid;
}
.sgs-toast.ok, .sgs-toast.nfo {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-100);
}
.sgs-toast.err {
  background: var(--error-50);
  color: var(--error-700);
  border-color: var(--error-100);
}
.sgs-toast.warn {
  background: var(--warning-50);
  color: var(--warning-700);
  border-color: var(--warning-100);
}

/* modal-bg (used by api.js openModal()) */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-bg .modal {
  background: white;
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}
.modal-bg .modal h3 {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--text-primary);
}
.modal-bg .modal .modal-form label {
  margin-top: 0.75rem;
}
.modal-bg .modal .row {
  display: flex;
  align-items: center;
}

/* btn-accent alias → btn-primary style */
.btn-accent, .btn.btn-accent {
  background: var(--primary-900);
  color: white;
  border-color: var(--primary-900);
}
.btn-accent:hover, .btn.btn-accent:hover {
  background: var(--primary-800);
  border-color: var(--primary-800);
}
.btn.full { width: 100%; }

/* search-wrap (used by autocomplete) */
.search-wrap {
  position: relative;
}
.search-wrap i {
  position: absolute;
  left: 0.75rem;
  top: 50%; transform: translateY(-50%);
  color: var(--secondary-400);
  font-size: 1.125rem;
  pointer-events: none;
}
.search-wrap input, .search-input {
  width: 100%;
  padding-left: 2.5rem !important;
}

/* autocomplete-list (old alias) */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: white;
  border: 1px solid var(--secondary-200);
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
  max-height: 240px;
  overflow-y: auto;
  z-index: 60;
  margin-top: 0.25rem;
  display: none;
}
.autocomplete-list.show { display: block; }

/* error-msg */
.error-msg {
  color: var(--error-500);
  font-size: 0.8125rem;
  margin: 0.5rem 0;
  min-height: 1rem;
}

/* Print styles */
@media print {
  .sidebar, .topbar, .sidebar-overlay, #toasts { display: none !important; }
  .main-content { margin-left: 0 !important; padding-top: 0 !important; }
  body { background: white; }
}

/* ══════════════════════════════════════════════════════════════
   MISSING UTILITY — added for page consistency
   ══════════════════════════════════════════════════════════════ */

/* flex row helper */
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* toolbar (search bars above tables) */
.toolbar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar-left { display: flex; align-items: center; gap: .75rem; flex: 1; flex-wrap: wrap; }

/* timestamps + monospace */
.ts   { font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.mono { font-family: 'Courier New', Courier, monospace; font-size: .85em; }

/* text color helpers */
.text-success { color: var(--success-500) !important; }
.text-warning  { color: var(--warning-500) !important; }
.text-danger   { color: var(--error-500)   !important; }

/* form layout */
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: .75rem; }
.form-field { display: flex; flex-direction: column; }
.form-field label { margin-bottom: .3rem; }
.chk-label { display: flex; align-items: center; gap: .5rem; font-size: .875rem; cursor: pointer; margin-top: .5rem; }
.chk-label input { width: auto; }

/* badge extras */
.badge-active   { display:inline-flex;align-items:center;padding:.2rem .6rem;border-radius:9999px;font-size:.72rem;font-weight:600;background:#f0fdf4;color:#15803d;border:1px solid #bbf7d0; }
.badge-inactive { display:inline-flex;align-items:center;padding:.2rem .6rem;border-radius:9999px;font-size:.72rem;font-weight:600;background:#f8fafc;color:#64748b;border:1px solid #cbd5e1; }

/* bulto pills (frio = blue, seco = amber) */
.bulto-badge {
  display: inline-flex; align-items: center; gap: .2rem;
  padding: .15rem .45rem; border-radius: 9999px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.bulto-badge.frio { background: #eff6ff; color: #1d4ed8; }
.bulto-badge.seco { background: #fffbeb; color: #b45309; }

/* generic small pill */
.pill { display: inline-flex; align-items: center; padding: .1rem .4rem; border-radius: .25rem; font-size: .68rem; font-weight: 600; }
.pill.dim { background: var(--secondary-100); color: var(--secondary-500); }

/* tb-select — compact select in filter bars */
.tb-select {
  height: 34px; padding: .3rem .5rem !important; font-size: .78rem !important;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: .5rem; color: var(--text-primary); cursor: pointer;
  max-width: 160px; width: auto;
}

/* pagination info label */
.page-info { font-size: .78rem; color: var(--text-muted); padding: 0 .5rem; white-space: nowrap; }

/* btn-icon color variants */
.btn-icon.success:hover { background: #f0fdf4; color: var(--success-600); }

/* storage indicator (topbar, admin only) */
.storage-indicator { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--text-secondary); padding: .25rem .75rem; }
.storage-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.storage-dot.green  { background: var(--success-500); }
.storage-dot.yellow { background: var(--warning-500); }
.storage-dot.red    { background: var(--error-500); }
.storage-bar { width: 70px; height: 5px; background: var(--secondary-200); border-radius: 3px; overflow: hidden; flex-shrink: 0; }
.storage-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.storage-bar-fill.green  { background: var(--success-500); }
.storage-bar-fill.yellow { background: var(--warning-500); }
.storage-bar-fill.red    { background: var(--error-500); }

/* bar chart (dashboard) */
.bar-chart-wrap { padding: 0 1.25rem 1rem; }
.bar-chart {
  display: flex; align-items: flex-end; gap: .375rem;
  height: 100px; padding-top: .5rem;
}
.bar {
  flex: 1; min-width: 16px;
  border-radius: .3rem .3rem 0 0; cursor: pointer;
  transition: opacity .15s;
}
.bar:hover { opacity: .8; }
/* separate labels row below the chart */
.bar-labels {
  display: flex; gap: .375rem; margin-top: 4px;
}
.bar-label {
  flex: 1; min-width: 16px; text-align: center; font-size: .58rem;
  color: var(--text-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
/* keep bar-chart inside card cleanly */
.card { overflow: visible; }
.card .table-wrap { border-radius: 0; border: none; }

/* confirm-badge for pedidos */
.badge-confirmed { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
