/* ------------------------------------------------------------
   ГЛОБАЛЬНЫЕ ПЕРЕМЕННЫЕ, СБРОС И БАЗОВАЯ ТИПОГРАФИКА
   Адаптивные отступы, светлая/тёмная темы, шрифты
------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
}
img, svg { display: block; max-width: 100%; height: auto; }
a { text-decoration: none; color: inherit; }
button, input, textarea, select { font: inherit; }
p { margin: 0 0 1rem; color: var(--color-text-muted); }
h1, h2, h3 { margin: 0 0 1rem; line-height: 1.08; }
h1 { font-family: var(--font-display); font-size: var(--text-2xl); }
h2 { font-family: var(--font-display); font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

/* Тема: светлая по умолчанию, тёмная — при атрибуте data-theme="dark" */
:root, [data-theme="light"] {
  --text-xs: clamp(.75rem,.7rem + .25vw,.875rem);
  --text-sm: clamp(.875rem,.8rem + .35vw,1rem);
  --text-base: clamp(1rem,.95rem + .25vw,1.125rem);
  --text-lg: clamp(1.125rem,1rem + .75vw,1.5rem);
  --text-xl: clamp(1.5rem,1.2rem + 1.25vw,2.25rem);
  --text-2xl: clamp(2rem,1.2rem + 2.5vw,3.5rem);
  --color-bg: #f7f6f2;
  --color-surface: #fbfaf7;
  --color-surface-2: #f1eee8;
  --color-text: #28251d;
  --color-text-muted: #666157;
  --color-text-faint: #9a9387;
  --color-primary: #183c54;
  --color-primary-hover: #112d3e;
  --color-primary-soft: #dde8ed;
  --shadow-sm: 0 2px 10px rgba(20,20,20,.05);
  --shadow-md: 0 18px 45px rgba(20,20,20,.08);
  --content: 1280px;
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Work Sans', 'Segoe UI', sans-serif;
}
[data-theme="dark"] {
  --color-bg: #171614;
  --color-surface: #1d1b19;
  --color-surface-2: #262320;
  --color-text: #ece6dc;
  --color-text-muted: #b8b0a5;
  --color-text-faint: #8e8578;
  --color-primary: #7fa8bc;
  --color-primary-hover: #9bc0d0;
  --color-primary-soft: #21303a;
  --shadow-sm: 0 2px 10px rgba(0,0,0,.22);
  --shadow-md: 0 18px 45px rgba(0,0,0,.35);
}

/* ------------------------------------------------------------
   КОМПОНЕНТЫ: контейнер, карточки, кнопки, сетки
   Все базовые утилиты для построения макета
------------------------------------------------------------ */
.container { width: min(calc(100% - 2rem), var(--content)); margin: 0 auto; }
.section { padding: clamp(3.25rem, 6vw, 5rem) 0; border-top: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent); }
.section-head { display: grid; grid-template-columns: .72fr 1.28fr; gap: 2rem; align-items: end; margin-bottom: 2rem; }
.kicker {
  font-size: var(--text-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: .75rem;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  padding: .45rem .85rem;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .02em;
  margin-bottom: 1rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 62px;
  padding: 1rem 2.4rem;
  border-radius: 999px;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all var(--transition);
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-secondary { background: transparent; color: var(--color-text); border-color: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-secondary:hover { background: var(--color-surface-2); }
.card {
  padding: 1.5rem;
  background: var(--color-surface);
  border-radius: 1.2rem;
  border: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
  box-shadow: var(--shadow-sm);
}
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .75rem; }
.list li { display: flex; gap: .75rem; color: var(--color-text-muted); font-size: var(--text-sm); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-primary); margin-top: .6rem; flex: 0 0 auto; }
.panel {
  padding: 1.75rem;
  background: var(--color-surface);
  border-radius: 1.2rem;
  border: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
  box-shadow: var(--shadow-sm);
}
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1.25rem 0; }
.stat {
  padding: 1rem;
  border-radius: 1rem;
  background: var(--color-surface-2);
  border: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}
.stat strong { display: block; font-size: var(--text-lg); color: var(--color-text); margin-bottom: .2rem; }
.stat span { font-size: var(--text-sm); color: var(--color-text-muted); word-break: break-word; }
.okved-list { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: 0.5rem; }
.media-card {
  overflow: hidden;
  border-radius: 1.2rem;
  border: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.media-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}
.leader-caption { font-size: var(--text-xs); color: var(--color-text-faint); padding: .85rem 1rem; border-top: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent); }
.meta { display: grid; gap: 1rem; margin-top: 1.25rem; }
.meta-row strong { display: block; font-size: var(--text-sm); margin-bottom: .2rem; color: var(--color-text); }
.meta-row a { color: var(--color-primary); text-decoration: underline; }
.note { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: 0.5rem; }

/* ------------------------------------------------------------
   ФОТО-БЛОКИ: руководитель и офис (заменяют SVG-заглушки реальными JPG)
------------------------------------------------------------ */
.leader-photo,
.office-photo {
  width: 100%;
  min-height: 420px;
  height: 100%;                /* растягивается на всю высоту родительской ячейки */
  overflow: hidden;
  border-radius: 1.2rem;
  background: var(--color-surface-2);
}
.leader-photo img,
.office-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.leader-photo img {
  object-position: center 18%;
}

/* ------------------------------------------------------------
   ШАПКА: липкая, с блюром, адаптивное меню
------------------------------------------------------------ */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
}
.header-inner {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: .9rem;
}
.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  padding: 8px;
  background: var(--color-surface-2);
  border: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
  color: var(--color-primary);
}
.brand-title { font-weight: 700; font-size: var(--text-sm); }
.brand-sub { font-size: var(--text-xs); color: var(--color-text-muted); }
.nav { display: flex; gap: 1.2rem; align-items: center; }
.nav a { font-size: var(--text-sm); color: var(--color-text-muted); transition: color var(--transition); }
.nav a:hover { color: var(--color-text); }
.header-actions { display: flex; align-items: center; gap: .75rem; }
.menu-toggle, .theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--color-text) 12%, transparent);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.theme-toggle { display: inline-flex; }
.menu-toggle { display: none; }

/* ------------------------------------------------------------
   ГЕРО-БЛОК: преимущества, карточки направлений
------------------------------------------------------------ */
.hero { padding: clamp(2.75rem, 4vw, 3.5rem) 0 clamp(3rem, 6vw, 5rem); }
.hero-grid { display: flex; flex-direction: column; gap: 2.5rem; }
.hero-text-block { width: 100%; }
.hero-actions { display: flex; justify-content: center; gap: 1.25rem; margin-top: 2rem; flex-wrap: wrap; }
.hero-card { padding: 2rem; background: var(--color-surface); border-radius: 1.2rem; box-shadow: var(--shadow-sm); border: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent); }
.hero-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; margin-top: 1.5rem; }
.fact {
  background: var(--color-surface);
  border-radius: 1.2rem;
  padding: 1.5rem;
  border: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
  box-shadow: var(--shadow-sm);
}
.fact strong { display: block; font-size: var(--text-base); color: var(--color-text); margin-bottom: 0.5rem; font-weight: 700; }
.fact span { display: inline-block; color: var(--color-text-muted); max-width: 32ch; font-size: var(--text-sm); line-height: 1.4; }
.item-list { display: grid; gap: 1rem; margin-top: 1.5rem; }
.item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1rem;
  border-radius: 1rem;
  background: color-mix(in srgb, var(--color-surface-2) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}
.icon-box {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

/* ------------------------------------------------------------
   БЛОК КАРТЫ И МАРШРУТА
------------------------------------------------------------ */
.office-map { margin-top: 1.75rem; }
.office-map-card {
  position: relative;
  display: grid;
  overflow: hidden;
  border-radius: 1rem;
  background: var(--color-surface-2);
  border: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
  box-shadow: var(--shadow-sm);
}
.office-map-canvas {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(260px, 32vw, 360px);
  background: var(--color-surface-2);
}
.office-map-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  text-align: center;
  text-decoration: underline;
}
.office-map-canvas.leaflet-container .office-map-fallback {
  display: none;
}
.office-map-canvas .leaflet-control-attribution {
  font-size: 10px;
}
.office-map-canvas .leaflet-popup-content-wrapper,
.office-map-canvas .leaflet-popup-tip {
  background: var(--color-surface);
  color: var(--color-text);
}
.office-map-canvas .leaflet-popup-content {
  margin: .75rem .9rem;
  font-family: var(--font-body);
  font-size: var(--text-xs);
}
[data-theme="dark"] .office-map-canvas .leaflet-tile {
  filter: brightness(.78) contrast(1.06) saturate(.88);
}
.office-route-btn {
  width: 100%;
  min-height: 52px;
  border: none;
  border-top: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
  background: transparent;
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  text-decoration: none;
}
.office-route-btn svg { flex: 0 0 auto; }
.office-route-btn:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ------------------------------------------------------------
   ФОРМА ОБРАТНОЙ СВЯЗИ
------------------------------------------------------------ */
form { display: grid; gap: 1rem; }
.field { display: grid; gap: .5rem; }
.field-error {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
label { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); }
input, textarea, select {
  width: 100%;
  padding: .95rem 1rem;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--color-text) 14%, transparent);
  background: var(--color-surface-2);
  color: var(--color-text);
}
.field.has-error input {
  border-color: #b3261e;
  box-shadow: 0 0 0 3px color-mix(in srgb, #b3261e 18%, transparent);
}
textarea { min-height: 130px; resize: vertical; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  min-width: min(320px, calc(100vw - 32px));
  max-width: min(420px, calc(100vw - 32px));
  padding: 1rem 1.25rem;
  border-radius: 16px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  font-weight: 600;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity .3s ease, transform .3s ease, visibility .3s ease;
}
.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.toast.success { border-left: 4px solid #4caf50; }
.toast.error {
  border-left: 4px solid #d33;
  color: #ff5a52;
}

/* ------------------------------------------------------------
   ФУТЕР И АДАПТИВНЫЕ СЕТКИ
------------------------------------------------------------ */
.footer { padding: 2rem 0 2.5rem; border-top: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent); margin-top: 1rem; }
.footer-grid { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.footer-note { font-size: var(--text-xs); color: var(--color-text-faint); max-width: 72ch; }
.footer-meta { display: grid; gap: .55rem; justify-items: end; }
.footer-admin-link { color: var(--color-text-faint); font-size: var(--text-xs); text-decoration: none; }
.footer-admin-link:hover { color: var(--color-primary); text-decoration: underline; }
.leader-name-large { font-size: var(--text-xl); margin-bottom: 0.5rem; font-family: var(--font-display); }

/* Адаптивность: планшеты и мобильные устройства */
@media (max-width: 1080px) {
  .about-grid, .office-grid, .contact-grid, .leader-grid { grid-template-columns: 1fr; }
  .grid-3, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .leader-photo,
  .office-photo {
    max-width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }
}
@media (max-width: 760px) {
  .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 78px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1.5rem;
    background: var(--color-bg);
    border-bottom: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
    gap: 1rem;
    backdrop-filter: blur(8px);
    opacity: 0;
    transform: translateY(-12px);
    visibility: hidden;
    transition: opacity 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.2), transform 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.2), visibility 0.35s;
  }
  .nav.open {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
  }
  .menu-toggle { display: inline-flex; }
  .header-actions .btn { display: none; }
  .hero-facts { grid-template-columns: 1fr; }
  .grid-3, .stats { grid-template-columns: 1fr; }
  .section-head { grid-template-columns: 1fr; gap: 1rem; }
  .hero-card { padding: 1.5rem; }
  .leader-photo,
  .office-photo {
    max-width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }
}

/* ------------------------------------------------------------
   АНИМАЦИИ И ПЕРЕХОДЫ (сохраняем исходные плавные эффекты)
   - плавное появление при скролле (reveal)
   - ховеры на карточках, кнопках, иконках
------------------------------------------------------------ */
:root {
  --transition: 180ms cubic-bezier(.16,1,.3,1);
}
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.65s cubic-bezier(0.2, 0.9, 0.4, 1.1), transform 0.65s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}
.reveal.visible {
  opacity: 1;
  transform: none;
}
/* Общие переходы для интерактивных элементов */
.btn, .menu-toggle, .theme-toggle, .nav a, .fact, .card, .item, .office-route-btn, .stat, .media-card img, .brand-mark {
  transition: all 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.2);
}
.btn:active { transform: scale(0.96); }
.fact:hover, .card:hover, .stat:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
}
.item:hover {
  transform: translateX(6px);
  background: color-mix(in srgb, var(--color-surface) 96%, var(--color-primary));
  border-color: var(--color-primary-soft);
}
.brand-mark:hover {
  transform: rotate(4deg) scale(1.02);
  background: var(--color-primary-soft);
}
.media-card {
  transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.4, 1.2), box-shadow 0.35s ease;
}
.media-card:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-md);
}
.media-card img {
  transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.4, 1.2);
}
.media-card:hover img {
  transform: scale(1.02);
}
.icon-box svg {
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.2);
}
.item:hover .icon-box svg {
  transform: scale(1.1);
}
input, textarea, select {
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.2s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
  outline: none;
  transform: scale(1.01);
}
.theme-toggle:active svg {
  transform: rotate(30deg);
}
.hero-actions .btn:hover {
  transform: translateY(-3px);
}
.office-map-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.office-map-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.stat strong {
  transition: color 0.2s ease;
}
.stat:hover strong {
  color: var(--color-primary);
}
/* Дополнительные сетки для страницы "О компании" и "Руководитель" */
.about-grid, .office-grid, .contact-grid, .leader-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 1080px) {
  .about-grid, .office-grid, .contact-grid, .leader-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------
   Административная панель
------------------------------------------------------------ */
.admin-section {
  padding-top: 8rem;
}

.admin-section-head {
  align-items: flex-end;
  gap: 1.5rem;
}

.admin-actions,
.admin-form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-actions {
  justify-content: flex-end;
}

.admin-actions form,
.admin-row-actions form {
  display: inline-flex;
}

.admin-auth-section {
  min-height: 100vh;
  display: grid;
  align-items: center;
}

.admin-auth-panel,
.admin-form-panel {
  max-width: 760px;
  margin: 0 auto;
}

.admin-auth-panel {
  max-width: 540px;
}

.admin-table-panel {
  overflow-x: auto;
  padding: 0;
}

.admin-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
  text-align: left;
  vertical-align: top;
  font-size: var(--text-sm);
}

.admin-table th {
  background: var(--color-surface-2);
  color: var(--color-text);
  font-weight: 700;
  text-transform: uppercase;
  font-size: var(--text-xs);
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-message {
  max-width: 320px;
  white-space: pre-wrap;
}

.admin-row-actions {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  align-items: flex-start;
}

.admin-link,
.admin-danger-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--color-primary);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.admin-danger-link {
  color: #b3261e;
}

.admin-alert {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-radius: 8px;
  background: var(--color-surface-2);
  border: 1px solid color-mix(in srgb, var(--color-text) 10%, transparent);
  font-size: var(--text-sm);
  font-weight: 600;
}

.admin-alert-error {
  color: #b3261e;
  border-color: color-mix(in srgb, #b3261e 35%, transparent);
}

.admin-empty {
  max-width: 720px;
}

@media (max-width: 760px) {
  .admin-section {
    padding-top: 6.5rem;
  }

  .admin-section-head {
    align-items: flex-start;
  }

  .admin-actions {
    justify-content: flex-start;
  }

  .admin-actions .btn,
  .admin-form-actions .btn,
  .header-actions .btn {
    min-height: 48px;
    padding: .8rem 1.2rem;
  }
}
