/* NetWin application shell. Shared by the browser and installed application. */
:root { --nw-rail: 256px; --nw-header: calc(64px + env(safe-area-inset-top)); --nw-ink: #102f3a; --nw-accent: #51d6b0; }
body.nw-compact { --nw-rail: 80px; }
body { font-family: Inter, system-ui, sans-serif; }
.nw-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--nw-rail); z-index: 1035; background: var(--nw-ink); color: #e6f2f4; display: flex; flex-direction: column; padding: 24px 14px 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.nw-brand { display: flex; align-items: center; gap: 12px; color: white; text-decoration: none; padding: 0 6px 28px; white-space: nowrap; }
.nw-brand img { width: 40px; height: 40px; flex: 0 0 40px; }
.nw-brand strong { display: block; font-size: 21px; letter-spacing: -.7px; }
.nw-brand small { display: block; font-size: 10px; letter-spacing: 1.7px; color: #b2cbd1; }
.nw-nav { display: flex; flex-direction: column; gap: 7px; overflow-y: auto; flex: 1; }
.nw-nav a { min-height: 48px; display: flex; align-items: center; gap: 14px; color: #c4d9df; text-decoration: none; border-radius: 10px; padding: 12px 14px; font-size: 14px; font-weight: 500; }
.nw-nav a i { font-size: 20px; width: 24px; flex: 0 0 24px; text-align: center; }
.nw-nav a:hover { color: white; background: #ffffff12; }
.nw-nav a.active { color: #fff; background: #234852; box-shadow: inset 3px 0 var(--nw-accent); }
.nw-account { border-top: 1px solid #ffffff24; margin-top: 20px; padding-top: 18px; }
.nw-user { display: block; font-size: 13px; margin-bottom: 12px; overflow-wrap: anywhere; }
.nw-account > div { flex-wrap: wrap; }
.nw-header { position: fixed; top: 0; left: var(--nw-rail); right: 0; height: var(--nw-header); display: flex; align-items: center; gap: 14px; padding: 8px 24px; z-index: 1030; background: #fff; border-bottom: 1px solid #dfe8eb; }
.nw-header-title { color: var(--nw-ink); font-weight: 650; font-size: 15px; }
.nw-header-caption { color: #697e86; font-size: 12px; margin-left: auto; }
.nw-icon-button { background: transparent; border: 1px solid #d5e1e5; color: var(--nw-ink); border-radius: 10px; width: 44px; height: 44px; display: inline-grid; place-items: center; flex-shrink: 0; }
.nw-icon-button:hover { background: #edf5f5; }
.nw-sidebar-close { display: none; }
.nw-backdrop { display: none; }
.nw-compact .nw-brand-copy, .nw-compact .nw-nav-label, .nw-compact .nw-account { display: none; }
.nw-compact .nw-sidebar { padding-inline: 10px; }
.nw-compact .nw-brand { padding-inline: 10px; }
.nw-compact .nw-nav a { padding-inline: 18px; }
#app-container { isolation: isolate; margin-left: var(--nw-rail); width: calc(100% - var(--nw-rail)) !important; padding-top: var(--nw-header) !important; }
body:not([data-netwin-page="map"]) #app-container { min-height: 100dvh; }
body[data-netwin-page="map"] #app-container { height: 100dvh; }
#map-wrapper { top: var(--nw-header) !important; height: calc(100% - var(--nw-header)) !important; }
#map-wrapper .leaflet-popup-content { max-height: min(55dvh, 480px); overflow-y: auto; overscroll-behavior: contain; }
#map-wrapper .leaflet-popup-content > div { min-width: 0 !important; max-width: 100% !important; }
/* Keep the popup title and close button clear of floating panels at every viewport size. */
body:has(#map-wrapper.netwin-popup-open) .map-only-panel { visibility: hidden; }
.netwin-line-legend { background: white; color: #183b46; border-radius: 8px; padding: 9px 12px; max-width: min(320px, calc(100vw - 100px)); box-shadow: 0 2px 10px #0002; font-size: 12px; }
.netwin-line-legend summary { cursor: pointer; font-weight: 700; }
.netwin-line-legend label { display: block; margin-top: 8px; }
.netwin-line-legend select { display: block; width: 100%; padding: 8px; margin: 5px 0; }
.netwin-line-legend p { margin: 6px 0 0; }
.netwin-depart-colors { max-height: 140px; overflow: auto; }
.netwin-depart-colors span { display: inline-block; width: 20px; height: 4px; margin-right: 7px; vertical-align: middle; }
.netwin-corridor-picker button { white-space: normal; min-height: 44px; }
#ortho-wrapper { left: var(--nw-rail) !important; top: var(--nw-header) !important; width: calc(100% - var(--nw-rail)) !important; height: calc(100dvh - var(--nw-header)) !important; }
#ortho-controls { top: var(--nw-header) !important; }
.netwin-map-search-control { top: 80px !important; width: min(560px, calc(100% - 32px)) !important; }
.floating-sidebar-left, .floating-sidebar-right { top: 152px !important; max-height: calc(100dvh - 172px); }
.floating-sidebar-left { width: 290px; left: 16px; }
.floating-sidebar-right { width: 300px; right: 16px; }
.nw-install { margin-top: 12px; width: 100%; text-align: left; color: #c4d9df; border: 1px solid #49636b; border-radius: 9px; background: transparent; padding: 10px; min-height: 44px; }
.nw-install[hidden], .nw-update[hidden], .nw-network[hidden] { display: none !important; }
.nw-network { font-size: 12px; color: #805400; background: #fff3cc; border-radius: 6px; padding: 6px 10px; }
.nw-update { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: calc(var(--nw-rail) + 16px); z-index: 1040; background: #102f3a; color: white; padding: 12px 16px; border-radius: 12px; box-shadow: 0 8px 30px #102f3a33; max-width: calc(100vw - var(--nw-rail) - 32px); }
.nw-update button { margin-left: 12px; }
:focus-visible { outline: 3px solid #148268; outline-offset: 3px; }
@media (max-width: 1199.98px) and (min-width: 768px) {
  .floating-sidebar-left, .floating-sidebar-right { width: 240px; padding: 16px !important; }
}
@media (max-width: 991.98px) {
  :root, body.nw-compact { --nw-rail: 0px; }
  .nw-sidebar { width: 280px; max-width: calc(100vw - 40px); transform: translateX(-100%); visibility: hidden; padding: 24px 16px; z-index: 1050; }
  .nw-menu-open .nw-sidebar { transform: translateX(0); visibility: visible; }
  .nw-menu-open .nw-backdrop { display: block; position: fixed; inset: 0; z-index: 1045; background: #071d2bc0; border: 0; }
  .nw-menu-open { overflow: hidden !important; }
  .nw-menu-open .nw-update { visibility: hidden; }
  .nw-compact .nw-brand-copy, .nw-compact .nw-nav-label, .nw-compact .nw-account { display: block; }
  .nw-sidebar-close { display: inline-grid; position: absolute; top: 18px; right: 12px; color: white; border-color: #49636b; width: 36px; height: 36px; }
  .nw-brand { padding-left: 4px !important; }
  .nw-brand strong { font-size: 19px; }
  .nw-header { padding-inline: 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .nw-header-caption { display: none; }
  .nw-network { margin-left: auto; }
  .nw-nav a { min-height: 48px; }
  input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 44px; }
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .leaflet-popup-content { max-width: calc(100vw - 80px); max-height: 55dvh; overflow: auto; }
  .leaflet-bar a, .leaflet-touch .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
  .leaflet-control-layers-toggle { width: 44px !important; height: 44px !important; }
  .nw-update { left: 12px; max-width: calc(100vw - 24px); }
}
@media (max-width: 767.98px) {
  .floating-sidebar-left, .floating-sidebar-right { top: 144px !important; width: calc(100% - 24px) !important; left: 12px !important; right: 12px !important; max-height: calc(100dvh - 238px); padding: 12px 16px !important; min-width: 0; }
  .floating-sidebar-right { top: 226px !important; }
  .floating-sidebar-left:has(+ .floating-sidebar-right:not(.panel-collapsed)) { z-index: 1002; }
  .floating-sidebar-left:not(.panel-collapsed) { z-index: 1003; }
  .floating-sidebar-left:not(.panel-collapsed) ~ .floating-sidebar-right { top: auto !important; bottom: max(12px, env(safe-area-inset-bottom)); }
  .map-only-panel .border-bottom { margin-bottom: 0 !important; padding-bottom: 0 !important; min-height: 36px; }
  .map-only-panel:not(.panel-collapsed) .collapsible-body { padding-top: 16px; }
  .netwin-map-search-control { top: 76px !important; width: calc(100% - 16px) !important; }
  .netwin-map-search-control .btn { padding-inline: 12px !important; font-size: 13px; }
  #app-container .container, #app-container .container-fluid { padding-left: 16px; padding-right: 16px; }
  #app-container h1 { font-size: clamp(1.6rem, 6vw, 2.1rem); overflow-wrap: anywhere; }
  #app-container .d-flex { flex-wrap: wrap; }
  #app-container .input-group, #app-container .netwin-map-search-control form { flex-wrap: nowrap; }
  #app-container .netwin-map-search-control .input-group { min-width: 0; width: auto; flex: 1; }
  #app-container .netwin-map-search-control .btn { flex-shrink: 0; }
  .sld-detail-grid { grid-template-columns: 1fr; gap: 6px; }
  #ortho-popup, #ortho-popup .card { max-width: calc(100vw - 24px) !important; }
}
@media (prefers-reduced-motion: no-preference) {
  .nw-sidebar { transition: width .18s ease, transform .18s ease; }
}
