/* Apple iOS 18 & iPadOS Design System - 100% REM Scalable & Immersive App Experience */
:root, [data-color-mode="light"] {
  --ios-bg: #F2F2F7;
  --ios-card: #FFFFFF;
  --ios-card-secondary: #F8F9FA;
  --ios-sidebar: #ECECEE;
  --ios-text: #000000; /* Pure black for maximum legibility */
  --ios-subtext: #3C3C43; /* High-contrast charcoal, never washed out */
  --ios-blue: #007AFF;
  --ios-blue-light: rgba(0, 122, 255, 0.12);
  --ios-blue-hover: #0062CC;
  --ios-green: #0E7A3E; /* High-contrast Canadian Emerald Green (5.4:1 contrast, eliminates blurriness) */
  --ios-green-light: rgba(14, 122, 62, 0.12);
  --ios-orange: #FF9500;
  --ios-orange-light: rgba(255, 149, 0, 0.12);
  --ios-red: #FF3B30;
  --ios-red-light: rgba(255, 59, 48, 0.12);
  --ios-border: #D1D1D6; /* Clear, sharp boundaries */
  --ios-border-focus: #007AFF;
  --ios-input-bg: #FFFFFF;
  --ios-input-border: #8E8E93;
  --ios-shadow-sm: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.05);
  --ios-shadow-md: 0 0.375rem 1rem rgba(0, 0, 0, 0.09);
  --safe-top: max(env(safe-area-inset-top, 0px), 2.5rem);
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), 1rem);
  --safe-left: env(safe-area-inset-left, 0rem);
  --safe-right: env(safe-area-inset-right, 0rem);
  --island-offset-left: 3.75rem;
  --ios-topbar-bg: rgba(255, 255, 255, 0.92);
  --ios-tabbar-bg: rgba(255, 255, 255, 0.94);
}

[data-color-mode="dark"], .dark-theme {
  --ios-bg: #000000;
  --ios-card: #1C1C1E;
  --ios-card-secondary: #2C2C2E;
  --ios-sidebar: #121214;
  --ios-text: #FFFFFF;
  --ios-subtext: #D1D1D6; /* Crisp 85% white, 100% readable */
  --ios-border: #38383A;
  --ios-input-bg: #2C2C2E;
  --ios-input-border: #48484A;
  --ios-blue-light: rgba(10, 132, 255, 0.25);
  --ios-green-light: rgba(48, 209, 88, 0.25);
  --ios-shadow-sm: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.35);
  --ios-shadow-md: 0 0.375rem 1rem rgba(0, 0, 0, 0.5);
  --ios-topbar-bg: rgba(28, 28, 30, 0.92);
  --ios-tabbar-bg: rgba(28, 28, 30, 0.94);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-mode="light"]) {
    --ios-bg: #000000;
    --ios-card: #1C1C1E;
    --ios-card-secondary: #2C2C2E;
    --ios-sidebar: #121214;
    --ios-text: #FFFFFF;
    --ios-subtext: #D1D1D6;
    --ios-border: #38383A;
    --ios-input-bg: #2C2C2E;
    --ios-input-border: #48484A;
    --ios-blue-light: rgba(10, 132, 255, 0.25);
    --ios-green-light: rgba(48, 209, 88, 0.25);
    --ios-shadow-sm: 0 0.125rem 0.375rem rgba(0, 0, 0, 0.35);
    --ios-shadow-md: 0 0.375rem 1rem rgba(0, 0, 0, 0.5);
    --ios-topbar-bg: rgba(28, 28, 30, 0.92);
    --ios-tabbar-bg: rgba(28, 28, 30, 0.94);
  }
}

html {
  font-size: 100%;
  height: 100%;
  -webkit-text-size-adjust: 100%;
  background-color: var(--ios-bg);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--ios-bg);
  color: var(--ios-text);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  letter-spacing: -0.01em;
}

/* Base Full-Screen App Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

/* ==========================================================================
   MOBILE TOP NAVIGATION BAR (SLEEK GLASS HEADER)
   ========================================================================== */
.mobile-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: max(env(safe-area-inset-top, 0px), 2.875rem);
  padding-bottom: 0.5rem;
  padding-left: max(env(safe-area-inset-left, 0px), 0.75rem);
  padding-right: max(env(safe-area-inset-right, 0px), 0.75rem);
  background: var(--ios-topbar-bg, rgba(255, 255, 255, 0.92));
  backdrop-filter: blur(1.5rem);
  -webkit-backdrop-filter: blur(1.5rem);
  border-bottom: 0.0625rem solid var(--ios-border);
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.03);
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  overflow-x: hidden;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

html, body, #root, .app-layout {
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

[data-color-mode=dark] .mobile-top-bar,
.dark-theme .mobile-top-bar {
  background: rgba(28, 28, 30, 0.92) !important;
}

[data-color-mode=light] .mobile-top-bar,
.light-theme .mobile-top-bar {
  background: rgba(255, 255, 255, 0.92) !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-mode=light]) .mobile-top-bar {
    background: rgba(28, 28, 30, 0.92);
  }
}

.mobile-app-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.mobile-app-logo {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.625rem;
  background: linear-gradient(135deg, var(--ios-blue) 0%, #0051B3 100%);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0.25rem 0.625rem rgba(0, 122, 255, 0.3);
}

.mobile-brand-title {
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ios-text);
  line-height: 1.2;
}

.mobile-brand-user {
  font-size: 0.6875rem;
  color: var(--ios-subtext);
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================================================
   MOBILE BOTTOM TAB BAR (HIGH IMPACT FLOATING GLASS DOCK)
   ========================================================================== */
.mobile-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--ios-tabbar-bg, rgba(255, 255, 255, 0.94));
  backdrop-filter: blur(1.75rem);
  -webkit-backdrop-filter: blur(1.75rem);
  border-top: 0.09375rem solid var(--ios-border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.4375rem 0.5rem calc(var(--safe-bottom) + 0.4375rem) 0.5rem;
  z-index: 100;
  box-shadow: 0 -0.375rem 1.5rem rgba(0, 0, 0, 0.12);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

[data-color-mode=dark] .mobile-tab-bar,
.dark-theme .mobile-tab-bar {
  background: rgba(28, 28, 30, 0.94) !important;
}

[data-color-mode=light] .mobile-tab-bar,
.light-theme .mobile-tab-bar {
  background: rgba(255, 255, 255, 0.94) !important;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-mode=light]) .mobile-tab-bar {
    background: rgba(28, 28, 30, 0.94);
  }
}

.mobile-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1875rem;
  background: transparent;
  border: none;
  color: var(--ios-subtext);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.375rem 0.625rem;
  border-radius: 0.875rem;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 3.75rem;
  position: relative;
}

.mobile-tab-item:active {
  transform: scale(0.92);
}

.mobile-tab-item.active {
  color: var(--ios-blue);
  background: var(--ios-blue-light);
  font-weight: 700;
}

.mobile-tab-item.active svg {
  stroke: var(--ios-blue);
  stroke-width: 2.5;
  filter: drop-shadow(0 0.125rem 0.25rem rgba(0, 122, 255, 0.3));
}

/* ==========================================================================
   DESKTOP & IPAD SIDEBAR (PROMINENT & MODERN)
   ========================================================================== */
.desktop-sidebar {
  display: none;
}

@media screen and (min-width: 48rem) {
  .mobile-top-bar, .mobile-tab-bar {
    display: none !important;
  }

  .app-layout {
    flex-direction: row;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    width: 17.5rem;
    background: var(--ios-card);
    border-right: 0.0625rem solid var(--ios-border);
    padding: 1.75rem 1.125rem;
    flex-shrink: 0;
    box-shadow: 0.25rem 0 1.25rem rgba(0, 0, 0, 0.02);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 1.75rem;
    padding: 0 0.5rem;
  }

  .sidebar-brand h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--ios-text);
  }

  .sidebar-user {
    font-size: 0.75rem;
    color: var(--ios-subtext);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0.125rem;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
  }

  .sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border-radius: 0.875rem;
    border: none;
    background: transparent;
    color: var(--ios-text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar-item:hover {
    background: var(--ios-card-secondary);
    color: var(--ios-blue);
    transform: translateX(0.125rem);
  }

  .sidebar-item.active {
    background: var(--ios-blue);
    color: #FFFFFF;
    font-weight: 700;
    box-shadow: 0 0.25rem 0.875rem rgba(0, 122, 255, 0.3);
  }

  .sidebar-item.active svg {
    stroke: #FFFFFF;
    stroke-width: 2.2;
  }
}

/* ==========================================================================
   CONTENT VIEWPORT
   ========================================================================== */
.content-viewport {
  flex: 1;
  padding: 1rem;
  padding-bottom: calc(var(--safe-bottom) + 5.5rem);
  max-width: 48rem;
  margin: 0 auto;
  width: 100%;
  min-width: 0; /* critical for flex children so content can shrink/grow */
  min-height: 0;
  overflow-y: auto;
  background: var(--ios-bg);
  color: var(--ios-text);
  box-sizing: border-box;
}

@media screen and (min-width: 48rem) {
  .content-viewport {
    max-width: 72rem;
    margin: 0 auto;
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    box-sizing: border-box;
    height: 100%;
  }
}

/* ==========================================================================
   CARDS & CONTAINERS
   ========================================================================== */
.ios-card {
  background: var(--ios-card);
  border-radius: 1.125rem;
  padding: 1.375rem;
  margin-bottom: 1.125rem;
  border: 0.0625rem solid var(--ios-border);
  box-shadow: var(--ios-shadow-sm);
  transition: box-shadow 0.2s ease;
}

.ios-card-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ios-text);
}

/* ==========================================================================
   RICH, PROMINENT INPUT TEXT BOXES & TYPOGRAPHY
   ========================================================================== */
.ios-input-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
}

.ios-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ios-subtext);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4375rem;
  line-height: 1.2;
}

/* High-Impact Input Text Box */
.ios-input {
  width: 100%;
  height: 3.125rem !important; /* 50px rich touch target */
  min-height: 3.125rem !important;
  line-height: 3.125rem !important;
  background: var(--ios-input-bg) !important;
  border: 0.09375rem solid var(--ios-input-border) !important;
  border-radius: 0.75rem !important;
  padding: 0 1rem !important;
  font-size: 1.0625rem !important; /* Prominent readable font */
  font-weight: 600 !important;
  color: var(--ios-text) !important;
  outline: none !important;
  box-sizing: border-box !important;
  box-shadow: inset 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  -webkit-appearance: none;
  appearance: none;
}

/* Select specific styling with matching alignment and height */
select.ios-input {
  height: 3.125rem !important;
  min-height: 3.125rem !important;
  line-height: normal !important;
  padding: 0 2.25rem 0 1rem !important;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2214%22%20height%3D%2214%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%238E8E93%22%20stroke-width%3D%222.5%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22m6%209%206%206%206-6%22%2F%3E%3C%2Fsvg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.875rem center !important;
  background-size: 1rem !important;
  cursor: pointer;
}

/* Date input specific styling for identical size & alignment */
input[type="date"].ios-input {
  height: 3.125rem !important;
  min-height: 3.125rem !important;
  line-height: 3rem !important;
  padding: 0 0.875rem !important;
  cursor: pointer;
}

.ios-input:focus {
  border-color: var(--ios-blue) !important;
  background: var(--ios-card) !important;
  box-shadow: 0 0 0 0.25rem rgba(0, 122, 255, 0.18), inset 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.02) !important;
}

.ios-input::placeholder {
  color: #B0B0B5;
  font-weight: 500;
}

/* ==========================================================================
   PERFECT SIDE-BY-SIDE EQUAL ALIGNMENT ROWS
   ========================================================================== */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
  align-items: start;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  align-items: start;
}

.form-row-4 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.625rem;
  align-items: start;
}

/* On smaller screens keep 2-column layouts harmonious */
@media screen and (max-width: 32rem) {
  .form-row-3 {
    grid-template-columns: 1fr 1fr !important;
  }
  .form-row-4 {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ==========================================================================
   BUTTONS & ACTIONS
   ========================================================================== */
.ios-btn-primary {
  background: linear-gradient(135deg, var(--ios-blue) 0%, #0062CC 100%);
  color: #FFFFFF;
  border: none;
  border-radius: 0.875rem;
  padding: 0.875rem 1.25rem;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 0.25rem 0.875rem rgba(0, 122, 255, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ios-btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 0.125rem 0.375rem rgba(0, 122, 255, 0.25);
}

.ios-btn-secondary {
  background: var(--ios-card-secondary);
  color: var(--ios-text);
  border: 0.0625rem solid var(--ios-border);
  border-radius: 0.875rem;
  padding: 0.75rem 1.125rem;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  transition: all 0.15s ease;
}

.ios-btn-secondary:hover {
  background: var(--ios-border);
}

.ios-btn-secondary:active {
  transform: scale(0.97);
}

/* ==========================================================================
   SEGMENTED CONTROLS & SUB-TABS
   ========================================================================== */
.ios-segmented {
  display: flex;
  background: var(--ios-bg);
  padding: 0.25rem;
  border-radius: 0.875rem;
  margin-bottom: 1.125rem;
  border: 0.0625rem solid var(--ios-border);
}

.ios-segment-btn {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: none;
  background: transparent;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ios-subtext);
  border-radius: 0.625rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ios-segment-btn.active {
  background: linear-gradient(135deg, #007AFF 0%, #0056B3 100%) !important;
  color: #FFFFFF !important;
  border: 0.0625rem solid #0056B3 !important;
  box-shadow: 0 0.25rem 0.75rem rgba(0, 122, 255, 0.35) !important;
  font-weight: 800 !important;
}

/* ==========================================================================
   UBER/LYFT HERO GIG ACTION BUTTON
   ========================================================================== */
.gig-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
  text-transform: uppercase;
}

.gig-action-btn.start-gig {
  background: linear-gradient(135deg, #0E7A3E 0%, #085226 100%);
  color: #FFFFFF;
  box-shadow: 0 0.25rem 0.875rem rgba(52, 199, 89, 0.4);
}

.gig-action-btn.end-gig {
  background: linear-gradient(135deg, #FF3B30 0%, #C20012 100%);
  color: #FFFFFF;
  box-shadow: 0 0.25rem 0.875rem rgba(255, 59, 48, 0.4);
}

.gig-action-btn:active {
  transform: scale(0.95);
}

.hero-go-btn-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0;
  position: relative;
}

.hero-go-btn {
  width: 7.75rem;
  height: 7.75rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #0E7A3E 0%, #085226 100%);
  color: #FFFFFF;
  font-size: 1.1875rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0.75rem 2rem rgba(52, 199, 89, 0.45), inset 0 0.125rem 0.25rem rgba(255, 255, 255, 0.5);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  z-index: 2;
}

.hero-go-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 1rem 2.5rem rgba(52, 199, 89, 0.6);
}

.hero-go-btn:active {
  transform: scale(0.95);
}

.hero-go-aura {
  position: absolute;
  width: 9.5rem;
  height: 9.5rem;
  border-radius: 50%;
  border: 0.125rem solid rgba(52, 199, 89, 0.35);
  animation: hero-pulse 2s infinite ease-out;
  pointer-events: none;
}

.hero-go-aura.second {
  width: 11.5rem;
  height: 11.5rem;
  animation: hero-pulse 2s infinite ease-out 0.6s;
}

@keyframes hero-pulse {
  0% { transform: scale(0.85); opacity: 0.8; }
  100% { transform: scale(1.25); opacity: 0; }
}

.pulse-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #FFFFFF;
  animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.6; }
  100% { transform: scale(0.9); opacity: 1; }
}

/* Dashboard Grid for Desktop */
@media screen and (min-width: 48rem) {
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
  }

  .col-span-2 {
    grid-column: span 2;
  }
}

/* ==========================================================================
   IPHONE DYNAMIC ISLAND & MOBILE LANDSCAPE ADAPTATION
   Accommodates top selfie camera / Dynamic Island when rotated to landscape
   Moves navigation menus and brand headers cleanly to the right of the cutout
   ========================================================================== */
.iphone-landscape-island {
  display: none;
}

@media screen and (orientation: landscape) and (max-height: 35rem) {
  /* 1. Dedicated Dynamic Island Hardware Silhouette on Left Bezel */
  .iphone-landscape-island {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: max(0.5rem, calc(env(safe-area-inset-left, 0rem) * 0.15 + 0.375rem));
    top: 50%;
    transform: translateY(-50%);
    z-index: 9999;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .island-pill {
    width: 2.125rem;
    height: 7.75rem;
    background: #000000;
    border-radius: 1.125rem;
    box-shadow: 0 0 0 0.0625rem rgba(255, 255, 255, 0.12), 0 0.375rem 1.125rem rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    padding: 0.625rem 0;
  }

  .island-lens {
    width: 0.875rem;
    height: 0.875rem;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #1f2d52 0%, #0c1222 65%, #000000 100%);
    border: 0.0625rem solid rgba(255, 255, 255, 0.2);
    position: relative;
    box-shadow: inset 0 0 0.1875rem rgba(0, 0, 0, 0.9);
  }

  .island-reflection {
    width: 0.25rem;
    height: 0.25rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
  }

  .island-sensor {
    width: 0.5625rem;
    height: 0.5625rem;
    border-radius: 50%;
    background: radial-gradient(circle, #10141d 0%, #030508 100%);
    border: 0.0625rem solid rgba(255, 255, 255, 0.08);
  }

  /* 2. Move Desktop & Landscape Sidebar Menus to the Right */
  .desktop-sidebar {
    padding-left: calc(max(env(safe-area-inset-left, 0rem), var(--island-offset-left)) + 0.875rem) !important;
    padding-right: 0.875rem !important;
    padding-top: 1rem !important;
    padding-bottom: max(env(safe-area-inset-bottom, 0rem), 1rem) !important;
    width: calc(16.5rem + max(env(safe-area-inset-left, 0rem), var(--island-offset-left))) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-brand {
    margin-bottom: 0.875rem !important;
  }

  .sidebar-brand h1 {
    font-size: 1.125rem !important;
  }

  .sidebar-nav {
    gap: 0.3125rem !important;
  }

  .sidebar-item {
    padding: 0.5625rem 0.875rem !important;
    font-size: 0.875rem !important;
  }

  /* 3. Move Mobile Top Navigation Bar Menus to the Right */
  .mobile-top-bar {
    padding-left: calc(max(env(safe-area-inset-left, 0rem), var(--island-offset-left)) + 1rem) !important;
    padding-right: calc(max(env(safe-area-inset-right, 0rem), 0.75rem)) !important;
    padding-top: max(env(safe-area-inset-top, 0rem), 0.5rem) !important;
    padding-bottom: 0.5rem !important;
  }

  /* 4. Move Mobile Bottom Tab Bar Menus Away from Island & Safe Insets */
  .mobile-tab-bar {
    padding-left: calc(max(env(safe-area-inset-left, 0rem), var(--island-offset-left)) + 1rem) !important;
    padding-right: calc(max(env(safe-area-inset-right, 0rem), 1rem)) !important;
    padding-bottom: max(env(safe-area-inset-bottom, 0rem), 0.375rem) !important;
  }

  .mobile-tab-item {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.6875rem !important;
  }

  /* 5. Content Viewport Landscape Clearance */
  .content-viewport {
    padding-left: calc(max(env(safe-area-inset-left, 0rem), 1rem)) !important;
    padding-right: calc(max(env(safe-area-inset-right, 0rem), 1.5rem)) !important;
    padding-bottom: max(env(safe-area-inset-bottom, 0rem), 2rem) !important;
  }
}

/* ==========================================================================
   ENHANCEMENTS & UI BUG FIXES
   ========================================================================== */

/* Spinner Animation for Download/Export Buttons */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* Full Width Grid Spanning Helper */
.full-width-span {
  grid-column: 1 / -1;
  width: 100%;
}

/* PWA Add to Home Screen Banner */
.pwa-install-banner {
  background: var(--ios-card);
  border: 0.0625rem solid var(--ios-border);
  border-radius: 1rem;
  padding: 0.875rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--ios-shadow-sm);
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-sizing: border-box;
  width: 100%;
}

/* Select options readability in dark and light modes */
select.ios-input option {
  background: var(--ios-card);
  color: var(--ios-text);
}

/* Form row 3 responsive balancing for odd child */
@media screen and (max-width: 32rem) {
  .form-row-3 > :last-child:nth-child(odd) {
    grid-column: span 2;
  }
}

/* Mobile top bar responsive layout */
@media screen and (max-width: 26rem) {
  .mobile-brand-user {
    display: none;
  }
  .mobile-top-bar {
    padding-left: 0.375rem;
    padding-right: 0.375rem;
  }
  .mobile-app-brand {
    gap: 0.25rem;
  }
}

@media screen and (max-width: 25rem) {
  .mobile-exit-text {
    display: none;
  }
}

/* ==========================================================================
   MOBILE UI OVERHAUL & POLISH (iOS 17/18 NATIVE STANDARD)
   ========================================================================== */


/* ==========================================================================
   EQUAL-WIDTH SEGMENTED TABS & DATE-TIME PRECISION ALIGNMENT
   Guarantees 100% identical tab widths, zero crossing over on mobile,
   and pixel-perfect Date & Start Time alignment across iPhone Air & Android.
   ========================================================================== */
.desktop-tab-label {
  display: inline;
}
.mobile-tab-label {
  display: none;
}

.segmented-equal-tabs {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important; /* GUARANTEES 100% EQUAL WIDTH FOR ALL 3 TABS */
  background: var(--ios-bg);
  border-radius: 0.875rem;
  padding: 0.3125rem;
  margin-bottom: 1.5rem;
  border: 0.0625rem solid var(--ios-border);
  gap: 0.375rem;
  box-sizing: border-box;
  width: 100%;
}

.segmented-equal-btn {
  width: 100% !important;
  min-width: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  padding: 0.75rem 0.625rem;
  border-radius: 0.625rem;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  transition: all 0.18s ease;
  box-sizing: border-box;
}

/* Date & Time Input Alignment Lock */
.date-time-row {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 0.875rem !important;
  margin-bottom: 1.125rem !important;
  align-items: start !important;
  width: 100% !important;
}

.date-time-group {
  margin-bottom: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
}

.date-time-label {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  height: 1.5rem !important;
  min-height: 1.5rem !important;
  max-height: 1.5rem !important;
  line-height: 1.5rem !important;
  margin-bottom: 0.375rem !important;
  font-size: 0.875rem !important;
  font-weight: 700 !important;
  box-sizing: border-box !important;
}

/* Strict input normalization to eliminate iOS Safari WebKit Date misalignment */
.date-time-input,
input[type="date"].date-time-input,
input[type="text"].date-time-input {
  display: block !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  width: 100% !important;
  height: 3.125rem !important;
  min-height: 3.125rem !important;
  max-height: 3.125rem !important;
  line-height: normal !important;
  padding: 0 0.875rem !important;
  border-radius: 0.75rem !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}

input[type="date"].date-time-input::-webkit-date-and-time-value {
  text-align: left !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 100% !important;
  min-height: 3.125rem !important;
  line-height: 3.125rem !important;
  display: flex !important;
  align-items: center !important;
}

input[type="date"].date-time-input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.65;
  padding: 0;
  margin: 0;
}

@media screen and (max-width: 48rem) {
  /* Responsive Equal-Width Tabs & Labels on Mobile (Zero crossover guaranteed) */
  .desktop-tab-label {
    display: none !important;
  }
  .mobile-tab-label {
    display: inline !important;
  }
  .segmented-equal-tabs {
    padding: 0.25rem !important;
    gap: 0.25rem !important;
  }
  .segmented-equal-btn {
    padding: 0.625rem 0.1875rem !important;
    font-size: 0.8125rem !important;
    gap: 0.1875rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  .date-time-input {
    height: 3.125rem !important;
    min-height: 3.125rem !important;
    max-height: 3.125rem !important;
    padding: 0 0.75rem !important;
    font-size: 1rem !important;
  }






  html {
    font-size: 106.25%; /* Scales base typography from 16px to 17px for superior mobile legibility */
  }

  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    font-size: 1rem;
    line-height: 1.5;
  }

  .content-viewport {
    padding: 0.875rem 0.875rem calc(var(--safe-bottom) + 5.25rem) 0.875rem;
  }

  .ios-card {
    border-radius: 1rem;
    padding: 1.125rem 1rem;
    box-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.05);
    margin-bottom: 0.875rem;
  }

  /* Enhanced mobile typography: larger, crisp labels and inputs */
  .ios-label {
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    margin-bottom: 0.375rem !important;
  }

  /* Prevent Safari input zoom while keeping spacious touch targets */
  .ios-input, select.ios-input, textarea.ios-input {
    font-size: 1.0625rem !important;
    padding: 0.75rem 0.875rem !important;
    border-radius: 0.75rem !important;
  }

  .ios-btn-primary, .ios-btn-secondary {
    font-size: 1.0625rem !important;
    padding: 0.875rem 1.25rem !important;
    font-weight: 800 !important;
  }

  .ios-segment-btn {
    font-size: 0.9375rem !important;
    padding: 0.6875rem 0.75rem !important;
    font-weight: 800 !important;
  }

  /* Tactile feedback on mobile buttons */
  button:active, .ios-btn-primary:active, .ios-btn-secondary:active {
    transform: scale(0.97);
    transition: transform 0.1s cubic-bezier(0.2, 0.8, 0.4, 1);
  }

  /* Clear alignment for 3-button trip log footer */
  .trip-action-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.375rem !important;
  }

  /* Clean alignment for 2-button expense action footer */
  .expense-action-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }

  /* Ensure Leaflet map container fits mobile width */
  .leaflet-container {
    border-radius: 0.75rem;
    font-family: inherit;
  }

  /* Enlarge table headers and row items for mobile readability */
  table, th, td {
    font-size: 0.875rem !important;
  }
}

/* Open-Source OpenStreetMap Dark & Sci-Fi Tactical Tiles (No API Keys, No Watermarks) */
.dark-mode-tiles {
  filter: invert(100%) hue-rotate(180deg) brightness(90%) contrast(95%) !important;
}

.scifi-map-tiles {
  filter: brightness(0.65) invert(1) contrast(2.5) hue-rotate(190deg) saturate(0.4) !important;
}

.leaflet-container {
  background: var(--ios-bg, #040813);
  overflow: hidden;
}

/* Keep tiles absolutely positioned even if the Leaflet CDN stylesheet is blocked.
   Without this, tile <img> elements flow in a horizontal strip and the map
   looks stuck in landscape. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-map-pane svg,
.leaflet-map-pane canvas {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-container img.leaflet-tile,
.leaflet-container .leaflet-tile {
  max-width: none !important;
  max-height: none !important;
  box-sizing: content-box;
}

/* Route map follows the phone: tall in portrait, a wide strip in landscape. */
.trip-route-map {
  width: 100%;
  height: min(70dvh, 28rem);
  min-height: 18rem;
}

@media screen and (orientation: landscape) {
  .trip-route-map {
    height: 16rem;
    min-height: 12rem;
  }
}