/* ==========================================================================
   УК «Горизонт» — стили сайта и админки.
   Шрифты системные: внешние подключения (Google Fonts) в РФ часто медленные
   или недоступны и блокируют отрисовку страницы.
   ========================================================================== */

:root {
  --color-bg: #F7F5F0;
  --color-surface: #FFFFFF;
  --color-ink: #1E2B38;
  --color-brand: #2E5266;
  --color-brand-dark: #1E3745;
  --color-accent: #DB9435;
  --color-accent-dark: #B8761E;
  --color-muted: #6B7A87;
  --color-line: #DEDACF;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(30, 55, 69, 0.06);
  --shadow-md: 0 6px 20px rgba(30, 55, 69, 0.10);
  --font-display: 'PT Serif', 'Times New Roman', Georgia, serif;
  --font-body: 'PT Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-ink);
  background: var(--color-bg);
  line-height: 1.6;
  font-size: 16px;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.22;
  margin: 0 0 0.5em;
  color: var(--color-brand-dark);
}
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.4rem); }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
a { color: var(--color-brand); text-underline-offset: 2px; }
a:hover { color: var(--color-accent-dark); }
img, svg, iframe { max-width: 100%; }
code { background: rgba(30,55,69,0.07); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

.muted { color: var(--color-muted); font-size: 0.92rem; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 820px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--color-accent); color: #241703;
  padding: 10px 16px; z-index: 100; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid rgba(219, 148, 53, 0.65); outline-offset: 2px; }

/* --- Верхняя строка ------------------------------------------------------ */
.site-topbar { background: var(--color-brand-dark); color: #E1E9ED; font-size: 0.84rem; }
.topbar-inner {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 20px; flex-wrap: wrap; gap: 4px 16px;
}
.topbar-inner a { color: #fff; text-decoration: none; font-weight: 700; }
.topbar-inner a:hover { color: var(--color-accent); }

/* --- Шапка --------------------------------------------------------------- */
.site-header { background: var(--color-surface); position: sticky; top: 0; z-index: 20; box-shadow: var(--shadow-sm); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; flex-shrink: 0; }
.brand-logo { height: 46px; width: auto; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--font-display); font-size: 1.35rem; color: var(--color-brand-dark); }
.brand-text small { color: var(--color-muted); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }

.main-nav ul { list-style: none; display: flex; gap: 2px; margin: 0; padding: 0; flex-wrap: wrap; }
.main-nav a {
  display: inline-block; padding: 8px 11px; text-decoration: none;
  color: var(--color-ink); border-radius: var(--radius); font-size: 0.94rem;
  transition: background 0.15s ease;
}
.main-nav a:hover { background: var(--color-bg); }
.main-nav a.active { color: var(--color-brand-dark); font-weight: 700; background: var(--color-bg); box-shadow: inset 0 -2px 0 var(--color-accent); }
.nav-toggle { display: none; }

.horizon-line { height: 4px; background: linear-gradient(90deg, var(--color-brand) 0%, var(--color-brand) 55%, var(--color-accent) 100%); }

/* --- Кнопки -------------------------------------------------------------- */
.btn {
  display: inline-block; padding: 10px 18px; border-radius: var(--radius);
  text-decoration: none; font-weight: 700; border: 2px solid transparent;
  cursor: pointer; font-family: var(--font-body); font-size: 0.95rem; line-height: 1.3;
  transition: background 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.6; cursor: default; }
.btn-accent { background: var(--color-accent); color: #2A1B04; }
.btn-accent:hover { background: var(--color-accent-dark); color: #fff; }
.btn-outline { background: transparent; border-color: var(--color-brand); color: var(--color-brand); }
.btn-outline:hover { background: var(--color-brand); color: #fff; }
.btn-ghost { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.6); color: #fff; }
.btn-ghost:hover { background: #fff; color: var(--color-brand-dark); }
.btn-ghost-dark { background: transparent; border-color: var(--color-line); color: var(--color-muted); }
.btn-ghost-dark:hover { background: var(--color-line); color: var(--color-ink); }
.btn-small { padding: 6px 12px; font-size: 0.83rem; }
.btn-danger { background: #C0453A; color: #fff; border-color: #C0453A; }
.btn-danger:hover { background: #9E362D; color: #fff; }
.header-cta { white-space: nowrap; }

/* --- Первый экран -------------------------------------------------------- */
.hero {
  position: relative; overflow: hidden; color: #EDF2F4;
  background:
    radial-gradient(900px 400px at 80% -10%, rgba(219,148,53,0.22), transparent 60%),
    linear-gradient(160deg, #24485B 0%, var(--color-brand-dark) 70%);
}
.hero .wrap { position: relative; z-index: 2; padding: 72px 20px 110px; }
.hero-eyebrow {
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem;
  color: var(--color-accent); margin-bottom: 10px; font-weight: 700;
}
.hero h1 { color: #fff; max-width: 700px; margin-bottom: 14px; }
.hero p.lead { max-width: 620px; font-size: 1.12rem; color: #CFDCE3; }
.hero-actions { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.hero-emergency {
  margin-top: 28px; display: inline-flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,0.22); border: 1px solid rgba(255,255,255,0.16);
  padding: 10px 16px; border-radius: 999px; font-size: 0.95rem;
}
.hero-emergency a { color: #fff; font-weight: 700; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--color-accent); box-shadow: 0 0 0 0 rgba(219,148,53,0.7); animation: pulse 2.2s infinite; }
@keyframes pulse {
  70% { box-shadow: 0 0 0 12px rgba(219,148,53,0); }
  100% { box-shadow: 0 0 0 0 rgba(219,148,53,0); }
}
.hero-skyline { position: absolute; bottom: 0; left: 0; right: 0; height: 90px; z-index: 1; opacity: 0.45; }
.hero-skyline rect { fill: #0F1D26; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pulse { animation: none; }
}

/* --- Секции -------------------------------------------------------------- */
.section { padding: 56px 0; }
.section-alt { background: var(--color-surface); border-top: 1px solid var(--color-line); border-bottom: 1px solid var(--color-line); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-cta { background: var(--color-brand); color: #fff; }
.section-cta h2 { color: #fff; }
.cta-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.cta-inner p { margin: 0; color: #D5E2E9; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 24px; }
.card-grid.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card {
  background: var(--color-surface); border: 1px solid var(--color-line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm);
}
.card h3 { margin-bottom: 8px; }
.card p:last-child { margin-bottom: 0; }
a.card { display: block; color: inherit; transition: box-shadow 0.15s ease, transform 0.05s ease; }
a.card:hover { box-shadow: var(--shadow-md); border-color: var(--color-brand); }
a.card h3 { color: var(--color-brand-dark); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px; margin-top: 8px; }
.stat { text-align: center; padding: 16px 8px; background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius); }
.stat .num { font-family: var(--font-display); font-size: 2.1rem; color: var(--color-brand); display: block; line-height: 1.1; }
.stat .label { color: var(--color-muted); font-size: 0.88rem; }

.prose h3 { margin-top: 1.4em; }
.prose ul { padding-left: 22px; }
.prose li { margin-bottom: 6px; }

.checklist { padding-left: 20px; margin: 0; }
.checklist li { margin-bottom: 8px; }

/* --- Таблицы ------------------------------------------------------------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; margin: 16px 0; background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--color-line); vertical-align: top; }
th { background: var(--color-bg); font-family: var(--font-display); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FBFAF7; }
.cell-message { max-width: 320px; }

/* --- Формы --------------------------------------------------------------- */
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 0.92rem; }
.form-field p.muted { margin: 6px 0 0; }
.form-field input, .form-field textarea, .form-field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--color-line);
  border-radius: var(--radius); font-family: var(--font-body); font-size: 1rem;
  background: var(--color-surface); color: var(--color-ink);
}
.form-field textarea { resize: vertical; min-height: 90px; }
.form-field input:focus, .form-field textarea:focus, .form-field select:focus {
  outline: none; border-color: var(--color-brand); box-shadow: 0 0 0 3px rgba(46,82,102,0.18);
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.inline-form { display: flex; gap: 6px; align-items: center; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; align-items: center; }
.filter-bar input, .filter-bar select { padding: 9px 12px; border: 1px solid var(--color-line); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.95rem; background: var(--color-surface); }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.alert { padding: 14px 16px; border-radius: var(--radius); margin: 16px 0; }
.alert-success { background: #E4F1E7; color: #245A34; border: 1px solid #B7DCC0; }
.alert-error { background: #FBE7E4; color: #7A2A20; border: 1px solid #F0BFB6; }
.alert-info { background: #E7EFF4; color: #244A5E; border: 1px solid #BFD6E2; }
.alert code { background: rgba(0,0,0,0.06); }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 24px 0; flex-wrap: wrap; }

/* --- Новости и документы ------------------------------------------------- */
.news-date { color: var(--color-accent-dark); font-weight: 700; font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; }
.news-body p:last-child { margin-bottom: 0; }

/* Список новостей — карточки */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 22px; margin-top: 24px; }
.news-card {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s ease, transform 0.05s ease;
}
.news-card:hover { box-shadow: var(--shadow-md); }
.news-card-img { display: block; height: 160px; background-size: cover; background-position: center; background-color: var(--color-bg); }
.news-card-img-placeholder { background-image: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%); }
.news-card-body { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px 20px; flex: 1; }
.news-card-title { font-family: var(--font-display); font-size: 1.08rem; color: var(--color-brand-dark); line-height: 1.3; }
.news-card-excerpt { color: var(--color-muted); font-size: 0.92rem; flex: 1; }
.news-card-more { color: var(--color-brand); font-weight: 700; font-size: 0.88rem; margin-top: 4px; }
.news-card:hover .news-card-more { color: var(--color-accent-dark); }

/* Отдельная страница новости */
.news-article-cover { width: 100%; max-height: 420px; object-fit: cover; border-radius: var(--radius); margin: 16px 0 24px; display: block; }

/* Слайдер новостей на главной — без JS, на CSS scroll-snap */
.news-slider-wrap { margin-top: 24px; }
.news-slider {
  display: flex; gap: 18px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  padding-bottom: 8px; -webkit-overflow-scrolling: touch;
}
.news-slider::-webkit-scrollbar { height: 8px; }
.news-slider::-webkit-scrollbar-thumb { background: var(--color-line); border-radius: 4px; }
.news-slide {
  scroll-snap-align: start; scroll-margin-left: 4px;
  flex: 0 0 300px; display: flex; flex-direction: column; text-decoration: none; color: inherit;
  background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.news-slide-img { display: block; height: 150px; background-size: cover; background-position: center; background-color: var(--color-bg); }
.news-slide-img-placeholder { background-image: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%); }
.news-slide-body { display: flex; flex-direction: column; gap: 5px; padding: 14px 16px 18px; }
.news-slide-title { font-family: var(--font-display); font-size: 1rem; color: var(--color-brand-dark); line-height: 1.3; }
.news-slide-excerpt { color: var(--color-muted); font-size: 0.88rem; }
.news-slider-nav { display: flex; gap: 8px; justify-content: center; margin-top: 14px; }
.news-slider-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-line); display: inline-block; }
.news-slider-dot:hover { background: var(--color-accent); }

@media (max-width: 640px) {
  .news-slide { flex-basis: 82vw; }
}

.doc-list { list-style: none; padding: 0; margin: 20px 0 0; }
.doc-list li { border-bottom: 1px solid var(--color-line); }
.doc-list li:last-child { border-bottom: none; }
.doc-link { display: flex; gap: 14px; align-items: center; padding: 14px 6px; text-decoration: none; color: var(--color-ink); border-radius: var(--radius); }
.doc-link:hover { background: var(--color-surface); }
.doc-link .doc-title { display: block; font-weight: 700; color: var(--color-brand); }
.doc-link .muted { display: block; font-size: 0.85rem; }
.doc-icon {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 6px;
  background: #C0453A; color: #fff; font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; letter-spacing: 0.05em;
}

.map-frame { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-line); line-height: 0; }

/* --- Ошибки -------------------------------------------------------------- */
.error-screen { max-width: 640px; margin: 80px auto; padding: 32px; text-align: center; background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius); }
.error-code { font-family: var(--font-display); font-size: 4rem; color: var(--color-accent); margin: 0; line-height: 1; }

/* --- Подвал -------------------------------------------------------------- */
.site-footer { background: var(--color-brand-dark); color: #C4D0D6; }
.footer-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 28px; padding: 42px 20px; }
.footer-col strong { color: #fff; display: block; margin-bottom: 10px; font-family: var(--font-display); font-size: 1.05rem; }
.footer-col a { color: #fff; }
.footer-col a:hover { color: var(--color-accent); }
.footer-nav { list-style: none; padding: 0; margin: 0; }
.footer-nav li { margin-bottom: 6px; }
.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.12); padding: 16px 20px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 0.85rem;
}
.footer-bottom a { color: #C4D0D6; }

/* --- Админка ------------------------------------------------------------- */
.admin-body { background: var(--color-bg); font-family: var(--font-body); }
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 230px; background: var(--color-brand-dark); color: #EDF2F4; padding: 22px 0; flex-shrink: 0; }
.admin-brand { padding: 0 20px 6px; font-family: var(--font-display); font-size: 1.25rem; color: #fff; }
.admin-brand small { display: block; font-family: var(--font-body); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: #92A7B2; }
.admin-sidebar ul { list-style: none; margin: 18px 0 0; padding: 0; }
.admin-sidebar a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 20px; color: #C4D0D6; text-decoration: none; border-left: 3px solid transparent;
}
.admin-sidebar a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.admin-sidebar a.active { background: rgba(255,255,255,0.10); color: #fff; border-left-color: var(--color-accent); font-weight: 700; }
.sidebar-count { background: var(--color-accent); color: #2A1B04; border-radius: 999px; padding: 1px 8px; font-size: 0.75rem; font-weight: 700; }
.admin-main { flex: 1; padding: 28px 32px; min-width: 0; }
.admin-topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-bottom: 26px; padding-bottom: 14px; border-bottom: 1px solid var(--color-line); flex-wrap: wrap;
}
.admin-topbar-links { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.92rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
.admin-login { width: 100%; max-width: 380px; background: var(--color-surface); padding: 32px; border-radius: var(--radius); border: 1px solid var(--color-line); box-shadow: var(--shadow-md); }
.admin-login-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.admin-login-head h1 { font-size: 1.3rem; margin: 0; }

.admin-thumb { display: block; width: 52px; height: 40px; border-radius: 6px; background-size: cover; background-position: center; background-color: var(--color-bg); border: 1px solid var(--color-line); }
.admin-thumb-empty { background-image: linear-gradient(135deg, var(--color-brand) 0%, var(--color-brand-dark) 100%); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.gallery-item { display: flex; flex-direction: column; gap: 6px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.badge-new { background: #FDEBD3; color: #8A5A0F; }
.badge-progress { background: #DCE7F0; color: #274C6B; }
.badge-done { background: #E1EFE3; color: #2A6338; }
.actions-row { display: flex; gap: 8px; align-items: center; }

/* --- Адаптив ------------------------------------------------------------- */
@media (max-width: 900px) {
  .nav-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--color-bg); border: 1px solid var(--color-line);
    border-radius: var(--radius); padding: 9px 14px; font-family: var(--font-body);
    font-size: 0.95rem; font-weight: 700; color: var(--color-ink); cursor: pointer;
  }
  .nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
    display: block; width: 18px; height: 2px; background: var(--color-brand-dark); position: relative;
  }
  .nav-toggle-bars::before, .nav-toggle-bars::after { content: ''; position: absolute; left: 0; }
  .nav-toggle-bars::before { top: -6px; }
  .nav-toggle-bars::after { top: 6px; }
  .main-nav { position: static; }
  .main-nav ul {
    display: none; flex-direction: column; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--color-surface); border-top: 1px solid var(--color-line);
    padding: 10px 20px; z-index: 30; box-shadow: var(--shadow-md);
  }
  .main-nav ul.open { display: flex; }
  .site-header { position: relative; }
  .header-cta { display: none; }
  .topbar-inner { font-size: 0.8rem; }

  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: 100%; padding: 14px 0; }
  .admin-sidebar ul { display: flex; flex-wrap: wrap; margin-top: 10px; }
  .admin-sidebar a { border-left: none; border-bottom: 3px solid transparent; padding: 8px 14px; }
  .admin-sidebar a.active { border-left: none; border-bottom-color: var(--color-accent); }
  .admin-main { padding: 20px 16px; }
}

/* Таблицы на телефоне — карточками, чтобы не ломать вёрстку */
@media (max-width: 640px) {
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; left: -9999px; }
  table { border: none; background: transparent; }
  tbody tr {
    background: var(--color-surface); border: 1px solid var(--color-line);
    border-radius: var(--radius); margin-bottom: 12px; padding: 6px 4px;
  }
  td { border-bottom: 1px dashed var(--color-line); padding: 8px 12px; }
  tr td:last-child { border-bottom: none; }
  td[data-label]::before {
    content: attr(data-label) ': ';
    font-weight: 700; color: var(--color-muted); font-size: 0.82rem;
  }
  .cell-message { max-width: none; }
}
