/* ===== VARIABLES ===== */
:root {
  --primary: #1a3a6b;
  --primary-light: #2a52a0;
  --primary-dark: #0f2547;
  --accent: #e8a020;
  --accent-hover: #c88010;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --bg: #f0f4f9;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 260px;
  --header-h: 64px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; color: var(--text); }

/* ===== LOGIN PAGE ===== */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-body::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
  top: -200px; right: -200px;
}

.login-body::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
  bottom: -150px; left: -100px;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
  color: white;
  box-shadow: 0 4px 16px rgba(26,58,107,0.3);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

.login-form .form-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 6px;
}

.login-form .form-control,
.login-form .input-group-text {
  border-color: var(--border);
  height: 44px;
}

.login-form .input-group-text {
  background: var(--bg);
  color: var(--text-muted);
  border-right: none;
}

.login-form .input-group .form-control {
  border-left: none;
}

.login-form .input-group .form-control:focus {
  box-shadow: none;
  border-color: var(--primary-light);
}

.login-form .input-group:focus-within .input-group-text {
  border-color: var(--primary-light);
}

.btn-login {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none;
  height: 48px;
  font-weight: 600;
  font-size: 15px;
  border-radius: 10px;
  transition: all 0.2s;
  color: white;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(26,58,107,0.4);
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.login-footer p {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 100;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

.sidebar-header {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: white;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
}

.brand-name {
  color: white;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
}

.brand-sub {
  color: rgba(255,255,255,0.6);
  font-size: 12px;
}

.sidebar-client-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.07);
  margin: 12px 12px 0;
  border-radius: 10px;
}

.client-avatar {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.client-name {
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.client-casillero {
  color: rgba(255,255,255,0.6);
  font-size: 12px;
}

.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav .nav-item { margin: 2px 10px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  position: relative;
}

.sidebar-nav .nav-link:hover {
  color: white;
  background: rgba(255,255,255,0.12);
}

.sidebar-nav .nav-link.active {
  color: white;
  background: rgba(255,255,255,0.18);
  font-weight: 600;
}

.sidebar-nav .nav-link i {
  width: 20px;
  text-align: center;
  font-size: 15px;
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.1);
  margin: 8px 10px;
}

.nav-link-danger { color: rgba(255,100,100,0.8) !important; }
.nav-link-danger:hover { color: #ff6b6b !important; background: rgba(255,100,100,0.1) !important; }

.badge-count {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}

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

/* TOP HEADER */
.top-header {
  height: var(--header-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.btn-icon {
  width: 38px; height: 38px;
  border: none;
  background: transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  transition: all 0.2s;
  cursor: pointer;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text-muted);
}
.header-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  width: 200px;
  color: var(--text);
}

.badge-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}

.btn-user {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  transition: all 0.2s;
}
.btn-user:hover { background: var(--bg); }

.user-avatar {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
}

.client-av { background: var(--accent) !important; }

/* PAGE CONTENT */
.page-content { padding: 28px; flex: 1; }

.content-section { display: none; }
.content-section.active { display: block; }

.section-header { margin-bottom: 24px; }

.section-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* STAT CARDS */
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }

.stat-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-change {
  font-size: 12px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-change.positive { color: var(--success); }
.stat-change.neutral { color: var(--text-muted); }

.stat-blue .stat-icon { background: #eff6ff; color: var(--info); }
.stat-blue .stat-value { color: var(--info); }
.stat-orange .stat-icon { background: #fff7ed; color: #f97316; }
.stat-orange .stat-value { color: #f97316; }
.stat-yellow .stat-icon { background: #fffbeb; color: var(--warning); }
.stat-yellow .stat-value { color: var(--warning); }
.stat-green .stat-icon { background: #f0fdf4; color: var(--success); }
.stat-green .stat-value { color: var(--success); }

/* CARD PANEL */
.card-panel {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* TABLES */
.admin-table {
  font-size: 14px;
  margin: 0;
}

.admin-table thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

.admin-table tbody tr:hover { background: #f8fafc; }
.admin-table tbody tr:last-child td { border-bottom: none; }

.table-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

/* SEARCH BAR */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text-muted);
}
.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  width: 240px;
  color: var(--text);
}

/* STATUS BADGES */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-miami { background: #eff6ff; color: #2563eb; }
.status-transito { background: #fff7ed; color: #ea580c; }
.status-panama { background: #fef3c7; color: #d97706; }
.status-listo { background: #ecfdf5; color: #059669; }
.status-entregado { background: #f0fdf4; color: #16a34a; }
.status-activo { background: #f0fdf4; color: #16a34a; }
.status-inactivo { background: #fef2f2; color: #dc2626; }
.status-pagado { background: #f0fdf4; color: #16a34a; }
.status-pendiente { background: #fffbeb; color: #d97706; }

/* FILTER CHIPS */
.filter-chip {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: white;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  user-select: none;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* TRACKING RESULT */
.tracking-timeline {
  padding: 20px;
}

.timeline-item {
  display: flex;
  gap: 16px;
  position: relative;
  padding-bottom: 24px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 40px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }

.timeline-dot {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  z-index: 1;
}

.timeline-dot.active { background: var(--primary); color: white; }
.timeline-dot.done { background: var(--success); color: white; }
.timeline-dot.pending { background: var(--border); color: var(--text-muted); }

.timeline-content { flex: 1; }
.timeline-title { font-weight: 600; font-size: 15px; }
.timeline-date { font-size: 12px; color: var(--text-muted); }
.timeline-desc { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* ADDRESS BOX */
.address-box {
  background: var(--bg);
  border-radius: 10px;
  padding: 24px;
  margin: 0 20px 16px;
  border: 2px dashed var(--border);
}

.address-line {
  margin-bottom: 8px;
  font-size: 15px;
}

.address-label {
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 8px;
  font-size: 13px;
}

/* PROFILE */
.profile-avatar {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: white;
  font-weight: 700;
  margin: 24px auto 0;
}

/* SUCURSALES */
.sucursal-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
}
.sucursal-flag { font-size: 24px; }
.sucursal-name { font-weight: 600; font-size: 14px; }
.sucursal-addr { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* CHARTS PLACEHOLDER */
.chart-placeholder {
  padding: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 180px;
  gap: 20px;
}

.chart-bar-group {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 100%;
  width: 100%;
  justify-content: space-around;
}

.chart-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.chart-bar {
  width: 100%;
  max-width: 60px;
  background: var(--primary);
  border-radius: 6px 6px 0 0;
  transition: opacity 0.2s;
}
.chart-bar:hover { opacity: 0.8; }
.bar-orange { background: #f97316; }
.bar-yellow { background: var(--warning); }
.bar-green { background: var(--success); }

.chart-bar-item span {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ACTION BUTTONS */
.btn-action {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* RECENT CLIENT ITEM */
.recent-client-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}
.recent-client-item:last-child { border-bottom: none; }
.recent-client-item:hover { background: var(--bg); }

.rc-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.rc-name { font-weight: 600; font-size: 14px; }
.rc-casillero { font-size: 12px; color: var(--text-muted); }
.rc-date { font-size: 12px; color: var(--text-muted); margin-left: auto; white-space: nowrap; }

/* SIDEBAR TOGGLE (mobile) */
.sidebar.collapsed { transform: translateX(-100%); }
.main-content.expanded { margin-left: 0; }

/* RESPONSIVE */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-content { padding: 16px; }
  .header-search { display: none; }
  .stat-value { font-size: 22px; }
}

/* CLIENT THEME ACCENT */
.client-theme .sidebar {
  background: linear-gradient(180deg, #0f2547 0%, #1a3a6b 60%, #1e4080 100%);
}

.client-theme .nav-link.active {
  background: rgba(232,160,32,0.2);
  border-left: 3px solid var(--accent);
}

/* BREADCRUMB */
.breadcrumb { font-size: 14px; }
.breadcrumb-item.active { color: var(--text); font-weight: 500; }

/* MODAL */
.modal-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; }

/* PLAN STATS */
.plan-stat { }
.progress { height: 8px; border-radius: 4px; background: var(--border); }
.progress-bar { border-radius: 4px; }

/* TOOLTIP like info rows */
.info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-muted); }
.info-row .value { font-weight: 600; }
