:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #61706d;
  --line: #d9e1dd;
  --panel: #ffffff;
  --soft: #f4f7f3;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b42318;
  --ok: #28715f;
  --shadow: 0 10px 28px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #edf2ee;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.file-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

button.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

button.danger {
  background: #fff;
  color: var(--danger);
  border-color: #f2bbb5;
}

button.small {
  min-height: 32px;
  padding: 5px 9px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.file-button input {
  display: none;
}

.topbar-link {
  text-decoration: none;
}

.topbar {
  min-height: 88px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.panel h2,
.view h2 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel,
.workspace {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel h2,
.view h2 {
  font-size: 1.1rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  margin-top: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  min-height: 38px;
}

textarea {
  resize: vertical;
}

.summary {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.summary div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.summary dt {
  color: var(--muted);
}

.summary dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
}

.source-links {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.source-links a,
.resource-link {
  color: var(--accent);
  font-weight: 750;
  text-decoration: none;
}

.source-links a:hover,
.resource-link:hover {
  text-decoration: underline;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.tab {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.view {
  display: none;
  padding: 18px;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 16px;
}

.view-header p,
.muted {
  margin: 4px 0 0;
  color: var(--muted);
}

.route-list,
.transfer-list,
.proposal-list,
.destination-list,
.verification-list,
.timeline {
  display: grid;
  gap: 12px;
}

.dashboard-content,
.trip-log-content {
  display: grid;
  gap: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  display: grid;
  gap: 4px;
  min-height: 78px;
}

.metric strong {
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.city-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.city-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
}

.city-summary summary {
  cursor: pointer;
  font-weight: 850;
}

.city-summary summary span {
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: 6px;
}

.city-summary p {
  margin: 8px 0 0;
  color: var(--muted);
}

.subtabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.log-section {
  display: grid;
  gap: 12px;
}

.day-log {
  display: grid;
  gap: 12px;
}

.log-checklist {
  display: grid;
  gap: 8px;
}

.log-check {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: start;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 500;
}

.log-check input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.log-check span {
  display: grid;
  gap: 4px;
}

.log-check small,
.log-check em {
  color: var(--muted);
  font-size: 0.76rem;
}

.data-table {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(150px, 1fr));
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.data-table > div {
  min-width: 150px;
  padding: 9px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.data-table > div:nth-child(var(--cols)n) {
  border-right: 0;
}

.data-table .table-head {
  background: var(--soft);
  color: var(--ink);
  font-weight: 850;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.item.soft {
  background: var(--soft);
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.item-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  border-radius: 999px;
  background: #e6f3ef;
  color: var(--ok);
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 800;
}

.badge.pending {
  background: #fff4de;
  color: var(--accent-2);
}

.badge.warn {
  background: #fff0ee;
  color: var(--danger);
}

.inline-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.city-grid,
.transfer-grid,
.destination-grid,
.verification-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.transfer-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.destination-grid,
.verification-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.day {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.date-chip {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  font-weight: 850;
}

.date-chip span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.agenda {
  display: grid;
  gap: 8px;
}

.agenda-row {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.agenda-row:last-child {
  border-bottom: 0;
}

.time {
  color: var(--muted);
  font-weight: 800;
}

.link-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.map-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

.map-provider-toggle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.map-provider-toggle .active {
  background: var(--accent);
  color: #fff;
}

.real-map-panel,
.google-map-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  margin-bottom: 12px;
}

.real-map-header,
.google-map-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
}

.real-map-header h3,
.google-map-header h3 {
  margin: 0;
  font-size: 1rem;
}

.real-map-header p,
.google-map-header p {
  margin: 4px 0 0;
  color: var(--muted);
}

.map-link-button {
  min-height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  white-space: nowrap;
}

.real-route-map {
  width: 100%;
  height: min(76vh, 760px);
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  position: relative;
  z-index: 1;
  isolation: isolate;
  overflow: hidden;
}

.map-shell {
  position: relative;
}

.map-native-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 30;
  display: grid;
  gap: 6px;
  pointer-events: none;
}

.map-native-controls button {
  width: 38px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.map-native-controls button:last-child {
  width: auto;
  padding: 0 10px;
}

.real-route-map.is-dragging {
  cursor: grabbing;
}

.real-route-map,
.real-route-map * {
  filter: none !important;
}

.ol-viewport,
.ol-unselectable {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent !important;
  opacity: 1 !important;
  touch-action: none;
}

.ol-viewport {
  position: relative;
  cursor: grab;
}

.ol-viewport.ol-grabbing {
  cursor: grabbing;
}

.ol-layer,
.ol-overlaycontainer,
.ol-overlaycontainer-stopevent {
  position: absolute;
  inset: 0;
  background: transparent !important;
  opacity: 1 !important;
}

.ol-overlaycontainer,
.ol-overlaycontainer-stopevent {
  pointer-events: none;
}

.ol-overlaycontainer-stopevent .ol-control {
  pointer-events: auto;
}

.ol-layer {
  width: 100%;
  height: 100%;
}

.ol-layer canvas {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 1 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
  pointer-events: none;
}

.ol-control {
  position: absolute;
  z-index: 10;
  pointer-events: auto;
}

.ol-zoom {
  top: 10px;
  left: 10px;
}

.ol-zoom button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  opacity: 1 !important;
  cursor: pointer;
  display: block;
  padding: 0;
}

.leaflet-container {
  overflow: hidden;
  touch-action: none;
  font: 12px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  filter: inherit;
  visibility: hidden;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: visiblePainted;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control-zoom {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin: 10px;
}

.leaflet-control-zoom a {
  width: 30px;
  height: 30px;
  background: #fff;
  color: var(--ink);
  display: grid;
  place-items: center;
  text-decoration: none;
  font-weight: 900;
}

.leaflet-popup {
  position: absolute;
  text-align: center;
  margin-bottom: 20px;
}

.leaflet-popup-content-wrapper {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 10px;
}

.map-fallback {
  display: none;
  color: var(--muted);
  margin: 10px 0 0;
}

.route-pin {
  width: 34px;
  height: 42px;
}

.route-pin span {
  width: 30px;
  height: 30px;
  border-radius: 999px 999px 999px 0;
  background: #e85d5d;
  border: 3px solid #fff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 5px 14px rgba(23, 33, 31, 0.32);
  transform: rotate(-45deg);
}

.route-pin b {
  display: block;
  transform: rotate(45deg);
}

.map-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.map-legend div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 8px 10px;
  display: grid;
  gap: 2px;
}

.map-legend strong {
  font-size: 1rem;
}

.map-legend span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.google-map-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.google-detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.google-detail-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.google-detail-card span {
  color: var(--muted);
  font-weight: 800;
}

.itinerary-budget .itinerary-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.itinerary-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 2px;
}

.itinerary-summary strong {
  font-size: 1.05rem;
}

.itinerary-summary span {
  color: var(--muted);
  font-weight: 750;
}

.itinerary-editor,
.daily-itinerary,
.site-list {
  display: grid;
  gap: 12px;
}

.itinerary-editor {
  margin-top: 12px;
}

.itinerary-city {
  background: #fff;
}

.site-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.site-row-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.view-header.compact {
  margin-top: 18px;
}

.day-plan {
  background: #fff;
}

.proposal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.proposal-card p,
.comfort-item p,
.clean-list {
  color: var(--muted);
}

.budget-table {
  display: grid;
  grid-template-columns: 1.25fr repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-top: 12px;
  overflow-x: auto;
}

.budget-table > div {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  min-width: 130px;
}

.budget-table .table-head {
  background: var(--soft);
  color: var(--ink);
  font-weight: 850;
}

.comfort-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.comfort-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.comfort-item div {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.clean-list {
  margin: 12px 0 0;
  padding-left: 20px;
}

.clean-list li + li {
  margin-top: 8px;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
  width: calc(100% - 28px);
}

dialog::backdrop {
  background: rgba(23, 33, 31, 0.35);
}

.dialog-form {
  display: grid;
  gap: 10px;
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  margin: 8px 0 0;
}

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

  .topbar,
  .view-header,
  .real-map-header,
  .google-map-header {
    flex-direction: column;
    align-items: stretch;
  }

  .city-grid,
  .transfer-grid,
  .proposal-grid,
  .destination-grid,
  .verification-grid,
  .site-grid,
  .metric-grid,
  .split-grid,
  .city-summary-grid,
  .itinerary-budget .itinerary-summary {
    grid-template-columns: 1fr 1fr;
  }

  .comfort-list {
    grid-template-columns: 1fr;
  }

  .google-map-details {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .layout,
  .view,
  .topbar {
    padding: 12px;
  }

  .field-grid,
  .city-grid,
  .transfer-grid,
  .proposal-grid,
  .destination-grid,
  .verification-grid,
  .site-grid,
  .metric-grid,
  .split-grid,
  .city-summary-grid,
  .log-check,
  .itinerary-budget .itinerary-summary,
  .day,
  .agenda-row {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media print {
  .topbar-actions,
  .sidebar,
  .tabs,
  button,
  .link-row {
    display: none !important;
  }

  .layout {
    display: block;
  }

  .workspace,
  .panel,
  .item {
    box-shadow: none;
  }

  .view {
    display: block;
  }
}
