:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #172027;
  --muted: #647078;
  --paper: rgba(251, 250, 247, 0.94);
  --line: rgba(24, 34, 41, 0.12);
  --accent: #d66e43;
  --shadow: 0 18px 55px rgba(17, 25, 31, 0.18);
}

* { box-sizing: border-box; }
html, body, #map { width: 100%; height: 100%; margin: 0; }
body { overflow: hidden; color: var(--ink); background: #dfe5e7; }
button { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.topbar {
  position: fixed;
  z-index: 2;
  top: 20px;
  left: 22px;
  right: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.brand, .freshness, .panel, .manage-button {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.2);
}
.topbar-actions { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.manage-button { padding: 10px 13px; border-radius: 999px; color: var(--ink); cursor: pointer; font-size: 12px; font-weight: 750; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 214px;
  padding: 10px 14px 10px 11px;
  border-radius: 16px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: conic-gradient(from 35deg, #d66e43, #e6bd70, #527c70, #34596d, #d66e43);
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.58);
}

.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; letter-spacing: -0.01em; }
.brand div > span { color: var(--muted); font-size: 11px; margin-top: 2px; }

.freshness {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #48a276; box-shadow: 0 0 0 4px rgba(72,162,118,.14); }

.panel {
  position: fixed;
  z-index: 2;
  right: 22px;
  top: 86px;
  width: 270px;
  max-height: calc(100dvh - 108px);
  padding: 18px;
  overflow: hidden;
  border-radius: 20px;
}
.panel.collapsed { width: 54px; height: 54px; padding: 0; border-color: transparent; border-radius: 50%; background: transparent; box-shadow: none; backdrop-filter: none; }
.panel-toggle { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; padding: 9px 38px; border: 0; color: var(--ink); background: transparent; cursor: pointer; font-size: 12px; font-weight: 750; }
.sheet-grabber { position: absolute; top: 2px; left: 50%; width: 34px; height: 4px; border-radius: 999px; background: var(--line); transform: translateX(-50%); }
.sheet-chevron { position: absolute; right: 10px; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s ease; }
.panel:not(.collapsed) .sheet-chevron { transform: rotate(225deg); }
.panel.collapsed .panel-content { display: none; }
.panel.collapsed .panel-toggle { width: 54px; min-height: 54px; padding: 0; border: 1px solid rgba(255,255,255,.72); border-radius: 50%; background: var(--paper); box-shadow: var(--shadow); }
.panel.collapsed .panel-toggle > span { display: none; }
.panel.collapsed .panel-toggle::before { content: ""; width: 20px; height: 16px; background: linear-gradient(currentColor,currentColor) 0 1px/20px 2px no-repeat, linear-gradient(currentColor,currentColor) 0 7px/20px 2px no-repeat, linear-gradient(currentColor,currentColor) 0 13px/20px 2px no-repeat; opacity: .72; }
.panel-content { max-height: calc(100dvh - 188px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }

.eyebrow { margin: 0 0 10px; color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.preview-badge { display: inline-block; margin-left: 5px; padding: 2px 5px; border: 1px solid rgba(214,110,67,.38); border-radius: 999px; color: #a34f2d; font-size: 8px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px; }
.region-picker { position: relative; display: block; }
.region-picker::after { content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
#region-select { width: 100%; appearance: none; padding: 11px 36px 11px 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: rgba(255,255,255,.54); cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; }
#region-select:focus-visible { outline: 2px solid rgba(0,165,184,.7); outline-offset: 2px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(80,90,96,.06); }
.mode { padding: 8px 7px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.mode.selected { color: #fff; background: #1f313b; box-shadow: 0 3px 10px rgba(19,31,39,.18); }
.mode-detail { min-height: 28px; margin: 8px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.themes { display: grid; gap: 7px; }
.theme { display: grid; grid-template-columns: 44px 1fr; gap: 11px; align-items: center; width: 100%; padding: 7px; border: 1px solid transparent; border-radius: 13px; text-align: left; color: var(--ink); background: transparent; cursor: pointer; }
.theme:hover { background: rgba(80,90,96,.06); }
.theme.selected { border-color: rgba(214,110,67,.45); background: rgba(214,110,67,.08); }
.theme strong, .theme small { display: block; }
.theme strong { font-size: 13px; }
.theme small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.swatch { width: 44px; height: 34px; border-radius: 9px; border: 1px solid rgba(0,0,0,.1); }
.swatch.daylight { background: linear-gradient(145deg, #cfe3c5 0 38%, #f4f1ea 38% 55%, #e8b06d 55% 63%, #9bc8df 63%); }
.swatch.midnight { background: linear-gradient(145deg, #18332d 0 38%, #101820 38% 55%, #c7a260 55% 63%, #102b3c 63%); }
.swatch.dark-blue { background: linear-gradient(145deg, #0f2a2a 0 38%, #07111f 38% 55%, #d2b56f 55% 63%, #071e34 63%); }
.swatch.dark-red { background: linear-gradient(145deg, #1b1910 0 38%, #160909 38% 55%, #ff8b6b 55% 63%, #151018 63%); }
.swatch.dark-green { background: linear-gradient(145deg, #12321f 0 38%, #07120d 38% 55%, #c5b66c 55% 63%, #0a1a1c 63%); }
.swatch.cyberpunk { background: linear-gradient(145deg, #071f20 0 35%, #060711 35% 52%, #ff2aa3 52% 59%, #00e5ff 59% 68%, #171028 68%); box-shadow: inset 0 0 12px rgba(0,229,255,.3), 0 0 8px rgba(255,42,163,.2); }
.swatch.cyberpunk-tactical { background: #03040b; box-shadow: inset 0 0 12px rgba(0,234,255,.28), 0 0 8px rgba(140,98,244,.22); }
.swatch.has-preview { background-position: center; background-size: cover; }
.control-hint { margin: 6px 2px 0; color: var(--muted); font-size: 9px; line-height: 1.4; }
.control-hint[hidden] { display: none; }
.theme[data-theme="cyberpunk-tactical"].selected { animation: tactical-pulse 2.8s ease-in-out infinite; }
@keyframes tactical-pulse { 0%, 100% { box-shadow: 0 0 0 rgba(0,234,255,0); } 50% { box-shadow: 0 0 18px rgba(0,234,255,.13); } }
.rule { height: 1px; background: var(--line); margin: 16px 0; }
.action { display: inline-block; width: 100%; margin-top: 7px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink); background: rgba(255,255,255,.54); cursor: pointer; font-size: 12px; font-weight: 650; text-align: center; text-decoration: none; }
.action[hidden] { display: none; }
.action:hover { transform: translateY(-1px); }
.action.primary { border-color: #1f313b; color: #fff; background: #1f313b; }
.hint { margin: 10px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.choice-intro { margin: -2px 2px 10px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.path-card { margin-top: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.42); }
.path-card h3 { margin: 5px 0 4px; font-size: 13px; }
.path-card > p { margin: 0 0 8px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.path-badge { display: inline-block; padding: 3px 6px; border-radius: 999px; color: #216b61; background: rgba(72,162,118,.12); font-size: 8px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.path-badge.offline { color: #6d4da3; background: rgba(140,98,244,.12); }
.recommended-path { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.recommended-path > strong { margin-left: 4px; font-size: 11px; }
.recommended-path > p { margin: 6px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.path-badge.recommended { color: #255f78; background: rgba(52,139,174,.13); }
.raster-option { margin-top: 10px; border-top: 1px solid var(--line); }
.raster-option summary { padding-top: 10px; cursor: pointer; color: var(--ink); font-size: 10px; font-weight: 750; }
.validation-note { margin-top: 8px !important; padding-top: 8px; border-top: 1px solid var(--line); }
.delivery-guide { margin: 9px 0 0; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.4); }
.delivery-guide summary { padding: 10px 12px; cursor: pointer; color: var(--ink); font-size: 11px; font-weight: 750; }
.delivery-guide[open] summary { border-bottom: 1px solid var(--line); }
.delivery-option { display: grid; gap: 2px; padding: 9px 11px 0; }
.delivery-option strong { font-size: 10px; }
.delivery-option span, .delivery-guide p { color: var(--muted); font-size: 9px; line-height: 1.4; }
.delivery-guide p { margin: 10px 11px 11px; padding-top: 9px; border-top: 1px solid var(--line); }
#toast { position: fixed; z-index: 3; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 9px 13px; border-radius: 10px; color: white; background: #1f313b; opacity: 0; transition: .2s ease; pointer-events: none; font-size: 12px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.manager-dialog { width: min(760px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); overflow-y: auto; overscroll-behavior: contain; padding: 0; border: 1px solid rgba(255,255,255,.78); border-radius: 20px; color: var(--ink); background: #fbfaf7; box-shadow: 0 28px 90px rgba(10,18,24,.36); }
.manager-dialog::backdrop, .atak-share-dialog::backdrop { background: rgba(8,14,18,.56); backdrop-filter: blur(5px); }
.atak-share-dialog { width: min(430px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 0; border: 1px solid rgba(255,255,255,.78); border-radius: 20px; color: var(--ink); background: #fbfaf7; box-shadow: 0 28px 90px rgba(10,18,24,.36); }
.atak-share-content { padding: 18px 22px 22px; }
.atak-share-content[hidden], .atak-server-setup[hidden], .manager-warning[hidden], .atak-share-qr[hidden] { display: none; }
.atak-server-setup { padding: 16px 22px 22px; }
.atak-server-setup label { display: block; color: var(--ink); font-size: 11px; font-weight: 750; }
.atak-server-setup input { width: 100%; margin-top: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; font: 12px/1.35 monospace; }
.atak-share-qr { width: min(100%, 310px); margin: 0 auto 12px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.atak-share-qr svg { display: block; width: 100%; height: auto; }
.atak-link-label { display: block; margin-top: 12px; color: var(--muted); font-size: 10px; font-weight: 700; }
.atak-share-link { width: 100%; margin-top: 5px; padding: 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; font: 10px/1.35 monospace; }
.atak-share-content .validation-note { color: var(--muted); font-size: 11px; line-height: 1.45; }
.manager-header { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 15px; border-bottom: 1px solid var(--line); background: rgba(251,250,247,.96); }
.manager-header .eyebrow { margin-bottom: 3px; }
.manager-header h2 { margin: 0; font-size: 22px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: white; cursor: pointer; font-size: 24px; line-height: 1; }
.manager-warning { margin: 18px 22px 0; padding: 11px 13px; border: 1px solid rgba(186,119,46,.28); border-radius: 11px; color: #72512c; background: #fff6e8; font-size: 12px; }
.manager-section { margin: 18px 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.manager-section:last-of-type, .manager-section:has(+ .manager-section[hidden]:last-of-type) { border-bottom: 0; }
.manager-section[hidden] { display: none; }
.manager-section h3 { margin: 0 0 12px; font-size: 15px; }
.manager-view[hidden] { display: none; }
.manager-tabs { display:flex; gap:8px; padding:16px 22px 0; }
.manager-tabs [aria-selected="true"] { background:#224f65; color:white; }
#manager-imagery-panel[hidden], #manager-osm-panel[hidden] { display:none; }
.manager-dialog.imagery-active { width:min(1400px,calc(100vw - 28px)); }
#manager-imagery-frame { display:block; width:100%; height:calc(100dvh - 245px); min-height:420px; border:0; }
.manager-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.manager-section-head h3 { margin-bottom: 0; }
.manager-section-head .action { width: auto; min-width: 118px; margin: 0; }
.manager-back { margin: 0 0 14px; padding: 0; border: 0; color: #315e54; background: transparent; cursor: pointer; font-size: 11px; font-weight: 800; }
.manager-back:hover { text-decoration: underline; }
.manager-section label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.manager-section input, .manager-section select { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; font: inherit; font-size: 12px; }
.source-fields { display: grid; gap: 10px; margin-top: 10px; }
.source-fields[hidden] { display: none; }
.catalog-combobox { position: relative; }
.catalog-results { position: absolute; z-index: 4; top: calc(100% + 5px); left: 0; right: 0; max-height: min(360px, 45dvh); overflow-y: auto; overscroll-behavior: contain; padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: white; box-shadow: 0 16px 38px rgba(18,31,38,.18); }
.catalog-results[hidden] { display: none; }
.catalog-result-group + .catalog-result-group { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); }
.catalog-group-label { margin: 5px 7px 3px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.catalog-option { display: grid; gap: 2px; width: 100%; padding: 8px 9px; border: 0; border-radius: 8px; color: var(--ink); background: transparent; cursor: pointer; text-align: left; }
.catalog-option:hover, .catalog-option.active { background: #edf4f1; outline: none; }
.catalog-option strong { font-size: 12px; }
.catalog-option span { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.map-name-field { margin-top: 10px; }
.advanced-fields { margin-top: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.5); }
.advanced-fields summary { cursor: pointer; color: var(--muted); font-size: 10px; font-weight: 750; }
.advanced-fields[open] summary { margin-bottom: 9px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.manager-help, .empty-state { color: var(--muted); font-size: 11px; line-height: 1.45; }
.catalog-summary { margin: -2px 1px 0; color: var(--muted); font-size: 10px; }
.manager-list { display: grid; gap: 9px; }
.map-row, .job-row { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.map-row-head, .job-row-head { display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.map-row strong, .job-row strong { display: block; font-size: 13px; }
.map-meta { margin-top: 3px; color: var(--muted); font-size: 10px; }
.map-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.small-action { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fafafa; cursor: pointer; font-size: 10px; font-weight: 750; }
.small-action.danger { color: #8a342d; border-color: rgba(157,55,45,.25); }
.delete-confirm { display: grid; gap: 9px; margin-top: 9px; padding: 10px; border: 1px solid rgba(157,55,45,.2); border-radius: 9px; background: #fff7f5; }
.delete-confirm[hidden] { display: none; }
.map-actions[hidden] { display: none; }
.rename-form { display: grid; gap: 9px; margin-top: 9px; }
.rename-form[hidden] { display: none; }
.rename-input { width: 100%; min-height: 36px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; font: inherit; font-size: 12px; }
.rename-actions { display: flex; justify-content: flex-end; gap: 6px; }
.delete-question { margin: 0; color: #6e302b; font-size: 11px; font-weight: 700; line-height: 1.4; }
.delete-confirm-actions { display: flex; justify-content: flex-end; gap: 6px; }
.job-state { padding: 3px 6px; border-radius: 999px; color: #315e54; background: #e7f3ef; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.job-state.failed { color: #8a342d; background: #faeae8; }
.job-progress { width: 100%; height: 6px; margin-top: 9px; accent-color: #527c70; }
.job-steps { display: grid; grid-template-columns: repeat(4, 1fr); margin: 12px 0 2px; padding: 0; list-style: none; }
.job-step { position: relative; display: grid; justify-items: center; gap: 5px; color: #9aa3a1; font-size: 8px; font-weight: 750; letter-spacing: .03em; text-transform: uppercase; }
.job-step:not(:last-child)::after { content: ""; position: absolute; z-index: 0; top: 5px; left: calc(50% + 7px); width: calc(100% - 14px); height: 2px; background: #dce2df; }
.job-step.complete:not(:last-child)::after { background: #6f9e90; }
.job-step-dot { position: relative; z-index: 1; width: 12px; height: 12px; border: 2px solid #c8d0cd; border-radius: 50%; background: white; box-shadow: 0 0 0 3px white; }
.job-step.complete { color: #527c70; }
.job-step.complete .job-step-dot { border-color: #527c70; background: #527c70; }
.job-step.current { color: #244f45; }
.job-step.current .job-step-dot { border-color: #527c70; background: white; animation: job-step-pulse 1.6s ease-out infinite; }
.job-step.failed { color: #8a342d; }
.job-step.failed .job-step-dot { border-color: #b8564d; background: #b8564d; }
@keyframes job-step-pulse { 0% { box-shadow: 0 0 0 3px white, 0 0 0 3px rgba(82,124,112,.35); } 70%, 100% { box-shadow: 0 0 0 3px white, 0 0 0 9px rgba(82,124,112,0); } }
.job-error { margin: 8px 0 0; color: #8a342d; font-size: 10px; }
.job-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.manager-status { min-height: 20px; margin: 0 22px 20px; color: #315e54; font-size: 11px; }
.manager-status.create-status { min-height: 0; margin: 10px 0 0; }
.maplibregl-ctrl-bottom-right { right: 82px; }
html[data-controls-expanded="true"] .maplibregl-ctrl-bottom-right { right: 300px; }

@media (prefers-reduced-motion: reduce) {
  .theme[data-theme="cyberpunk-tactical"].selected { animation: none; }
  .job-step.current .job-step-dot { animation: none; }
  #toast, .action, .panel, .sheet-chevron { transition: none; }
}

@media (max-width: 680px) {
  .topbar { top: 10px; left: 10px; right: 10px; }
  .freshness { display: none; }
  .manage-button { padding: 9px 11px; }
  .panel { left: 10px; right: 10px; top: auto; bottom: 10px; width: auto; max-height: calc(100dvh - 110px); padding: 8px 13px 13px; overflow: hidden; transition: max-height .2s ease; }
  .panel.collapsed { left: auto; width: 54px; height: 54px; padding: 0; border-color: transparent; border-radius: 50%; background: transparent; box-shadow: none; backdrop-filter: none; }
  .panel-content { max-height: calc(100dvh - 175px); padding-top: 8px; overflow-y: auto; overscroll-behavior: contain; }
  .themes { grid-template-columns: 1fr 1fr; }
  .mode-detail { display: none; }
  .action { width: 100%; }
  .maplibregl-ctrl-bottom-right { right: 0; bottom: 78px; }
  html[data-controls-expanded="true"] .maplibregl-ctrl-bottom-right { right: 0; bottom: 155px; }
  .manager-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .manager-header { padding: 16px; }
  .manager-section, .manager-warning { margin-left: 16px; margin-right: 16px; }
  .field-row { grid-template-columns: 1fr; }
}
