/* ==========================================================================
   Базовые настройки и сброс
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: #2c2c2c;
  background: #eef1f5;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: #1a6bb5;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #0d4a86;
  text-decoration: underline;
}

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
  color: #1b3a5c;
  margin: 0 0 15px;
}

h1 { font-size: 1.9em; }
h2 { font-size: 1.4em; margin-top: 25px; }
h3 { font-size: 1.15em; }

p { margin: 0 0 12px; }

ul {
  padding-left: 22px;
  margin: 0 0 15px;
}

ul li { margin-bottom: 6px; }

/* ==========================================================================
   Контейнер
   ========================================================================== */
.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 15px;
}

/* ==========================================================================
   Шапка сайта
   ========================================================================== */
.site-header {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 100;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 0;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
  min-width: 0;
}

.logo-area img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.15em;
  font-weight: 700;
  color: #1b3a5c;
  line-height: 1.2;
}

.logo-text span {
  display: block;
  font-size: 0.68em;
  font-weight: 400;
  color: #6b7785;
  margin-top: 3px;
}

.lang-switcher {
  font-size: 0.9em;
  color: #6b7785;
  white-space: nowrap;
  padding: 6px 12px;
  background: #f4f6f9;
  border-radius: 6px;
}

.lang-switcher span { color: #1b3a5c; font-weight: 600; }

/* Кнопка мобильного меню */
.menu-toggle {
  display: none;
  background: #1a6bb5;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 1.2em;
  cursor: pointer;
  transition: background 0.2s ease;
}

.menu-toggle:hover { background: #0d4a86; }

/* ==========================================================================
   Главное меню
   ========================================================================== */
.main-nav {
  background: linear-gradient(180deg, #1b3a5c 0%, #16314d 100%);
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-list > li {
  position: relative;
  margin: 0;
}

.nav-list > li > a {
  display: block;
  color: #eaf1f8;
  padding: 14px 16px;
  font-size: 0.88em;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.nav-list > li > a:hover,
.nav-list > li > a.active {
  background: #0d4a86;
  color: #ffffff;
  text-decoration: none;
}

.nav-list > li > a .fa-chevron-down {
  font-size: 0.7em;
  margin-left: 5px;
  opacity: 0.7;
}

/* Выпадающие подменю */
.nav-list ul {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 260px;
  background: #ffffff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  border-radius: 0 0 8px 8px;
  list-style: none;
  padding: 8px 0;
  margin: 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 200;
}

.nav-list > li:hover > ul {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-list ul li { margin: 0; }

.nav-list ul li a {
  display: block;
  padding: 9px 18px;
  color: #2c2c2c;
  font-size: 0.88em;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-list ul li a:hover,
.nav-list ul li a.active {
  background: #f0f5fa;
  color: #1a6bb5;
  text-decoration: none;
}

/* ==========================================================================
   Основная сетка (3 колонки)
   ========================================================================== */
.content-wrapper {
  display: grid;
  grid-template-columns: 280px 1fr 220px;
  gap: 20px;
  padding: 20px 0;
  align-items: start;
}

.sidebar { width: 100%; }

/* ==========================================================================
   Виджеты (боковые блоки)
   ========================================================================== */
.widget {
  background: #ffffff;
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.widget:last-child { margin-bottom: 0; }

.widget-title {
  font-size: 1em;
  font-weight: 700;
  color: #1b3a5c;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e8eef5;
  line-height: 1.3;
}

.widget-title a {
  color: #1b3a5c;
  text-decoration: none;
}

.widget-title a:hover {
  color: #1a6bb5;
  text-decoration: none;
}

.widget-image img {
  width: 100%;
  border-radius: 6px;
  transition: transform 0.25s ease;
}

.widget-image:hover img { transform: scale(1.02); }

/* Информационные строки в виджетах */
.info-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.9em;
  line-height: 1.4;
}

.info-item:last-child { margin-bottom: 0; }

.info-item i {
  color: #1a6bb5;
  font-size: 1em;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.info-item b {
  display: block;
  color: #1b3a5c;
  font-size: 0.9em;
}

.info-item span { color: #4a5568; }

/* Таблица паспортного стола */
.passport-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  margin-bottom: 12px;
}

.passport-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #eef1f5;
  vertical-align: top;
}

.passport-table .table-header td {
  background: #f4f7fb;
  color: #1b3a5c;
  text-align: center;
  border-bottom: 2px solid #d5e0ec;
}

.passport-table tr:last-child td { border-bottom: none; }

/* Карта */
.map-container iframe {
  width: 100%;
  height: 220px;
  border: 0;
  border-radius: 6px;
}

/* Информеры */
.informer-wrapper {
  padding: 12px !important;
  overflow: hidden;
}

.informer-wrapper iframe {
  width: 100%;
  border: 0;
  display: block;
}

/* ==========================================================================
   Основной контент
   ========================================================================== */
.main-content {
  background: #ffffff;
  border-radius: 8px;
  padding: 25px 28px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  min-width: 0;
}

.page-title {
  margin-bottom: 22px;
  padding-bottom: 15px;
  border-bottom: 2px solid #eef1f5;
}

.page-title h1 { margin-bottom: 8px; }

.subtitle {
  color: #6b7785;
  font-size: 0.92em;
  margin: 0;
}

.director-info {
  margin-top: 10px;
  font-size: 0.95em;
  color: #2c2c2c;
}

.hero-image {
  margin: 0 0 22px;
  border-radius: 8px;
  overflow: hidden;
}

.hero-image img {
  width: 100%;
  border-radius: 8px;
}

.content-section p.indent {
  text-indent: 28px;
  text-align: justify;
}

.content-section h2 {
  margin-top: 28px;
  padding-left: 12px;
  border-left: 4px solid #1a6bb5;
}

.content-section ul {
  padding-left: 24px;
}

.content-section ul li {
  position: relative;
  padding-left: 6px;
}

/* ==========================================================================
   Таблица контактов
   ========================================================================== */
/* === Таблица контактов === */
.contacts-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    margin: 0 0 30px;
    font-size: 0.94rem;
    background: #fff;
}
.contacts-table thead th {
    background: linear-gradient(135deg, #0dcaf0, #0891b2);
    color: #fff;
    padding: 14px 12px;
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
    border: none;
    letter-spacing: 0.3px;
}
.contacts-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #e9ecef;
    color: #212529;
    vertical-align: middle;
    line-height: 1.5;
}
.contacts-table tbody tr:nth-child(even) td {
    background: #f0fbff;
}
.contacts-table tbody tr:last-child td {
    border-bottom: none;
}
.contacts-table tbody tr:hover td {
    background: #fff8e1;
}
.contacts-table tbody td:first-child {
    text-align: center;
    font-weight: 600;
    color: #0891b2;
    width: 60px;
}
.contacts-table tbody td.post {
    font-weight: 600;
    color: #0a2540;
}
.contacts-table tbody td a {
    color: #0891b2;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
    white-space: nowrap;
}
.contacts-table tbody td a:hover {
    color: #0dcaf0;
    text-decoration: underline;
}

/* Строки-заголовки разделов (например «5. Бухгалтерия») */
.contacts-table tbody tr.group-title td {
    background: linear-gradient(135deg, #e0f7ff 0%, #d2effc 100%) !important;
    color: #0a2540;
    font-weight: 700;
    font-size: 1rem;
    padding: 12px 16px;
    border-left: 4px solid #0dcaf0;
    letter-spacing: 0.3px;
}

/* === Адаптив === */
@media (max-width: 900px) {
    .contacts-table { font-size: 0.88rem; }
    .contacts-table thead th,
    .contacts-table tbody td { padding: 10px 9px; }
}

@media (max-width: 768px) {
    /* Преобразование таблицы в карточки */
    .contacts-table,
    .contacts-table thead,
    .contacts-table tbody,
    .contacts-table tr,
    .contacts-table th,
    .contacts-table td {
        display: block;
        width: 100%;
    }

    .contacts-table thead { display: none; }

    .contacts-table {
        box-shadow: none;
        border-radius: 0;
        background: transparent;
        font-size: 0.92rem;
        margin: 0 0 20px;
    }

    /* Строка-заголовок раздела */
    .contacts-table tbody tr.group-title {
        background: transparent;
        margin-top: 15px;
    }
    .contacts-table tbody tr.group-title td {
        border-radius: 10px;
        border-left: 4px solid #0dcaf0;
        padding: 12px 14px;
    }

    /* Обычная строка-карточка */
    .contacts-table tbody tr {
        background: #fff;
        border-left: 4px solid #0dcaf0;
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 12px 14px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    }

    .contacts-table tbody td {
        padding: 6px 0;
        border-bottom: none;
        background: transparent !important;
        display: flex;
        align-items: flex-start;
        gap: 8px;
        text-align: left;
        word-break: break-word;
    }

    /* Подписи полей через data-label */
    .contacts-table tbody td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        color: #0891b2;
        flex-shrink: 0;
        min-width: 82px;
    }

    /* Ячейка с номером — в виде плашки */
    .contacts-table tbody td:first-child {
        display: inline-block;
        background: linear-gradient(135deg, #0dcaf0, #0891b2) !important;
        color: #fff;
        font-weight: 600;
        padding: 3px 12px;
        border-radius: 20px;
        margin-bottom: 8px;
        width: auto;
        font-size: 0.8rem;
    }

    /* Если у ячейки с номером тоже есть data-label — не показывать подпись */
    .contacts-table tbody td:first-child[data-label]::before {
        content: none;
    }

    /* Ссылки переносятся нормально */
    .contacts-table tbody td a {
        white-space: normal;
        word-break: break-word;
    }
}

/* ==========================================================================
   Новости
   ========================================================================== */
.news-list { margin-top: 10px; }

.news-year {
  font-size: 1.5em;
  color: #1b3a5c;
  margin: 30px 0 20px;
  padding: 10px 0 10px 15px;
  border-left: 5px solid #1a6bb5;
  background: linear-gradient(90deg, #f4f7fb 0%, transparent 100%);
  border-radius: 0 6px 6px 0;
}

.news-year:first-child { margin-top: 0; }

.news-item {
  background: #fafbfd;
  border: 1px solid #e8eef5;
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 15px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.news-item:hover {
  box-shadow: 0 4px 14px rgba(26, 107, 181, 0.12);
  transform: translateY(-2px);
}

.news-date {
  display: inline-block;
  font-size: 0.8em;
  color: #ffffff;
  background: #1a6bb5;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 10px;
  font-weight: 500;
}

.news-title {
  font-size: 1.1em;
  color: #1b3a5c;
  margin: 0 0 10px;
  line-height: 1.35;
}

.news-excerpt p {
  font-size: 0.92em;
  color: #4a5568;
  line-height: 1.55;
  margin-bottom: 8px;
  text-align: justify;
}

.news-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.9em;
  font-weight: 600;
  color: #1a6bb5;
  text-decoration: none;
  transition: color 0.2s ease, transform 0.2s ease;
}

.news-link:hover {
  color: #0d4a86;
  text-decoration: none;
}

.news-link i {
  margin-left: 5px;
  transition: transform 0.2s ease;
}

.news-link:hover i { transform: translateX(3px); }

/* ==========================================================================
   Баннеры в правом сайдбаре
   ========================================================================== */
.right-side-banners {
  display: grid;
  gap: 10px;
}

.banner-item {
  display: block;
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.banner-item img {
  width: 100%;
  display: block;
}

.banner-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Подвал
   ========================================================================== */
.site-footer {
  background: #1b3a5c;
  color: #d4e0ec;
  margin-top: 30px;
  padding: 22px 0;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.footer-copyright {
  font-size: 0.9em;
}

.footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-links a {
  color: #d4e0ec;
  font-size: 0.9em;
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: #ffffff;
  text-decoration: none;
}

.footer-links i { margin-right: 5px; }

/* ==========================================================================
   Кнопка для слабовидящих
   ========================================================================== */
#specialButton {
  position: fixed;
  right: 15px;
  bottom: 20px;
  z-index: 9999;
  background: #ffffff;
  border-radius: 50%;
  padding: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease;
}

#specialButton:hover { transform: scale(1.08); }

#specialButton img {
  width: 34px;
  height: 34px;
}

/* ==========================================================================
   Адаптивность
   ========================================================================== */

/* Планшет — 1024px */
@media (max-width: 1024px) {
  .content-wrapper {
    grid-template-columns: 240px 1fr;
  }

  .sidebar.right {
    grid-column: 1 / -1;
  }

  .sidebar.right .widget {
    margin-bottom: 0;
  }

  .right-side-banners {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* Мобильные — 768px */
@media (max-width: 768px) {
  body { font-size: 14px; }

  .header-top {
    flex-wrap: wrap;
    gap: 10px;
  }

  .logo-text { font-size: 1em; }

  .menu-toggle { display: block; }

  .main-nav {
    display: none;
    border-radius: 8px;
    margin-top: 10px;
  }

  .main-nav.is-open {
    display: block;
  }

  .nav-list {
    flex-direction: column;
  }

  .nav-list > li > a {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    white-space: normal;
  }

  .nav-list ul {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: #16314d;
    border-radius: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .nav-list > li.is-expanded > ul {
    max-height: 500px;
  }

  .nav-list ul li a {
    color: #c8d8e8;
    padding: 10px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }

  .nav-list ul li a:hover,
  .nav-list ul li a.active {
    background: #0d4a86;
    color: #ffffff;
  }

  /* ============================================================
     ГЛАВНОЕ ИЗМЕНЕНИЕ: центральный контент — ПЕРВЫМ
     ============================================================ */
  .content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 15px 0;
  }

  .main-content {
    order: 1;            /* Центральный контент — сверху */
    padding: 18px 15px;
  }

  .sidebar.left {
    order: 2;            /* Левый сайдбар — после контента */
    width: 100%;
  }

  .sidebar.right {
    order: 3;            /* Правый сайдбар — в конце */
    width: 100%;
  }

  /* Карта, Gismeteo и myfin на мобильных — скрываем или переносим вниз */
  .sidebar.left .map-container,
  .sidebar.left .informer-wrapper {
    /* Оставляем, но они теперь идут после контента */
  }

  .contacts-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.85em;
  }

  .contacts-table thead th,
  .contacts-table tbody td {
    padding: 8px 6px;
  }

  .hero-image img { border-radius: 6px; }

  .news-item { padding: 14px 15px; }

  .news-year { font-size: 1.3em; }

  .footer-content {
    flex-direction: column;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }

  #specialButton img {
    width: 28px;
    height: 28px;
  }
}

/* Очень узкие экраны — 480px */
@media (max-width: 480px) {
  .logo-area img {
    width: 45px;
    height: 45px;
  }

  .logo-text span { display: none; }

  .lang-switcher { font-size: 0.8em; padding: 5px 8px; }

  .page-title h1 { font-size: 1.4em; }

  h2 { font-size: 1.2em; }

  .right-side-banners {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================================================
   Печать
   ========================================================================== */
@media print {
  .site-header,
  .site-footer,
  .sidebar,
  #specialButton,
  .lang-switcher,
  .menu-toggle {
    display: none !important;
  }

  .content-wrapper {
    display: block;
  }

  .main-content {
    box-shadow: none;
    padding: 0;
  }

  a { color: #000; text-decoration: underline; }
}