/* ============================================================
   Agridence GeoJSON Studio — styled against the Agridence
   product design system (design-system reference + GPSNR
   prototype): Nunito Sans, primary #145FF5, white topbar with
   blue-tinted shadow, 12px radii, semantic compliant/partial/
   non-compliant palette, slate toasts.
   ============================================================ */

:root {
  /* ── DS primitives ── */
  --color-primary: #145FF5;
  --color-primary-dark: #0750E0;
  --color-primary-pressed: #0042C5;
  --color-primary-light: #E8F0FF;
  --color-primary-hover: #F4F8FF;
  --color-surface-subtle: #F5F6F8;
  --color-surface-nav: #2F3A4A;
  --color-surface-hover: #ECEEF1;
  --color-surface-overlay: rgba(15,23,42,0.45);
  --color-border-default: #D5DAE2;
  --color-border-strong: #5D6D85;
  --color-border-input: #4F5F76;
  --color-border-muted: #A9B4C3;
  --color-text-primary: #000000;
  --color-text-secondary: #4F5F76;
  --color-text-muted: #8391A6;
  --color-compliant-bg: #E5F3E5;
  --color-compliant-text: #005200;
  --color-non-compliant-bg: #FFEBEB;
  --color-non-compliant-text: #910000;
  --color-partial-bg: #FFF09B;
  --color-partial-text: #5B4100;
  --color-neutral-bg: #ECEEF1;
  --color-neutral-text: #39465A;
  --color-secondary-bg: #ECEEF1;
  --color-secondary-text: #2F3A4A;
  --color-secondary-hover: #D5DAE2;
  --color-warning-border: #E5A900;
  --color-info-bg: #E8F0FF;
  --color-info-text: #145FF5;
  --color-risk-protected: #7E22CE;
  --color-risk-protected-bg: #F3E8FF;
  --color-risk-no-risk: #166534;
  --color-delete: #DA0000;
  --color-delete-hover: #BF0000;
  --color-icon-default: #5D6D85;
  --color-toast-success: #007E00;

  --font-primary: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;

  --radius-card: 12px;
  --radius-button: 12px;
  --radius-input: 12px;
  --radius-chip: 24px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-ghost: 8px;

  --shadow-card: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-topbar: 0px 1px 3px 1px rgba(0,71,207,0.24);
  --shadow-popover: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-modal: 0 8px 40px rgba(0,0,0,0.18);
  --shadow-toast: 0 4px 16px rgba(0,0,0,0.20);

  --motion-fast: 120ms;
  --motion-base: 200ms;
  --motion-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --focus-ring: 0 0 0 3px rgba(20, 95, 245, 0.24);

  /* ── app aliases (map data colours are DS-aligned hues) ── */
  --ok: var(--color-risk-no-risk);
  --warn: var(--color-warning-border);
  --err: var(--color-delete);
  --risk: var(--color-risk-protected);
  --panel-w: 468px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-primary);
  color: var(--color-text-primary);
  background: #fff;
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; color: var(--color-text-primary); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }

#app {
  display: grid;
  grid-template-rows: 56px 1fr 34px;
  height: 100vh;
}

/* ---------------- topbar (DS: white, blue-tinted shadow) ---------------- */
header.topbar {
  background: #fff;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px 0 16px;
  position: relative;
  z-index: 1200;
  box-shadow: var(--shadow-topbar);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .agd-logo { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.brand .agd-logo svg { width: 32px; height: 32px; display: block; }
.brand .sep { width: 1px; height: 22px; background: var(--color-border-default); }
.brand .name { font-weight: 700; font-size: 14px; color: var(--color-text-primary); white-space: nowrap; }
.brand .tagline { font-size: 12px; color: var(--color-text-secondary); font-weight: 400; white-space: nowrap; margin-top: 1px; }
.version-chip {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600;
  background: var(--color-primary-light); color: var(--color-primary-dark);
  padding: 2px 10px; border-radius: var(--radius-chip);
}
header .spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---------------- buttons (DS spec: 600 14px, radius 12) ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: var(--radius-button);
  border: none;
  font-size: 14px; font-weight: 600;
  padding: 8px 16px;
  height: 40px;
  cursor: pointer;
  transition: background var(--motion-fast) var(--motion-ease), border-color var(--motion-fast) var(--motion-ease), box-shadow var(--motion-fast) var(--motion-ease);
  user-select: none;
  white-space: nowrap;
}
.btn svg { flex: 0 0 auto; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not([disabled]) { background: var(--color-primary-dark); }
.btn-primary:active:not([disabled]) { background: var(--color-primary-pressed); }
/* header actions on the white topbar = DS secondary buttons (class name kept for markup stability) */
.btn-onnavy { background: var(--color-secondary-bg); color: var(--color-secondary-text); }
.btn-onnavy:hover:not([disabled]) { background: var(--color-secondary-hover); }
.btn-ghost { background: #fff; color: var(--color-primary); border: 1px solid var(--color-primary); }
.btn-ghost:hover:not([disabled]) { background: var(--color-primary-hover); }
.btn-quiet { background: transparent; color: var(--color-text-secondary); }
.btn-quiet:hover:not([disabled]) { background: var(--color-surface-hover); color: var(--color-text-primary); }
.btn-danger { background: var(--color-non-compliant-bg); color: var(--color-delete); }
.btn-danger:hover:not([disabled]) { background: var(--color-delete); color: #fff; }
.btn-sm { height: 32px; padding: 4px 12px; font-size: 13px; }
.topbar-actions .btn { height: 34px; padding: 6px 14px; font-size: 13px; }

/* export dropdown (DS .dl-popover) */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: #fff; color: var(--color-text-primary);
  border: 1px solid var(--color-border-default); border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  min-width: 250px; padding: 6px 0;
  z-index: 1500; display: none;
}
.menu.open { display: block; animation: pop var(--motion-fast) var(--motion-ease); }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; text-align: left;
  padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--color-text-primary);
  cursor: pointer;
}
.menu button:hover { background: var(--color-surface-hover); }
.menu .menu-note { font-size: 11px; color: var(--color-text-muted); padding: 4px 16px 6px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px);} to { opacity: 1; transform: none; } }

/* ---------------- main split ---------------- */
main.split { display: grid; grid-template-columns: 1fr var(--panel-w); min-height: 0; position: relative; }
main.split.panel-collapsed { grid-template-columns: 1fr 0; }
main.split.panel-collapsed aside.panel { visibility: hidden; }
#map { position: relative; z-index: 1; background: #DDE3EC; }
#map:focus { outline: none; }

/* map floating toolbar (DS card + tb-icon-btn) */
.map-toolbar {
  position: absolute; top: 14px; left: 14px; z-index: 800;
  display: flex; flex-direction: column; gap: 6px;
  background: #fff; border: 1px solid var(--color-border-default);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 6px;
}
.map-toolbar .tb-group { display: flex; flex-direction: column; gap: 2px; }
.map-toolbar .tb-sep { height: 1px; background: var(--color-border-default); margin: 3px 2px; }
.tool-btn {
  width: 34px; height: 34px; border-radius: var(--radius-ghost); border: 0;
  background: transparent; color: var(--color-icon-default);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  transition: background var(--motion-fast) var(--motion-ease), color var(--motion-fast) var(--motion-ease);
}
.tool-btn:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.tool-btn.active { background: var(--color-primary-light); color: var(--color-primary); }
.tool-btn.active-coral { background: var(--color-primary); color: #fff; }
.tool-btn[disabled] { opacity: .35; cursor: not-allowed; }
.tool-btn .tip {
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #1E2230; color: #fff; font-size: 12px; font-weight: 600;
  padding: 4px 9px; border-radius: var(--radius-sm); white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity var(--motion-fast) var(--motion-ease);
  z-index: 900;
}
.tool-btn:hover .tip { opacity: 1; }

/* layers control: one button top-right, popover with basemap radio + overlay toggles */
.layers-ctl { position: absolute; top: 14px; right: 14px; z-index: 800; }
.layers-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 12px 0 10px;
  background: #fff; border: 1px solid var(--color-border-default);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  font-size: 13px; font-weight: 700; color: var(--color-text-primary); cursor: pointer;
}
.layers-btn:hover { background: var(--color-surface-subtle); }
.layers-btn svg:first-child { color: var(--color-icon-default); }
.layers-btn svg:last-child { color: var(--color-text-muted); transition: transform var(--motion-fast) var(--motion-ease); }
.layers-ctl.open .layers-btn { border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.layers-ctl.open .layers-btn svg:last-child { transform: rotate(180deg); }
.layers-ctl .layers-btn.has-overlay::after {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--color-primary); margin-left: 2px;
}
.layers-pop {
  position: absolute; right: 0; top: calc(100% + 6px); width: 290px;
  background: #fff; border: 1px solid var(--color-border-default); border-radius: var(--radius-card);
  box-shadow: var(--shadow-popover); padding: 10px 12px 12px; display: none;
}
.layers-ctl.open .layers-pop { display: block; animation: pop var(--motion-fast) var(--motion-ease); }
.lp-head { font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--color-text-muted); margin: 4px 0 6px; }
.lp-head + .lp-head, .lp-group + .lp-head { margin-top: 12px; }
.lp-group { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.lp-opt {
  border: 1px solid var(--color-border-default); background: #fff; border-radius: var(--radius-md);
  font-size: 12.5px; font-weight: 600; color: var(--color-text-secondary);
  padding: 7px 10px; cursor: pointer; text-align: left;
}
.lp-opt:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.lp-opt.active { background: var(--color-primary-light); border-color: var(--color-primary); color: var(--color-primary); font-weight: 700; }
.lp-ov { display: flex; align-items: center; gap: 9px; padding: 6px 4px; border-radius: var(--radius-md); cursor: pointer; }
.lp-ov:hover { background: var(--color-surface-subtle); }
.lp-ov input[type="checkbox"] { accent-color: var(--color-primary); width: 16px; height: 16px; margin: 0; flex: 0 0 auto; }
.lp-ov .sw { width: 18px; height: 12px; border-radius: 3px; flex: 0 0 auto; border: 2px solid transparent; }
.lp-ov-text { display: flex; flex-direction: column; min-width: 0; }
.lp-ov-text b { font-size: 13px; font-weight: 700; color: var(--color-text-primary); }
.lp-ov-text small { font-size: 11px; color: var(--color-text-muted); line-height: 1.35; }

/* legend */
.legend {
  position: absolute; bottom: 26px; left: 14px; z-index: 800;
  background: rgba(255,255,255,.97); border: 1px solid var(--color-border-default);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card);
  padding: 12px 14px; min-width: 178px;
  backdrop-filter: blur(3px);
}
.legend h4 {
  margin: 0 0 8px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-text-muted); font-weight: 700;
}
.legend .lg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; }
.legend .lg-head h4 { margin: 0; }
.lg-hide {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin: -4px -6px -4px 0; padding: 0;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--color-text-muted); cursor: pointer;
}
.lg-hide:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.lg-hide svg { width: 14px; height: 14px; }
/* collapsed legend: a small pill in the same corner that restores the box */
.legend-pill {
  position: absolute; bottom: 26px; left: 14px; z-index: 800;
  display: inline-flex; align-items: center;
  height: 30px; padding: 0 12px;
  background: rgba(255,255,255,.97); border: 1px solid var(--color-border-default);
  border-radius: var(--radius-chip); box-shadow: var(--shadow-card);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--color-text-secondary); cursor: pointer;
}
.legend-pill:hover { background: #fff; color: var(--color-text-primary); }
.legend .lg-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 2.5px 0; color: var(--color-text-secondary); font-weight: 600; }
.legend .sw { width: 20px; height: 12px; border-radius: 3px; flex: 0 0 auto; border: 2px solid transparent; }
.sw-ok { background: rgba(22,101,52,.18); border-color: var(--ok); }
.sw-warn { background: rgba(229,169,0,.22); border-color: var(--warn); }
.sw-err { background: rgba(218,0,0,.16); border-color: var(--err); }
.sw-risk { background: rgba(126,34,206,.12); border-color: var(--risk); border-style: dashed; }
.sw-layer { background: repeating-linear-gradient(45deg, rgba(126,34,206,.28) 0 3px, rgba(126,34,206,.06) 3px 6px); border-color: var(--risk); }
.sw-sel { background: rgba(20,95,245,.14); border-color: var(--color-primary); }
.sw-gfc { background: rgba(0, 191, 216, .45); border-color: #00A5BB; }
.sw-loss { background: rgba(230, 47, 191, .55); border-color: #C4229F; }
.sw-natural { background: rgba(57, 255, 20, .65); border-color: #16A34A; }

/* JRC forest-cover tiles recolour (data layer, unchanged) */
.gfc-tiles { filter: hue-rotate(85deg) saturate(1.5) brightness(1.2); }

/* ---------------- cluster bubbles ---------------- */
.agd-cluster {
  background: rgba(47, 58, 74, .92);
  border: 3px solid var(--ok);
  border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-primary);
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .35), 0 0 0 4px rgba(255, 255, 255, .35);
  cursor: pointer;
  transition: transform var(--motion-fast) var(--motion-ease);
}
.agd-cluster:hover { transform: scale(1.07); }
.agd-cluster.c-s { font-size: 12px; }
.agd-cluster.c-m { font-size: 13px; }
.agd-cluster.c-l { font-size: 14px; }
.agd-cluster.has-warn { border-color: var(--warn); }
.agd-cluster.has-err { border-color: #fff; background: rgba(218, 0, 0, .92); }
.agd-cluster.has-risk { outline: 2.5px dashed var(--risk); outline-offset: 3px; }
.agd-dot-wrap { background: none; border: none; }

/* self-intersection markers: fixed-size × at each crossing, above the plots */
.agd-kink-wrap { background: none; border: none; }
.agd-kink {
  display: block; box-sizing: border-box; position: relative;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--err);
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
  cursor: pointer;
  transition: transform var(--motion-fast) var(--motion-ease);
}
.agd-kink::before, .agd-kink::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 9px; height: 2.5px; border-radius: 1px; background: var(--err);
  transform: translate(-50%, -50%) rotate(45deg);
}
.agd-kink::after { transform: translate(-50%, -50%) rotate(-45deg); }
.agd-kink-wrap:hover .agd-kink { transform: scale(1.15); }
.agd-dot {
  display: block; width: 12px; height: 12px; margin: 2px;
  border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .45);
}
.leaflet-cluster-anim .leaflet-marker-icon { transition: transform .25s ease-out, opacity .25s ease-in; }

/* selection info card over map */
.sel-card {
  position: absolute; bottom: 26px; right: 14px; z-index: 800;
  background: #fff; border: 1px solid var(--color-border-default); border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-card); box-shadow: var(--shadow-popover);
  padding: 12px 14px; max-width: 330px; display: none;
}
.sel-card.show { display: block; animation: pop .14s var(--motion-ease); }
.sel-card .sc-name { font-weight: 700; color: var(--color-text-primary); font-size: 14px; margin-bottom: 2px; }
.sel-card .sc-meta { font-size: 12px; color: var(--color-text-secondary); margin-bottom: 10px; }
.sel-card .sc-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* empty state (DS login-stage gradient + upload-zone) */
.empty-state {
  position: absolute; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #145FF5 0%, #2F3A4A 100%);
}
.empty-card { text-align: center; color: #fff; max-width: 580px; padding: 30px; }
.empty-card img { height: 40px; margin-bottom: 22px; }
.empty-card h1 { font-size: 30px; margin: 0 0 8px; font-weight: 800; letter-spacing: -0.5px; }
.empty-card h1 em { color: #fff; font-style: normal; opacity: .8; }
.empty-card p.lead { color: rgba(255,255,255,.82); font-size: 15px; margin: 0 auto 26px; max-width: 470px; line-height: 1.55; }
.dropzone {
  background: #fff; color: var(--color-text-primary);
  border: 2px dashed var(--color-border-default); border-radius: var(--radius-card);
  padding: 32px 30px; margin-bottom: 18px;
  transition: border-color var(--motion-base) var(--motion-ease), background var(--motion-base) var(--motion-ease);
  box-shadow: var(--shadow-modal);
}
.dropzone.drag { border-color: var(--color-primary); background: var(--color-primary-light); }
.dropzone .dz-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.dropzone .dz-sub { color: var(--color-text-muted); font-size: 13px; margin-bottom: 16px; }
.dropzone .dz-actions { display: flex; gap: 10px; justify-content: center; }
.dropzone .btn-onnavy { background: var(--color-secondary-bg); color: var(--color-secondary-text); }
.privacy-note { font-size: 12px; color: rgba(255,255,255,.75); max-width: 470px; margin: 0 auto; line-height: 1.55; }

/* drag overlay when data already loaded */
.drop-overlay {
  position: absolute; inset: 0; z-index: 1400; display: none;
  background: var(--color-surface-overlay); backdrop-filter: blur(2px);
  align-items: center; justify-content: center;
}
.drop-overlay.show { display: flex; }
.drop-overlay .inner {
  border: 2px dashed #fff; color: #fff; border-radius: var(--radius-card);
  padding: 40px 60px; font-size: 17px; font-weight: 700;
  background: rgba(20,95,245,.35);
}

/* ---------------- side panel ---------------- */
aside.panel {
  background: #fff;
  border-left: 1px solid var(--color-border-default);
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  z-index: 700;
}
.panel-expand-btn {
  position: absolute; top: 50%; right: 0; transform: translateY(-50%);
  z-index: 850;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 30px; padding: 12px 0;
  background: var(--color-primary-light); color: var(--color-primary);
  border: 1px solid var(--color-primary); border-right: 0;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  cursor: pointer; box-shadow: -2px 0 8px rgba(15,23,42,.10);
}
.panel-expand-btn:hover { background: var(--color-primary); color: #fff; }
.panel-expand-btn .pe-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; font-weight: 700; letter-spacing: .05em; white-space: nowrap; }
.panel-expand-btn svg { width: 16px; height: 16px; }

/* tabs (DS page-tab) */
.tabs {
  display: flex; border-bottom: 1px solid var(--color-border-default);
  padding: 0 16px; gap: 24px; background: #fff; flex: 0 0 auto;
}
.tab {
  border: 0; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--color-text-secondary);
  padding: 11px 0 9px; position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--color-text-primary); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab .count {
  font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px;
  background: var(--color-surface-hover); color: var(--color-text-secondary);
}
.tab.active .count { background: var(--color-primary-light); color: var(--color-primary); }
.tab .count.err { background: var(--color-non-compliant-bg); color: var(--color-non-compliant-text); }
.tab .count.risk { background: var(--color-risk-protected-bg); color: var(--color-risk-protected); }
.tabs-tool {
  margin-left: auto; align-self: center;
  width: 30px; height: 30px; border: 1px solid var(--color-border-default); border-radius: var(--radius-md);
  background: #fff; color: var(--color-text-secondary); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.tabs-tool:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }

.tab-body { flex: 1; overflow: auto; min-height: 0; display: none; }
.tab-body.active { display: flex; flex-direction: column; }

/* scrollbars */
.tab-body::-webkit-scrollbar, .table-scroll::-webkit-scrollbar, textarea::-webkit-scrollbar { width: 10px; height: 10px; }
.tab-body::-webkit-scrollbar-thumb, .table-scroll::-webkit-scrollbar-thumb, textarea::-webkit-scrollbar-thumb {
  background: var(--color-border-muted); border-radius: 6px; border: 2px solid #fff;
}

/* ---------------- plots table (DS ds-table + table-toolbar) ---------------- */
.table-tools { padding: 12px 16px 10px; display: flex; gap: 8px; align-items: center; background: var(--color-surface-subtle); border-bottom: 1px solid var(--color-border-default); flex: 0 0 auto; }
.search-box { position: relative; flex: 1; }
.search-box input {
  width: 100%; border: 1px solid var(--color-border-input); border-radius: var(--radius-input);
  padding: 8px 12px 8px 32px; font-size: 13px; height: 36px; background: #fff;
}
.search-box input:focus { border-color: var(--color-primary); outline: none; box-shadow: 0 0 0 3px rgba(20,95,245,0.12); }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); }
.search-scope {
  border: 1px solid var(--color-border-input); border-radius: var(--radius-input); background: #fff;
  font-size: 12px; font-weight: 600; color: var(--color-text-secondary);
  padding: 6px 6px; height: 36px; cursor: pointer; flex: 0 0 auto;
}
.search-scope:focus { border-color: var(--color-primary); outline: none; }
mark.hl { background: var(--color-partial-bg); color: inherit; padding: 0 1px; border-radius: 3px; }

.filter-chips { display: flex; gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--color-border-default); background: var(--color-surface-subtle); flex: 0 0 auto; flex-wrap: wrap; }
.fchip {
  border: 1px solid var(--color-border-default); background: #fff; border-radius: var(--radius-md);
  font-size: 12px; font-weight: 600; color: var(--color-text-secondary);
  padding: 5px 12px; cursor: pointer;
  transition: background var(--motion-fast) var(--motion-ease);
}
.fchip:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.fchip.active { background: var(--color-primary-light); border-color: var(--color-primary); color: var(--color-primary); font-weight: 700; }
.fchip.active.f-err { background: var(--color-non-compliant-bg); border-color: var(--err); color: var(--color-non-compliant-text); }
.fchip.active.f-warn { background: var(--color-partial-bg); border-color: var(--warn); color: var(--color-partial-text); }
.fchip.active.f-ok { background: var(--color-compliant-bg); border-color: var(--ok); color: var(--color-compliant-text); }
.fchip.active.f-risk { background: var(--color-risk-protected-bg); border-color: var(--risk); color: var(--color-risk-protected); }

.table-scroll { flex: 1; overflow: auto; min-height: 0; }
table.plots {
  width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed;
}
table.plots .col-area { width: 82px; text-align: right; }
table.plots .col-status { width: 100px; }
table.plots .col-risk { width: 74px; }
table.plots thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--color-surface-subtle); color: var(--color-text-primary);
  font-size: 13px; text-align: left; font-weight: 700;
  padding: 10px 12px; border-bottom: 1px solid var(--color-border-strong);
  cursor: pointer; user-select: none; white-space: nowrap;
}
table.plots thead th .sort-arrow { font-size: 9px; margin-left: 3px; color: var(--color-primary); }
table.plots tbody td { padding: 9px 10px; border-bottom: 1px solid var(--color-border-default); vertical-align: middle; overflow: hidden; }
table.plots thead th { padding-left: 10px; padding-right: 10px; }
table.plots tbody tr { cursor: pointer; transition: background var(--motion-fast) var(--motion-ease); }
table.plots tbody tr:hover { background: var(--color-surface-hover); }
table.plots tbody tr.selected { background: var(--color-primary-light); box-shadow: inset 3px 0 0 var(--color-primary); }
table.plots tbody tr.flash { animation: rowflash 1.2s var(--motion-ease); }
@keyframes rowflash { 0% { background: var(--color-primary-light);} 100% { background: transparent; } }
td.num { font-family: var(--mono); font-size: 12px; text-align: right; white-space: nowrap; }
.plot-name { font-weight: 700; color: var(--color-text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plot-id { font-size: 11px; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.geom-tag { font-size: 11px; font-weight: 700; color: var(--color-text-secondary); }

/* status chips (DS chips: radius 24, 12px/600, no dots) */
.chip {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 600;
  border-radius: var(--radius-chip); padding: 2px 10px; white-space: nowrap;
}
.chip-ok { background: var(--color-compliant-bg); color: var(--color-compliant-text); }
.chip-warn { background: var(--color-partial-bg); color: var(--color-partial-text); }
.chip-err { background: var(--color-non-compliant-bg); color: var(--color-non-compliant-text); }
.chip-risk { background: var(--color-risk-protected-bg); color: var(--color-risk-protected); }
.chip-info { background: var(--color-info-bg); color: var(--color-info-text); }
.chip-muted { background: var(--color-neutral-bg); color: var(--color-neutral-text); }

.table-foot { padding: 8px 16px; font-size: 12px; color: var(--color-text-secondary); border-top: 1px solid var(--color-border-default); background: #fff; flex: 0 0 auto; }

/* ---------------- issues tab (DS integrity-banner) ---------------- */
.pane-pad { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.callout {
  border-radius: var(--radius-card); padding: 13px 16px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13px; line-height: 1.5;
  border: 1px solid transparent;
}
.callout.ok { background: var(--color-compliant-bg); border-color: #BEE3BE; color: var(--color-compliant-text); }
.callout.warn { background: var(--color-partial-bg); border-color: var(--color-warning-border); color: var(--color-partial-text); }
.callout.err { background: var(--color-non-compliant-bg); border-color: #FFCDCD; color: var(--color-non-compliant-text); }
.callout.info { background: var(--color-primary-hover); border-color: var(--color-primary-light); color: var(--color-text-secondary); }
.callout.navy { background: var(--color-surface-nav); border-color: var(--color-surface-nav); color: #fff; }
.callout h4 { margin: 0 0 3px; font-size: 14px; font-weight: 700; }
.callout.info h4 { color: var(--color-text-primary); }
.callout p { margin: 0; }

.issue-card {
  border: 1px solid var(--color-border-default); border-radius: var(--radius-card);
  background: #fff; overflow: hidden; box-shadow: var(--shadow-card);
}
.issue-card .ic-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px; cursor: pointer; user-select: none;
}
.issue-card .ic-head:hover { background: var(--color-surface-subtle); }
.issue-card.sev-error { border-left: 4px solid var(--err); }
.issue-card.sev-warning { border-left: 4px solid var(--warn); }
.issue-card.sev-info { border-left: 4px solid var(--color-primary); }
.ic-title { font-weight: 700; color: var(--color-text-primary); font-size: 13.5px; flex: 1; }
.ic-rule { font-family: var(--mono); font-size: 10px; color: var(--color-text-secondary); background: var(--color-surface-subtle); border-radius: 4px; padding: 1px 5px; }
.ic-body { padding: 0 14px 13px; display: none; }
.issue-card.open .ic-body { display: block; }
.ic-desc { font-size: 13px; color: var(--color-text-secondary); margin: 2px 0 9px; line-height: 1.5; }
.ic-feats { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.feat-link {
  border: 1px solid var(--color-border-default); background: #fff;
  border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; color: var(--color-primary);
  padding: 3px 8px; cursor: pointer; font-family: var(--mono);
}
.feat-link:hover { border-color: var(--color-primary); background: var(--color-primary-hover); }
.ic-detail { font-size: 12px; color: var(--color-text-muted); margin-bottom: 8px; }
.chev { transition: transform var(--motion-fast) var(--motion-ease); color: var(--color-text-muted); flex: 0 0 auto; }
.issue-card.open .chev { transform: rotate(90deg); }

/* ---------------- risk tab ---------------- */
.risk-layer-row {
  border: 1px solid var(--color-border-default); border-radius: var(--radius-card);
  padding: 10px 12px; display: flex; align-items: center; gap: 10px; background: #fff;
  margin-bottom: 8px;
}
.risk-layer-row input[type="checkbox"] { accent-color: var(--color-primary); width: 16px; height: 16px; }
.risk-layer-row .rl-swatch { width: 16px; height: 16px; border-radius: 4px; flex: 0 0 auto; border: 2px dashed var(--risk); background: rgba(126,34,206,.12); }
.risk-layer-row .rl-name { font-weight: 700; color: var(--color-text-primary); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.risk-layer-row .rl-meta { font-size: 12px; color: var(--color-text-secondary); }
.risk-layer-row .rl-meta select {
  border: 1px solid var(--color-border-input); border-radius: var(--radius-md);
  font-size: 12px; padding: 2px 6px; background: #fff; cursor: pointer;
}
.risk-hit {
  border: 1px solid var(--color-border-default); border-left: 4px solid var(--risk);
  border-radius: var(--radius-card); padding: 11px 14px; background: #fff; cursor: pointer;
  box-shadow: var(--shadow-card);
}
.risk-hit:hover { background: var(--color-risk-protected-bg); }
.risk-hit .rh-name { font-weight: 700; color: var(--color-text-primary); font-size: 13.5px; display: flex; justify-content: space-between; gap: 8px; }
.risk-hit .rh-details { font-size: 12.5px; color: var(--color-text-secondary); margin-top: 4px; }
.risk-hit .rh-details .pct { font-weight: 700; color: var(--color-risk-protected); font-family: var(--mono); }
.risk-bar { height: 5px; border-radius: 4px; background: var(--color-surface-hover); margin-top: 8px; overflow: hidden; }
.risk-bar i { display: block; height: 100%; background: var(--risk); border-radius: 4px; }

/* ---------------- fix / file tab (DS table-card) ---------------- */
.sect { border: 1px solid var(--color-border-default); border-radius: var(--radius-card); background: #fff; overflow: hidden; box-shadow: var(--shadow-card); }
.sect > .sect-head {
  padding: 11px 14px; font-weight: 700; color: var(--color-text-primary); font-size: 13px;
  border-bottom: 1px solid var(--color-border-default); background: var(--color-surface-subtle);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sect > .sect-body { padding: 14px; }
.sect.collapsible > .sect-head { cursor: pointer; user-select: none; }
.sect.collapsible > .sect-head:hover { background: var(--color-surface-hover); }
.sect.collapsible > .sect-head .chev svg { display: block; }
.sect.collapsible.open > .sect-head .chev { transform: rotate(90deg); }
.sect.collapsible:not(.open) > .sect-body { display: none; }
.sect.collapsible:not(.open) > .sect-head { border-bottom: 0; }
.issues-meta { padding: 0 2px; }
.kv-row { display: flex; gap: 6px; margin-bottom: 8px; align-items: center; }
.kv-row input, .kv-row select {
  border: 1px solid var(--color-border-input); border-radius: var(--radius-md);
  padding: 7px 10px; font-size: 13px; min-width: 0; height: 34px; background: #fff;
}
.kv-row input { flex: 1; }
.kv-row input:focus { border-color: var(--color-primary); outline: none; box-shadow: 0 0 0 3px rgba(20,95,245,0.12); }
.recov-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--color-text-secondary); }
.recov-list li { margin-bottom: 4px; }
textarea.json-view {
  width: 100%; height: 260px; resize: vertical;
  font-family: var(--mono); font-size: 11px; line-height: 1.5;
  border: 1px solid var(--color-border-default); border-radius: var(--radius-md);
  background: #1E2230; color: #C9D1D9; padding: 10px;
  white-space: pre; overflow: auto;
}

/* ---------------- properties tab ---------------- */
.props-empty { padding: 40px 20px; text-align: center; color: var(--color-text-muted); font-size: 13px; }
.props-empty svg { display: block; margin: 0 auto 10px; color: var(--color-border-muted); }
.quick-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qf { display: flex; flex-direction: column; gap: 4px; }
.qf label { font-size: 12px; font-weight: 600; color: var(--color-text-primary); }
.qf input {
  border: 1px solid var(--color-border-input); border-radius: var(--radius-md);
  padding: 7px 10px; font-size: 13px; height: 36px; background: #fff;
}
.qf input:focus { border-color: var(--color-primary); outline: none; box-shadow: 0 0 0 3px rgba(20,95,245,0.12); }
.qf.full { grid-column: 1 / -1; }
.qf .hint { font-size: 11px; color: var(--color-text-muted); }

/* ---------------- footer ---------------- */
footer.statusbar {
  background: #fff; border-top: 1px solid var(--color-border-default);
  display: flex; align-items: center; gap: 16px; padding: 0 16px;
  font-size: 12px; color: var(--color-text-secondary); z-index: 1000;
}
.stat { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.stat b { color: var(--color-text-primary); font-weight: 700; font-family: var(--mono); font-size: 12px; }
.stat .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-err { background: var(--err); } .dot-warn { background: var(--warn); }
.dot-ok { background: var(--ok); } .dot-risk { background: var(--risk); }
.traces-chip {
  margin-left: auto; font-weight: 700; font-size: 12px;
  border-radius: var(--radius-chip); padding: 3px 12px;
}
.traces-chip.ready { background: var(--color-compliant-bg); color: var(--color-compliant-text); }
.traces-chip.blocked { background: var(--color-non-compliant-bg); color: var(--color-non-compliant-text); }
.traces-chip.empty { background: var(--color-neutral-bg); color: var(--color-neutral-text); }

/* contact touchpoints (quiet by design) */
.contact-link {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-primary); font-size: 12px; font-weight: 600;
  color: var(--color-text-secondary); padding: 2px 4px; border-radius: 4px;
  white-space: nowrap;
}
.contact-link:hover { color: var(--color-primary); text-decoration: underline; }
.contact-note { margin-top: 10px; }
.contact-inline {
  background: none; border: none; cursor: pointer; padding: 0;
  font: inherit; font-weight: 700; color: #fff; opacity: .92;
  text-decoration: underline; text-underline-offset: 2px;
}
.contact-inline:hover { opacity: 1; }

/* ---------------- toasts (DS: slate / green / red) ---------------- */
#toasts {
  position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%);
  z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--color-surface-nav); color: #fff;
  border-radius: var(--radius-card); box-shadow: var(--shadow-toast);
  padding: 12px 18px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in var(--motion-base) var(--motion-ease); max-width: 640px;
  pointer-events: auto;
}
.toast .t-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: rgba(255,255,255,.55); }
.toast.success { background: var(--color-toast-success); }
.toast.error { background: var(--color-delete); }
.toast.warn .t-dot { background: var(--color-partial-bg); }
.toast.leaving { animation: toast-out .25s var(--motion-ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------------- modal (DS spec) ---------------- */
.modal-back {
  position: fixed; inset: 0; z-index: 2500;
  background: var(--color-surface-overlay); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
}
.modal-back.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius-card); box-shadow: var(--shadow-modal);
  width: min(580px, calc(100vw - 40px)); max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: pop .16s var(--motion-ease);
}
.modal .m-head {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--color-border-default);
  display: flex; align-items: center; justify-content: space-between;
}
.modal .m-head h3 { margin: 0; font-size: 18px; color: var(--color-text-primary); font-weight: 700; }
.modal .m-close { border: 0; background: none; cursor: pointer; color: var(--color-text-secondary); padding: 4px; border-radius: var(--radius-sm); display: flex; }
.modal .m-close:hover { background: var(--color-surface-hover); color: var(--color-text-primary); }
.modal .m-body { padding: 20px 24px; overflow: auto; font-size: 14px; color: var(--color-text-secondary); }
.modal .m-foot {
  padding: 16px 24px; border-top: 1px solid var(--color-border-default);
  display: flex; justify-content: flex-end; gap: 12px; background: #fff;
}
.fix-opt { display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px; border-radius: var(--radius-md); }
.fix-opt:hover { background: var(--color-surface-subtle); }
.fix-opt input[type="checkbox"] { margin-top: 3px; accent-color: var(--color-primary); width: 16px; height: 16px; }
.fix-opt .fo-label { font-weight: 700; color: var(--color-text-primary); font-size: 13.5px; }
.fix-opt .fo-sub { font-size: 12px; color: var(--color-text-secondary); line-height: 1.45; }
.fix-opt .fo-count { margin-left: auto; font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--color-text-secondary); background: var(--color-surface-hover); border-radius: 10px; padding: 1px 8px; align-self: center; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-size: 13px; font-weight: 600; color: var(--color-text-primary); margin-bottom: 6px; }
.form-field input[type="text"], .form-field input[type="number"] {
  width: 100%; border: 1px solid var(--color-border-input); border-radius: var(--radius-input);
  padding: 8px 12px; font-size: 14px; height: 40px;
}
.form-field input:focus { border-color: var(--color-primary); outline: none; box-shadow: 0 0 0 3px rgba(20,95,245,0.12); }

/* ---------------- leaflet chrome overrides ---------------- */
.leaflet-container { font-family: var(--font-primary); }
.leaflet-bar { border: 1px solid var(--color-border-default) !important; box-shadow: var(--shadow-card) !important; border-radius: var(--radius-md) !important; overflow: hidden; }
.leaflet-bar a { color: var(--color-text-primary) !important; }
.leaflet-control-attribution {
  background: rgba(255,255,255,.85) !important; font-size: 10px !important; color: var(--color-text-secondary) !important;
}
.leaflet-control-attribution a { color: var(--color-primary) !important; }
.leaflet-top.leaflet-right .leaflet-control-zoom { margin-top: 64px; margin-right: 14px; }

/* vertex editing handles */
.v-handle {
  background: #fff; border: 2.5px solid var(--color-primary); border-radius: 50%;
  box-shadow: 0 1px 4px rgba(15,23,42,.4); cursor: grab;
}
.v-handle:active { cursor: grabbing; }
/* vertex picked for deletion (click a handle): filled, with a halo */
.v-handle.active { background: var(--color-primary); border-color: #fff; box-shadow: 0 0 0 3px rgba(20,95,245,.35), 0 1px 4px rgba(15,23,42,.4); }
.v-mid {
  background: rgba(255,255,255,.9); border: 2px solid var(--color-border-strong);
  border-radius: 50%; opacity: .8; cursor: copy;
}
.v-mid:hover { opacity: 1; background: #fff; border-color: var(--color-primary); }
.map-hint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 850; background: #1E2230; color: #fff;
  font-size: 12.5px; font-weight: 600; border-radius: var(--radius-chip);
  padding: 7px 16px; box-shadow: var(--shadow-toast); display: none;
  max-width: 70%; text-align: center;
}
.map-hint.show { display: block; animation: pop .15s var(--motion-ease); }
.map-hint kbd {
  font-family: var(--mono); background: rgba(255,255,255,.18); border-radius: 4px;
  padding: 0 5px; font-size: 11px;
}

/* help modal: tool + shortcut reference */
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; }
.help-grid h4 { margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--color-text-muted); }
.help-row { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: 13px; color: var(--color-text-secondary); }
.help-row .tool-btn { width: 28px; height: 28px; flex: 0 0 auto; background: var(--color-surface-subtle); cursor: default; }
.help-row b { color: var(--color-text-primary); font-weight: 700; }
.help-row kbd, .help-keys kbd {
  display: inline-block; font-family: var(--mono); font-size: 11px; line-height: 1;
  background: var(--color-surface-subtle); border: 1px solid var(--color-border-default); border-bottom-width: 2px;
  border-radius: 5px; padding: 4px 6px; color: var(--color-text-primary); white-space: nowrap;
}
.help-keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; align-items: center; font-size: 13px; color: var(--color-text-secondary); }
@media (max-width: 640px) { .help-grid { grid-template-columns: 1fr; } }

/* small helpers */
.muted { color: var(--color-text-muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.mt8 { margin-top: 8px; } .mb8 { margin-bottom: 8px; }
.hidden { display: none !important; }
code.k { font-family: var(--mono); background: var(--color-surface-subtle); border-radius: 4px; padding: 1px 5px; font-size: 12px; color: var(--color-primary); }

@media (max-width: 1100px) {
  :root { --panel-w: 400px; }
  .brand .tagline { display: none; }
}
