/* Shared visual system and viewport layout. Loaded after page styles. */
:root, :root[data-theme="light"] {
  --primary-color: #167766;
  --primary-color-hover: #105e51;
  --title-color: #167766;
  --accent-gradient: linear-gradient(120deg, #167766, #239586);
  --accent-glow: rgba(22, 119, 102, .12);
  --bg-primary: #f4f6f5;
  --bg-secondary: #fff;
  --bg-body: #fff;
  --bg-card: #fff;
  --bg-card-hover: #f5f9f7;
  --bg-glass: #fff;
  --text-primary: #20342f;
  --text-secondary: #596e66;
  --text-muted: #708279;
  --border-subtle: #e1e8e3;
  --bg-glass-border: #e1e8e3;
  --border-active: #85b4a7;
  --shadow-card: 0 2px 10px #183d2805;
  --shadow-card-hover: 0 12px 32px #183d2810;
  --main-top-offset: calc(64px + env(safe-area-inset-top, 0px));
  --panel-width: 360px;
}
:root[data-theme="dark"] {
  --primary-color: #238876;
  --primary-color-hover: #2b9e8a;
  --title-color: #85d5bd;
  --bg-primary: #111b19;
  --bg-secondary: #182521;
  --bg-body: #182521;
  --bg-card: #182521;
  --bg-card-hover: #22342e;
  --bg-glass: #182521;
  --text-primary: #e5eee9;
  --text-secondary: #afc2b8;
  --text-muted: #91a69b;
  --border-subtle: #30433a;
  --bg-glass-border: #30433a;
  --border-active: #629b85;
}
html { overflow: auto; }
body { overflow: auto; font-family: system-ui, "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #56ab94; outline-offset: 3px; }
.top-navbar {
  top: 0; height: var(--main-top-offset); padding: env(safe-area-inset-top, 0px) 24px 0;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border-subtle);
  pointer-events: auto; gap: 12px;
}
.top-navbar-brand, .top-navbar-home, .user-dropdown-toggle {
  box-shadow: none; backdrop-filter: none; background: transparent; border: 0; border-radius: 10px;
}
.top-navbar-brand { padding: 0; font-size: 15px; white-space: nowrap; }
.top-navbar-home:hover, .top-navbar-brand:hover { box-shadow: none; }
.top-navbar-home { padding: 0 10px; }
.user-dropdown-menu-inner { background: var(--bg-secondary); }
.user-dropdown-container:focus-within .user-dropdown-menu { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.map-page { overflow: hidden; }
.map-page .app-container {
  position: fixed; inset: var(--main-top-offset) 0 0; width: 100%;
  height: auto; min-height: 0; display: grid; grid-template-columns: var(--panel-width) minmax(0, 1fr);
}
.map-page .side-panel {
  position: relative; inset: auto; width: 100%; height: 100%; max-height: none; min-height: 0;
  border: 0; border-right: 1px solid var(--border-subtle); border-radius: 0;
  background: var(--bg-secondary); box-shadow: none; backdrop-filter: none;
  transform: none; transition: none; overflow: hidden;
}
.map-page .app-container:has(.panel-closed) { grid-template-columns: minmax(0, 1fr); }
.map-page .side-panel.panel-closed { display: none; }
.map-page .map-container { width: 100%; height: 100%; min-width: 0; min-height: 0; }
.panel-header { padding: 24px 20px 18px; flex-shrink: 0; }
.panel-title h1 { font-size: 22px; color: var(--text-primary); letter-spacing: -.6px; }
.panel-subtitle { margin-top: 8px; line-height: 1.6; }
.panel-header-actions { margin-top: 14px; }
.header-action-btn { border-radius: 8px; box-shadow: none; }
.stats-bar { padding: 14px 20px; gap: 8px; flex-shrink: 0; }
.stat-chip { background: var(--bg-primary); border: 0; border-radius: 7px; box-shadow: none; padding: 7px 10px; }
.filter-bar { padding: 12px 20px; flex-wrap: nowrap; overflow-x: auto; flex-shrink: 0; }
.filter-chip { box-shadow: none; border-radius: 999px; flex-shrink: 0; padding: 7px 12px; }
.trip-list { min-height: 0; padding: 16px 16px 12px; overscroll-behavior: contain; }
.trip-card { border-radius: 12px; box-shadow: none; padding: 16px; margin-bottom: 12px; }
.trip-card:hover { box-shadow: none; transform: none; }
.trip-card.active { box-shadow: 0 0 0 1px var(--card-accent-color); }
.card-route, .card-header { min-width: 0; }
.route-city { overflow-wrap: anywhere; }
.panel-add-trip-btn {
  position: static; flex: 0 0 auto; width: calc(100% - 32px); height: 44px; margin: 8px 16px 16px;
  border-radius: 10px; box-shadow: none; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary-color); color: white; font-size: 14px; transform: none;
}
.panel-add-trip-btn:hover { transform: none; background: var(--primary-color-hover); box-shadow: none; }
.map-page .panel-toggle { left: calc(var(--panel-width) + 16px); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); border-radius: 10px; padding: 0; }
.map-page:has(.panel-closed) .panel-toggle { left: 16px; }
.panel-toggle button { width: auto; min-width: 44px; height: 40px; padding: 0 12px; border-radius: 10px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.panel-toggle button svg { width: 16px; height: 16px; }
.leaflet-top.leaflet-right { top: 8px; right: 8px; }
.leaflet-control-attribution { background: var(--bg-secondary) !important; }
.leaflet-control-layers { max-width: calc(100vw - 32px); }
[data-theme="dark"] .default-map-tiles { filter: brightness(.72) saturate(.65); }
.map-status { position: absolute; top: 16px; left: 16px; right: 70px; z-index: 800; padding: 10px 14px; border-radius: 10px; background: var(--bg-secondary); color: var(--text-secondary); font-size: 13px; box-shadow: var(--shadow-card-hover); }
.map-status[hidden] { display: none; }
.modal-overlay, .password-overlay { z-index: 4000; padding: 16px; overflow-y: auto; }
.modal-card { width: min(600px, 100%); max-height: calc(100dvh - 32px); border-radius: 18px; }
.modal-header, .modal-tabs { flex-shrink: 0; }
.modal-header h2 { color: var(--text-primary); }
.modal-body { min-height: 0; overscroll-behavior: contain; }
.form-group { min-width: 0; }
.form-group input, .form-group select { min-width: 0; width: 100%; }
.modal-tab.active { border-bottom-color: var(--primary-color); }
.password-card { max-height: calc(100dvh - 32px); overflow: auto; }
.landing-container, .login-container { height: auto; min-height: 100dvh; padding: calc(var(--main-top-offset) + 40px) 24px 40px !important; }
.hero-content { max-width: 720px; }
.hero-content h1 { font-size: clamp(32px, 6vw, 60px); letter-spacing: -.05em; color: var(--text-primary); background: none; -webkit-text-fill-color: currentColor; }
.hero-subtitle { line-height: 1.9; max-width: 480px; margin: 20px auto 32px; }
.enter-btn { background: var(--primary-color); border-radius: 12px; box-shadow: none; }
.login-panel { border-radius: 20px; box-shadow: var(--shadow-card-hover); }
.material-login { background: var(--bg-primary); }
@media (max-width: 768px) {
  .top-navbar { padding-left: 12px; padding-right: 12px; gap: 4px; }
  .top-navbar-brand { font-size: 13px; gap: 6px; }
  .top-navbar > div { gap: 2px !important; }
  .top-navbar-home { min-width: 34px; padding: 0 7px; }
  .map-page .app-container { display: flex; flex-direction: column-reverse; }
  .map-page .map-container { flex: 1 1 44%; height: auto; }
  .map-page .side-panel { flex: 0 1 56%; height: 56%; border-right: 0; border-top: 1px solid var(--border-subtle); }
  .panel-header { padding: 12px 16px 8px; position: relative; }
  .panel-title h1 { font-size: 18px; }
  .panel-subtitle { display: none; }
  .panel-header-actions { position: absolute; right: 16px; top: 10px; margin: 0; }
  .stats-bar { padding: 8px 16px; }
  .filter-bar { padding: 8px 16px; }
  .map-page .panel-toggle { left: 12px; bottom: calc(56% + 12px - var(--main-top-offset) * .56); }
  .map-page:has(.panel-closed) .panel-toggle { bottom: 28px; }
  .panel-add-trip-btn { margin-bottom: max(10px, env(safe-area-inset-bottom, 0px)); height: 40px; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-body { padding: 16px; }
}
@media (max-height: 540px) and (max-width: 768px) {
  .map-page .app-container { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
  .map-page .side-panel, .map-page .map-container { height: 100%; }
  .map-page .panel-toggle { left: 312px; bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (max-width: 380px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-section-title, .form-submit, .form-group.full-width { grid-column: 1 / -1; }
  .top-navbar-brand { font-size: 12px; }
}
