* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Montserrat", Arial, sans-serif;
  background: linear-gradient(180deg, #f7fbff 0%, #ffffff 35%);
  color: #1f2a38;
}
.container { width: min(1160px, calc(100% - 32px)); margin: 0 auto; }
.site-header { background: #ffffff; border-bottom: 1px solid #d8ebff; position: sticky; top: 0; z-index: 220; }
.header-inner { display: flex; align-items: center; gap: 16px; padding: 12px 0; }
.logo-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; flex-shrink: 0; }
.logo img { width: 64px; height: 64px; }
.logo strong { font-size: clamp(16px, 2.1vw, 20px); line-height: 1.2; }
.logo-wrap small.editable-region,
.logo small {
  color: #4b6a88;
  display: block;
  font-size: clamp(10px, 1.35vw, 12px);
  line-height: 1.3;
  overflow-wrap: anywhere;
  min-width: 0;
}
.header-phone-wrap { position: relative; display: inline-flex; align-items: center; }
.header-phone {
  color: #0d4f84;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid #c8ddf5;
  background: #eef7ff;
  border-radius: 8px;
  padding: 8px 12px;
}
.header-phone:hover { background: #e1f0ff; }
.main-nav { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.main-nav a, .auth-trigger, .menu-toggle, button {
  border: 1px solid #c8ddf5;
  background: #f7fbff;
  color: #12406d;
  border-radius: 8px;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.main-nav a:hover, .auth-trigger:hover, button:hover { background: #e5f2ff; }
.admin-link { background: #fff7e0 !important; border-color: #ffd778 !important; color: #775400 !important; }
.main-content { padding: 28px 0; min-height: calc(100vh - 190px); }
.admin-page { border: 2px solid #ffd778; border-radius: 14px; padding: 16px; background: #fffdf7; }
h1, h2, h3 { color: #0b3f73; margin-top: 0; }
.hero h1 { font-size: clamp(24px, 4.4vw, 40px); line-height: 1.2; }
.hero { background: linear-gradient(120deg, #00a0e3 0%, #0085c9 45%, #006eb1 100%); color: #fff; border-radius: 14px; padding: 24px; }
.hero strong { color: #ffe08a; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.card { background: #fff; border: 1px solid #dbe9f9; border-radius: 12px; padding: 16px; }
.btn-link {
  display: inline-block;
  text-decoration: none;
  border: 1px solid #c8ddf5;
  background: #f7fbff;
  color: #12406d;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
}
.btn-link:hover { background: #e5f2ff; }
.cta-link {
  background: linear-gradient(120deg, #ffa800 0%, #ffbe2f 100%);
  border-color: #d99300;
  color: #1f2a38;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(255, 168, 0, 0.28);
  cursor: pointer;
}
.cta-link:hover {
  background: linear-gradient(120deg, #ffbc2f 0%, #ffd263 100%);
}
.full-width-block { margin-top: 18px; }
.full-width-block ol { margin: 10px 0 0; padding-left: 20px; }
.full-width-block li { margin: 8px 0; line-height: 1.5; }
.home-wide-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 18px;
  align-items: start;
}
.services-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #dce9f7; border-radius: 10px; overflow: hidden; }
.services-table th, .services-table td { border: 1px solid #e5eff9; padding: 10px; text-align: left; vertical-align: top; }
.services-table th { background: #f2f8ff; }
.services-head { margin-bottom: 16px; }
.services-head p { margin: 0; color: #446281; }
.services-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; margin-bottom: 18px; align-items: start; }
.services-catalog h2, .callback-box h2, .services-price h2 { margin-bottom: 10px; }
.service-filter-label {
  display: block;
  margin: 6px 0 6px;
  color: #1a4f79;
  font-weight: 600;
}
.service-filter-input {
  width: 100%;
  border: 1px solid #c7dbef;
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  margin-bottom: 10px;
}
.service-filter-input:focus {
  outline: none;
  border-color: #57a8eb;
  box-shadow: 0 0 0 3px rgba(87, 168, 235, 0.15);
}
.services-tree {
  border: 1px solid #e3eefb;
  border-radius: 10px;
  background: #fbfdff;
  padding: 10px 12px;
  max-height: 520px;
  overflow: auto;
}
.services-tree summary {
  font-weight: 600;
  color: #104777;
  padding: 4px 0;
}
.services-tree span {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 7px;
  background: #eef6ff;
  color: #1d4f7a;
}
.callback-box p { margin-top: 0; color: #4f6b86; }
.callback-form { display: grid; gap: 8px; }
.callback-form label { font-size: 14px; font-weight: 600; color: #19486f; }
.callback-form input, .callback-form textarea {
  width: 100%;
  border: 1px solid #c7dbef;
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  background: #ffffff;
}
.callback-form input:focus, .callback-form textarea:focus {
  outline: none;
  border-color: #57a8eb;
  box-shadow: 0 0 0 3px rgba(87, 168, 235, 0.15);
}
.callback-form small { color: #5d7891; font-size: 12px; line-height: 1.3; }
.services-price { overflow-x: auto; }
.admin-service-manager { list-style: none; padding-left: 18px; }
.admin-service-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.admin-inline-form { display: inline-flex; gap: 6px; margin: 0; }
.admin-title-form input[type="text"] { min-width: 280px; }
.admin-title-form input[name="service_price"] { min-width: 130px; }
.save-state { min-width: 72px; color: #2f6b2f; font-size: 12px; }
.hit-counter {
  font-size: 12px;
  color: #1a557f;
  background: #eef7ff;
  border: 1px solid #c9def3;
  border-radius: 8px;
  padding: 6px 8px;
}
.admin-root-add { margin: 0 0 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.root-add-btn {
  background: linear-gradient(120deg, #28b446 0%, #41cf61 100%);
  border-color: #1f8f38;
  color: #ffffff;
  font-weight: 700;
}
.stats-chart { display: grid; gap: 8px; }
.stats-item { display: grid; grid-template-columns: minmax(180px, 36%) 1fr auto; gap: 10px; align-items: center; }
.stats-label { color: #0e436f; font-size: 14px; }
.stats-bar-wrap { height: 12px; background: #e9f3ff; border-radius: 999px; overflow: hidden; border: 1px solid #d0e4f8; }
.stats-bar { height: 100%; background: linear-gradient(120deg, #00a0e3 0%, #28b0ef 100%); }
.stats-value { font-weight: 700; color: #15517c; min-width: 28px; text-align: right; }
.branch-add-btn {
  min-width: 34px;
  padding: 7px 10px;
  background: #edf7ff;
  border-color: #9ec7ef;
  color: #0c4a78;
  font-weight: 700;
}
.hidden-add-form { display: none; margin: 4px 0 8px 26px; }
.hidden-add-form.open { display: inline-flex; }
.tree ul { list-style: none; padding-left: 18px; margin: 6px 0; }
.tree li { margin: 6px 0; }
.tree details > summary { cursor: pointer; }
.tree-note { display: flex; align-items: center; gap: 8px; }
.folder::before { content: "+"; display: inline-flex; width: 18px; height: 18px; border: 1px solid #b5cde7; border-radius: 3px; align-items: center; justify-content: center; font-weight: 700; }
details[open] > summary .folder::before { content: "-"; }
.file::before { content: "txt"; font-size: 11px; color: #555; border: 1px solid #c8d8ea; padding: 0 4px; border-radius: 4px; }
.notes-actions { margin: 8px 0 10px 26px; display: grid; gap: 6px; }
.notes-action-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.notes-action-form input {
  border: 1px solid #c3d7ee;
  border-radius: 7px;
  padding: 7px 8px;
  font-family: inherit;
}
.notes-action-form input[name="name"] { min-width: 220px; }
.notes-action-form input[name="content"] { min-width: 260px; }
.modal[hidden]:not(.is-open) { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 1000; display: block; }
body.has-modal-open { overflow: hidden; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(4, 18, 33, 0.55); }
.modal-box { position: relative; width: min(420px, calc(100% - 24px)); margin: 8vh auto; background: #fff; border-radius: 12px; padding: 18px; }
.modal-box--wide { width: min(920px, calc(100% - 24px)); max-height: calc(100vh - 16vh); overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal-close-btn {
  border: 1px solid #c3d7ee;
  background: #f5faff;
  color: #0f4f80;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.modal-box form { display: grid; gap: 10px; }
.modal-box input, textarea {
  width: 100%; border: 1px solid #c3d7ee; border-radius: 8px; padding: 9px; font-family: inherit;
}
.content-edit-form textarea {
  min-height: 320px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.45;
}
.content-edit-hint { margin: 0; font-size: 13px; color: #5a7188; }
.content-edit-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.content-edit-status { margin: 0; min-height: 18px; font-size: 13px; color: #195f2f; }
.content-edit-status.is-error { color: #8a2323; }
.btn-secondary {
  border: 1px solid #c3d7ee;
  background: #f5faff;
  color: #0f4f80;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}
.editable-region { position: relative; }
.edit-block-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  width: 34px;
  height: 34px;
  border: 1px solid #ffd778;
  border-radius: 8px;
  background: #fff7e0;
  color: #775400;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0.92;
}
.edit-block-btn:hover { background: #ffefb8; opacity: 1; }
.hero.editable-region .edit-block-btn { top: 12px; right: 12px; }
.logo-wrap small.editable-region .edit-block-btn,
.header-phone-wrap.editable-region .edit-block-btn {
  top: 50%;
  right: -4px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  font-size: 14px;
}
.logo-wrap small.editable-region,
.header-phone-wrap.editable-region { padding-right: 30px; }
.is-admin .hero,
.is-admin .card.editable-region,
.is-admin .logo-wrap small.editable-region,
.is-admin .header-phone-wrap.editable-region {
  outline: 1px dashed rgba(255, 168, 0, 0.45);
  outline-offset: 2px;
}
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; border: 1px solid transparent; }
.flash.ok { background: #ebffef; border-color: #97d8a8; color: #195f2f; }
.flash.err { background: #fff0f0; border-color: #f2b2b2; color: #8a2323; }
.site-footer { border-top: 1px solid #d8ebff; padding: 18px 0; font-size: 14px; color: #334e69; background: #f9fcff; }
.footer-nav { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.footer-nav a {
  text-decoration: none;
  color: #0f4f80;
  border: 1px solid #c8ddf5;
  background: #eef7ff;
  border-radius: 8px;
  padding: 6px 10px;
}
.footer-nav a:hover { background: #e0f0ff; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .home-wide-grid { grid-template-columns: 1fr; }
  .services-layout { grid-template-columns: 1fr; }
  .header-inner { gap: 10px; }
  .header-inner { flex-wrap: wrap; }
  .logo-wrap { min-width: 0; flex: 1 1 100%; order: 1; }
  .logo { min-width: 0; }
  .logo img { width: 52px; height: 52px; }
  .logo strong { font-size: clamp(14px, 4.8vw, 18px); }
  .logo small { font-size: clamp(9px, 2.8vw, 11px); }
  .hero h1 { font-size: clamp(21px, 7vw, 30px); }
  .header-phone-wrap,
  .header-phone {
    order: 2;
    flex: 1 1 auto;
    margin-left: 0;
  }
  .header-phone {
    text-align: left;
  }
  .menu-toggle { display: inline-block; order: 3; margin-left: auto; }
  .main-nav {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: min(86vw, 320px);
    z-index: 120;
    margin-left: 0;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    background: #ffffff;
    border-right: 1px solid #d8ebff;
    box-shadow: 12px 0 26px rgba(7, 35, 61, 0.15);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .main-nav.open { transform: translateX(0); }
  .main-nav a, .main-nav .auth-trigger { width: 100%; text-align: left; }
  body.menu-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 110;
    background: rgba(4, 18, 33, 0.48);
  }
}
@media (min-width: 901px) {
  .menu-toggle { display: none; }
}
