:root {
  --ink: #122033;
  --ink-2: #35465a;
  --muted: #66778a;
  --accent: #087ac1;
  --accent-strong: #05639f;
  --accent-soft: #e8f4fb;
  --surface: #ffffff;
  --canvas: #f3f6f9;
  --border: #e0e7ee;
  --border-strong: #cbd6e1;
  --sidebar: #071b31;
  --sidebar-2: #0d3155;
  --sidebar-ink: #f4f8fc;
  --sidebar-muted: #a8bdd2;
  --sidebar-accent: #1594dc;
  --warning-ink: #6a4f00;
  --radius: 16px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(18, 32, 51, 0.04), 0 8px 24px rgba(18, 32, 51, 0.055);

  /* Dash 4 component theme */
  --Dash-Fill-Interactive-Strong: var(--accent);
  --Dash-Fill-Interactive-Weak: var(--accent-soft);
  --Dash-Text-Primary: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background:
    radial-gradient(circle at 84% 0%, rgba(8, 122, 193, 0.07), transparent 24rem),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

body.has-maximized {
  overflow: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.01em;
}

.app-shell {
  display: grid;
  grid-template-columns: 312px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------------------------------------------------------------- sidebar */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem 1.35rem 1.35rem;
  background:
    radial-gradient(circle at 15% 5%, rgba(41, 151, 218, 0.2), transparent 14rem),
    linear-gradient(165deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-ink);
  --Dash-Fill-Interactive-Strong: var(--sidebar-accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand h1 {
  font-size: 1.1rem;
  line-height: 1.2;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: linear-gradient(145deg, #1594dc, #0872b4);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.sidebar-section {
  padding: 1.15rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-section h2 {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  margin-bottom: 0.7rem;
}

.field {
  margin-top: 0.7rem;
}

.field > label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sidebar-ink);
}

.hint {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--sidebar-muted);
}

.sidebar .dash-dropdown,
.sidebar .dash-dropdown * {
  color: var(--ink);
  font-size: 0.86rem;
}

.filters {
  margin-top: 0.6rem;
}

.filters > summary,
.help > summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--sidebar-muted);
}

.filters[open] > summary,
.help[open] > summary {
  color: var(--sidebar-ink);
}

.time-label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  color: #ffffff;
}

.sidebar .dash-slider-mark {
  color: var(--sidebar-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.sidebar .rc-slider {
  margin: 0.4rem 0.6rem 1.6rem;
}

.sidebar .rc-slider-mark-text {
  color: var(--sidebar-muted);
  font-size: 0.68rem;
  white-space: nowrap;
}

.sidebar .rc-slider-track {
  background: var(--sidebar-accent);
}

.sidebar .rc-slider-rail {
  background: rgba(255, 255, 255, 0.18);
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 0.4rem;
  margin: 1.2rem 0 0.4rem;
}

.button {
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-ink);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 120ms ease;
}

.button:hover {
  background: rgba(255, 255, 255, 0.14);
}

.button.primary {
  background: var(--sidebar-accent);
  border-color: var(--sidebar-accent);
  color: #0d1f2d;
  font-weight: 600;
}

.button.primary:hover {
  background: #8cc4e8;
}

.button.ghost {
  width: 100%;
  margin-top: 0.8rem;
  text-align: left;
}

.settings-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-weight: 600;
}

.settings-open::before {
  content: "⚙";
  margin-right: 0.35rem;
  color: var(--sidebar-muted);
}

.badge-count {
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: #d97706;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-count:empty {
  display: none;
}

.help {
  margin-top: 1.4rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--sidebar-muted);
  font-size: 0.8rem;
}

.help ul {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
}

.help li {
  margin-bottom: 0.35rem;
}

/* ------------------------------------------------------------------- main */

.main {
  min-width: 0;
  width: 100%;
  max-width: 1780px;
  margin: 0 auto;
  padding: 1.6rem 2rem 2.5rem;
}

.corridor-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid rgba(8, 122, 193, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(105deg, rgba(232, 244, 251, 0.78), rgba(255, 255, 255, 0.96) 45%),
    var(--surface);
  box-shadow: var(--shadow);
}

.corridor-header h2 {
  margin: 0.1rem 0 0.5rem;
  font-size: 1.8rem;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.page-eyebrow {
  display: block;
  color: var(--accent-strong);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}

.chip.strong {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  font-weight: 600;
}

.chip.focus {
  border-color: var(--ink);
  color: var(--ink);
  font-weight: 600;
}

.network-status {
  display: grid;
  gap: 0.1rem;
  min-width: 250px;
  padding: 0.75rem 1rem;
  border: 1px solid #d8eaf5;
  border-radius: 12px;
  background: rgba(239, 248, 253, 0.9);
  text-align: right;
}

.network-status .eyebrow {
  color: var(--muted);
}

.network-status strong {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  font-size: 0.95rem;
}

.network-status small {
  color: var(--muted);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

/* ------------------------------------------------------------------ panels */

.panel {
  min-width: 0;
  margin-bottom: 1.25rem;
  padding: 1rem 1.15rem 0.7rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  min-height: 36px;
  margin-bottom: 0.55rem;
}

.panel-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.8rem;
  min-width: 0;
}

.panel-head h3 {
  font-size: 1.02rem;
  font-weight: 650;
}

.panel-hint {
  font-size: 0.76rem;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.4rem;
}

.icon-button,
.chip-button,
.menu > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 30px;
  padding: 0 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease;
}

.icon-button {
  justify-content: center;
  width: 30px;
  padding: 0;
  font-size: 0.95rem;
}

.icon-button:hover,
.chip-button:hover,
.menu > summary:hover,
.menu[open] > summary {
  background: var(--accent-soft);
  border-color: #c9d8e6;
}

/* <details> drop-down menus */

.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu > summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 0.7rem;
}

.menu-key {
  color: var(--muted);
}

.menu-body {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 260px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(18, 40, 58, 0.16);
}

.menu-heading {
  margin: 0.45rem 0.5rem 0.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.menu-heading + .menu-options + .menu-heading {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.menu-options label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.84rem;
}

.menu-options label:hover {
  background: var(--canvas);
}

.menu-options input {
  accent-color: var(--accent);
}

/* Segmented control built on RadioItems */

.pills {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--canvas);
}

.pills label {
  display: inline-flex;
  align-items: center;
  height: 24px;
  margin: 0;
  padding: 0 0.6rem;
  border-radius: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.pills input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pills label:has(input:checked) {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(18, 40, 58, 0.12);
}

/* Graph containers: height lives here so a panel can grow to full screen.
   !important overrides the inline height: 100% set on responsive graphs. */

.graph {
  width: 100%;
}

.graph-section {
  height: 570px !important;
}

.graph-map {
  height: 430px !important;
}

.graph-medium {
  height: 430px !important;
}

.panel.is-maximized {
  position: fixed;
  inset: 12px;
  z-index: 1000;
  margin: 0;
  overflow: auto;
  box-shadow: 0 0 0 100vmax rgba(18, 40, 58, 0.55);
}

.panel.is-maximized .graph {
  height: calc(100vh - 90px) !important;
}

.panel.is-maximized .graph-section {
  height: calc(100vh - 190px) !important;
}

/* Segment selection under the cross-section */

.segment-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.3rem 0.2rem 0.2rem 3.2rem;
}

.segment-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.segment-slider {
  min-width: 0;
}

.segment-label {
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.8rem;
  padding: 0.35rem 0.2rem 0.5rem 3.2rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.legend-title {
  font-weight: 700;
  color: var(--ink);
}

.legend-item + .legend-title {
  margin-left: 0.8rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.legend-item i {
  display: inline-block;
  width: 12px;
  height: 9px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, 0.92fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.analysis-grid .panel {
  margin-bottom: 0;
}

.panel-profile {
  max-width: none;
}

.error {
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: #fdecec;
  border: 1px solid #f3b8b8;
  color: #8a1f1f;
}

.notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.85rem;
  align-items: baseline;
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid #dbe5ed;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.5;
}

.notice strong {
  color: var(--ink-2);
  white-space: nowrap;
}

.notice p {
  margin: 0;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1320px) {
  .analysis-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    column-gap: 1.25rem;
    height: auto;
  }

  .sidebar .brand {
    grid-column: 1 / -1;
  }

  .sidebar > .sidebar-section:nth-of-type(1) {
    grid-column: 1;
  }

  .sidebar > .sidebar-section:nth-of-type(2) {
    grid-column: 2;
  }

  .sidebar > .sidebar-section:nth-of-type(3) {
    grid-column: 1 / -1;
  }

  .sidebar .help {
    grid-column: 1 / -1;
  }

  .analysis-grid {
    grid-template-columns: 1fr;
  }

  .corridor-header,
  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .network-status {
    text-align: left;
  }

  .segment-bar,
  .legend-row {
    padding-left: 0.2rem;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 1rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .sidebar .brand,
  .sidebar > .sidebar-section:nth-of-type(n),
  .sidebar .help {
    grid-column: 1;
  }

  .corridor-header {
    padding: 1rem;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .segment-bar {
    grid-template-columns: 1fr;
  }

  .notice {
    grid-template-columns: 1fr;
  }
}

/* Native controls of the static site (the Dash app styles its own widgets). */

.sidebar select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
}

.sidebar select[multiple] {
  min-height: 5.5rem;
}

.sidebar input[type="range"] {
  width: 100%;
  accent-color: var(--sidebar-accent);
}

.time-marks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.15rem;
  color: var(--sidebar-muted);
  font-size: 0.68rem;
}

.dual-range {
  position: relative;
  height: 28px;
}

.dual-range input[type="range"] {
  position: absolute;
  left: 0;
  top: 4px;
  width: 100%;
  margin: 0;
  pointer-events: none;
  appearance: none;
  background: transparent;
}

.dual-range input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
}

.dual-range input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
}

.segment-bar {
  grid-template-columns: auto auto minmax(0, 1fr) auto auto auto;
}

.km-num {
  width: 4.6rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 0.82rem;
  text-align: right;
}

@media (max-width: 680px) {
  .segment-bar {
    grid-template-columns: 1fr 1fr;
  }

  .dual-range {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .segment-title,
  .segment-label,
  .segment-bar .chip-button {
    grid-column: 1 / -1;
  }
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  background: var(--surface);
  color: var(--ink);
  box-shadow: -16px 0 40px rgba(7, 27, 49, 0.18);
  transform: translateX(100%);
  transition: transform 200ms ease;
}

.drawer-open .drawer {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background: rgba(7, 27, 49, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.drawer-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.35rem 1rem;
  border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
  font-size: 1.05rem;
}

.drawer-lede,
.drawer .hint,
.settings-status,
.setting-unit {
  color: var(--muted);
}

.drawer-lede,
.setting-unit,
.settings-status {
  font-size: 0.78rem;
}

.drawer-lede {
  display: block;
  margin-top: 0.25rem;
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem 1.35rem 1rem;
}

.drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.9rem 1.35rem;
  border-top: 1px solid var(--border);
  background: var(--canvas);
}

.drawer .button {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--ink);
}

.drawer .button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.setting-group {
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.setting-group > summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 6rem 3rem;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.45rem;
}

.setting-row label {
  font-size: 0.82rem;
  color: var(--ink-2);
}

.setting-input {
  width: 100%;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font: inherit;
  text-align: right;
}

.setting-input.changed {
  box-shadow: 0 0 0 2px #d97706;
}
