:root {
  --portal-primary: #3b7ddd;
  --portal-primary-dark: #1e3a5f;
  --portal-accent: #20c997;
  --portal-bg: #f4f6f9;
  --portal-card-radius: 0.5rem;
  --portal-shadow: 0 0 1px rgba(0, 0, 0, 0.08), 0 4px 14px rgba(30, 58, 95, 0.06);
}

body.portal-body {
  background: var(--portal-bg);
  min-height: 100vh;
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  font-family: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

.portal-topbar {
  background: linear-gradient(135deg, var(--portal-primary-dark) 0%, var(--portal-primary) 100%);
  color: #fff !important;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(30, 58, 95, 0.15);
}

.portal-topbar h1 {
  color: #fff !important;
  font-size: 1.25rem;
  margin: 0;
  font-weight: 600;
}

.portal-topbar .subtitle {
  font-size: 0.85rem;
  opacity: 0.9;
  margin-top: 0.15rem;
}

.portal-page-actions {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
}

.portal-page-actions .btn-primary {
  min-height: 2.5rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(59, 125, 221, 0.35);
}

/* Same scroll behaviour as admin long modals */
.elongo-modal-form-scroll .modal-dialog {
  max-height: calc(100vh - 2rem);
  margin: 1rem auto;
}

.elongo-modal-form-scroll .modal-content,
.elongo-modal-form-scroll .modal-content > form {
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.elongo-modal-form-scroll .modal-body {
  overflow-y: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

.elongo-modal-form-scroll .modal-header,
.elongo-modal-form-scroll .modal-footer {
  flex-shrink: 0;
}

.portal-content {
  padding: 1rem 1.25rem 2rem;
  max-width: 1140px;
  margin: 0 auto;
}

.portal-card {
  background: #fff;
  border-radius: var(--portal-card-radius);
  box-shadow: var(--portal-shadow);
  border: 1px solid rgba(0, 0, 0, 0.04);
  margin-bottom: 1rem;
  overflow: hidden;
}

.portal-card .card-header {
  background: #fff;
  border-bottom: 1px solid #eef1f5;
  font-weight: 600;
  padding: 0.75rem 1rem;
}

.portal-card .card-body {
  padding: 1rem;
}

/* AdminLTE-style small boxes */
.portal-small-box {
  border-radius: var(--portal-card-radius);
  box-shadow: var(--portal-shadow);
  display: block;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
  color: #fff;
  min-height: 88px;
}

.portal-small-box .inner {
  padding: 0.85rem 1rem;
}

.portal-small-box .inner h3 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.15rem;
  color: #fff !important;
}

.portal-small-box .inner p {
  font-size: 0.8rem;
  margin: 0;
  opacity: 0.95;
}

.portal-small-box .icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.25;
  font-size: 2.5rem;
}

.portal-small-box.bg-primary { background: linear-gradient(135deg, #3b7ddd, #2563b8); }
.portal-small-box.bg-success { background: linear-gradient(135deg, #28a745, #1e7e34); }
.portal-small-box.bg-warning { background: linear-gradient(135deg, #ffc107, #d39e00); color: #212529; }
.portal-small-box.bg-danger { background: linear-gradient(135deg, #dc3545, #bd2130); }
.portal-small-box.bg-info { background: linear-gradient(135deg, #17a2b8, #117a8b); }
.portal-small-box.bg-secondary { background: linear-gradient(135deg, #6c757d, #545b62); }

.portal-alert-strip {
  border-left: 4px solid #ffc107;
  background: #fff8e6;
  border-radius: var(--portal-card-radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.portal-quick-actions .btn {
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
}

.portal-list-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #eef1f5;
}

.portal-list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.portal-list-item:first-child {
  padding-top: 0;
}

.portal-badge-active,
.portal-badge-success { background: #d1e7dd; color: #0f5132; }
.portal-badge-expired,
.portal-badge-danger { background: #f8d7da; color: #842029; }
.portal-badge-pending,
.portal-badge-warning { background: #fff3cd; color: #664d03; }
.portal-badge-info { background: #cff4fc; color: #055160; }
.portal-badge-secondary { background: #e9ecef; color: #495057; }

.portal-kit-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
}

.portal-kit-hero .qr-wrap img {
  max-width: 140px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 4px;
  background: #fff;
}

.portal-detail-dl dt {
  font-weight: 600;
  color: #6c757d;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.portal-detail-dl dd {
  margin-bottom: 0.75rem;
}

#portalMap,
#portalFleetMap,
#portalPartnerMap,
#portalKitDetailMap {
  height: 260px;
  border-radius: var(--portal-card-radius);
  z-index: 1;
}

.portal-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: space-around;
  padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom));
  z-index: 1030;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.portal-bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.65rem;
  color: #6c757d;
  text-decoration: none;
  padding: 0.35rem 0.4rem;
  min-width: 3.25rem;
  border-radius: 8px;
}

.portal-bottom-nav a.active {
  color: var(--portal-primary);
  background: rgba(59, 125, 221, 0.08);
}

.portal-bottom-nav i,
.portal-bottom-nav svg {
  width: 1.2rem;
  height: 1.2rem;
  margin-bottom: 0.1rem;
}

.portal-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, var(--portal-primary-dark) 0%, var(--portal-primary) 55%, #5a9fd4 100%);
}

.portal-login-card {
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  border: none;
}

.portal-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  height: 100vh;
  background: var(--portal-primary-dark);
  color: #fff;
  padding: 1.25rem 0;
  z-index: 1000;
  overflow-y: auto;
}

.portal-sidebar .brand-block {
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 0.75rem;
}

.portal-sidebar a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.85);
  padding: 0.6rem 1.25rem;
  text-decoration: none;
  font-size: 0.9rem;
}

.portal-sidebar a.active,
.portal-sidebar a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.portal-with-sidebar {
  margin-left: 0;
}

@media (min-width: 768px) {
  body.portal-body {
    padding-bottom: 0;
  }

  .portal-bottom-nav {
    display: none;
  }

  .portal-with-sidebar {
    margin-left: 250px;
  }

  #portalMap,
  #portalFleetMap,
  #portalPartnerMap,
  #portalKitDetailMap {
    height: 320px;
  }
}

.portal-print-brand {
  display: none;
}

@media print {
  .portal-sidebar,
  .portal-bottom-nav,
  .portal-topbar,
  .portal-no-print {
    display: none !important;
  }

  .portal-with-sidebar {
    margin-left: 0 !important;
  }

  body.portal-body {
    background: #fff;
  }

  .portal-print-brand {
    display: block !important;
    margin-bottom: 1rem;
  }
}

.portal-map-full {
  min-height: 420px;
  height: 420px;
  border-radius: var(--portal-card-radius);
  overflow: hidden;
  background: #e9ecef;
}

#portalFleetMap,
#portalPartnerMap {
  min-height: 280px;
}

#portalPartnerMap.leaflet-container {
  z-index: 1;
}

.portal-map-legend .rounded-circle {
  vertical-align: middle;
}

.portal-login-card .input-group .portal-toggle-pw {
  font-size: 0.8rem;
}

.portal-login-card .nav-pills .nav-link {
  font-size: 0.9rem;
}

.portal-profile-avatar-wrap {
  flex-shrink: 0;
}

.portal-profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--portal-primary);
  display: block;
}

.portal-profile-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--portal-primary) 0%, var(--portal-primary-dark) 100%);
  color: #fff;
  font-size: 2rem;
  font-weight: 600;
}
