:root {
  --bg: #f6f4ef; --panel: #fffdf9; --card: #fff; --ink: #1d2330; --dim: #667085; --faint: #98a2b3;
  --line: #e7e2d7; --accent: #1f6f5c; --accent-ink: #fff; --accent-soft: #e3f1ec;
  --s-hi: #1f8a5c; --s-mid: #c98a12; --s-lo: #b8452f; --s-none: #a3a8b3;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 14px rgba(16,24,40,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #161a22; --card: #1b2029; --ink: #e8eaee; --dim: #a0a9b8; --faint: #6b7487;
    --line: #2a313e; --accent: #3fb896; --accent-ink: #06261d; --accent-soft: #173a31;
    --s-hi: #3fbf87; --s-mid: #e0a73a; --s-lo: #e2694f; --s-none: #5f6777;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
button, select, input { font: inherit; color: inherit; }
select, input[type=search], input[type=text], textarea {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
button { cursor: pointer; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; }
.ghost:hover { background: var(--card); }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 7px 14px; font-weight: 600; }
.wide { width: 100%; }
.spacer { flex: 1; }

/* header */
.top { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  background: var(--panel); border-bottom: 1px solid var(--line); height: 56px; }
.brand { font-weight: 750; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
#profileSel { width: auto; max-width: 240px; }
.tabs { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; color: var(--dim); font-weight: 550; }
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.kpis { display: flex; gap: 14px; color: var(--dim); font-size: 13px; }
.kpis b { color: var(--ink); font-variant-numeric: tabular-nums; }
.user { color: var(--dim); font-size: 13px; white-space: nowrap; }
#filtersToggle { display: none; }

/* layout */
.layout { display: grid; grid-template-columns: 270px 1fr; height: calc(100vh - 56px); }
.filters { overflow: auto; padding: 14px 16px 30px; border-right: 1px solid var(--line); background: var(--panel); }
.f-group { margin-bottom: 16px; }
.f-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650; margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.f-label output { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 13px; }
.mini { cursor: pointer; border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; text-transform: none; letter-spacing: 0; color: var(--dim); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 2px 9px; font-size: 12.5px; cursor: pointer; user-select: none; white-space: nowrap; }
.chip .n { color: var(--faint); margin-left: 3px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.on .n { color: inherit; opacity: .75; }
.check { display: flex; gap: 6px; align-items: center; margin-top: 6px; color: var(--dim); font-size: 13px; cursor: pointer; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.main { overflow: auto; position: relative; }
.resultbar { display: flex; align-items: center; padding: 10px 20px 0; color: var(--dim); font-size: 13px; }
.mini-link { font-size: 12px; color: var(--faint); }
.view { display: none; }
.view.on { display: block; }

/* list */
#view-list { padding: 10px 20px 40px; }
.hit { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: start; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); transition: border-color .12s; }
.hit:hover { border-color: var(--accent); }
.hit.sel { outline: 2px solid var(--accent); }
.score { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-weight: 750; font-size: 17px; color: #fff; font-variant-numeric: tabular-nums; }
.score small { display: block; font-size: 9px; font-weight: 600; opacity: .85; margin-top: -4px; }
.s-hi { background: var(--s-hi); } .s-mid { background: var(--s-mid); } .s-lo { background: var(--s-lo); } .s-none { background: var(--s-none); }
.hit h3 { margin: 0; font-size: 15px; line-height: 1.3; }
.hit .co { color: var(--dim); }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 5px; color: var(--dim); font-size: 12.5px; align-items: center; }
.hit p.sum { margin: 6px 0 0; color: var(--ink); opacity: .85; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pill { display: inline-block; border-radius: 6px; padding: 1px 7px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--line); background: var(--bg); color: var(--dim); }
.pill.lang { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.lang.key { background: var(--accent); color: var(--accent-ink); }
.v-yes { background: #dcf5e8; color: #146c43; border-color: transparent; }
.v-likely { background: #e6f2d9; color: #4a7313; border-color: transparent; }
.v-possible { background: #fbf0d3; color: #8a5a00; border-color: transparent; }
.v-no { background: #fbe1dc; color: #a2321c; border-color: transparent; }
@media (prefers-color-scheme: dark) {
  .v-yes { background: #143a28; color: #6fe0a6; } .v-likely { background: #26371a; color: #a7d86a; }
  .v-possible { background: #3b2f12; color: #f0c25e; } .v-no { background: #40201a; color: #f5917c; }
}
.side { text-align: right; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.star { background: none; border: 0; font-size: 18px; color: var(--faint); padding: 0; line-height: 1; }
.star.on { color: #e3a008; }
.st { font-size: 11.5px; color: var(--dim); text-transform: capitalize; }
.empty { text-align: center; color: var(--dim); padding: 70px 20px; }
.more { display: block; margin: 12px auto; }

/* map */
#view-map { height: calc(100vh - 56px - 30px); padding: 8px 20px 20px; }
#view-map.on { display: block; }
#map { height: 100%; border-radius: 12px; border: 1px solid var(--line); }
.mk { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; display: grid; place-items: center; color: #fff; font-size: 10.5px; font-weight: 750; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.mk.approx { border-style: dashed; opacity: .85; }
.leaflet-popup-content { margin: 10px 12px; font: 13px/1.4 system-ui, sans-serif; }
.leaflet-popup-content h4 { margin: 0 0 3px; font-size: 14px; }
.marker-cluster div { font-weight: 700; }

/* board */
.board.on { display: flex; gap: 10px; padding: 10px 20px 20px; overflow-x: auto; height: calc(100vh - 56px - 30px); align-items: stretch; }
.col { flex: 0 0 250px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: flex; flex-direction: column; min-height: 0; }
.col h4 { margin: 0; padding: 10px 12px; font-size: 12.5px; text-transform: capitalize; display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
.col h4 span { color: var(--faint); }
.col .cards { padding: 8px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.col.drop { outline: 2px dashed var(--accent); }
.bcard { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; cursor: grab; font-size: 12.5px; }
.bcard b { display: block; font-size: 13px; margin-bottom: 2px; }
.bcard .row { display: flex; justify-content: space-between; gap: 6px; color: var(--dim); align-items: center; }
.bscore { font-weight: 750; border-radius: 5px; color: #fff; padding: 0 5px; font-size: 11.5px; }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .18s ease; z-index: 2000; overflow: auto; box-shadow: -10px 0 40px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.scrim { position: fixed; inset: 0; background: rgba(10,14,20,.25); z-index: 1999; display: none; }
.scrim.open { display: block; }
.drawer-inner { padding: 20px 24px 60px; }
.d-head { display: flex; gap: 14px; align-items: flex-start; }
.d-head h2 { margin: 0 0 4px; font-size: 20px; line-height: 1.25; }
.d-close { margin-left: auto; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; align-items: center; }
.d-actions select { width: auto; }
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 5px 12px; font-size: 13px; margin: 12px 0; }
.facts dt { color: var(--faint); } .facts dd { margin: 0; }
.box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.box h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.why { border-left: 3px solid var(--accent); }
.bd { display: grid; grid-template-columns: 140px 1fr 34px; gap: 4px 8px; align-items: center; font-size: 12.5px; margin-top: 6px; }
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); }
.tl { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.tl li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.tl .when { color: var(--faint); font-size: 11.5px; }
.prose { font-size: 13.5px; } .prose p { margin: 0 0 .6em; } .prose h1, .prose h2, .prose h3 { font-size: 15px; margin: 1em 0 .4em; }
.prose table { border-collapse: collapse; } .prose td, .prose th { border: 1px solid var(--line); padding: 3px 7px; }
.prose-wrap { padding: 16px 24px 50px; max-width: 900px; }
.run { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 10px; }
.run .meta { margin: 0 0 6px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .filters { display: none; position: fixed; top: 56px; left: 0; right: 0; bottom: 0; z-index: 1500; border: 0; }
  .filters.open { display: block; }
  #filtersToggle { display: inline-block; }
  .kpis, .user { display: none; }
  .top { gap: 8px; padding: 8px 12px; flex-wrap: wrap; height: auto; }
  .top .spacer { display: none; }
  #profileSel { flex: 1; min-width: 0; }
  .tabs { order: 5; width: 100%; justify-content: space-between; }
  .layout { height: auto; min-height: calc(100vh - 100px); }
  .filters { top: 100px; }
  #view-map, .board.on { height: calc(100vh - 140px); }
  .tabs button { padding: 5px 8px; }
  #view-list, .resultbar { padding-left: 12px; padding-right: 12px; }
  .hit { grid-template-columns: 44px 1fr; } .hit .side { grid-column: 2; flex-direction: row; justify-content: space-between; }
  .score { width: 42px; height: 42px; font-size: 15px; }
  .facts { grid-template-columns: 105px 1fr; }
}

.pill.out { background: #e8e6fb; color: #4b3fb5; border-color: transparent; vertical-align: 2px; }
@media (prefers-color-scheme: dark) { .pill.out { background: #2a2650; color: #b3abff; } }
.box.contact { border-left: 3px solid #6c5ce7; }
