/* ForestRisk — OSI v6 PHENIPS portál */

:root {
  --bg: #0b0f14;
  --panel: rgba(15, 20, 26, 0.86);
  --panel-solid: #10151c;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e8edf2;
  --text-dim: #9aa5b1;
  --text-faint: #6b7683;
  --accent: #5ec26a;
  --accent-soft: rgba(94, 194, 106, 0.16);
  --danger: #e53935;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: #0d1117;
  cursor: crosshair;
}

/* ---------- panely ---------- */

.panel {
  position: absolute;
  z-index: 1000;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

#brand {
  top: 14px;
  left: 14px;
  width: 336px;
  padding: 14px 16px 12px;
  user-select: none;
}

#brand .brand-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

#brand .logo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

#brand .badge {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

#brand h1 {
  margin: 4px 0 2px;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

#brand .sub {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
}

#controls {
  top: 132px;
  left: 14px;
  width: 336px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding: 12px 14px 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

#controls::-webkit-scrollbar { width: 8px; }
#controls::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.sec-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 10px 2px 7px;
}

.sec-label:first-child { margin-top: 0; }

/* ---------- modely ---------- */

.model-row .model-btn {
  flex: 1;
  padding: 7px 0 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.model-row .model-btn:hover { color: var(--text); border-color: var(--border-strong); }

.model-row .model-btn.active {
  color: #08130a;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(94, 194, 106, 0.3);
}

/* ---------- roky ---------- */

.year-row {
  display: flex;
  gap: 6px;
}

.year-btn {
  flex: 1;
  position: relative;
  padding: 8px 0 7px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.year-btn:hover { color: var(--text); border-color: var(--border-strong); }

.year-btn.active {
  color: #08130a;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(94, 194, 106, 0.35);
}

.year-btn .dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.year-btn.active .dot { background: #08130a; }

/* ---------- vrstvy ---------- */

.layer-list { display: flex; flex-direction: column; gap: 5px; }

.layer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  text-align: left;
  transition: all 0.15s ease;
}

.layer-btn:hover { background: rgba(255, 255, 255, 0.07); }

.layer-btn.active {
  background: var(--accent-soft);
  border-color: rgba(94, 194, 106, 0.5);
}

.layer-btn .chip {
  width: 26px;
  height: 14px;
  border-radius: 4px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.layer-btn .txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.layer-btn .name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
}

.layer-btn .range {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.25;
}

/* ---------- průhlednost ---------- */

.op-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.op-row svg { flex: none; opacity: 0.7; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--panel-solid);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text);
  border: 3px solid var(--panel-solid);
}

.op-val {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  width: 34px;
  text-align: right;
  flex: none;
}

/* ---------- legenda ---------- */

.legend-bar {
  height: 12px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  margin: 4px 1px 3px;
}

.legend-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  padding: 0 1px;
}

.legend-desc {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.45;
  margin: 7px 1px 0;
}

.class-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4.5px 2px;
  font-size: 12.5px;
}

.class-row .sw {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.4);
}

.class-row .lb { flex: 1; }

.class-row .pc {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

/* ---------- statistika ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.stat-cell {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px 7px;
}

.stat-cell .v {
  font-size: 16.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-cell .k {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-top: 2px;
}

.share-bar {
  display: flex;
  height: 7px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.share-bar div { height: 100%; }

/* ---------- podkladové mapy ---------- */

.bm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.bm-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-dim);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.bm-btn:hover { color: var(--text); border-color: var(--border-strong); }

.bm-btn.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(94, 194, 106, 0.5);
}

.bm-btn.wide { grid-column: 1 / -1; }

.bm-chip {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  flex: none;
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

/* legenda kategorického podkladu (dřeviny) */

#bmlegend {
  display: none;
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 9px;
  flex-wrap: wrap;
  gap: 5px 12px;
}

#bmlegend .bl-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

#bmlegend .bl-sw {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.4);
}

/* ---------- výřez Sentinel-2 v popupu ---------- */

.crop-wrap {
  position: relative;
  border-radius: 9px;
  overflow: hidden;
  cursor: zoom-in;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 2px;
}

.crop-wrap img {
  display: block;
  width: 100%;
  image-rendering: auto;
}

.crop-wrap::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#fff, #fff) center / 1.5px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 1.5px no-repeat;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.9));
  pointer-events: none;
}

.crop-cap {
  font-size: 10px;
  color: var(--text-faint);
  text-align: center;
  margin: 3px 0 8px;
  font-variant-numeric: tabular-nums;
}

.crop-cap.big {
  font-size: 12px;
  color: var(--text-dim);
  margin: 6px 2px 14px;
  line-height: 1.45;
  text-align: left;
}

/* ---------- přepínač rozsahu detailu ---------- */

.km-switch {
  display: flex;
  gap: 6px;
  margin: 2px 0 12px;
}

.km-btn {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.km-btn:hover { color: var(--text); border-color: var(--border-strong); }

.km-btn.active {
  color: #08130a;
  background: var(--accent);
  border-color: var(--accent);
}

.crop-detail {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
}

.crop-detail img {
  display: block;
  width: 100%;
}

.crop-detail::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.9));
  pointer-events: none;
}

.crop-big .crop-wrap {
  cursor: default;
}

.crop-big img {
  border-radius: 10px;
  border: 1px solid var(--border-strong);
}

/* ---------- horní tlačítka ---------- */

#topbtns {
  top: 14px;
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 1001;
}

.tool-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  color: var(--text-dim);
  box-shadow: var(--shadow);
  transition: all 0.15s ease;
}

.tool-btn:hover { color: var(--text); border-color: var(--border-strong); }

/* ---------- status bar ---------- */

#statusbar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 12px;
  background: rgba(10, 14, 19, 0.82);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  z-index: 900;
  font-variant-numeric: tabular-nums;
}

#statusbar .hint { margin-left: auto; color: var(--text-faint); }

#statusbar .hint b { color: var(--text-dim); font-weight: 600; }

/* ---------- leaflet ---------- */

.leaflet-container { font-family: inherit; }

.leaflet-control-attribution {
  background: rgba(10, 14, 19, 0.75) !important;
  color: var(--text-faint) !important;
  font-size: 10px !important;
  border-radius: 6px 0 0 0;
}

.leaflet-bottom { bottom: 38px; }

.leaflet-control-attribution a { color: var(--text-dim) !important; }

.leaflet-control-scale-line {
  background: rgba(10, 14, 19, 0.75) !important;
  color: var(--text-dim) !important;
  border-color: var(--border-strong) !important;
  font-size: 10px !important;
  margin-bottom: 36px !important;
}

.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-bar a:hover { background: var(--panel-solid) !important; }

.data-layer { transition: opacity 0.4s ease; }

/* ---------- popup ---------- */

.leaflet-popup-content-wrapper {
  background: var(--panel);
  backdrop-filter: blur(14px);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  box-shadow: var(--shadow);
  padding: 2px;
}

.leaflet-popup-tip { background: var(--panel-solid); }

.leaflet-popup-content {
  margin: 12px 14px 10px;
  width: 340px !important;
  font-family: inherit;
  line-height: 1.4;
}

.leaflet-popup-close-button { color: var(--text-faint) !important; }

.pop-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 2px;
}

.pop-score {
  font-size: 25px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pop-unit { font-size: 11px; color: var(--text-faint); font-weight: 400; }

.pop-class {
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  color: #10130c;
  white-space: nowrap;
}

.pop-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin: 2px 0 9px;
  font-variant-numeric: tabular-nums;
}

.comp-row {
  display: grid;
  grid-template-columns: 74px 1fr 40px;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  font-size: 11.5px;
}

.comp-row .nm { color: var(--text-dim); }

.comp-row .vl {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.comp-track {
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.comp-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.pop-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.tag {
  font-size: 10.5px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 7px;
  font-variant-numeric: tabular-nums;
}

.tag b { color: var(--text); font-weight: 600; }

.pop-warn {
  font-size: 12px;
  color: var(--text-dim);
  padding: 10px 2px 2px;
}

/* ---------- info modal ---------- */

#modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 12, 0.6);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

#modal-bg.open { display: flex; }

#modal {
  width: min(940px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px 24px 20px;
  scrollbar-width: thin;
}

#modal h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

#modal .m-sub { color: var(--text-dim); font-size: 12.5px; margin: 0 0 14px; }

#modal h3 {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 18px 0 8px;
}

#modal p, #modal li {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 6px 0;
}

#modal b { color: var(--text); font-weight: 600; }

#modal .formula {
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13.5px;
  background: rgba(94, 194, 106, 0.08);
  border: 1px solid rgba(94, 194, 106, 0.25);
  color: var(--text);
  border-radius: 9px;
  padding: 11px 13px;
  margin: 8px 0;
  overflow-x: auto;
  white-space: nowrap;
}

#modal table { border-collapse: collapse; width: 100%; margin: 6px 0; }

#modal td, #modal th {
  font-size: 12.5px;
  text-align: left;
  padding: 6px 9px 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: top;
}

#modal th { color: var(--text-faint); font-weight: 600; width: 168px; }

#modal .foot { font-size: 11px; color: var(--text-faint); margin-top: 16px; }

.m-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  #brand { width: calc(100vw - 28px); }
  #controls {
    top: 118px;
    width: calc(100vw - 28px);
    max-height: 44vh;
  }
}
