:root {
  --velocity-red: #e63946;
  --velocity-red-dark: #c1121f;
  --velocity-gold: #f4a261;
  --bg-dark: #0d1117;
  --bg-card: #161b22;
  --bg-sidebar: #010409;
  --border-color: #30363d;
  --text-primary: #f0f6fc;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottomnav-height: 64px;
  --header-height: 60px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  margin: 0;
}

h1, h2, h3, h4, h5, .page-title, .auth-title, .bike-title {
  font-family: 'Rajdhani', sans-serif;
  letter-spacing: 0.02em;
}

/* Auth */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #010409 0%, #1a0a0d 50%, #0d1117 100%);
}

.auth-wrapper {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  background: radial-gradient(circle at center, rgba(230,57,70,0.15), transparent 70%);
}

.auth-brand .brand-icon {
  font-size: 4rem;
  color: var(--velocity-red);
  margin-bottom: 1rem;
}

.auth-brand h1 {
  font-size: 3rem;
  margin: 0;
  color: var(--text-primary);
}

.auth-brand p {
  color: var(--velocity-gold);
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem 4rem;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
}

.auth-title { margin-bottom: 0.25rem; }

@media (max-width: 768px) {
  .auth-wrapper { grid-template-columns: 1fr; }
  .auth-brand { padding: 2rem; min-height: 30vh; }
  .auth-card { padding: 2rem; border-left: none; border-top: 1px solid var(--border-color); }
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--velocity-red);
  font-family: 'Rajdhani', sans-serif;
}

.sidebar-brand strong { display: block; font-size: 1.2rem; color: var(--text-primary); }
.sidebar-brand small { color: var(--text-muted); }

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 0.25rem;
  transition: all 0.15s;
}

.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.nav-item.active { background: rgba(230,57,70,0.15); color: var(--velocity-red); }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--velocity-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.user-chip .name { font-size: 0.85rem; font-weight: 600; }
.user-chip .role { font-size: 0.75rem; color: var(--text-muted); text-transform: capitalize; }

.app-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
}

.app-header {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
}

.page-title { margin: 0; font-size: 1.75rem; }
.page-subtitle { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.app-content { padding: 2rem; flex: 1; }

/* Cards */
.panel-card, .bike-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.panel-card .card-header {
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  height: 100%;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.stat-value { font-size: 1.5rem; font-weight: 700; font-family: 'Rajdhani', sans-serif; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; }

.bike-card .card-body { padding: 1.25rem; }
.bike-meta, .event-meta { display: flex; gap: 1rem; font-size: 0.85rem; color: var(--text-muted); }
.event-meta div { margin-bottom: 0.35rem; }

/* Tables */
.table-dark {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-primary);
  --bs-table-border-color: var(--border-color);
  --bs-table-hover-bg: rgba(255,255,255,0.03);
}

/* Forms */
.form-control, .form-select {
  background: var(--bg-dark);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
  background: var(--bg-dark);
  border-color: var(--velocity-red);
  color: var(--text-primary);
  box-shadow: 0 0 0 0.2rem rgba(230,57,70,0.25);
}

.form-label { color: var(--text-muted); font-size: 0.85rem; }

/* Buttons */
.btn-velocity {
  background: var(--velocity-red);
  border-color: var(--velocity-red);
  color: #fff;
  font-weight: 600;
}

.btn-velocity:hover, .btn-velocity:focus {
  background: var(--velocity-red-dark);
  border-color: var(--velocity-red-dark);
  color: #fff;
}

.link-velocity { color: var(--velocity-red); text-decoration: none; }
.link-velocity:hover { color: var(--velocity-gold); }

/* Tier badges */
.tier-silver { background: #6c757d !important; }
.tier-gold { background: #d4a017 !important; color: #000 !important; }
.tier-diamond { background: #0dcaf0 !important; color: #000 !important; }
.tier-platinum { background: #e2e8f0 !important; color: #000 !important; }

.list-group-item { border-color: var(--border-color) !important; color: var(--text-primary); }

/* ============================================================
   PORTAL SHELL — Desktop sidebar + Mobile bottom nav
   ============================================================ */

.portal-body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.portal-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.portal-sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
}

.portal-main {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

.portal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 1rem 1.25rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(22, 27, 34, 0.95);
  backdrop-filter: blur(12px);
  min-height: var(--header-height);
}

.portal-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.portal-header-brand {
  color: var(--velocity-red);
  font-size: 1.5rem;
}

.portal-header .page-title {
  margin: 0;
  font-size: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-header .page-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.portal-content {
  padding: 1rem 1.25rem 2rem;
  flex: 1;
}

.portal-bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 300;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: rgba(1, 4, 9, 0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--bottomnav-height) + var(--safe-bottom));
}

.bottomnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.65rem;
  min-height: 44px;
  padding: 0.35rem 0.25rem;
  transition: color 0.15s;
}

.bottomnav-item i { font-size: 1.25rem; }
.bottomnav-item.active { color: var(--velocity-red); }
.bottomnav-item:active { transform: scale(0.96); }

/* Mobile app-like layout */
@media (max-width: 991.98px) {
  .portal-main { margin-left: 0; }
  .portal-content {
    padding: 1rem 1rem calc(var(--bottomnav-height) + var(--safe-bottom) + 1rem);
  }
  .toolbar form { flex-wrap: wrap; }
  .toolbar .form-control,
  .toolbar .form-select { width: 100% !important; }
}

/* Desktop web app */
@media (min-width: 992px) {
  .portal-content { padding: 1.5rem 2rem 2rem; }
  .portal-header .page-title { font-size: 1.75rem; }
}

/* Mobile cards (customer app) */
.mobile-card-list { display: flex; flex-direction: column; gap: 0.75rem; }
.mobile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1rem;
}

.member-hero {
  background: linear-gradient(135deg, rgba(230,57,70,0.2), rgba(22,27,34,1));
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem;
}

.member-hero-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.member-hero-stats {
  display: flex;
  gap: 1.5rem;
}

.member-hero-stats .label,
.profile-grid .label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.section-header h5 { margin: 0; font-size: 1rem; }
.section-header a { font-size: 0.85rem; color: var(--velocity-red); text-decoration: none; }

.avatar-lg { width: 56px; height: 56px; font-size: 1.25rem; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.75rem; }

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.invoice-amount {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: 'Rajdhani', sans-serif;
}

.stat-value-sm { font-size: 1.1rem; }

.btn-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portal-admin { --portal-accent: #e63946; }
.portal-staff { --portal-accent: #f4a261; }
.portal-customer { --portal-accent: #e63946; }

/* Auth mobile */
@media (max-width: 768px) {
  .auth-brand h1 { font-size: 2rem; }
  .auth-card { padding: 1.5rem; }
}

/* Legacy sidebar (unused) */
@media (max-width: 992px) {
  .sidebar { width: 72px; }
  .sidebar-brand div, .nav-item span, .user-chip div, .sidebar-footer .btn span { display: none; }
  .app-main { margin-left: 72px; }
  .nav-item { justify-content: center; padding: 0.7rem; }
}
