/* ===== Лесная аналитика — светлая академическая тема ===== */

:root {
  --green: #2e7d32;
  --green-dark: #1b5e20;
  --green-mid: #43a047;
  --green-light: #e8f5e9;
  --green-pale: #f1f8f1;
  --ink: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --bg: #f5f7f5;
  --card: #ffffff;
  --red: #c62828;
  --red-bg: #fdecea;
  --amber: #b26a00;
  --amber-bg: #fff7e6;
  --blue: #1565c0;
  --blue-bg: #e8f0fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 42, 20, 0.06), 0 4px 16px rgba(15, 42, 20, 0.06);
  --shadow-hover: 0 2px 4px rgba(15, 42, 20, 0.08), 0 8px 24px rgba(15, 42, 20, 0.1);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

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

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-title { font-weight: 700; font-size: 15px; color: var(--ink); line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; }
.nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { background: var(--green-pale); color: var(--green-dark); }
.nav a.active {
  background: var(--green-light);
  color: var(--green-dark);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--green);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 11.5px;
  color: var(--faint);
  border-top: 1px solid var(--line);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 700; font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip-ok { background: var(--green-light); color: var(--green-dark); }
.chip-err { background: var(--red-bg); color: var(--red); }
.chip-wait { background: #f1f5f9; color: var(--muted); }

#api-banner:empty { display: none; }
.api-banner {
  margin: 12px 28px 0;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--red-bg);
  border: 1px solid #f5c6c2;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.api-banner p { margin: 0; flex: 1; min-width: 200px; }

.content { flex: 1; padding: 24px 28px 48px; width: 100%; max-width: 1600px; }

.section { display: none; }
.section.active { display: block; animation: fadein 0.18s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.sec-head { margin-bottom: 18px; }
.sec-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.sec-sub { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 860px; }

/* ===== Фильтры ===== */
.filters:empty { display: none; }
.filters { margin-bottom: 16px; }
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld > label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.fld select,
.fld input[type="text"],
.fld input[type="number"] {
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  min-width: 160px;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}
.fld select:focus,
.fld input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12); }
.fld input[type="number"] { min-width: 110px; width: 110px; }
.fld input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.1); }

.combobox { position: relative; }
.combobox .cb-input { min-width: 200px; width: 200px; padding-right: 30px; }
.cb-clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  border: none;
  background: #eef2ee;
  color: var(--muted);
  width: 20px; height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.cb-clear:hover { background: #dde6dd; color: var(--ink); }
.cb-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 42, 20, 0.14);
  max-height: 264px;
  overflow-y: auto;
  padding: 4px;
}
.cb-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 7px 10px;
  border-radius: 7px;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
}
.cb-item:hover, .cb-item.hl { background: var(--green-light); color: var(--green-dark); }
.cb-n { font-size: 11.5px; color: var(--faint); }
.cb-empty { padding: 8px 10px; color: var(--faint); font-size: 12.5px; }

.seg { display: inline-flex; background: #eef2ee; border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg-btn {
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: #fff; color: var(--green-dark); box-shadow: 0 1px 3px rgba(15, 42, 20, 0.12); }

/* ===== Карточки ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.kpi .kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .kpi-value { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin: 3px 0 2px; color: var(--ink); }
.kpi .kpi-value.acc { color: var(--green-dark); }
.kpi .kpi-sub { font-size: 12px; color: var(--faint); }

.card-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}
.card-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.grid-2 .card { margin: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.chart { width: 100%; height: 340px; }
.chart-sm { height: 280px; }
.chart-lg { height: 420px; }

/* ===== Таблицы ===== */
.table-wrap, .table-scroll { overflow-x: auto; overscroll-behavior-x: contain; }
.table-scroll { border-radius: 8px; }
.table-scroll table.tbl { width: 100%; min-width: 0; }
.table-scroll--xl table.tbl { width: 100%; min-width: 0; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl th, .tbl td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fbfdfb;
  user-select: none;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--green-dark); }
.tbl th .sort-arrow { font-size: 10px; margin-left: 3px; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:nth-child(even) { background: #fafcfa; }
.tbl tbody tr:hover { background: var(--green-pale); }
.tbl .cell-main { font-weight: 600; }
.tbl td.wrap, .tbl th.wrap { white-space: normal; min-width: 220px; max-width: 420px; }
.tbl th.wrap-soft, .tbl td.wrap-soft { white-space: normal; min-width: 0; max-width: 130px; overflow-wrap: anywhere; line-height: 1.35; }
.tbl tfoot td { font-weight: 700; background: #fbfdfb; border-top: 2px solid var(--line); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-error { background: var(--red-bg); color: var(--red); }
.badge-warning { background: var(--amber-bg); color: var(--amber); }
.badge-info { background: var(--blue-bg); color: var(--blue); }
.badge-muted { background: #f1f5f9; color: var(--muted); }

/* ===== Кнопки ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 9px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  text-decoration: none;
}
.btn:hover { background: var(--green-dark); box-shadow: var(--shadow-hover); }
.btn-ghost {
  background: #fff;
  color: var(--green-dark);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--green-pale); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pager-info { color: var(--muted); font-size: 13px; margin-right: auto; }
.pager .pg { min-width: 32px; padding: 5px 8px; }
.pager .pg.active-page { background: var(--green); border-color: var(--green); color: #fff; }

/* ===== Состояния ===== */
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 28px 4px; }
.spinner {
  width: 18px; height: 18px;
  border: 2.5px solid var(--green-light);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 14px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty strong { color: var(--muted); }

.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--red-bg);
  border: 1px solid #f5c6c2;
  border-radius: var(--radius);
  color: var(--red);
}
.error-banner p { margin: 0; flex: 1; min-width: 220px; }

.info-banner {
  padding: 12px 16px;
  background: var(--blue-bg);
  border: 1px solid #c9dcf7;
  border-radius: var(--radius);
  color: var(--blue);
  font-size: 13px;
}

/* ===== Составы ===== */
.formula-box {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding: 8px 4px;
}
.formula {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--green-dark);
  line-height: 1.1;
}
.formula-count { color: var(--muted); font-size: 13.5px; }

/* ===== Карта (Ареалы) ===== */
.map-card { padding: 0; overflow: hidden; }
.map-wrap { width: 100%; height: 500px; background: #e8efe8; }
.map-wrap .maplibregl-popup-content {
  font-family: var(--font);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(15, 42, 20, 0.2);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--ink);
}
.map-wrap .maplibregl-popup-content h3 { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--green-dark); }
.map-wrap .maplibregl-popup-content p { margin: 2px 0; }
.map-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
  font-size: 12.5px;
  color: var(--muted);
}
.legend-title { font-weight: 700; color: var(--ink); }
.legend-scale { display: flex; align-items: center; gap: 8px; }
.legend-bar {
  width: 180px; height: 10px;
  border-radius: 5px;
  border: 1px solid rgba(0,0,0,0.08);
}
.legend-val { font-variant-numeric: tabular-nums; color: var(--ink); }
.map-overlay-note {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 10;
  background: rgba(255,255,255,0.94);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 11.5px;
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.map-holder { position: relative; }

/* ===== Биомасса ===== */
.stub {
  padding: 36px 24px;
  text-align: center;
}
.stub h3 { margin: 0 0 8px; font-size: 17px; color: var(--ink); }
.stub p { margin: 0 auto; color: var(--muted); max-width: 560px; }

/* ===== Прочее ===== */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt8 { margin-top: 8px; }
.link { color: var(--green-dark); text-decoration: underline; cursor: pointer; }
.link:hover { color: var(--green); }

/* ===== ИИ-анализ (чат) ===== */
.chat-card { display: flex; flex-direction: column; }
.chat-msgs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 62vh;
  overflow-y: auto;
  padding: 6px 2px;
  margin-bottom: 12px;
}
.chat-msg { display: flex; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-ai { justify-content: flex-start; }
.chat-bubble {
  max-width: 84%;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  min-width: 0;
}
.chat-bubble-user {
  background: var(--green);
  color: #fff;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-bubble-ai {
  background: #f1f5f1;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.chat-answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-typing { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.chat-typing .spinner { width: 15px; height: 15px; }
.chat-note { font-size: 12px; color: var(--faint); margin-top: 6px; }
.chat-table { margin-top: 10px; }
.chat-table .table-scroll { border: 1px solid var(--line); background: #fff; }
.chat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chat-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 13px;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--green-dark);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.chat-chip:hover { background: var(--green-light); border-color: var(--green-mid); }
.chat-input-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-input-row textarea {
  flex: 1;
  min-height: 46px;
  max-height: 180px;
  resize: vertical;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}
.chat-input-row textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12); }
.chat-hint { font-size: 11.5px; color: var(--faint); margin-top: 8px; }

.sql-block {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8faf8;
  overflow: hidden;
}
.sql-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  background: #eef2ee;
}
.sql-head span { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sql-copy { padding: 3px 10px; font-size: 12px; }
.sql-block pre {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre;
}

/* ===== Модальное окно (импорт) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(15, 42, 20, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 16px;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(15, 42, 20, 0.28);
  width: 100%;
  max-width: 680px;
  padding: 20px 22px;
  animation: fadein 0.15s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.modal-close {
  border: none;
  background: #eef2ee;
  color: var(--muted);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.modal-close:hover { background: #dde6dd; color: var(--ink); }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.import-file-name { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.modal .table-scroll { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); margin-top: 8px; }

/* ===== Markdown (Инструкция) ===== */
.md-body { font-size: 14px; line-height: 1.65; overflow-wrap: anywhere; }
.md-body h1 { font-size: 22px; font-weight: 800; margin: 0 0 10px; letter-spacing: -0.01em; }
.md-body h2 { font-size: 18px; font-weight: 700; margin: 22px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md-body h3 { font-size: 15.5px; font-weight: 700; margin: 16px 0 6px; }
.md-body h4 { font-size: 14px; font-weight: 700; margin: 12px 0 4px; }
.md-body p { margin: 8px 0; }
.md-body ul, .md-body ol { margin: 8px 0; padding-left: 24px; }
.md-body li { margin: 3px 0; }
.md-body code {
  background: #f1f5f1;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.md-body pre {
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
}
.md-body pre code { background: none; border: none; padding: 0; font-size: 12.5px; }
.md-body table { border-collapse: collapse; margin: 12px 0; max-width: 100%; display: block; overflow-x: auto; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 6px 12px; font-size: 13px; text-align: left; }
.md-body th { background: #fbfdfb; font-weight: 600; }
.md-body a { color: var(--green-dark); }
.md-body blockquote {
  margin: 10px 0;
  padding: 6px 14px;
  border-left: 3px solid var(--green-mid);
  background: var(--green-pale);
  color: var(--muted);
  border-radius: 0 8px 8px 0;
}
.md-body hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.md-body img { max-width: 100%; }
.md-plain { white-space: pre-wrap; font-size: 13px; margin: 0; }

.seg-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== Адаптивность ===== */
/* Скрытие второстепенных колонок таблиц: lg — ноутбуки, md — планшеты, sm — телефоны */
@media (max-width: 1450px) {
  .tbl th.col-lg, .tbl td.col-lg { display: none; }
}
@media (max-width: 1000px) {
  .tbl th.col-md, .tbl td.col-md { display: none; }
  .tbl th, .tbl td { padding: 7px 8px; font-size: 12.5px; }
}
@media (max-width: 640px) {
  .tbl th.col-sm, .tbl td.col-sm { display: none; }
}

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

@media (max-width: 960px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 8px 12px; }
  .nav a { padding: 7px 12px; }
  .nav a.active { box-shadow: inset 0 -3px 0 var(--green); }
  .sidebar-foot { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 10px 14px; }
  .map-wrap { height: 380px; }
  .formula { font-size: 34px; }
}

@media (max-width: 640px) {
  .content { padding: 12px 10px 32px; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; }
  .topbar-right { display: none; }
  .brand { padding: 12px 12px 10px; }
  .brand-mark { width: 32px; height: 32px; flex-basis: 32px; font-size: 15px; }
  .brand-title { font-size: 14px; }
  .nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 6px 10px; }
  .nav a { flex: 0 0 auto; white-space: nowrap; padding: 7px 10px; font-size: 12.5px; }
  .filter-bar { gap: 8px; padding: 10px; }
  .filter-bar > .fld { flex: 1 1 100%; }
  .fld input[type="number"] { width: 100%; min-width: 0; }
  .combobox { width: 100%; }
  .combobox .cb-input { width: 100%; min-width: 0; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .card { padding: 12px 14px; }
  .kpi .kpi-value { font-size: 22px; }
  .chart { height: 260px; }
  .chart-lg { height: 320px; }
  .map-wrap { height: 320px; }
  .chat-bubble { max-width: 94%; }
  .modal { max-width: 100%; margin: 0 8px; padding: 16px; }
  .pager { flex-wrap: wrap; gap: 4px; }
  .pager-info { flex-basis: 100%; }
  .pager .pg { min-width: 28px; padding: 4px 7px; font-size: 12.5px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  .seg-btn { padding: 6px 10px; font-size: 12.5px; }
  .tbl th, .tbl td { padding: 6px 6px; font-size: 12px; }
  .tbl th.wrap-soft, .tbl td.wrap-soft { max-width: 90px; }
  .md-body h1 { font-size: 19px; }
  .md-body table { font-size: 12px; }
}
