:root {
  --navy: #1a3a5c;
  --navy-dark: #122840;
  --sidebar-w: 240px;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */

body { background: #f0f4f8; font-family: 'Segoe UI', system-ui, sans-serif; }

.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--navy); color: #fff;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
  z-index: 1000; overflow-y: auto;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-brand {
  padding: 1.25rem 1rem;
  font-size: 1.1rem; font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-nav { flex: 1; padding: .5rem 0; }

.nav-section {
  padding: .6rem 1rem .2rem;
  font-size: .68rem; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: rgba(255,255,255,.4);
}

.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1rem; color: rgba(255,255,255,.75);
  text-decoration: none; font-size: .88rem;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.13); color: #fff; border-left-color: #fff; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: .8rem;
}

.badge-role { font-size: .7rem; color: rgba(255,255,255,.55); }

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin .25s ease;
}
.main-content.expanded { margin-left: 0; }

.topbar {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-weight: 600; font-size: .95rem; color: var(--navy); }

.page-content { padding: 1.5rem; }

/* ── Login ─────────────────────────────────────────────────────────────────── */

.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #2d6a9f 100%);
}
.login-card { width: 100%; max-width: 400px; border: none; border-radius: 1rem; }
.login-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
}

/* ── Stat cards ────────────────────────────────────────────────────────────── */

.stat-card {
  background: #fff; border-radius: .75rem;
  padding: 1.25rem; display: flex; align-items: center; gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: .6rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--navy); }
.stat-label { font-size: .8rem; color: #64748b; }

/* ── Tablas ────────────────────────────────────────────────────────────────── */

.table thead th {
  font-size: .75rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: #64748b; border-top: none;
}
.card { border: none; border-radius: .75rem; }
.card-header {
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  font-size: .9rem; padding: .85rem 1.25rem;
}

/* ── Role badges ───────────────────────────────────────────────────────────── */

.role-admin      { background: #dbeafe; color: #1e40af; }
.role-despachador{ background: #d1fae5; color: #065f46; }
.role-chofer     { background: #fef3c7; color: #92400e; }
.role-superadmin { background: #ede9fe; color: #5b21b6; }
.role-cliente    { background: #fce7f3; color: #9d174d; }

/* ── Mobile PWA ────────────────────────────────────────────────────────────── */

.pwa-body {
  background: #f0f4f8; min-height: 100vh;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.pwa-header {
  background: var(--navy); color: #fff;
  padding: 1rem 1.25rem;
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.pwa-content { padding: 1.25rem; max-width: 480px; margin: 0 auto; }

.step-btn {
  width: 100%; padding: 1rem;
  font-size: 1.1rem; font-weight: 600;
  border-radius: .75rem; border: none;
  cursor: pointer; transition: transform .1s, box-shadow .1s;
}
.step-btn:active { transform: scale(.97); }

.trip-card {
  background: #fff; border-radius: .75rem;
  padding: 1.25rem; margin-bottom: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ── Timeline ──────────────────────────────────────────────────────────────── */

.timeline { position: relative; padding-left: 1.5rem; }
.timeline::before {
  content: ''; position: absolute; left: .4rem; top: 0; bottom: 0;
  width: 2px; background: #e2e8f0;
}
.timeline-item { position: relative; padding-bottom: 1.25rem; }
.timeline-dot {
  position: absolute; left: -1.1rem; top: .2rem;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--navy); border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--navy);
}
.timeline-time { font-size: .72rem; color: #94a3b8; }
.timeline-label { font-weight: 600; font-size: .88rem; }

/* ── Mapa ──────────────────────────────────────────────────────────────────── */

#map { border-radius: .75rem; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */

.btn-primary { background: var(--navy); border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn-outline-primary { color: var(--navy); border-color: var(--navy); }
.btn-outline-primary:hover { background: var(--navy); border-color: var(--navy); }

.fab {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--navy); color: #fff; border: none;
  font-size: 1.5rem; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(26,58,92,.4); cursor: pointer;
  text-decoration: none;
}
.fab:hover { background: var(--navy-dark); color: #fff; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f0f4f8; }
::-webkit-scrollbar-thumb { background: #b0bec5; border-radius: 3px; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.3); }
  .main-content { margin-left: 0 !important; }
}

/* Overlay al abrir sidebar en móvil */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 999;
}
.sidebar-overlay.show { display: block; }
