:root {
  --navy: #0b1f4d;
  --navy-deep: #071536;
  --navy-soft: #1a3266;
  --navy-text: #0d2b5e;
  --gold: #d4a017;
  --gold-bright: #f0b429;
  --ink: #12203a;
  --muted: #5b6b86;
  --line: rgba(13, 43, 94, 0.12);
  --line-strong: rgba(13, 43, 94, 0.18);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.88);
  --bg: #e8eef6;
  --panel: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --shadow: 0 8px 24px rgba(13, 43, 94, 0.08), 0 2px 6px rgba(13, 43, 94, 0.04);
  --shadow-lg: 0 16px 40px rgba(13, 43, 94, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --font: Arial, Verdana, Helvetica, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tree-gap: 1.35rem;
  --toggle-size: 22px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(255, 255, 255, 0.9), transparent 60%),
    linear-gradient(165deg, #f4f7fb 0%, #e4ebf5 45%, #dce5f2 100%);
  line-height: 1.5;
  font-size: 15px;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }

.icon {
  display: inline-block;
  vertical-align: -0.2em;
  flex-shrink: 0;
}

.page {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 calc(2.5rem + var(--safe-bottom));
}
.page--login {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* ========== Topbar ========== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, var(--navy-deep), var(--navy));
  color: #fff;
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 18px rgba(7, 21, 54, 0.2);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.topbar__mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  color: var(--navy-deep);
  font-weight: 700;
  font-size: 0.68rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.topbar__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}
.topbar__sub {
  margin: 0.15rem 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.8rem;
}

.user-chip {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar .btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}
.topbar .btn--ghost:hover {
  background: rgba(240, 180, 41, 0.18);
  border-color: var(--gold-bright);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.7rem 1.05rem;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .12s ease;
  min-height: 44px;
}
.btn:hover { transform: translateY(-1px); }
.btn--sm { padding: 0.4rem 0.7rem; font-size: 0.8rem; min-height: 34px; }
.btn--block { width: 100%; }
.btn--primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: #c49212;
  color: var(--navy-deep);
  box-shadow: 0 4px 12px rgba(212, 160, 23, 0.3);
}
.btn--primary:hover { filter: brightness(1.04); }
.btn--primary:disabled,
.btn--register:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn--danger {
  background: #fff;
  border-color: #fda29b;
  color: var(--danger);
}
.btn--danger:hover { background: var(--danger-bg); }
.btn--ghost {
  background: rgba(255, 255, 255, 0.55);
  border-color: var(--line-strong);
  color: var(--navy-text);
}
.btn--ghost:hover {
  background: #fff;
  border-color: var(--navy-soft);
}

.btn--register {
  width: 100%;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(13, 43, 94, 0.14);
  color: var(--navy-text);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  font-size: 0.88rem;
  min-height: 46px;
}
.btn--register:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(13, 43, 94, 0.28);
  box-shadow: var(--shadow-lg);
}

.field-hint-senha {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

/* ========== Login ========== */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 480px);
  background: #000;
}
.login__visual {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: #000;
  padding: 2rem;
}
.login__visual img {
  width: 100%;
  height: 100%;
  max-height: calc(100vh - 4rem);
  max-height: calc(100dvh - 4rem);
  object-fit: contain;
}
.login__panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 2rem;
  background: #fff;
  min-height: 100vh;
  min-height: 100dvh;
  border-left: 3px solid var(--gold);
}
.login__eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.login__brand {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 700;
  color: var(--navy-deep);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.login__number {
  display: inline-block;
  margin-top: 0.85rem;
  padding: 0.3rem 0.65rem;
  background: var(--navy-deep);
  color: var(--gold-bright);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  border-radius: 8px;
}
.login__desc {
  margin: 1.25rem 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.login__footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

/* ========== Forms ========== */
.form { display: grid; gap: 0.95rem; }
.field { display: grid; gap: 0.35rem; }
.field span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  background: #fff;
  min-height: 44px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11, 31, 77, 0.12);
}
.field input[data-uppercase] { text-transform: uppercase; }

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.alert {
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
  background: var(--glass-strong);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}
.alert--erro {
  border-color: #fecdca;
  background: var(--danger-bg);
  color: var(--danger);
}
.alert--ok {
  border-color: #abefc6;
  background: var(--ok-bg);
  color: var(--ok);
}

/* ========== Admin ========== */
.admin-home {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

.candidato__foto {
  margin: 0;
  background: #000;
  border: 1px solid rgba(212, 160, 23, 0.3);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.candidato__foto img {
  width: 100%;
  object-fit: contain;
  background: #000;
  min-height: 320px;
}
.candidato__nome {
  margin: 0;
  padding: 0.9rem 1rem;
  background: var(--navy-deep);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
}
.candidato__nome small {
  display: block;
  margin-top: 0.2rem;
  color: var(--gold-bright);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  font-weight: 700;
}

/* ========== Stats (estrutura da referência) ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.4rem;
}

.stat-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.stat-card {
  position: relative;
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem 0.85rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  overflow: hidden;
  min-height: 148px;
  display: flex;
  flex-direction: column;
}
.stats--admin .stat-card { min-height: 140px; }

.stat-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.stat-card__label {
  display: block;
  color: var(--navy-text);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card__icon {
  color: var(--navy-text);
  opacity: 0.85;
}

.stat-card__value {
  margin-top: 0.35rem;
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--navy-text);
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-card__spark {
  display: block;
  width: 100%;
  height: 48px;
  margin-top: auto;
  opacity: 0.9;
}
.stat-card__spark-grid {
  stroke: rgba(13, 43, 94, 0.1);
  stroke-width: 1;
  fill: none;
}
.stat-card__spark-line {
  stroke: var(--navy-text);
}

.panel,
.map-panel,
.tree,
.card-form,
.table-wrap {
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.map-panel { padding: 1.15rem 1.2rem 1.2rem; background: var(--glass-strong); }
.map-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--line);
}
.map-panel__intro {
  min-width: min(100%, 240px);
  flex: 1 1 220px;
}
.map-panel__head h2,
.section-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy-text);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.map-panel__desk,
.map-panel__mobile {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}
.map-panel__mobile { display: none; }

.map-select {
  display: grid;
  gap: 0.35rem;
  flex: 1 1 260px;
  max-width: 360px;
  min-width: min(100%, 220px);
}
.map-select__label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.map-select__field {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0.55rem 0.85rem;
  background: #fff;
  color: var(--navy-text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(13, 43, 94, 0.05);
  cursor: pointer;
}
.map-select__field:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11, 31, 77, 0.12);
}

.mapa-ro {
  height: min(56vh, 500px);
  min-height: 300px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #e8eef6;
}
.mapa-hint {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.25em;
}

.mapa-sigla { background: transparent !important; border: none !important; }
.mapa-sigla span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(7, 21, 54, 0.9);
  color: #f5d56e;
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.2;
  pointer-events: none;
  white-space: nowrap;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 1.25rem;
  align-items: start;
}
.card-form { padding: 1.15rem; }

/* ========== Árvore / Estrutura ========== */
.tree {
  padding: 0;
  overflow: hidden;
  background: var(--glass);
}

.tree__head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
}
.tree__head .section-title {
  margin: 0;
  font-size: 1.1rem;
}

.tree > .empty,
.tree > .tree-list {
  padding: 1rem 1rem 1.25rem;
}

.empty {
  color: var(--muted);
  padding: 1.25rem 1.1rem;
  margin: 0;
  font-size: 0.9rem;
}
.empty--nested {
  margin: 0.35rem 0 0.65rem;
  padding: 0.65rem 0 0.65rem 2.1rem;
  font-size: 0.85rem;
}

.tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-item {
  position: relative;
  margin: 0 0 0.85rem;
}
.tree-item:last-child { margin-bottom: 0; }

/* Painel filho + linhas em L */
.tree-panel {
  position: relative;
  margin: 0.15rem 0 0;
  padding: 0.35rem 0 0 calc(var(--toggle-size) + var(--tree-gap));
}

.tree-list--nested {
  position: relative;
  margin: 0;
  padding: 0;
}

.tree-list--nested > .tree-item {
  position: relative;
  padding-left: 0;
}

.tree-list--nested > .tree-item::before {
  content: "";
  position: absolute;
  left: calc((var(--toggle-size) / 2) * -1 - var(--tree-gap) + 1px);
  top: 0;
  bottom: calc(100% - 1.55rem);
  width: 1px;
  background: rgba(13, 43, 94, 0.28);
}

.tree-list--nested > .tree-item::after {
  content: "";
  position: absolute;
  left: calc((var(--toggle-size) / 2) * -1 - var(--tree-gap) + 1px);
  top: 1.55rem;
  width: calc(var(--tree-gap) - 2px);
  height: 1px;
  background: rgba(13, 43, 94, 0.28);
}

.tree-list--nested > .tree-item:last-child::before {
  bottom: auto;
  height: 1.55rem;
}

/* ========== Person row / card ========== */
.person-row {
  display: grid;
  grid-template-columns: var(--toggle-size) minmax(0, 1fr);
  gap: var(--tree-gap);
  align-items: start;
}

.person-row__toggle {
  width: var(--toggle-size);
  height: var(--toggle-size);
  margin-top: 1.35rem;
  border: 1px solid rgba(13, 43, 94, 0.35);
  background: rgba(255, 255, 255, 0.85);
  color: var(--navy-text);
  border-radius: 4px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 1px 2px rgba(13, 43, 94, 0.08);
}
.person-row__toggle:hover {
  background: #fff;
  border-color: var(--navy);
}

.person-row__toggle-minus { display: none; }
.person-row__toggle[aria-expanded="true"] .person-row__toggle-plus { display: none; }
.person-row__toggle[aria-expanded="true"] .person-row__toggle-minus { display: block; }

.person-row__spacer {
  width: var(--toggle-size);
  height: var(--toggle-size);
  margin-top: 1.35rem;
}

.person-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
  padding: 0.9rem 1.1rem;
  background: var(--glass-strong);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.person-card__avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, #dce6f5, #b8c8e0);
  color: var(--navy-text);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 0 0 1px rgba(13, 43, 94, 0.08);
  overflow: hidden;
}
.person-card__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.foto-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}
.foto-upload__preview {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: #f1f5f9;
  overflow: hidden;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.foto-upload__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.foto-upload__placeholder {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
  padding: 0.25rem;
}
.field--foto > span {
  display: block;
  margin-bottom: 0.35rem;
}

.person-card__main { min-width: 0; }

.person-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.person-card__identity {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.person-card__papel {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.person-card__nome {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy-text);
  line-height: 1.25;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.person-card__count {
  flex: 0 0 auto;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.person-card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.85rem;
  margin-top: 0.55rem;
}

.person-link,
.person-link-form {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--navy-text);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  opacity: 0.88;
}
.person-link:hover {
  opacity: 1;
  color: var(--navy-deep);
  text-decoration: underline;
}
.person-link--danger { color: var(--danger); }
.person-link--danger:hover { color: #912018; }

.person-card__details {
  margin-top: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  background: rgba(13, 43, 94, 0.04);
  border: 1px solid var(--line);
}
.person-card__details p {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--ink);
}
.person-card__details p:last-child { margin-bottom: 0; }
.person-card__details span {
  display: inline-block;
  min-width: 5.5rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

/* ========== Modal ========== */
body.modal-open { overflow: hidden; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal[hidden] { display: none !important; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 21, 54, 0.45);
  backdrop-filter: blur(3px);
}
.modal__dialog {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  max-height: min(90vh, 860px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line-strong);
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 2;
}
.modal__head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy-deep);
}
.modal__close {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.modal__close:hover { color: var(--ink); background: #f8fafc; }
.modal__body { padding: 1.15rem; }
.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.leaflet-container { font: inherit; background: #e8eef6; }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .admin-home { grid-template-columns: 240px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login__visual {
    min-height: 38vh;
    min-height: 38dvh;
    padding: 1rem;
  }
  .login__visual img {
    max-height: 34vh;
    max-height: 34dvh;
  }
  .login__panel {
    min-height: auto;
    border-left: 0;
    border-top: 3px solid var(--gold);
  }
  .admin-home,
  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .mapa-ro { height: 52vh; min-height: 300px; }
  .map-panel__desk { display: none; }
  .map-panel__mobile { display: block; }
  .map-select { max-width: none; flex: 1 1 100%; }
}

@media (max-width: 640px) {
  .page {
    width: calc(100% - 1.25rem);
    padding-top: 1rem;
  }
  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 0.75rem 0.9rem;
    min-height: 0;
  }
  .topbar__right {
    width: 100%;
    justify-content: space-between;
  }
  .tree > .empty,
  .tree > .tree-list {
    padding: 0.85rem 0.7rem 1rem;
  }
  --tree-gap: 0.85rem;
  .person-card {
    grid-template-columns: 44px minmax(0, 1fr);
    padding: 0.75rem 0.8rem;
  }
  .person-card__avatar {
    width: 44px;
    height: 44px;
    font-size: 0.8rem;
  }
  .person-card__top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  .person-card__count {
    margin-top: 0;
  }
  .person-card__actions {
    gap: 0.35rem 0.7rem;
  }
  .modal {
    padding: 0;
    align-items: end;
  }
  .modal__dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
}
