:root {
  --fond: #ffffff;
  --fond-2: #f4f5f1;
  --text: #1d2420;
  --text-2: #5b665f;
  --linie: #e1e4dd;
  --accent: #24452f;
  --accent-2: #3d7a52;
  --umbra: 0 6px 24px rgba(20, 30, 25, .16), 0 1px 3px rgba(20, 30, 25, .12);
  --raza: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #1b211e;
    --fond-2: #252c28;
    --text: #e8ece9;
    --text-2: #a2ada6;
    --linie: #333b36;
    --accent: #8fd1a5;
    --accent-2: #8fd1a5;
    --umbra: 0 6px 24px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #1b211e;
  --fond-2: #252c28;
  --text: #e8ece9;
  --text-2: #a2ada6;
  --linie: #333b36;
  --accent: #8fd1a5;
  --accent-2: #8fd1a5;
  --umbra: 0 6px 24px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: #e9ece4;
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#harta { position: absolute; inset: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { display: block; }
a { color: var(--accent-2); }
[hidden] { display: none !important; }

/* ---------- panou */
.panou {
  position: absolute; z-index: 2;
  top: 12px; left: 12px; bottom: 12px;
  width: 360px;
  display: flex; flex-direction: column;
  background: var(--fond);
  border-radius: var(--raza);
  box-shadow: var(--umbra);
  overflow: hidden;
}
.panou-cap { padding: 14px 16px 0; border-bottom: 1px solid var(--linie); }
.maner { display: none; }
.titlu { display: flex; gap: 10px; align-items: center; }
.sigla { width: 36px; height: 36px; color: #24452f; flex: none; }
.titlu h1 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.titlu p { margin: 0; color: var(--text-2); font-size: 12.5px; }
.file { display: flex; gap: 4px; margin-top: 12px; }
.fila {
  border: 0; background: none; padding: 8px 10px 10px;
  color: var(--text-2); font-weight: 600; font-size: 13.5px;
  border-bottom: 2px solid transparent;
}
.fila.activ { color: var(--text); border-bottom-color: var(--accent-2); }

.continut { flex: 1; overflow-y: auto; padding: 12px 16px 18px; overscroll-behavior: contain; }
.continut.text p, .continut.text li { color: var(--text); }
.mic { color: var(--text-2); font-size: 12px; }
.sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 18px 0 8px; }
.surse { padding-left: 18px; }
.surse li { margin-bottom: 6px; }

.cautare {
  display: flex; align-items: center; gap: 8px;
  background: var(--fond-2); border-radius: 10px; padding: 0 10px;
}
.cautare svg { width: 17px; height: 17px; fill: none; stroke: var(--text-2); stroke-width: 2; stroke-linecap: round; flex: none; }
.cautare input {
  flex: 1; border: 0; background: none; outline: none;
  padding: 10px 0; font: inherit; color: var(--text); min-width: 0;
}
.rezumat { color: var(--text-2); font-size: 12.5px; margin: 10px 2px 6px; }

.lista { list-style: none; margin: 0; padding: 0; }
.lista .grup { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin: 14px 2px 4px; }
.element {
  display: flex; gap: 10px; align-items: center; width: 100%;
  text-align: left; border: 0; background: none;
  padding: 9px 6px; border-radius: 10px;
}
.element:hover, .element:focus-visible { background: var(--fond-2); outline: none; }
.element .nume { font-weight: 600; line-height: 1.3; }
.element .date { color: var(--text-2); font-size: 12.5px; }
.element .tip-punct { width: 22px; height: 22px; display: grid; place-items: center; flex: none; font-size: 15px; }
.marcaj { flex: none; border-radius: 4px; box-shadow: 0 0 0 1px rgba(0,0,0,.18); }

.inapoi {
  display: inline-flex; align-items: center; gap: 4px;
  border: 0; background: none; padding: 4px 6px 4px 0; color: var(--accent-2); font-weight: 600;
}
.inapoi svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.det-cap { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0 4px; }
.det-cap h2 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: -.01em; }
.det-cap .sub-titlu { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.cifre { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 14px 0; }
.cifra { background: var(--fond-2); border-radius: 10px; padding: 8px 8px 7px; }
.cifra b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.cifra span { color: var(--text-2); font-size: 11.5px; }
.profil { position: relative; margin: 6px 0 12px; touch-action: none; }
.profil svg { width: 100%; height: auto; overflow: visible; }
.profil .eticheta { font-size: 10.5px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.profil .grila { stroke: var(--linie); stroke-width: 1; }
.profil .cursor { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; }
.profil-info { position: absolute; top: -2px; right: 0; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.butoane { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--linie); background: var(--fond);
  padding: 9px 12px; border-radius: 10px; font-weight: 600; font-size: 13.5px;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.principal { background: #24452f; border-color: #24452f; color: #fff; }
.btn:hover { filter: brightness(.97); }
.descriere { color: var(--text); margin: 14px 0 0; font-size: 13.5px; }
.nota { color: var(--text-2); font-size: 12px; margin-top: 12px; }

/* ---------- straturi și legendă */
.straturi { display: flex; flex-direction: column; gap: 2px; }
.comutator {
  display: flex; align-items: center; gap: 12px; padding: 9px 4px;
  border-radius: 10px; cursor: pointer;
}
.comutator:hover { background: var(--fond-2); }
.comutator .mostra { width: 34px; height: 20px; flex: none; border-radius: 4px; overflow: hidden; }
.comutator .et { flex: 1; }
.comutator .et small { display: block; color: var(--text-2); font-size: 12px; }
.comutator input { width: 18px; height: 18px; accent-color: #24452f; }
.legenda { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 12.5px; }
.legenda div { display: flex; align-items: center; gap: 8px; }
.legenda svg, .legenda canvas { flex: none; }

/* ---------- unelte hartă */
.unelte {
  position: absolute; z-index: 2; top: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.btn-rotund {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: var(--fond); box-shadow: var(--umbra);
  font-weight: 700; font-size: 13px; display: grid; place-items: center;
}
.btn-rotund[aria-pressed="true"] { background: #24452f; color: #fff; }
.btn-rotund svg { width: 22px; height: 22px; transition: transform .2s; }
.btn-rotund .ac-n { fill: #d7263d; }
.maplibregl-ctrl-top-right { top: 104px; }
.maplibregl-ctrl-group { border-radius: 12px !important; box-shadow: var(--umbra) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 40px; height: 40px; }
.maplibregl-ctrl-attrib { font-size: 11px; }
.maplibregl-popup-content {
  border-radius: 12px; padding: 10px 14px; box-shadow: var(--umbra);
  font: 13.5px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond); color: var(--text);
}
.maplibregl-popup-tip { border-top-color: var(--fond) !important; border-bottom-color: var(--fond) !important; }
.maplibregl-popup-close-button { font-size: 18px; padding: 0 6px; color: var(--text-2); }
.pop-titlu { font-weight: 700; padding-right: 14px; }
.pop-sub { color: var(--text-2); font-size: 12.5px; }
.pop-lista { margin: 6px 0 0; padding: 0; list-style: none; }
.pop-lista button { display: flex; gap: 8px; align-items: center; border: 0; background: none; padding: 5px 0; text-align: left; width: 100%; }
.pop-lista button:hover { color: var(--accent-2); }

/* ---------- survol */
.survol {
  position: absolute; z-index: 3; left: 50%; bottom: 28px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(20, 28, 24, .82); color: #fff;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 16px; padding: 10px 10px 10px 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
  width: min(460px, calc(100vw - 32px));
}
.survol-info { flex: 1; min-width: 0; }
.survol-nume { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.survol-date { display: flex; gap: 14px; font-size: 13px; opacity: .85; font-variant-numeric: tabular-nums; }
.survol-bara { height: 3px; background: rgba(255,255,255,.25); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.survol-bara i { display: block; height: 100%; width: 0; background: #fff; }
.btn-mic {
  width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: rgba(255,255,255,.14); color: #fff; font-weight: 700; font-size: 12.5px;
  display: grid; place-items: center; flex: none;
}
.btn-mic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
body.in-survol .panou, body.in-survol .unelte, body.in-survol .maplibregl-ctrl-top-right { display: none; }

.incarcare {
  position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--fond); color: var(--text); padding: 12px 18px; border-radius: 12px; box-shadow: var(--umbra);
  display: flex; gap: 10px; align-items: center; font-weight: 600;
}
.incarcare span {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2.5px solid var(--linie); border-top-color: var(--accent-2);
  animation: roti .8s linear infinite;
}
@keyframes roti { to { transform: rotate(360deg); } }

/* ---------- telefon: panoul devine foaie jos */
@media (max-width: 720px) {
  .panou {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    height: 46vh; border-radius: 18px 18px 0 0;
    transition: height .25s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panou.restrans { height: 128px; }
  .panou.restrans .continut { overflow: hidden; }
  .panou-cap { padding-top: 6px; }
  .maner {
    display: block; width: 100%; height: 18px; border: 0; background: none; position: relative;
  }
  .maner::before {
    content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 5px;
    transform: translateX(-50%); border-radius: 3px; background: var(--linie);
  }
  .titlu .sigla { width: 30px; height: 30px; }
  .titlu h1 { font-size: 16px; }
  .file { margin-top: 6px; }
  .unelte { top: 12px; right: 12px; }
  .maplibregl-ctrl-top-right { top: 100px; }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: calc(46vh + 4px); transition: bottom .25s ease; }
  body.restrans .maplibregl-ctrl-bottom-right, body.restrans .maplibregl-ctrl-bottom-left { bottom: 132px; }
  body.in-survol .maplibregl-ctrl-bottom-right, body.in-survol .maplibregl-ctrl-bottom-left { bottom: 0; }
  .survol { bottom: calc(16px + env(safe-area-inset-bottom)); }
  .cifre { grid-template-columns: repeat(4, 1fr); }
}
