/* ─── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #F7F6F1;
  --surf:    #FFFFFF;
  --border:  #DDDAD0;
  --text:    #1A1912;
  --muted:   #6E6C5C;
  --accent:  #1D4520;
  --aclite:  #EEF4EE;
  --achov:   #143518;
  --red:     #B91C1C;
  --redlt:   #FEF2F2;
  --font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:    'SFMono-Regular', Menlo, Consolas, monospace;
  --rad:     4px;
  --shadow:  0 1px 3px rgba(0,0,0,0.07), 0 2px 8px rgba(0,0,0,0.04);
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ─── Brand ────────────────────────────────────────────── */
.brand {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  user-select: none;
}

/* ─── Buttons ──────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--rad);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
}
.btn-primary:hover:not(:disabled) { background: var(--achov); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.fw { width: 100%; }

.btn-outline-sm {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-family: var(--font);
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--rad);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.btn-outline-sm:hover { border-color: var(--text); color: var(--text); }

.btn-hero {
  display: inline-flex;
  align-items: center;
  height: 48px;
  padding: 0 28px;
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font);
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--rad);
  cursor: pointer;
  transition: background 0.12s;
}
.btn-hero:hover { background: var(--achov); }

/* ─── Landing ──────────────────────────────────────────── */
#landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.land-nav {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--surf);
  border-bottom: 1px solid var(--border);
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px 64px;
}

.hero-eye {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.hero-h1 {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 20px;
}

.hero-body {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 520px;
  margin-bottom: 36px;
}

.hero-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}
.hero-note a { color: var(--accent); text-decoration: none; }
.hero-note a:hover { text-decoration: underline; }

.chips-bar {
  padding: 20px 0;
  border-top: 1px solid var(--border);
  background: var(--surf);
}
.chips-inner {
  display: flex;
  gap: 8px;
  padding: 0 32px;
  flex-wrap: wrap;
}
.chips-inner span {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--aclite);
  border: 1px solid #C2D8C3;
  border-radius: 3px;
  color: var(--accent);
  white-space: nowrap;
}

.land-foot {
  padding: 16px 32px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.land-foot a { color: var(--accent); text-decoration: none; }
.land-foot a:hover { text-decoration: underline; }

/* ─── Modal ────────────────────────────────────────────── */
.modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-card {
  position: relative;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}

.modal-card--wide {
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-x {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--rad);
}
.modal-x:hover { background: var(--border); }

.modal-brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 4px;
}

.modal-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

.modal-foot {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.modal-foot a { color: var(--accent); text-decoration: none; }
.modal-foot a:hover { text-decoration: underline; }

/* ─── Form ──────────────────────────────────────────────── */
.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.field input {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--aclite);
}

/* ─── App layout ────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

.app-hdr {
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surf);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.hdr-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-lbl {
  font-size: 12px;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sb-block {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sb-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Search ────────────────────────────────────────────── */
.search-wrap { position: relative; }

.search-input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--aclite);
}

.srch-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ─── Candidates dropdown ───────────────────────────────── */
.cand-drop {
  position: absolute;
  top: calc(100% + 3px);
  left: 0; right: 0;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  z-index: 50;
  overflow: hidden;
}

.cand-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.08s;
}
.cand-item:last-child { border-bottom: none; }
.cand-item:hover { background: var(--aclite); }

.cand-score {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
  margin-left: 8px;
}

.cand-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--muted);
}

/* ─── Parcel panel ──────────────────────────────────────── */
.p-owner {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  line-height: 1.3;
}

.p-meta { display: flex; flex-direction: column; gap: 6px; }

.pm-row { display: flex; align-items: baseline; gap: 8px; }

.pm-k {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 100px;
  flex-shrink: 0;
}

.pm-v { font-size: 13px; }
.pm-v.mono { font-family: var(--mono); font-size: 11px; }

/* ─── Layer list ────────────────────────────────────────── */
.layers-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.sel-all-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.sel-all-txt { font-size: 11px; color: var(--muted); }

.loading-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: ldpulse 1s ease-in-out infinite;
}
@keyframes ldpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* Category headers inside layer list */
.cat-hdr {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.cat-hdr:first-child { padding-top: 4px; }

.layer-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
}
.layer-row:hover .l-name { color: var(--accent); }
.layer-row input[type=checkbox] { flex-shrink: 0; cursor: pointer; accent-color: var(--accent); }

.l-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.l-name {
  flex: 1;
  font-size: 12px;
  line-height: 1.4;
}

.l-src {
  color: var(--muted);
  font-weight: 400;
}

.l-count {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  flex-shrink: 0;
}
.l-count.hit { background: var(--aclite); color: var(--accent); }
.l-count.miss { color: var(--border); font-weight: 400; }

.l-badge {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
}
.row-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ─── Download area ─────────────────────────────────────── */
.dl-area {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dl-note { font-size: 12px; color: var(--muted); }

.dl-progress { display: flex; flex-direction: column; gap: 6px; }

.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0;
  transition: width 0.3s;
}
.progress-fill.indeterminate {
  width: 35%;
  animation: indeterminate 1.5s ease-in-out infinite;
}
@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

.dl-status { font-size: 12px; color: var(--muted); }

/* ─── Map ───────────────────────────────────────────────── */
#map-container {
  flex: 1;
  position: relative;
}

#map { width: 100%; height: 100%; }

.map-msg {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  white-space: nowrap;
  z-index: 10;
}

.map-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── History modal ─────────────────────────────────────── */
#hist-list {
  overflow-y: auto;
  max-height: calc(80vh - 140px);
  margin: 0 -4px;
}

.hist-entry {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  border-radius: var(--rad);
  transition: background 0.08s;
}
.hist-entry:last-child { border-bottom: none; }
.hist-entry:hover { background: var(--aclite); }

.hist-entry-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--aclite);
  border: 1px solid #C2D8C3;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 12px;
  color: var(--accent);
}

.hist-entry-body { flex: 1; min-width: 0; }

.hist-addr {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.hist-meta {
  font-size: 11px;
  color: var(--muted);
}

.hist-ts {
  font-size: 11px;
  color: var(--border);
  flex-shrink: 0;
  margin-top: 2px;
}

.hist-empty {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 24px 0 8px;
}

/* ─── Alerts ────────────────────────────────────────────── */
.alert-error {
  background: var(--redlt);
  border: 1px solid #FECACA;
  color: var(--red);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--rad);
  margin-bottom: 12px;
}

/* ─── Utilities ─────────────────────────────────────────── */
.hidden { display: none !important; }

@media (max-width: 640px) {
  .hero-h1 { font-size: 30px; }
  .app-body { flex-direction: column; }
  .sidebar { width: 100%; max-height: 45vh; border-right: none; border-bottom: 1px solid var(--border); }
  #map-container { flex: 1; min-height: 300px; }
}
