:root {
  --bg: #f6fbf5;
  --surface: #ffffff;
  --primary: #2d5a27;
  --primary-soft: #4d7c0f;
  --text: #1f2937;
  --muted: #4b5563;
  --border: #d9e7d4;
  --danger: #b91c1c;

  /* Публичные страницы (макеты design/work) */
  --pub-bg: #f5f7f5;
  --pub-heading: #1b4d3e;
  --pub-accent: #3a5a38;
  --pub-accent-soft: #e8f5e9;
  --pub-icon-bg: #f1f8e9;
  --pub-icon-stroke: #558b2f;
  --pub-text-muted: #666666;
  --pub-border: #e5e7eb;
  --pub-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --pub-container-max: 1400px;
  --pub-radius-lg: 16px;
  --pub-radius-md: 12px;
  --pub-radius-sm: 8px;
  --pub-action-bg: #e8f5e9;
  --pub-action-color: #2e7d32;
  --pub-action-hover-bg: #c8e6c9;
  --pub-action-hover-color: #1b5e20;

  --control-height: 40px;
  --control-radius: 12px;
  --focus-ring: #3b6bc4;
  --combo-hover: #eef6ef;
  --hero-fade: rgba(255, 255, 255, 0);

  /* Единая сетка таблиц (.ui-table) */
  --table-font-size: 0.92rem;
  --table-font-size-compact: 0.875rem;
  --table-th-font-size: 0.92rem;
  --table-cell-pad-y: 0.5rem;
  --table-cell-pad-x: 0.35rem;
  --table-cell-pad-compact-y: 0.35rem;
  --table-cell-pad-compact-x: 0.5rem;
  --table-v-align: top;
}

/*
  Тёмная тема Fenolog (переключатель в шапке, html[data-theme="dark"]).
  Эталон: глубокий teal/чёрный фон, листовой зелёный акцент.
*/
html[data-theme="dark"] {
  --bg: #243830;
  --surface: #314840;
  --primary: #8fca86;
  --primary-soft: #6eae66;
  --text: #f4f7f3;
  --muted: #c8d5cc;
  --border: #4a635a;
  --danger: #e3a8ab;
  --pub-bg: #1e302a;
  --pub-heading: #f4f7f3;
  --pub-accent: #9dce94;
  --pub-accent-soft: #3a5249;
  --pub-icon-bg: #3a5249;
  --pub-icon-stroke: #b7e0ae;
  --pub-text-muted: #c8d5cc;
  --pub-border: #4a635a;
  --pub-shadow: 0 2px 16px rgba(0, 0, 0, 0.18);
  --pub-action-bg: #45725f;
  --pub-action-color: #f4f7f3;
  --pub-action-hover-bg: #53856f;
  --pub-action-hover-color: #ffffff;
  --combo-hover: #3e5a50;
  --hero-fade: rgba(49, 72, 64, 0);
  --focus-ring: #8ec0ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top left, #eef8eb, var(--bg));
  color: var(--text);
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] body {
  background: radial-gradient(circle at top left, #314840, var(--bg));
}

body.service-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.service-page > .container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
}

body.service-page footer[data-global-footer] {
  flex-shrink: 0;
  margin-top: auto;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1rem;
}

/* Шапка — design/work/index1_2, index2 */
.topbar {
  position: sticky;
  top: 0.5rem;
  z-index: 50;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.7rem 1.35rem;
  margin-bottom: 1rem;
  border: none;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--pub-shadow);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-width: 0;
}

.topbar .nav-link,
.topbar .nav-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--pub-heading);
  text-decoration: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.topbar .nav-link:hover,
.topbar .nav-link-btn:hover {
  color: var(--pub-action-hover-color);
  background: var(--pub-accent-soft);
}

.topbar .nav-link:focus-visible,
.topbar .nav-link-btn:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.topbar .nav-link-active {
  color: var(--pub-action-hover-color);
  background: var(--pub-accent-soft);
  font-weight: 600;
}

/* Вторичная подсветка: стол открыт, но текущая страница — карта */
.topbar .nav-link-context {
  color: var(--pub-heading);
  font-weight: 600;
  background: transparent;
  box-shadow: inset 0 -2px 0 var(--pub-accent);
}

.topbar .nav-link-icon {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.topbar-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  min-width: 0;
}

.theme-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1.5px solid var(--pub-accent, #3a5a38);
  border-radius: 50%;
  background: transparent;
  color: var(--pub-accent, #3a5a38);
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: none;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
  background: var(--pub-accent-soft, rgba(58, 90, 56, 0.1));
  opacity: 1;
  transform: none;
  box-shadow: none;
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-toggle-icon {
  display: none;
  line-height: 0;
}

html:not([data-theme="dark"]) .theme-toggle .theme-toggle-icon--sun,
html[data-theme="dark"] .theme-toggle .theme-toggle-icon--moon {
  display: block;
}

html[data-theme="dark"] .theme-toggle {
  border-color: rgba(220, 232, 224, 0.55);
  color: #e8f0ea;
  background: rgba(32, 48, 40, 0.35);
}

html[data-theme="dark"] .theme-toggle:hover {
  background: rgba(32, 48, 40, 0.55);
}

.topbar .nav-link-login {
  color: #2c4c3b;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0.15rem 0.25rem;
  border-radius: 12px;
  font: inherit;
  text-align: right;
  transition: background-color 0.2s ease;
}

.topbar-user:hover {
  background: var(--pub-accent-soft);
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  line-height: 1.2;
}

.topbar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-user-role {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: lowercase;
}

.topbar-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pub-icon-stroke);
}

.topbar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

html:not([data-theme="dark"]) .topbar-user-avatar img,
html:not([data-theme="dark"]) .modal-form-icon img[data-theme-avatar] {
  transform: scale(0.72);
}

.topbar-user-chevron {
  width: 0.65rem;
  height: 0.65rem;
  flex-shrink: 0;
  opacity: 0.55;
}

.topbar-user-menu {
  position: relative;
  flex-shrink: 0;
}

.topbar-user-dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  left: 0;
  z-index: 1400;
  min-width: 0;
  width: auto;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}

.topbar-user-menu.is-open .topbar-user-dropdown,
.topbar-user-menu:hover .topbar-user-dropdown,
.topbar-user-menu:focus-within .topbar-user-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.topbar-user-dropdown__item {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
}

.topbar-user-dropdown__item:hover,
.topbar-user-dropdown__item:focus-visible {
  background: var(--combo-hover);
  outline: none;
}

.topbar-user-dropdown__item--logout {
  margin-top: 0;
  border-top: none;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  color: var(--danger);
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
}

.topbar-user-dropdown__item--logout:hover,
.topbar-user-dropdown__item--logout:focus-visible {
  background: #fdecec;
  color: #9b1c1c;
}

.page-crumb {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
}

.page-crumb a {
  color: var(--primary-soft);
  text-decoration: none;
}

.page-crumb a:hover {
  text-decoration: underline;
}

.page-lead {
  margin: 0 0 0.65rem;
  max-width: 78ch;
  line-height: 1.5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  color: var(--primary);
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #2c4c3b;
}

.brand-subtitle {
  font-size: 0.8125rem;
  color: #4a7c59;
  font-weight: 500;
}

.btn {
  display: inline-block;
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(45, 90, 39, 0.12);
  background: var(--pub-action-hover-bg);
  color: var(--pub-action-hover-color);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: #244720;
}

.btn-soft {
  background: var(--pub-action-bg);
  color: var(--pub-action-color);
  border: 1px solid var(--border);
}

.btn-soft:hover {
  background: var(--pub-action-hover-bg);
  color: var(--pub-action-hover-color);
}

.btn-compact {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 6px;
  min-height: 0;
}

.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--pub-action-hover-bg);
  color: var(--pub-action-hover-color);
}

.btn-danger {
  background: #b91c1c;
  color: #fff;
  border: 1px solid #991b1b;
}

.btn-danger:hover:not(:disabled) {
  background: #991b1b;
  color: #fff;
}

.section,
.panel {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
}

.muted {
  color: var(--muted);
}

.card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  background: var(--bg);
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #b6d3ad;
  box-shadow: 0 10px 22px rgba(31, 41, 55, 0.08);
}

.global-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem 0 1.5rem;
  text-align: center;
}

.global-footer-mark {
  display: inline-flex;
  flex-shrink: 0;
  line-height: 0;
}

.global-footer-icon {
  display: block;
  width: 0.9em;
  height: 0.9em;
}

.global-footer-text {
  line-height: 1.45;
}

.ui-title {
  margin: 0 0 0.65rem;
  color: var(--primary);
}

.ui-subtitle {
  margin: 0 0 0.6rem;
  color: var(--primary);
}

.ui-form-grid {
  display: grid;
  gap: 0.75rem;
  max-width: 760px;
}

.ui-label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.95rem;
}

.ui-input-narrow {
  max-width: 5.5rem;
  min-width: 4rem;
}

.ui-toolbar label,
.ui-toolbar-field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.ui-toolbar--align-end {
  align-items: end;
}

.ui-toolbar .ui-limit-label,
.ui-toolbar label.ui-limit-label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  white-space: normal;
}

.ui-limit-input {
  font-weight: 400;
  min-width: 4.5rem;
  max-width: 5.5rem;
}

.help-page .section.panel {
  margin-top: 1rem;
}

.help-tabs {
  display: inline-flex;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.35rem;
  background: var(--bg);
  margin-top: 0.5rem;
}

.help-tab-btn {
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.help-tab-btn.active {
  color: var(--pub-heading);
  background: var(--pub-accent-soft);
  border-color: var(--pub-border);
}

.help-panel {
  margin-top: 1rem;
}

.help-panel.is-hidden {
  display: none;
}

.concept-nav-table td:last-child {
  white-space: nowrap;
}

.page-lead {
  max-width: 75ch;
}

.help-quick-nav {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 0.75rem;
}

.help-quick-nav a.card {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.help-quick-nav a.card:hover {
  border-color: var(--primary-soft);
  box-shadow: 0 6px 16px rgba(45, 90, 39, 0.12);
}

.help-quick-nav a.card h3 {
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-size: 1.05rem;
}

.help-quick-nav a.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.ui-table td.ui-num,
.ui-table th.ui-num {
  text-align: right;
}

.ui-input,
.ui-form-grid input,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
select,
textarea {
  color: var(--text);
  background-color: var(--surface);
}

.ui-input,
.ui-form-grid input {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  padding: 0.55rem 0.6rem;
  font: inherit;
}

.ui-combo {
  position: relative;
  width: 100%;
}

.ui-combo-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.ui-combo-input {
  width: 100%;
  padding-right: 2rem;
  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='%236B7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}

.ui-combo.is-disabled .ui-combo-input {
  opacity: 0.65;
  cursor: not-allowed;
}

.ui-combo-input:focus,
.ui-combo-input:focus-visible {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 18%, transparent);
}

.ui-combo-list {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  max-height: min(420px, 62vh);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--pub-border, #e5e7eb);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.ui-combo-list--fixed-rows {
  max-height: calc(var(--combo-visible-rows, 6) * 1.82rem + 0.3rem);
}

.ui-combo-list--fixed-rows .ui-combo-option {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 0.32rem;
  padding-bottom: 0.32rem;
  line-height: 1.35;
}

.ui-combo-option {
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text);
}

.ui-combo-option:hover,
.ui-combo-option.is-active {
  background: var(--combo-hover);
}

.ui-combo-option.is-selected {
  font-weight: 600;
  color: var(--pub-heading, #14532d);
}

.ui-combo-empty,
.ui-combo-more {
  padding: 0.5rem 0.85rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.ui-input::placeholder,
.ui-toolbar input::placeholder,
.ui-form-grid input::placeholder,
.profile-grid input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.ui-file-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.ui-hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.ui-check,
.ui-switch-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.35;
  user-select: none;
}

.ui-switch-row {
  display: flex;
  min-height: 2rem;
}

.ui-check input[type="checkbox"],
.ui-check input[type="radio"],
.ui-switch-row input[type="checkbox"],
.ui-switch-row input[type="radio"],
.ui-choice-group input[type="checkbox"],
.ui-choice-group input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.ui-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f6fbf4;
}

.ui-choice-group legend {
  padding: 0 0.35rem;
  font-weight: 600;
  color: var(--primary);
}

.ui-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.ui-toolbar {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.ui-toolbar input,
.ui-toolbar select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  min-width: 170px;
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
}

.ui-toolbar .ui-toolbar-wide {
  min-width: 260px;
}

.ui-msg {
  min-height: 1.2rem;
  font-weight: 600;
}

.ui-msg.ok {
  color: var(--primary);
}

td.error,
.ui-msg.error {
  color: var(--danger);
}

.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--table-font-size);
}

.ui-table th,
.ui-table td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: var(--table-cell-pad-y) var(--table-cell-pad-x);
  vertical-align: var(--table-v-align);
}

.ui-table thead th {
  font-size: var(--table-th-font-size);
  font-weight: 600;
  white-space: nowrap;
  vertical-align: var(--table-v-align);
  color: var(--pub-heading);
}

.ui-table th.ui-th-sortable {
  cursor: pointer;
  white-space: nowrap;
  color: var(--primary);
}

.ui-table th.ui-th-sortable:hover {
  background: var(--pub-accent-soft);
}

.ui-table th.ui-th-sort-asc::after {
  content: " ▲";
  font-size: 0.72em;
  opacity: 0.75;
}

.ui-table th.ui-th-sort-desc::after {
  content: " ▼";
  font-size: 0.72em;
  opacity: 0.75;
}

.users-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  align-items: start;
}

body.user-panel-open .users-layout {
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.05fr);
}

.user-drawer {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  box-shadow: 0 14px 32px rgba(31, 41, 55, 0.1);
  padding: 1rem;
  max-height: calc(100vh - 5rem);
  overflow: auto;
  position: sticky;
  top: 5.5rem;
  animation: drawer-in 0.22s ease;
}

.user-drawer[hidden] {
  display: none !important;
}

.user-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.user-drawer .profile-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.ui-stat {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.25rem 0 0;
}

body.popup-page {
  margin: 0;
  background: #f4f8f2;
  min-height: 100vh;
}

.popup-root {
  max-width: 100%;
  padding: 1rem 1.1rem 1.5rem;
  box-sizing: border-box;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

body.ui-modal-open {
  overflow: hidden;
}

.ui-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  background: rgba(15, 23, 42, 0.45);
}

.ui-modal-dialog {
  width: min(100%, 520px);
  max-height: calc(100dvh - 2.5rem);
  margin: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.22);
  box-sizing: border-box;
}

.ui-modal-backdrop:has(.ui-modal-dialog--form) {
  background: rgba(58, 90, 56, 0.28);
}

.ui-modal-dialog--form {
  width: min(100%, 500px);
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-md);
  box-shadow: var(--pub-shadow);
}

.ui-modal-dialog--form-wide {
  width: min(100%, 640px);
}

.modal-form-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.modal-form-header__brand {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  min-width: 0;
}

.modal-form-icon {
  flex-shrink: 0;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--pub-icon-bg);
  color: var(--pub-icon-stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.modal-form-icon:has(img[data-theme-avatar]) {
  background: var(--bg);
  padding: 0;
}

.modal-form-icon svg,
.modal-form-icon img {
  width: 1.35rem;
  height: 1.35rem;
  stroke: currentColor;
}

.modal-form-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  stroke: none;
}

.modal-form-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--pub-heading);
  line-height: 1.25;
}

.modal-form-subtitle {
  margin: 0.3rem 0 0;
  font-size: 0.8125rem;
  color: var(--pub-text-muted);
  line-height: 1.35;
}

.modal-form-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  background: var(--bg);
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.modal-form-close:hover,
.modal-form-close:focus-visible {
  background: var(--pub-action-hover-bg);
  border-color: var(--pub-accent);
  color: var(--pub-action-hover-color);
  outline: none;
}

.modal-form-grid {
  display: grid;
  gap: 0.85rem 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  align-content: start;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--pub-border);
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.modal-field--full {
  grid-column: 1 / -1;
}

.modal-field--grow {
  min-height: 4.5rem;
}

.modal-field--grow .modal-field-textarea {
  flex: 1 1 auto;
  min-height: 4.5rem;
  height: 100%;
  resize: none;
}

.modal-field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-field input:focus {
  outline: none;
  border-color: var(--pub-accent);
  box-shadow: 0 0 0 3px rgba(58, 90, 56, 0.12);
}

.modal-field input[readonly] {
  background: var(--bg);
  color: var(--muted);
  cursor: default;
}

.modal-field-textarea {
  width: 100%;
  min-height: 4.5rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  font-size: 0.8125rem;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-field-textarea:focus {
  outline: none;
  border-color: var(--pub-accent);
  box-shadow: 0 0 0 3px rgba(58, 90, 56, 0.12);
}

.modal-form-note {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
  color: #4b5563;
  font-weight: 400;
}

.modal-field input[readonly] {
  background: var(--bg);
  color: #374151;
  cursor: default;
}

.modal-form-grid .ui-pheno-only[hidden] {
  display: none;
}

.modal-form-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
  padding-top: 1rem;
  flex-shrink: 0;
}

.modal-form-footer .btn-primary {
  border-radius: var(--pub-radius-sm);
  font-weight: 500;
  padding: 0.65rem 1.15rem;
}

.btn-desk-soft {
  background: var(--pub-action-bg);
  color: var(--pub-action-color);
  border: none;
  border-radius: var(--pub-radius-sm);
  font-weight: 500;
  padding: 0.65rem 1.15rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-desk-soft:hover {
  background: var(--pub-action-hover-bg);
  color: var(--pub-action-hover-color);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(58, 90, 56, 0.1);
}

.modal-form-msg {
  margin-top: 0.75rem;
}

.modal-form-msg:empty {
  display: none;
  margin: 0;
}

.ui-modal-backdrop:has(.ui-modal-dialog--profile) {
  background: rgba(58, 90, 56, 0.28);
}

.ui-modal-dialog--profile {
  width: min(100%, 720px);
  max-height: calc(100dvh - 2.5rem);
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-md);
  box-shadow: var(--pub-shadow);
}

.ui-modal-dialog--profile .popup-root {
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 100%;
  padding: 1.35rem;
  -webkit-overflow-scrolling: touch;
}

.ui-modal-dialog--admin-profile {
  width: min(100%, 800px);
}

.ui-modal-backdrop:has(.ui-modal-dialog--help) {
  background: rgba(58, 90, 56, 0.28);
}

.ui-modal-dialog--help {
  width: min(100%, 640px);
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-md);
  box-shadow: var(--pub-shadow);
}

.ui-modal-dialog--help .popup-root {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  padding: 1.35rem;
}

.modal-help {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.modal-help-header {
  margin-bottom: 0;
  flex-shrink: 0;
}

.modal-help .help-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--pub-border);
  line-height: 1.5;
  text-align: justify;
  color: var(--text);
  min-height: 0;
}

.modal-help .help-modal-body p {
  margin: 0 0 0.75rem;
}

.modal-help .help-modal-body p:last-child {
  margin-bottom: 0;
}

.help-modal-header {
  flex-shrink: 0;
}

.ui-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.help-trigger {
  flex-shrink: 0;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: 1px solid var(--pub-border);
  background: var(--pub-accent-soft);
  color: var(--pub-accent);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.help-trigger:hover,
.help-trigger:focus-visible {
  background: var(--pub-action-hover-bg);
  border-color: var(--border);
  color: var(--pub-action-hover-color);
  outline: none;
}

.topbar .nav-link-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-help-trigger {
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.82rem;
  margin-left: 0.05rem;
}

.nav-section-tip {
  position: absolute;
  z-index: 1300;
  max-width: min(22rem, calc(100vw - 1.5rem));
  padding: 0.75rem 2rem 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.5;
}

.nav-section-tip__text {
  margin: 0;
}

.nav-section-tip__close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  border: none;
  background: transparent;
  color: var(--pub-text-muted, #6b7280);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.15rem 0.25rem;
}

.ui-modal-dialog--wide {
  width: min(100%, 800px);
}

.ui-modal-backdrop:has(.ui-modal-dialog--graph) {
  background: rgba(58, 90, 56, 0.28);
}

.ui-modal-dialog--graph {
  width: min(100%, 880px);
  max-width: calc(100vw - 2rem);
  max-height: calc(100dvh - 2rem);
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-md);
  box-shadow: var(--pub-shadow);
}

.ui-modal-dialog--graph .popup-root {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 100%;
  padding: 1.35rem;
}

.seasons-graph-modal {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}

.sg-preview-header {
  flex-shrink: 0;
  margin-bottom: 0;
}

.sg-preview-subtitle {
  margin-top: 0.3rem !important;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--pub-text-muted);
}

.sg-preview-chart {
  flex: 1 1 auto;
  min-height: 220px;
  max-height: min(52dvh, 430px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  background: linear-gradient(180deg, var(--bg) 0%, var(--surface) 100%);
  overflow: hidden;
}

.sg-preview-loading {
  margin: 0;
  font-size: 0.92rem;
}

.sg-preview-svg {
  width: 100%;
  max-height: 100%;
}

.sg-preview-svg svg {
  width: 100%;
  height: auto;
  max-height: min(50dvh, 400px);
  display: block;
}

.sg-preview-meta {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sg-preview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
}

.sg-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
}

.sg-swatch {
  flex-shrink: 0;
  display: inline-block;
}

.sg-swatch--green {
  background: #008000;
  height: 0.22rem;
  width: 1.35rem;
  border-radius: 2px;
}

.sg-swatch--red {
  background: #e53935;
  height: 0.22rem;
  width: 1.35rem;
  border-radius: 2px;
}

.sg-swatch--blue {
  background: #1e40af;
  height: 0.65rem;
  width: 0.14rem;
  border-radius: 1px;
}

.sg-swatch--gray {
  background: #94a3b8;
  height: 0.22rem;
  width: 1.1rem;
  border-radius: 2px;
}

.sg-preview-note {
  margin: 0;
  font-size: 0.84rem;
}

.sg-preview-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-shrink: 0;
  padding-top: 1rem;
  margin-top: 0.15rem;
  border-top: 1px solid var(--pub-border);
}

.sg-preview-footer .btn-primary {
  border-radius: var(--pub-radius-sm);
  font-weight: 500;
  padding: 0.65rem 1.15rem;
}

.profile-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1rem;
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.profile-summary-grid dt {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.profile-summary-grid dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
  color: var(--text);
}

.nav-link-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  padding: 0.35rem 0.55rem;
}

.ui-modal-dialog .popup-root {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 1.35rem;
  box-sizing: border-box;
}

.ui-modal-dialog .popup-root.panel {
  margin-top: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.ui-modal-dialog .modal-form {
  min-height: 0;
}

.ui-modal-dialog--form .popup-root {
  padding: 1.35rem;
}

.ui-modal-dialog--profile .popup-root {
  /* Профиль длинный (пункты, вход, журнал) — прокрутка только здесь; остальные модалки без скролла. */
  display: block;
  padding: 1.35rem;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ui-modal-dialog #plot-msg:empty,
.ui-modal-dialog #node-msg:empty,
.ui-modal-dialog #pheno-info-msg:empty {
  display: none;
  margin: 0;
  padding: 0;
}

/* Профиль — design/work/index1 */
.profile-card-ui {
  position: relative;
}

.modal-profile-header {
  margin-bottom: 1rem;
  align-items: center;
}

.modal-profile-header .modal-form-header__brand {
  align-items: center;
  gap: 0.7rem;
}

.modal-profile-header .modal-form-icon {
  width: 2.5rem;
  height: 2.5rem;
}

.modal-profile-header .modal-form-title {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
}

.modal-profile-header .modal-form-subtitle {
  margin-top: 0.12rem;
  font-size: 0.8125rem;
  line-height: 1.3;
}

.modal-profile .profile-meta-grid {
  margin-top: 0;
  border-color: var(--pub-border);
  border-radius: var(--pub-radius-sm);
  background: var(--pub-accent-soft);
}

.modal-profile .profile-meta-item dt {
  color: var(--muted);
  font-weight: 600;
}

.modal-profile .profile-section-title {
  color: var(--pub-heading);
  font-size: 0.9375rem;
  font-weight: 600;
}

.modal-profile .profile-section-title--spaced {
  border-top-color: var(--pub-border);
}

.modal-profile .profile-email-login {
  border-color: var(--pub-border);
  border-radius: var(--pub-radius-sm);
  background: var(--bg);
}

.modal-profile .profile-email-login-line strong {
  color: var(--pub-heading);
}

.modal-profile .profile-input-group > span {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  padding-left: 0;
}

.modal-profile .profile-input-group input,
.modal-profile .profile-form-grid input {
  padding: 0.6rem 0.75rem;
  border-color: var(--pub-border);
  border-radius: var(--pub-radius-sm);
  font-size: 0.875rem;
}

.modal-profile .profile-input-group input:focus,
.modal-profile .profile-form-grid input:focus {
  border-color: var(--pub-accent);
  box-shadow: 0 0 0 3px rgba(58, 90, 56, 0.12);
}

.modal-profile .profile-footer {
  border-top-color: var(--pub-border);
  padding-top: 1rem;
}

.modal-profile .btn-profile-save {
  background: var(--primary);
  border-radius: var(--pub-radius-sm);
  font-weight: 500;
  padding: 0.65rem 1.15rem;
}

.modal-profile .btn-profile-logout {
  border-color: var(--pub-border);
  border-radius: var(--pub-radius-sm);
  color: var(--pub-accent);
  font-weight: 500;
  padding: 0.65rem 1.15rem;
}

.modal-profile .btn-profile-logout:hover {
  background: var(--pub-action-hover-bg);
  border-color: var(--pub-accent);
  color: var(--pub-action-hover-color);
}

.modal-admin-user .profile-input-group select,
.modal-admin-user .profile-form-grid select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
}

.modal-admin-user .profile-input-group select:focus,
.modal-admin-user .profile-form-grid select:focus {
  border-color: var(--pub-accent);
  box-shadow: 0 0 0 3px rgba(58, 90, 56, 0.12);
  outline: none;
}

.modal-admin-user .profile-acc-toggle {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: var(--control-height);
  padding: 0 0.7rem;
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  background: var(--surface);
  box-sizing: border-box;
}

.modal-admin-user .profile-acc-toggle .ui-check {
  margin: 0;
  font-size: 0.875rem;
  white-space: nowrap;
}

.modal-admin-user .profile-geo-block {
  margin: 0 0 0.85rem;
}

.profile-geo-block__head {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.profile-geo-block__head #panel-geo-count,
.profile-geo-block__head .profile-geo-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

.modal-admin-user .profile-geo-block__head {
  margin: 0 0 0.35rem;
}

.modal-admin-user .profile-geo-block .geo-ids-chips {
  min-height: 0;
  margin-bottom: 0.15rem;
}

.modal-admin-user .geo-ids-add-row .ui-input {
  flex: 1 1 auto;
  min-width: 0;
}

.modal-admin-user .btn-profile-reset {
  background: var(--surface);
  color: var(--pub-accent);
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  font-weight: 500;
  padding: 0.65rem 1.15rem;
}

.modal-admin-user .btn-profile-reset:hover {
  background: var(--bg);
  border-color: var(--border);
}

.modal-admin-user .modal-admin-footer {
  margin-bottom: 0.25rem;
}

.modal-admin-user .modal-admin-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.modal-admin-user .modal-admin-toolbar select,
.modal-admin-user .modal-admin-toolbar .modal-admin-select {
  flex: 0 1 11rem;
  width: auto;
  min-width: 8.5rem;
  max-width: 14rem;
}

.modal-admin-user .modal-admin-toolbar .ui-input--page-limit {
  flex: 0 0 auto;
}

.modal-admin-user .modal-admin-toolbar .desk-export-links {
  flex: 0 0 auto;
  margin-left: auto;
  flex-wrap: nowrap;
}

.modal-admin-user .ui-input--page-limit {
  width: calc(5ch + 2.75rem);
  min-width: calc(5ch + 2.75rem);
  max-width: calc(5ch + 2.75rem);
  box-sizing: border-box;
}

.desk-export-links {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.desk-export-links .btn {
  min-height: 2.15rem;
  padding: 0.35rem 0.7rem;
}

.desk-page .desk-filter-bar__actions .desk-export-links {
  margin-left: 0;
}

.modal-admin-user .modal-admin-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.modal-admin-user .modal-admin-select {
  min-width: 10rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
}

.modal-admin-user .modal-admin-select:focus {
  outline: none;
  border-color: var(--pub-accent);
  box-shadow: 0 0 0 3px rgba(58, 90, 56, 0.12);
}

.modal-admin-user .modal-admin-table-wrap {
  border: 1px solid var(--pub-border);
  border-radius: var(--pub-radius-sm);
  overflow: auto;
  background: var(--surface);
}

.modal-admin-user .modal-admin-table {
  margin: 0;
}

.modal-admin-user .modal-admin-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.profile-footer {
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.profile-footer-msg {
  margin: 0 0 0.65rem;
  min-height: 0;
}

.profile-footer-msg:empty {
  display: none;
  margin: 0;
}

.profile-card-ui > .profile-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
}

.profile-card-ui .profile-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.profile-card-ui .profile-header h1 {
  margin: 0 0 0.65rem;
  padding-right: 2.5rem;
  font-size: clamp(1.25rem, 2.2vw, 1.55rem);
  font-weight: 700;
  color: #1e4620;
  line-height: 1.25;
}

.profile-card-ui .profile-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.85rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.profile-card-ui .profile-meta-item {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.profile-card-ui .profile-meta-item dt {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  line-height: 1.2;
}

.profile-card-ui .profile-meta-item dd {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card-ui .profile-meta-mono {
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  font-size: 0.8rem;
  font-weight: 500;
}

.profile-card-ui .profile-meta,
.profile-card-ui .profile-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin: 0 0 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.profile-card-ui .profile-section-title {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--pub-heading);
}

.profile-card-ui .profile-section-title--spaced {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.profile-email-login {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.profile-email-login-line {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.profile-email-login-line strong {
  color: var(--pub-heading);
  word-break: break-all;
}

.profile-email-login-empty {
  margin: 0;
  font-size: 0.88rem;
}

.profile-email-login-forms {
  display: grid;
  gap: 0.85rem;
}

.profile-email-login-block {
  padding-top: 0.15rem;
}

.profile-email-login-title {
  margin: 0 0 0.55rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
}

.profile-email-login-grid {
  margin-bottom: 0.55rem;
}

.profile-email-login--admin .profile-action-buttons--compact {
  margin-top: 0.35rem;
  gap: 0.5rem;
}

.profile-action-buttons--compact {
  flex-wrap: wrap;
}

.profile-card-ui .profile-form-grid,
.ui-modal-dialog .profile-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 0.75rem;
  margin-bottom: 0.65rem;
}

.profile-card-ui .profile-input-group--wide {
  grid-column: 1 / -1;
}

.geo-ids-editor {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.geo-ids-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.geo-ids-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.45rem 0.2rem 0.55rem;
  border-radius: 999px;
  background: #eef6ee;
  border: 1px solid #d7e6d7;
  color: #1f3d2a;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.geo-ids-chip-remove {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #4b5563;
}

.geo-ids-add-row {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.geo-ids-suggest {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  max-height: 12rem;
  overflow: auto;
}

.geo-ids-suggest-item {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}

.geo-ids-suggest-item:hover {
  background: #f3f6f3;
}

.profile-card-ui .profile-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.profile-card-ui .profile-input-group > span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  padding-left: 0.2rem;
}

.profile-card-ui .profile-input-group input,
.profile-card-ui .profile-form-grid input,
.profile-card-ui .profile-form-grid select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
}

.profile-card-ui .profile-input-group input:focus,
.profile-card-ui .profile-form-grid input:focus,
.profile-card-ui .profile-form-grid select:focus {
  border-color: var(--primary);
  background: var(--surface);
  outline: none;
}

.profile-card-ui .profile-action-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  margin: 0;
}

.profile-card-ui .btn-profile-save {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.profile-card-ui .btn-profile-logout {
  margin-left: auto;
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.profile-card-ui .btn-profile-logout:hover {
  background: #fdecec;
  border-color: var(--danger);
  color: #9b1c1c;
}

.profile-card-ui .btn-profile-logout:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.profile-card-ui .btn-profile-reset {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.65rem 1.35rem;
  font-weight: 600;
  cursor: pointer;
}

.profile-card-ui .ui-choice-group {
  grid-column: 1 / -1;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: 12px;
}

@media (max-width: 540px) {
  .ui-modal-backdrop {
    padding: 0.75rem;
  }

  .modal-form-grid {
    grid-template-columns: 1fr;
  }

  .modal-form-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-form-footer .btn {
    width: 100%;
    justify-content: center;
  }

  .profile-card-ui .profile-form-grid,
  .ui-modal-dialog .profile-form-grid,
  .profile-summary-grid,
  .profile-card-ui .profile-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-card-ui .btn-profile-logout {
    margin-left: 0;
    width: 100%;
  }
}

.user-drawer .profile-grid input,
.user-drawer .profile-grid select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.55rem;
  font: inherit;
}

@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.ui-table-spaced {
  margin-top: 0.6rem;
}

.ui-table th.ui-th-narrow,
.ui-table td.ui-td-email-login {
  width: 6.5rem;
  white-space: nowrap;
  vertical-align: middle;
}

.ui-table th.ui-th-actions,
.ui-table td.ui-td-actions {
  width: 7.5rem;
  min-width: 7.5rem;
  max-width: 8rem;
  vertical-align: middle;
}

.ui-table td.ui-td-code {
  max-width: 5.5rem;
  width: 5.5rem;
  vertical-align: middle;
}

.ui-table td.ui-td-code .ui-code-wrap {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.25;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.users-table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

#users-section {
  overflow-x: hidden;
  min-width: 0;
}

.users-table th {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.users-table th:nth-child(1),
.users-table td.ui-td-code {
  width: 3.6rem;
}

.users-table th:nth-child(2),
.users-table td.ui-td-person {
  width: auto;
  min-width: 0;
}

.users-table th:nth-child(3),
.users-table td.ui-td-role {
  width: 7.6rem;
  min-width: 0;
  max-width: 7.6rem;
  overflow: hidden;
  vertical-align: middle;
}

.users-roles {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.08rem;
  max-width: 100%;
  overflow: hidden;
}

.users-roles--single,
.users-role-line {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  line-height: 1.25;
}

.users-table th:nth-child(4) {
  width: 3.9rem;
}

.users-table th:nth-child(5),
.users-table td.ui-td-geos {
  width: 4.55rem;
}

.users-table th:nth-child(6),
.users-table td.ui-td-contacts {
  width: 6.4rem;
}

.users-table .users-person-name {
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

.users-table td.ui-td-geos .users-geo-chips {
  gap: 0.15rem;
}

.users-table td.ui-td-geos .users-geo-chip,
.users-table td.ui-td-geos .users-geo-more {
  padding: 0.08rem 0.3rem;
  font-size: 0.7rem;
}

.users-geo-chip,
.users-geo-more {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #d7e6d7;
  background: #eef6ee;
  color: #1f3d2a;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.users-geo-more {
  cursor: pointer;
  font-weight: 700;
  color: #1f3d2a;
}

.users-table td.ui-td-contacts {
  min-width: 0;
  vertical-align: middle;
}

.users-contacts {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.users-contact-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
  line-height: 1.35;
}

.users-contact-line--phone {
  color: var(--muted);
  font-size: 0.78rem;
}

.ui-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
}

.ui-pill--ok {
  background: #e8f5e9;
  color: #2e5c2a;
  border: 1px solid #c8e6c9;
}

.ui-pill--warn {
  background: #fff8e1;
  color: #8a6d1d;
  border: 1px solid #ffe082;
}

.btn-table {
  display: block;
  width: 100%;
  max-width: 9.25rem;
  padding: 0.42rem 0.65rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 8px;
  line-height: 1.25;
  text-align: center;
  white-space: nowrap;
}

.btn-table:hover {
  transform: none;
  box-shadow: 0 4px 12px rgba(45, 90, 39, 0.1);
}

.ui-row-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.ui-row-actions--reg {
  min-width: 10.5rem;
  max-width: 12rem;
}

.ui-row-actions--reg .ui-input {
  width: 100%;
  min-width: 0;
  font-size: 0.875rem;
  padding: 0.4rem 0.5rem;
}

.ui-row-actions__danger {
  color: #8b2e2e;
  border-color: #e8c4c4;
}

.ui-row-actions__danger:hover {
  background: #fff5f5;
  color: #6d1f1f;
  border-color: #ddb0b0;
}

.ui-table-frame {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 0;
}

.ui-table-scroll {
  overflow: auto;
  flex: 0 1 auto;
  min-height: 120px;
}

.ui-table-pager {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.15rem 0 0.35rem;
}

.ui-table-pager .btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid var(--pub-border);
  background: var(--surface);
  color: var(--muted);
  box-shadow: none;
}

.ui-table-pager .btn:hover:not(:disabled) {
  background: var(--combo-hover);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.ui-table-pager .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ui-table-pager-info {
  flex: 1 1 8rem;
  min-width: 8rem;
  text-align: center;
  color: var(--muted);
}

.admin-dash-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 0.5rem;
}

.admin-dash-grid .card {
  margin: 0;
}

.admin-dash-roles {
  margin: 0.35rem 0 0;
  line-height: 1.4;
  font-size: 0.875rem;
}

.ui-td-role-clip {
  max-width: 13ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-dash-card--link {
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.admin-dash-card--link:hover,
.admin-dash-card--link:focus-visible {
  border-color: var(--border);
  box-shadow: 0 8px 20px rgba(45, 90, 39, 0.1);
  transform: translateY(-1px);
  outline: none;
}

.ui-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}

.ui-grid-auto {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.ui-grid-auto input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font: inherit;
}

.ui-form-narrow {
  max-width: 520px;
}

.u-self-end {
  align-self: end;
}

.u-mt-045 {
  margin-top: 0.45rem;
}

.u-mt-05 {
  margin-top: 0.5rem;
}

.u-mt-075 {
  margin-top: 0.75rem;
}

.u-mb-045 {
  margin-bottom: 0.45rem;
}

.ui-title-primary {
  margin-top: 0;
  color: var(--primary);
}

html[data-theme="dark"] .section,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .desk-sidebar,
html[data-theme="dark"] .desk-card,
html[data-theme="dark"] .pub-surface,
html[data-theme="dark"] .pub-hero,
html[data-theme="dark"] .ui-combo-list,
html[data-theme="dark"] .ui-modal-dialog,
html[data-theme="dark"] .ui-modal-backdrop .popup-root,
html[data-theme="dark"] .topbar-user-dropdown,
html[data-theme="dark"] .map-stat-card,
html[data-theme="dark"] .map-status-help,
html[data-theme="dark"] .map-sidebar,
html[data-theme="dark"] .map-filters,
html[data-theme="dark"] .map-list-card,
html[data-theme="dark"] .help-links-admin,
html[data-theme="dark"] .export-fieldset {
  background: var(--surface);
  color: var(--text);
  border-color: var(--pub-border);
}

html[data-theme="dark"] .ui-input,
html[data-theme="dark"] .ui-combo-input,
html[data-theme="dark"] .desk-page input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
html[data-theme="dark"] .pub-page input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
html[data-theme="dark"] .pub-page select,
html[data-theme="dark"] .desk-page select,
html[data-theme="dark"] textarea {
  background-color: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .ui-table th,
html[data-theme="dark"] .ui-table td {
  border-color: var(--border);
  color: var(--text);
}

html[data-theme="dark"] .muted,
html[data-theme="dark"] .page-lead,
html[data-theme="dark"] .page-crumb,
html[data-theme="dark"] .page-crumb a {
  color: var(--muted);
}

/* Чипы geoID: светлый фон + явный тёмный текст (в dark theme inherit делал белое-на-светлом). */
html[data-theme="dark"] .users-geo-chip,
html[data-theme="dark"] .users-geo-more,
html[data-theme="dark"] .geo-ids-chip {
  background: color-mix(in srgb, var(--pub-accent, #6fbf73) 22%, var(--surface));
  border-color: color-mix(in srgb, var(--pub-accent, #6fbf73) 40%, var(--border));
  color: var(--text);
}

html[data-theme="dark"] .geo-ids-chip-remove {
  color: var(--muted);
}

html[data-theme="dark"] .modal-admin-user .profile-geo-block__head #panel-geo-count {
  color: var(--text);
}

html[data-theme="dark"] .ui-table td.ui-td-code,
html[data-theme="dark"] .ui-table td.ui-td-code .ui-code-wrap {
  color: var(--text);
}

.roles-extended-backdrop {
  z-index: 1400;
}

.roles-extended-dialog {
  max-width: 26rem;
  padding: 1.15rem 1.25rem 1.1rem;
}

.roles-extended-lead {
  margin: 0 0 0.85rem;
  font-size: 0.875rem;
}

.roles-extended-checks {
  display: grid;
  gap: 0.45rem;
  margin: 0 0 0.75rem;
}

.roles-extended-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.roles-extended-msg {
  margin: 0 0 0.65rem;
}

html[data-theme="dark"] .btn {
  color: var(--text);
}

html[data-theme="dark"] .btn-primary {
  background: var(--pub-action-bg);
  color: var(--pub-action-color);
  border-color: var(--border);
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    grid-template-columns: 1fr;
    padding: 0.85rem 1rem;
  }

  .topbar nav {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-end {
    width: 100%;
  }

  .topbar-user {
    justify-content: flex-end;
  }

  .section,
  .panel {
    padding: 1rem;
  }
}

@media (max-width: 900px) {
  .ui-two-col {
    grid-template-columns: 1fr;
  }

  body.user-panel-open .users-layout {
    grid-template-columns: 1fr;
  }

  .user-drawer {
    position: static;
    max-height: none;
  }
}
