:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #6d7a76;
  --line: #dfe7e4;
  --paper: #f4f7f5;
  --white: #ffffff;
  --accent: #d4623a;
  --accent-dark: #9f4022;
  --green: #277a63;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
html, body { height: 100%; margin: 0; }
body { color: var(--ink); background: #111a19; }
button { font: inherit; }

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
  background: var(--paper);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 30px 20px;
  color: #f5f8f7;
  background: #111a19;
}

.eyebrow, .label, .detail-type {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(24px, 3vw, 38px); line-height: 1; letter-spacing: -.04em; }
.summary { display: flex; gap: 22px; color: #b9c6c2; font-size: 13px; }
.summary strong { color: white; }
.live-dot::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #59b98f; }
.live-dot.review::before { background: #e6ad45; }
.live-dot.archived::before { background: #b67a6a; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.settings-button {
  padding: 10px 13px;
  color: #f5f8f7;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px;
  cursor: pointer;
}
.settings-button:hover { background: rgba(255,255,255,.14); }

.workspace { display: grid; grid-template-columns: minmax(290px, 360px) 1fr; min-height: 0; }
.panel { z-index: 4; overflow: auto; padding: 22px; background: var(--white); border-right: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 2px 18px; }
.egrn-import { margin: -4px 0 14px; padding: 12px; background: #edf6f2; border: 1px dashed #9fc9b9; border-radius: 14px; transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease; }
.egrn-import:hover, .egrn-import:focus-visible { border-color: var(--green); background: #e5f3ed; box-shadow: 0 0 0 3px rgba(89,185,143,.18); outline: none; }
.egrn-import.is-dragging { border-color: var(--accent); background: #fff4e9; transform: translateY(-1px); box-shadow: 0 10px 24px rgba(196,91,48,.12); }
.egrn-import .egrn-drop-title { margin: 0 3px 9px; color: var(--ink); font-size: 12px; font-weight: 750; text-align: center; }
.import-button { display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 13px; color: #fff; background: var(--green); border-radius: 10px; font-size: 13px; font-weight: 800; cursor: pointer; }
.import-button:hover { background: #206b56; }
.egrn-import > p:last-child { margin: 8px 3px 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.filters { display: grid; gap: 9px; margin: 0 0 14px; padding: 12px; background: #f6f8f7; border: 1px solid var(--line); border-radius: 14px; }
.search-field input, .filter-row select {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d7e1de;
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
}
.search-field input::placeholder { color: #8b9793; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.filter-meta button { padding: 3px 0; color: var(--green); background: none; border: 0; font: inherit; font-weight: 750; cursor: pointer; }
.search-field input:focus-visible, .filter-row select:focus-visible { outline: 3px solid rgba(89,185,143,.24); outline-offset: 1px; }
.muted { margin: 0; color: var(--muted); }
.quiet-button { padding: 9px 12px; color: var(--ink); background: #eef3f1; border: 0; border-radius: 9px; cursor: pointer; }
.quiet-button:hover { background: #e2eae7; }

.object-list { display: grid; gap: 10px; }
.object-button {
  width: 100%;
  padding: 16px;
  text-align: left;
  color: inherit;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.object-button:hover, .object-button[aria-current="true"] {
  border-color: #9ebbb1;
  box-shadow: 0 10px 28px rgba(31, 65, 54, .09);
  transform: translateY(-1px);
}
.object-button h2 { margin: 4px 0 6px; font-size: 16px; line-height: 1.25; letter-spacing: -.015em; }
.object-button p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.object-kicker { display: flex; align-items: center; gap: 8px; color: var(--green) !important; font-size: 11px !important; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }
.object-kicker::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.object-button[data-actuality="active"] .object-kicker::before { background: #3b9b78; }
.object-button[data-actuality="archived"] .object-kicker::before { background: #a48f87; }
.object-status { display: inline-flex; margin-top: 10px !important; padding: 4px 7px; color: #8a5a14 !important; background: #fff4d6; border-radius: 7px; font-size: 10px !important; font-weight: 750; }
.object-button[data-actuality="active"] .object-status { color: #1d674f !important; background: #ddf5eb; }
.object-button[data-actuality="archived"] .object-status { color: #725e57 !important; background: #eee9e7; }
.empty-list { margin: 10px 2px; padding: 18px; color: var(--muted); background: #f6f8f7; border: 1px dashed #cfdad6; border-radius: 12px; font-size: 13px; line-height: 1.45; }

.map-wrap { position: relative; min-height: 0; }
.map { width: 100%; height: 100%; min-height: 520px; background: #dfe7e4; }
.map-state { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; justify-items: center; color: var(--muted); background: #edf2f0; }
.map-state[hidden] { display: none !important; }
.map-state.error { color: #7c3320; padding: 32px; text-align: center; }
.loader { width: 30px; height: 30px; border: 3px solid #c9d5d1; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.detail-card {
  position: absolute;
  z-index: 5;
  right: 20px;
  bottom: 20px;
  width: min(430px, calc(100% - 40px));
  max-height: calc(100% - 40px);
  overflow: auto;
  padding: 22px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(217,226,223,.9);
  border-radius: 16px;
  box-shadow: 0 22px 56px rgba(17, 33, 29, .18);
  backdrop-filter: blur(12px);
}

.osm-map { position: relative; overflow: hidden; background: #dce6e2; }
.osm-viewport { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
.osm-viewport.dragging { cursor: grabbing; }
.osm-tile { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; pointer-events: none; }
.osm-pin {
  position: absolute;
  z-index: 2;
  width: 26px;
  height: 26px;
  padding: 0;
  transform: translate(-50%, -100%);
  background: var(--accent);
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 0;
  box-shadow: 0 4px 12px rgba(17, 33, 29, .32);
  rotate: -45deg;
  cursor: pointer;
}
.osm-pin::after { content: ""; position: absolute; inset: 6px; background: #fff; border-radius: 50%; }
.osm-pin:hover, .osm-pin.selected { background: var(--accent-dark); scale: 1.12; }
.osm-pin.status-active { background: #277a63; }
.osm-pin.status-archived { background: #88756e; }
.osm-controls { position: absolute; z-index: 4; top: 14px; left: 14px; display: grid; overflow: hidden; border-radius: 10px; box-shadow: 0 6px 18px rgba(17, 33, 29, .18); }
.osm-controls button { width: 38px; height: 38px; padding: 0; color: var(--ink); background: #fff; border: 0; border-bottom: 1px solid var(--line); font-size: 24px; line-height: 1; cursor: pointer; }
.osm-controls button:last-child { border-bottom: 0; }
.osm-controls button:hover { background: #eef3f1; }
.map-provider-badge { position: absolute; z-index: 4; top: 14px; right: 14px; padding: 7px 10px; color: var(--muted); background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 9px; font-size: 11px; font-weight: 700; }
.osm-attribution { position: absolute; z-index: 4; right: 5px; bottom: 3px; padding: 2px 5px; color: #384943; background: rgba(255,255,255,.82); border-radius: 3px; font-size: 10px; text-decoration: none; }
.osm-attribution:hover { text-decoration: underline; }
.detail-card h2 { margin: 4px 32px 7px 0; font-size: 22px; line-height: 1.15; letter-spacing: -.025em; }
.detail-type { color: var(--accent-dark); }
.close-button { position: absolute; top: 13px; right: 13px; width: 34px; height: 34px; padding: 0; color: var(--muted); background: #eef3f1; border: 0; border-radius: 50%; font-size: 24px; line-height: 1; cursor: pointer; }
dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0 0; }
dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
dd { margin: 3px 0 0; font-size: 14px; font-weight: 700; }
.detail-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 16px; padding: 4px; background: #edf2f0; border-radius: 11px; }
.detail-tabs button { min-height: 37px; padding: 0 10px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; font-size: 12px; font-weight: 800; cursor: pointer; }
.detail-tabs button[aria-selected="true"] { color: var(--ink); background: #fff; box-shadow: 0 3px 10px rgba(17,33,29,.08); }
.detail-tabs span:not(:empty) { margin-left: 5px; padding: 2px 5px; color: #fff; background: var(--green); border-radius: 999px; font-size: 9px; }
.detail-panel { padding-top: 1px; }
.detail-note { margin: 13px 0 -7px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.document-button { width: 100%; min-height: 42px; margin-top: 16px; color: var(--green); background: #edf6f2; border: 1px solid #cfe2da; border-radius: 10px; font-weight: 800; cursor: pointer; }
.document-button:hover { background: #dfeee8; }
.object-sources { display: flex; gap: 5px; margin-top: 8px; }
.source-chip { padding: 3px 6px; border-radius: 6px; font-size: 9px; font-weight: 800; letter-spacing: .04em; }
.source-chip.egrn { color: #2c6655; background: #dff2ea; }
.source-chip.dueboard { color: #3f5785; background: #e4ebfa; }
.dueboard-empty { margin-top: 14px; padding: 15px; color: var(--muted); background: #f3f6f5; border: 1px dashed #cbd7d3; border-radius: 12px; font-size: 12px; line-height: 1.45; }
.dueboard-empty strong { color: var(--ink); }
.dueboard-empty p { margin: 6px 0 0; }
.dueboard-empty code { color: var(--green); word-break: break-all; }
.dueboard-progress-head { margin-top: 15px; padding: 14px; background: #edf3fb; border-radius: 12px; }
.dueboard-progress-head > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: #53647f; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.dueboard-progress-head strong { color: #30466d; font-size: 24px; letter-spacing: -.04em; }
.dueboard-progress { height: 7px; margin-top: 9px; overflow: hidden; background: #d5deed; border-radius: 99px; }
.dueboard-progress span { display: block; height: 100%; background: #5579b5; border-radius: inherit; }
.dueboard-facts { margin-top: 14px; }
.dueboard-files { display: grid; gap: 7px; margin-top: 14px; }
.dueboard-files .detail-note { margin: 0 0 2px; }
.dueboard-files a, .dueboard-files > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 11px; color: var(--ink); background: #f4f7f6; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; font-size: 12px; font-weight: 750; }
.dueboard-files small { color: var(--muted); font-weight: 500; text-align: right; }
.dueboard-file-note, .dueboard-snapshot-note { margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.dueboard-open { display: flex; align-items: center; justify-content: center; text-decoration: none; }

.settings-dialog {
  width: min(480px, calc(100vw - 28px));
  padding: 0;
  color: var(--ink);
  background: #f8faf9;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(17, 33, 29, .3);
}
.settings-dialog::backdrop { background: rgba(9, 16, 14, .48); backdrop-filter: blur(6px); }
.settings-dialog form { display: grid; gap: 16px; padding: 22px; }
.settings-head { position: relative; display: flex; align-items: flex-start; justify-content: space-between; padding-right: 40px; }
.settings-head h2 { margin: 0; font-size: 26px; letter-spacing: -.035em; }
.settings-head .eyebrow { color: var(--green); }
.settings-head .close-button { top: -3px; right: -3px; }
.settings-field { display: grid; gap: 7px; }
.settings-field > span { color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.settings-field select {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  font: inherit;
}
.settings-field input, .settings-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  font: inherit;
}
.settings-field textarea { resize: vertical; line-height: 1.4; }
.settings-note { margin: -2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.settings-save { min-height: 46px; color: #fff; background: var(--green); border: 0; border-radius: 11px; font-weight: 750; cursor: pointer; }
.settings-save:hover { background: #206b56; }
.settings-button:focus-visible, .import-button:focus-visible, .settings-field select:focus-visible, .settings-field input:focus-visible, .settings-field textarea:focus-visible, .settings-save:focus-visible { outline: 3px solid rgba(89,185,143,.35); outline-offset: 2px; }

.egrn-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(880px, calc(100dvh - 28px));
  padding: 0;
  color: var(--ink);
  background: #f8faf9;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(17, 33, 29, .3);
}
.egrn-dialog::backdrop { background: rgba(9, 16, 14, .48); backdrop-filter: blur(6px); }
.egrn-dialog form { display: grid; gap: 16px; padding: 22px; }
.egrn-dialog .eyebrow { color: var(--green); }
.egrn-dialog h2 { margin: 0; font-size: 26px; letter-spacing: -.035em; }
.import-progress { display: grid; min-height: 210px; place-content: center; justify-items: center; color: var(--muted); }
.import-progress p { margin: 13px 0 0; }
.egrn-preview { display: grid; gap: 15px; }
.egrn-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding: 14px; background: #edf3f1; border-radius: 12px; }
.egrn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
.location-note { margin: 0; padding: 11px 12px; color: #6c531c; background: #fff6dd; border: 1px solid #f0dfad; border-radius: 10px; font-size: 12px; line-height: 1.45; }
.import-error { padding: 16px; color: #7c3320; background: #fff0eb; border: 1px solid #edc7ba; border-radius: 12px; line-height: 1.5; }
.settings-save:disabled { opacity: .65; cursor: progress; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; padding: 18px 18px 16px; }
  .summary { display: none; }
  .settings-button { padding: 9px 11px; font-size: 12px; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(54dvh, 1fr); }
  .panel { max-height: 37dvh; padding: 14px 14px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .panel-head { padding: 0 2px 12px; }
  .filters { padding: 10px; }
  .egrn-import { margin-bottom: 10px; }
  .object-list { display: flex; overflow-x: auto; padding: 0 2px 6px; scroll-snap-type: x mandatory; }
  .object-button { min-width: min(78vw, 300px); scroll-snap-align: start; }
  .map { min-height: 54dvh; }
  .detail-card { right: 12px; bottom: 12px; width: calc(100% - 24px); padding: 18px; }
  .egrn-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .egrn-dialog form { padding: 17px; }
  .egrn-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .egrn-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}
