:root {
  --navy: #1f3864;
  --navy-2: #2f5597;
  --ink: #1d2433;
  --muted: #5b6475;
  --line: #d7dce5;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ok: #1e7b45;
  --warn: #9c6500;
  --bad: #9c0006;
  --accent: #ffb000;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 8px; color: var(--navy); }
h2 { font-size: 17px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); font-size: 12.5px; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; background: var(--navy); color: #fff; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 26px; height: 26px; border-radius: 6px; background: linear-gradient(135deg, #ffd34d, #ff8f00); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: .01em; }
.brand-sub { font-size: 11.5px; opacity: .75; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar label.operator { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: rgba(255,255,255,.88); margin: 0; white-space: nowrap; }
.operator input { width: 190px; padding: 5px 8px; border-radius: 6px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; }
.operator input::placeholder { color: rgba(255,255,255,.6); }
.operator input.missing { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,176,0,.35); }

.btn { border: 1px solid var(--navy-2); background: var(--navy-2); color: #fff; border-radius: 7px; padding: 7px 13px; cursor: pointer; font-weight: 550; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: inherit; border-color: currentColor; opacity: .9; }
.panel .btn.ghost { color: var(--navy-2); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.wide { width: 100%; }
.linkbtn { background: none; border: none; color: var(--navy-2); cursor: pointer; padding: 0; text-decoration: underline; font-size: 12.5px; }

.layout { flex: 1; display: flex; min-height: 0; margin-bottom: 22px; }
.panel { width: 440px; min-width: 380px; overflow-y: auto; background: var(--bg); border-right: 1px solid var(--line); padding: 14px; }
.mapwrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card.step { position: relative; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.step-num { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 12px; align-items: center; justify-content: center; margin-right: 8px; flex: none; }
.step-title { display: flex; align-items: center; font-weight: 650; color: var(--navy); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: #eef1f6; color: var(--muted); }
.pill.ok { background: #e6f4ec; color: var(--ok); }
.pill.warn { background: #fff4e0; color: var(--warn); }
.pill.bad { background: #fde8ea; color: var(--bad); }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 8px 0 3px; }
label input:not([type=checkbox]):not([type=radio]), label select, label textarea { display: block; width: 100%; margin-top: 3px; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,85,151,.35); border-color: var(--navy-2); }
label.check { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 12px; color: var(--ink); }
.tool .ico { font-size: 18px; line-height: 1; }
.tool.on { border-color: var(--navy-2); background: #eaf0fa; box-shadow: inset 0 0 0 1px var(--navy-2); }
.results { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.result { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 8px; cursor: pointer; }
.result:hover { border-color: var(--navy-2); }
.pieces { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.piece { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: #fbfcfe; font-size: 12.5px; }
.piece .top { display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.piece .name { font-weight: 600; color: var(--ink); }
.totals { margin-top: 8px; font-size: 13px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 3px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.project-list { display: flex; flex-direction: column; gap: 8px; }
.project-item { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; cursor: pointer; }
.project-item:hover { border-color: var(--navy-2); }
.project-item .pid { font-weight: 650; color: var(--navy); }
.console { background: #0f1724; color: #d6e2f5; font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: 11.5px; border-radius: 8px; padding: 8px 10px; height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console .err { color: #ffb4b4; }
.console .head { color: #9fe3b7; }
.downloads { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.download { display: flex; justify-content: space-between; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; background: #fff; font-size: 12.5px; }
.callout { border-left: 3px solid var(--accent); background: #fff8e6; padding: 8px 10px; border-radius: 4px; font-size: 12.5px; margin: 6px 0; }
.callout.info { border-left-color: var(--navy-2); background: #eef3fb; }
.counts { display: flex; gap: 6px; flex-wrap: wrap; }
details summary { cursor: pointer; color: var(--navy-2); font-size: 12.5px; margin-top: 6px; }

.sitemap { position: absolute; inset: 0; overflow: hidden; background: #dfe5ec; cursor: grab; user-select: none; }
.sitemap[data-mode=pin], .sitemap[data-mode=parcel], .sitemap[data-mode=draw] { cursor: crosshair; }
.sitemap-tiles { position: absolute; inset: 0; }
.sitemap-tile { position: absolute; left: 0; top: 0; image-rendering: auto; }
.sitemap-tile.missing { visibility: hidden; }
.sitemap-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sitemap-handle { fill: #fff; stroke: #ff6a00; stroke-width: 2; pointer-events: all; cursor: move; }
.sitemap-label { font-size: 12px; fill: #111; paint-order: stroke; stroke: rgba(255,255,255,.9); stroke-width: 3px; font-weight: 600; }
.sitemap-readout { position: absolute; left: 10px; bottom: 10px; background: rgba(255,255,255,.88); border-radius: 6px; padding: 3px 8px; font: 12px Consolas, Menlo, monospace; }
.sitemap-scale { position: absolute; left: 10px; bottom: 38px; font-size: 11.5px; background: rgba(255,255,255,.85); border-radius: 5px; padding: 3px 6px; }
.sitemap-scale .bar { height: 6px; border: 2px solid #222; border-top: none; margin-bottom: 2px; }
.sitemap-attrib { position: absolute; right: 8px; bottom: 6px; font-size: 11px; background: rgba(255,255,255,.8); padding: 2px 6px; border-radius: 4px; }
.map-toolbar { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: 0 2px 6px rgba(16,24,40,.12); }
.seg button { border: none; background: #fff; padding: 6px 10px; cursor: pointer; font-size: 12.5px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--navy); color: #fff; }
.seg.zoom { flex-direction: column; }
.seg.zoom button { border-right: none; border-bottom: 1px solid var(--line); font-size: 16px; width: 34px; }
.map-hint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: rgba(31,56,100,.94); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: 70%; text-align: center; }
.map-hint .btn { margin-left: 8px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 70vw; z-index: 50; font-size: 13px; }
.toast.bad { background: var(--bad); }
dialog { border: none; border-radius: 12px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: 480px; max-width: 92vw; }
dialog::backdrop { background: rgba(15,23,36,.45); }
.dlg { padding: 18px 20px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dlg .btn.ghost { color: var(--navy-2); }
.sitemap-readout:empty { display: none; }

.pathrow { display: flex; gap: 6px; align-items: center; }
.pathrow input { flex: 1; min-width: 0; }
.dlg h3 { margin: 14px 0 4px; font-size: 14px; }
.path { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; word-break: break-all; }
input.need { border-color: #c0392b; box-shadow: 0 0 0 2px rgba(192, 57, 43, 0.18); }
input.suggest { border-color: #d4a017; }
/* License badge in the top bar and its dialog */
.license-badge.ok { border-color: #8fd19e; }
.license-badge.trial { border-color: var(--accent); }
.license-badge.bad { border-color: var(--bad); color: #fff; background: var(--bad); }
.btn.ghost.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
#dlg-license .kv { margin: 6px 0 10px; }
/* Copyright footer on every page of the app (not printed in reports) */
.appfooter { position: fixed; left: 0; right: 0; bottom: 0; height: 22px; display: flex; justify-content: space-between;
  align-items: center; padding: 0 12px; font-size: 11px; color: #6b7280; background: #f7f8fa; border-top: 1px solid #e3e6eb;
  z-index: 5; }
@media print { .appfooter { display: none; } }

/* Harvest sources grouped by discipline */
.source-groups { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
fieldset.source-group { border: 1px solid var(--line, #d9dde3); border-radius: 6px; padding: 6px 10px 8px; margin: 0; }
fieldset.source-group legend { font-size: 12px; font-weight: 600; color: var(--muted, #5b6470); padding: 0 4px; }

/* Fill data gaps: the upload dialog and its schema-generated forms */
#dlg-upload { width: 760px; }
#dlg-upload .dlg { max-height: 86vh; overflow-y: auto; }
.sf-field { display: block; margin: 6px 0; }
.sf-label { font-size: 12.5px; font-weight: 600; color: var(--ink, #1d2433); display: block; margin-top: 4px; }
.sf-label .req { color: var(--bad); }
.sf-desc { display: block; font-size: 11.5px; }
.sf-fieldset { border: 1px solid var(--line, #d9dde3); border-radius: 6px; padding: 6px 10px 8px; margin: 6px 0; }
.sf-fieldset legend { font-size: 12.5px; font-weight: 600; padding: 0 4px; }
.sf-group { margin: 6px 0; }
.sf-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.sf-item { border-left: 3px solid #d6dbe4; padding-left: 8px; }
.sf-tuple input { width: 9em; }
.sf-prov { background: #f5f7fb; border-radius: 6px; padding: 4px 8px; margin: 6px 0; }
.sf-prov input[type="text"] { width: 16em; }
.sf-doc { background: #f7f8fa; border-radius: 6px; padding: 6px 8px; margin: 6px 0; }
.card.inset { background: #f9fafc; box-shadow: none; margin: 8px 0; }
ul.gaplist, ul.changes { margin: 4px 0 8px; padding-left: 18px; font-size: 12.5px; }
ul.gaplist li { margin: 6px 0; }
ul.gaplist .pill { margin-left: 6px; }
[hidden] { display: none !important; }

/* Progress of the running step (0.12.0): a moving bar, determinate only when the command counted its work. */
.progress { position: relative; height: 10px; border-radius: 5px; background: #e3e8ee; overflow: hidden; margin: 6px 0; }
.progress .bar { height: 100%; background: #2a6fb0; border-radius: 5px; transition: width 0.4s ease; }
.progress.indeterminate .bar { width: 30%; position: absolute; left: -30%; animation: progress-slide 1.6s linear infinite; }
@keyframes progress-slide { from { left: -30%; } to { left: 100%; } }
.progress-head { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.activity { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: #4a5566; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted.small { font-size: 12px; }
.keylink { font-size: 12px; color: #4a5566; margin: -6px 0 10px; }
.keylink a { color: #2a6fb0; }
