:root {
  --bg: #F5F3EC;
  --surface: #FFFFFF;
  --text: #1E2A1A;
  --accent: #2E7D4F;
  --accent-dark: #17472C;
  --neutral: #B7BFB2;
  --shadow: 0 6px 24px rgba(30, 42, 26, 0.08);
  --radius: 14px;
  --ease-in: cubic-bezier(0.4, 0.0, 0.2, 1);
  --ease-hover: cubic-bezier(0.4, 0.0, 1, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { color: var(--text); margin: 0 0 0.5em; letter-spacing: -0.2px; }
h1 { font-size: clamp(26px, 4.5vw, 40px); line-height: 1.15; }
h2 { font-size: clamp(20px, 3vw, 28px); }
h3 { font-size: 18px; }
p { margin: 0 0 1em; }
a { color: var(--accent); }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--neutral);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 16px;
}
.brand-mark { flex: 0 0 auto; }
.brand-name b { color: var(--accent-dark); }
.main-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav-link {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 15px;
}
.nav-link:hover { background: var(--bg); color: var(--accent-dark); }

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 10px;
  text-decoration: none;
  transition: transform 0.15s var(--ease-hover), box-shadow 0.15s var(--ease-hover), background 0.15s var(--ease-hover);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(46, 125, 79, 0.3); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--neutral); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-danger { background: #B4452E; color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }

/* ===== Views / routing ===== */
.view { animation: fadeUp 0.3s var(--ease-in) both; }
[hidden] { display: none !important; }

/* ===== Hero ===== */
.hero {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: center;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 13px;
  color: var(--accent-dark);
  margin-bottom: 12px;
}
.lead { color: #4a5346; font-size: 17px; }
.hero-media .hero-img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  height: auto;
}

/* ===== Sections ===== */
.section {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 20px;
  animation: fadeUp 0.3s var(--ease-in) both;
}
.section-title { text-align: center; }
.section-lead { text-align: center; max-width: 720px; margin: 0 auto 28px; color: #4a5346; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 28px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}
.stat img { margin: 0 auto 8px; }
.stat-num { display: block; font-weight: 700; font-size: 18px; color: var(--accent-dark); }
.stat-label { font-size: 13px; color: #4a5346; }

/* ===== Cards ===== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s var(--ease-hover), box-shadow 0.2s var(--ease-hover);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-img { width: 100%; height: 180px; object-fit: cover; }
.card-body { padding: 18px; }
.card-icon { margin-bottom: 10px; }
.card-body h3 { margin-bottom: 6px; }
.card-body p { color: #4a5346; font-size: 15px; margin: 0; }

/* ===== Lead form ===== */
.lead-form {
  max-width: 560px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius);
  padding: 24px;
}
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; margin-bottom: 6px; }
.req { color: #B4452E; }
input, textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  padding: 11px 12px;
  border: 1px solid var(--neutral);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 16px;
  color: #4a5346;
}
.consent input { width: auto; margin-top: 3px; }
.form-msg { min-height: 20px; margin-top: 10px; font-size: 14px; }
.form-msg.ok { color: var(--accent-dark); }
.form-msg.err { color: #B4452E; }

/* ===== Auth ===== */
.auth-wrap {
  max-width: 420px;
  margin: 60px auto;
  padding: 0 20px;
}
.auth-form {
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
}
.auth-form img { margin: 0 auto 12px; }
.auth-form .field { text-align: left; }
.hint { font-size: 13px; color: #4a5346; }

/* ===== Admin ===== */
#view-admin {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px;
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
}
.admin-sidebar {
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius);
  padding: 16px;
  align-self: start;
}
.sidebar-head { margin-bottom: 16px; }
.admin-user { font-weight: 700; display: block; margin-bottom: 8px; }
.role-label { font-size: 13px; color: #4a5346; display: block; margin-bottom: 4px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
}
.nav-btn:hover { background: var(--bg); }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-btn.active img { filter: brightness(0) invert(1); }

.admin-content { min-width: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  animation: fadeUp 0.25s var(--ease-in) both;
}
.panel h2 { margin-bottom: 14px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-head h2 { margin: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg);
  vertical-align: middle;
  overflow-wrap: anywhere;
}
table.data th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #4a5346;
}
.status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-Новая { background: #eaf4ee; color: var(--accent-dark); }
.status-В-работе { background: #f3ecdd; color: #7a5b1e; }
.status-Завершена, .status-Утверждена { background: #e7eeea; color: #3f5348; }
.status-Отклонена { background: #f6e7e4; color: #B4452E; }
.status-Черновик { background: #ece9e2; color: #6b645a; }
.status-На-утверждении { background: #eef2f6; color: #4a5a6a; }

/* approval of the current version by the client */
.approval-box {
  background: var(--surface);
  border: 1px solid var(--neutral);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 24px;
  align-items: center;
}
.approval-title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.approval-version { font-size: 18px; margin-bottom: 6px; }
.approval-client { color: #4a5346; font-size: 14px; margin-bottom: 6px; }
.approval-status-line { margin-bottom: 6px; }
.approval-updated { color: #4a5346; font-size: 13px; }
.approval-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 0; }
.approval-box .form-msg { grid-column: 1 / -1; margin: 0; }
@media (max-width: 640px) {
  .approval-box { grid-template-columns: 1fr; }
  .approval-actions { width: 100%; }
  .approval-actions .btn { flex: 1 1 100%; }
  /* Таблицы на узких экранах читаемы и прокручиваются внутри карточки,
     не растягивая страницу по горизонтали. */
  table.data { min-width: 560px; }
  table.data th, table.data td { padding: 8px 10px; }
}

.avatar { width: 32px; height: 32px; border-radius: 50%; }

/* charts */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 160px; margin: 20px 0; }
.bar { flex: 1; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 8px; }
.bar-label { font-size: 12px; text-align: center; color: #4a5346; margin-top: 6px; }
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; }

/* notify toggles */
.toggle { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.toggle input { width: auto; }
.toggle .switch { position: relative; width: 44px; height: 24px; }

/* photos */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-top: 16px; }
.photo-card { background: var(--bg); border-radius: 10px; overflow: hidden; border: 1px solid var(--neutral); }
.photo-card img { width: 100%; height: 120px; object-fit: cover; }
.photo-card figcaption { padding: 8px 10px; font-size: 13px; color: #4a5346; }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: #4a5346;
}
.empty img { margin: 0 auto 12px; opacity: 0.7; }

/* footer */
.site-footer {
  border-top: 1px solid var(--neutral);
  background: var(--surface);
  text-align: center;
  padding: 20px;
  font-size: 14px;
  color: #4a5346;
}

/* ===== Animation ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.cards .card { animation: fadeUp 0.3s var(--ease-in) both; }
.cards .card:nth-child(2) { animation-delay: 0.05s; }
.cards .card:nth-child(3) { animation-delay: 0.1s; }
.cards .card:nth-child(4) { animation-delay: 0.15s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  #view-admin { grid-template-columns: 1fr; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-sidebar { align-self: auto; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .cards { grid-template-columns: 1fr; }
}
