/* Платформа «Маппинг МО РСО-Алания» — фирменный стиль НМИЦ ТПМ */
:root {
  --green: #005e23;
  --green-deep: #00451a;
  --green-ink: #0b3d1e;
  --green-soft: #e4efe7;
  --green-tint: #f1f6f2;
  --gold: #cbab54;
  --gold-soft: #f4ecd6;
  --cream: #eae9e2;
  --bg: #f3f4f0;
  --card: #ffffff;
  --line: #e2e5df;
  --text: #22291f;
  --muted: #6b7367;
  --red: #b3261e;
  --red-soft: #fbe9e7;
  --blue: #2e6f9e;
  --serif: "Source Serif Pro", "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar: 252px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 40, 25, .05), 0 4px 16px rgba(20, 40, 25, .05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- каркас ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: linear-gradient(180deg, var(--green) 0%, var(--green-deep) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { padding: 26px 22px 18px; }
.brand .org { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
.brand h1 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 6px 0 2px; line-height: 1.15; }
.brand .region { font-size: 13px; opacity: .85; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; }
.nav button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: transparent; border: 0; color: rgba(255,255,255,.82);
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav button svg { width: 20px; height: 20px; flex: 0 0 20px; opacity: .85; }
.nav button .nav-text { display: flex; flex-direction: column; }
.nav button .nav-sub { font-size: 11px; opacity: .6; }
.nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav button.active { background: #fff; color: var(--green); font-weight: 600; }
.nav button.active svg { opacity: 1; }
.nav button.active .nav-sub { opacity: .7; }

.sidebar-foot { margin-top: auto; padding: 16px 22px 20px; font-size: 11px; line-height: 1.5; opacity: .65; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot b { display: block; font-weight: 600; opacity: 1; }

.content { flex: 1; min-width: 0; padding: 26px 32px 40px; }

.tab { display: none; }
.tab.active { display: block; }

/* ---------- заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.page-head h2 { font-family: var(--serif); font-size: 26px; font-weight: 600; margin: 0; color: var(--green-ink); }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px 12px;
}
.kpi .v { font-family: var(--serif); font-size: 28px; font-weight: 600; color: var(--green); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .v.red { color: var(--red); }
.kpi .v.gold { color: #9a7d2a; }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- карточки ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; font-weight: 600; margin: 0; }
.card-head .count { color: var(--muted); font-weight: 400; }
.card-head .spacer { flex: 1; }
.card.flush { padding: 0; overflow: hidden; }

.note { background: var(--gold-soft); border-radius: 10px; padding: 10px 14px; font-size: 13px; color: #5a4a1a; margin-bottom: 14px; }
.note b { color: #3f3410; }

/* ---------- фильтры ---------- */
.toolbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px; align-items: end; }
.toolbar .field { max-width: 460px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px; letter-spacing: .01em; }
select, input[type=text] {
  width: 100%; font: inherit; font-size: 13.5px; color: var(--text);
  padding: 8px 32px 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7367' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select:focus, input:focus { outline: 2px solid rgba(0,94,35,.25); border-color: var(--green); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 8px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--green); margin: 0; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 13.5px; font-weight: 500;
  padding: 8px 14px; border-radius: 9px; cursor: pointer; border: 1px solid transparent;
  transition: background .15s, box-shadow .15s;
}
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-deep); }
.btn.ghost { background: #fff; color: var(--green); border-color: #cfd9d1; }
.btn.ghost:hover { background: var(--green-tint); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- таблицы ---------- */
.table-wrap { max-height: 520px; overflow: auto; border-top: 1px solid var(--line); }
.card > .table-wrap { margin: 0 -18px -16px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
th {
  position: sticky; top: 0; z-index: 2;
  background: #fafbf8; color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  white-space: nowrap;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.dim { color: var(--muted); }
tbody tr:hover td { background: var(--green-tint); }
tr.lowq td { color: #8a2c25; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--cream); color: var(--text);
}
.badge.yes { background: var(--green-soft); color: var(--green); }
.badge.no { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--gold-soft); color: #7a5f16; }
.badge.info { background: #e6eef5; color: var(--blue); }

/* ---------- линейка: результат ---------- */
.lj-grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
.lj-form .field { margin-bottom: 12px; }
.lj-result { margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 14px; min-height: 60px; }
.lj-result .empty { color: var(--muted); font-size: 13px; }
.lj-result .big { display: flex; gap: 22px; align-items: baseline; }
.lj-result .big b { font-family: var(--serif); font-size: 34px; font-weight: 600; color: var(--green); line-height: 1; }
.lj-result .big small { font-size: 12px; color: var(--muted); margin-left: 4px; }
.lj-result .path { margin-top: 10px; font-size: 13px; color: var(--muted); }
.lj-result .path b { color: var(--text); font-weight: 600; }
.lj-result .method { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.lj-result .err { color: var(--red); font-size: 13px; }

/* ---------- карты ---------- */
.map-card { position: relative; }
.map { height: 600px; width: 100%; background: #e9ece6; }
.map.short { height: 440px; }
.map-legend {
  position: absolute; top: 12px; right: 12px; z-index: 800;
  background: rgba(255,255,255,.94); backdrop-filter: blur(4px);
  border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px;
  font-size: 12px; display: flex; flex-direction: column; gap: 5px; min-width: 150px;
}
.map-legend .t { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 2px; }
.map-legend span.item { display: flex; align-items: center; gap: 7px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.line-sample { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--green); }
.line-sample.dashed { border-top: 2px dashed #8a938c; }
.fac-label {
  background: var(--green-ink); color: #fff; font-size: 9.5px; font-weight: 600;
  padding: 1px 5px; border-radius: 4px; white-space: nowrap; transform: translate(-50%, -100%);
  box-shadow: 0 1px 2px rgba(0,0,0,.25); letter-spacing: .02em;
}
.leaflet-container { font-family: var(--sans); }
.leaflet-popup-content-wrapper { border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.leaflet-popup-content strong { display: block; font-size: 14px; margin-bottom: 4px; color: var(--green-ink); }
.leaflet-bar a { color: var(--green-ink); }

/* ---------- details (v1) ---------- */
details.card summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; font-weight: 600; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary .chev { width: 18px; height: 18px; transition: transform .2s; color: var(--muted); }
details.card[open] summary .chev { transform: rotate(90deg); }
details.card summary .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
details.card[open] summary { margin-bottom: 12px; }
details.card > .table-wrap { margin: 0 -18px -16px; }

@media (max-width: 1100px) {
  .lj-grid { grid-template-columns: 1fr; }
  .content { padding: 20px; }
}
