:root {
  color-scheme: light;
  --ink: #17343e;
  --muted: #6e8288;
  --line: #dce7e8;
  --paper: #fbfcfa;
  --panel: rgba(250, 252, 250, .96);
  --deep: #153d49;
  --accent: #e8a83d;
  --sea: #2f7f88;
  --shadow: 0 14px 38px rgba(19, 51, 60, .13);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body, .app-shell { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: #dce8e8; }
button, input { font: inherit; }
button { color: inherit; }

.topbar {
  position: relative;
  z-index: 1000;
  height: 68px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(23, 52, 62, .12);
  background: rgba(251, 252, 250, .96);
  backdrop-filter: blur(14px);
}

.brand-mark {
  width: 38px;
  height: 38px;
  position: relative;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--deep);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.brand-mark::before, .brand-mark::after, .brand-mark span {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  height: 2px;
  border-radius: 2px;
  background: #fff;
  transform: rotate(-18deg);
}
.brand-mark::before { top: 12px; }
.brand-mark span { top: 18px; background: var(--accent); }
.brand-mark::after { top: 24px; }

.brand-copy { min-width: 0; display: grid; line-height: 1.1; }
.brand-copy strong { font-size: 17px; letter-spacing: .01em; }
.brand-copy span { margin-top: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.quiet-button, .base-button, .icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}
.quiet-button { padding: 9px 12px; color: #49636a; border-radius: 9px; }
.quiet-button:hover { background: #edf3f2; }

.basemap-switch { display: flex; gap: 3px; padding: 4px; border: 1px solid #d7e2e3; border-radius: 12px; background: #f0f5f4; }
.base-button { min-height: 34px; padding: 0 13px; border-radius: 8px; font-size: 12px; font-weight: 700; }
.base-button.active { color: #fff; background: var(--deep); box-shadow: 0 4px 12px rgba(21,61,73,.2); }
.satellite-wrap { position: relative; }
.basemap-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}
.basemap-menu button { width: 100%; display: flex; gap: 9px; align-items: center; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; font-size: 13px; }
.basemap-menu button:hover { background: #eef4f3; }
.basemap-menu i { width: 9px; height: 9px; border: 1px solid #91a7ad; border-radius: 50%; }
.basemap-menu button.active i { border-color: var(--deep); background: var(--deep); box-shadow: 0 0 0 3px rgba(21,61,73,.12); }

.workspace { height: calc(100% - 68px); display: grid; grid-template-columns: 306px minmax(0, 1fr); }
.control-panel {
  position: relative;
  z-index: 700;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  scrollbar-width: thin;
}
.panel-heading { display: flex; justify-content: space-between; align-items: center; padding: 22px 20px 16px; }
.panel-heading > div { display: grid; gap: 4px; }
.panel-heading span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .13em; }
.panel-heading strong { font-size: 21px; letter-spacing: -.02em; }
.panel-section { margin: 0 13px 13px; padding: 14px 10px; border-top: 1px solid var(--line); }
.section-title { display: flex; justify-content: space-between; padding: 0 5px 10px; }
.section-title span { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.section-title small { color: var(--muted); }

.layer-row { display: grid; grid-template-columns: 18px 14px minmax(0,1fr) auto; align-items: center; gap: 9px; min-height: 51px; padding: 7px 6px; border-radius: 10px; cursor: pointer; }
.layer-row:hover { background: #f0f5f4; }
.layer-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--deep); }
.layer-swatch { width: 11px; height: 11px; border-radius: 3px; }
.ortho-swatch { background: linear-gradient(135deg, #2e6d59, #d9aa5e); }
.parcel-swatch { border: 2px solid #178fe6; background: rgba(23,143,230,.15); }
.building-swatch { border: 2px solid #e16244; background: rgba(225,98,68,.15); }
.structure-swatch { border: 2px solid #9a5ac2; background: rgba(154,90,194,.14); }
.imported-swatch { border: 2px dashed #15a276; background: rgba(21,162,118,.12); }
.layer-label { min-width: 0; display: grid; gap: 3px; }
.layer-label b { font-size: 13px; }
.layer-label small { overflow: hidden; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.layer-count { min-width: 26px; padding: 3px 6px; border-radius: 10px; color: #63787e; background: #e9f0ef; font-size: 10px; font-weight: 800; text-align: center; }
.opacity-row { display: grid; grid-template-columns: auto 1fr 36px; align-items: center; gap: 9px; margin: -3px 5px 8px 58px; color: var(--muted); font-size: 10px; }
.opacity-row input { width: 100%; accent-color: var(--deep); }
.opacity-row output { font-variant-numeric: tabular-nums; text-align: right; }

.alignment-disclosure { padding-top: 11px; }
.alignment-disclosure summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 5px; cursor: pointer; list-style: none; }
.alignment-disclosure summary::-webkit-details-marker { display: none; }
.alignment-disclosure summary span { color: #587078; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.alignment-disclosure summary small { color: var(--muted); font-size: 9px; }
.alignment-disclosure summary::after { content: "⌄"; margin-left: 3px; color: #6f858a; transition: transform .16s ease; }
.alignment-disclosure[open] summary::after { transform: rotate(180deg); }
.alignment-panel { padding: 11px 2px 2px; }
.shift-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 10px; background: #eaf1f0; }
.shift-tabs button { min-height: 31px; border: 0; border-radius: 8px; color: #587078; background: transparent; cursor: pointer; font-size: 11px; font-weight: 750; }
.shift-tabs button.active { color: #fff; background: var(--deep); box-shadow: 0 3px 10px rgba(21,61,73,.18); }
.shift-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.shift-fields label, .shift-step { display: grid; gap: 4px; color: var(--muted); font-size: 9px; font-weight: 700; }
.shift-fields input, .shift-step select { min-width: 0; height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; font-variant-numeric: tabular-nums; }
.shift-controls { display: grid; grid-template-columns: 1fr 78px; gap: 10px; align-items: center; margin-top: 9px; }
.shift-pad { display: grid; grid-template-columns: repeat(3, 32px); grid-template-rows: repeat(2, 30px); justify-content: center; gap: 3px; }
.shift-pad button { border: 1px solid var(--line); border-radius: 7px; background: #fff; cursor: pointer; font-size: 16px; font-weight: 800; }
.shift-pad button:hover { border-color: #8bb4b7; background: #e8f2f1; }
.shift-pad button:nth-child(1) { grid-column: 2; }
.shift-pad button:nth-child(2) { grid-column: 1; grid-row: 2; }
.shift-pad button:nth-child(3) { grid-column: 3; grid-row: 2; }
.shift-pad button:nth-child(4) { grid-column: 2; grid-row: 2; }
.reset-alignment { min-height: 30px; margin-top: 9px; padding: 0 9px; border: 1px solid var(--line); border-radius: 8px; color: #587078; background: #fff; cursor: pointer; font-size: 10px; font-weight: 700; }
.reset-alignment:disabled { cursor: wait; opacity: .55; }
.shift-status { min-height: 14px; margin: 8px 2px 0; color: var(--muted); font-size: 9px; line-height: 1.35; }
.shift-status.dirty { color: #a26716; }
.shift-status.saved { color: #168058; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.tool-grid button { min-height: 61px; display: grid; place-items: center; align-content: center; gap: 5px; padding: 8px; border: 1px solid var(--line); border-radius: 11px; background: #fff; cursor: pointer; font-size: 11px; font-weight: 700; }
.tool-grid button span { color: var(--sea); font-size: 20px; line-height: 1; }
.tool-grid button:hover, .tool-grid button.active { border-color: #8bb4b7; background: #e8f2f1; }
.text-button { margin-top: 10px; padding: 4px 5px; border: 0; color: #547078; background: transparent; cursor: pointer; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.tool-hint { min-height: 30px; margin: 12px 5px 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.source-note { display: flex; gap: 10px; align-items: flex-start; color: #587078; }
.source-note > div { display: grid; gap: 3px; }
.source-note b { color: var(--ink); font-size: 11px; }
.source-note small { font-size: 10px; line-height: 1.4; }
.status-dot { width: 8px; height: 8px; margin-top: 3px; flex: 0 0 auto; border-radius: 50%; background: #27a56f; box-shadow: 0 0 0 4px rgba(39,165,111,.12); }

.map-stage { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #dce7e4; }
.leaflet-container { font-family: inherit; }
.leaflet-interactive { cursor: pointer; }
.leaflet-control-zoom a { color: var(--deep); }
.leaflet-control-attribution { max-width: calc(100vw - 340px); font-size: 9px; }
.leaflet-tile-error { visibility: hidden !important; }
.feature-tooltip { border: 0; border-radius: 8px; color: #fff; background: rgba(21,61,73,.9); box-shadow: 0 5px 15px rgba(0,0,0,.16); font-weight: 700; }
.feature-tooltip::before { border-top-color: rgba(21,61,73,.9); }
.measurement-tooltip { border: 0; border-radius: 16px; color: #fff; background: #153d49; box-shadow: 0 5px 18px rgba(0,0,0,.2); font-size: 11px; font-weight: 800; }

.loading-card { position: absolute; z-index: 650; top: 50%; left: 50%; display: grid; place-items: center; gap: 5px; min-width: 190px; padding: 18px 22px; transform: translate(-50%,-50%); border: 1px solid rgba(255,255,255,.6); border-radius: 16px; background: rgba(251,252,250,.94); box-shadow: var(--shadow); text-align: center; }
.loading-card span { width: 24px; height: 24px; margin-bottom: 4px; border: 3px solid #d7e5e3; border-top-color: var(--sea); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-card b { font-size: 13px; }
.loading-card small { color: var(--muted); font-size: 10px; }
.loading-card.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.coordinate-card { position: absolute; z-index: 610; right: 12px; bottom: 30px; display: grid; gap: 2px; min-width: 250px; padding: 8px 11px; border: 1px solid rgba(255,255,255,.75); border-radius: 10px; background: rgba(251,252,250,.9); box-shadow: 0 7px 22px rgba(19,51,60,.12); backdrop-filter: blur(8px); pointer-events: none; }
.coordinate-card span { color: var(--muted); font-size: 9px; }
.coordinate-card strong { font-size: 10px; font-weight: 750; font-variant-numeric: tabular-nums; }
.map-badge { position: absolute; z-index: 610; top: 12px; left: 12px; padding: 6px 9px; border: 1px solid rgba(255,255,255,.7); border-radius: 8px; color: rgba(23,52,62,.68); background: rgba(251,252,250,.76); font-size: 9px; font-weight: 900; letter-spacing: .11em; pointer-events: none; }
.toast { position: fixed; z-index: 2000; left: 50%; bottom: 25px; max-width: min(430px, calc(100vw - 30px)); padding: 11px 15px; transform: translate(-50%, 20px); border-radius: 10px; color: #fff; background: #17343e; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.visible { transform: translate(-50%,0); opacity: 1; }
.popup-card { min-width: 220px; }
.popup-card .kind { color: #71858b; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.popup-card h3 { margin: 5px 0 9px; font-size: 15px; }
.popup-card dl { margin: 0; }
.popup-card div { display: grid; grid-template-columns: 74px 1fr; gap: 8px; padding: 4px 0; border-top: 1px solid #edf1f1; }
.popup-card dt { color: #71858b; font-size: 10px; }
.popup-card dd { margin: 0; font-size: 10px; line-height: 1.35; }

.icon-button { width: 36px; height: 36px; padding: 8px; border-radius: 9px; }
.icon-button span { display: block; height: 2px; margin: 3px 0; border-radius: 2px; background: var(--deep); }
.mobile-only { display: none; }

@media (max-width: 760px) {
  .mobile-only { display: inline-block; }
  .topbar { height: 61px; padding: 0 10px; gap: 8px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-copy strong { font-size: 15px; }
  .brand-copy span { display: none; }
  .quiet-button { display: none; }
  .base-button { min-height: 32px; padding: 0 9px; font-size: 11px; }
  .workspace { height: calc(100% - 61px); display: block; }
  .control-panel { position: absolute; z-index: 1200; inset: 61px auto 0 0; width: min(314px, calc(100vw - 38px)); transform: translateX(-102%); box-shadow: var(--shadow); transition: transform .22s ease; }
  .control-panel.open { transform: translateX(0); }
  .panel-heading .icon-button { font-size: 24px; line-height: 1; }
  .map-stage { width: 100%; height: 100%; }
  .coordinate-card { right: 8px; bottom: 28px; left: 8px; min-width: 0; }
  .leaflet-control-attribution { max-width: calc(100vw - 10px); font-size: 8px; }
  .map-badge { top: 8px; left: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; }
}

