/* ==========================================================================
   StroyIngWWW — витрина + портал регистрации СтройИнж.
   Фирменные токены и компоненты из рабочего StroyIng (палитра #2a78d6/#eda100,
   зонирование .modal-section/.sect-*), плюс маркетинговые блоки витрины.
   Тёмная тема — по data-bs-theme="dark" (правило КИТ).
   ========================================================================== */
:root {
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --border:         rgba(11,11,11,0.10);
  --modal-surface:  #eef0f3;
  --modal-ring:     rgba(60,60,60,0.45);

  --slot-blue:    #2a78d6;
  --slot-aqua:    #1baf7a;
  --slot-yellow:  #eda100;
  --slot-green:   #008300;
  --slot-violet:  #4a3aa7;
  --slot-red:     #e34948;

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;

  --accent: #2a78d6;
  --accent-glow: rgba(42,120,214,0.35);
}
[data-bs-theme="dark"] {
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --border:         rgba(255,255,255,0.10);
  --modal-surface:  #26261f;
  --modal-ring:     rgba(180,180,180,0.45);

  --slot-blue:    #3987e5;
  --slot-aqua:    #199e70;
  --slot-yellow:  #c98500;
  --slot-green:   #008300;
  --slot-violet:  #9085e9;
  --slot-red:     #e66767;
  --accent: #3987e5;
  --accent-glow: rgba(57,135,229,0.40);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* -------------------------------------------------------------- шапка */
.topbar { background: var(--surface-1); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none; color: var(--text-primary); }
.brand-logo { display: block; flex: none; object-fit: contain; }
.brand-name .b-1 { color: var(--accent); }
.brand-name .b-2 { color: var(--slot-yellow); }
.brand .app-version { margin-left: 8px; font-size: 11px; font-weight: 500; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.nav-links { display: flex; gap: 4px; margin-left: 4px; }
.nav-links a { color: var(--text-secondary); text-decoration: none; font-size: 13.5px; font-weight: 500; padding: 7px 12px; border-radius: 8px; transition: background .12s, color .12s; }
.nav-links a:hover { background: var(--page-plane); color: var(--text-primary); }
.nav-links a.active { background: var(--accent); color: #fff; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar-user .user-name { color: var(--text-secondary); font-weight: 500; text-decoration: none; }
a.user-name:hover { color: var(--accent); }
.topbar-user .logout-link { color: var(--text-secondary); text-decoration: none; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; }
.topbar-user .logout-link:hover { color: var(--text-primary); background: var(--page-plane); }

main { max-width: 1120px; width: 100%; margin: 0 auto; padding: 28px 24px 56px; flex: 1 0 auto; }

/* -------------------------------------------------------------- flash */
.flash-messages { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash { background: rgba(42,120,214,.10); border: 1px solid var(--accent); color: var(--text-primary); border-radius: 8px; padding: 10px 14px; font-size: 13px; word-break: break-word; }

/* -------------------------------------------------------------- кнопки */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-size: 13.5px; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--border); }
.btn.secondary:hover { border-color: var(--accent); }
.btn.danger { background: #c62828; }
.btn.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-mini { border: none; border-radius: 6px; color: #fff; cursor: pointer; font-size: 11px; line-height: 1.4; padding: 3px 9px; }
.btn-mini.icon-start { background: #2e7d32; }
.btn-mini.icon-stop { background: #c62828; }

/* -------------------------------------------------------------- зонирование */
.modal-section { border: 1.5px solid var(--sect-border, rgba(42,120,214,.7)); border-radius: 12px; background: var(--sect-bg, rgba(42,120,214,.06)); padding: 16px 18px; margin-bottom: 18px; }
.modal-section > .modal-section-head { font-weight: 700; font-size: 12.5px; letter-spacing: .02em; text-transform: uppercase; color: var(--sect-border); margin: 0 0 10px; }
.modal-section.sect-blue  { --sect-border: rgba(42,120,214,.70); --sect-bg: rgba(42,120,214,.055); }
.modal-section.sect-green { --sect-border: rgba(25,135,84,.72);  --sect-bg: rgba(25,135,84,.06); }
.modal-section.sect-amber { --sect-border: rgba(214,151,28,.85); --sect-bg: rgba(237,161,0,.09); }
.modal-section.sect-slate { --sect-border: rgba(90,110,140,.78); --sect-bg: rgba(109,127,150,.07); }
[data-bs-theme="dark"] .modal-section.sect-blue  { --sect-border: rgba(90,150,255,.75); --sect-bg: rgba(42,120,214,.14); }
[data-bs-theme="dark"] .modal-section.sect-green { --sect-border: rgba(80,210,150,.70); --sect-bg: rgba(25,135,84,.16); }
[data-bs-theme="dark"] .modal-section.sect-amber { --sect-border: rgba(255,205,90,.75); --sect-bg: rgba(237,161,0,.13); }
[data-bs-theme="dark"] .modal-section.sect-slate { --sect-border: rgba(170,190,215,.70); --sect-bg: rgba(109,127,150,.16); }

/* -------------------------------------------------------------- бейджи */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid var(--border); color: var(--text-secondary); }
.badge-blue   { color: var(--slot-blue);   border-color: var(--slot-blue);   background: rgba(42,120,214,.10); }
.badge-yellow { color: var(--slot-yellow); border-color: var(--slot-yellow); background: rgba(237,161,0,.12); }
.badge-green  { color: var(--slot-green);  border-color: var(--slot-green);  background: rgba(0,131,0,.10); }

/* -------------------------------------------------------------- таблицы */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; font-weight: 600; margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.table-wrap { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; padding: 8px 10px; box-shadow: inset 0 -1px 0 var(--gridline); }
.data-table tbody td { padding: 9px 10px; border-bottom: 1px solid var(--gridline); vertical-align: top; }
.data-table tbody tr:hover td { background: rgba(42,120,214,.05); }
.line-date { color: var(--text-muted); font-size: 11.5px; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; word-break: break-all; }
.cell-nolink { white-space: nowrap; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 22px; }
.card-kv { font-size: 13.5px; }
.card-kv > span { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .02em; color: var(--text-muted); }

/* -------------------------------------------------------------- формы */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-secondary); }
.field input[type="text"], .field input[type="password"], .field .select, .field select {
  width: 100%; max-width: 560px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-size: 13.5px; color: var(--text-primary); }
.field input:focus, .field .select:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.field.checkboxes { display: flex; gap: 20px; }
.field.checkboxes label { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text-primary); }
.form-actions { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.muted { color: var(--text-muted); font-size: 13px; }
.perm-flag { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.perm-flag input { accent-color: var(--accent); }
/* подписи слева (правило Кит) */
.settings-form .field { display: flex; align-items: center; gap: 14px; }
.settings-form .field label { min-width: 200px; margin-bottom: 0; white-space: nowrap; }
.settings-form .field input { flex: 1 1 auto; max-width: 420px; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.filter-bar label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); }

/* спиннер */
.spinner { width: 16px; height: 16px; flex: 0 0 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wait-row { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--text-secondary); }

/* модалка подтверждения */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--modal-surface); border: 1px solid var(--modal-ring); border-radius: 10px; width: 480px; max-width: 100%; box-shadow: 0 16px 48px rgba(0,0,0,.5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 2px 7px; border-radius: 6px; }
.confirm-text { padding: 2px 16px 0; font-size: 13.5px; line-height: 1.55; white-space: pre-line; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 16px; }

/* ==========================================================================
   ВИТРИНА
   ========================================================================== */
.section-title { font-size: 26px; font-weight: 700; margin: 0 0 6px; text-align: center; }
.section-lead { color: var(--text-secondary); font-size: 15px; margin: 0 auto 22px; text-align: center; max-width: 720px; }
.wide { margin: 40px 0; }
.center-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }

/* герой */
.hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 32px; align-items: center; padding: 24px 0 8px; }
.hero-art { min-width: 0; }
.site-svg { width: 100%; height: auto; display: block; border-radius: 16px; box-shadow: 0 8px 30px rgba(20,40,70,.12); }
.load-group { animation: load-lift 4s ease-in-out infinite; transform-origin: 510px 96px; }
@keyframes load-lift { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-16px) rotate(-1.2deg); } }
@media (prefers-reduced-motion: reduce) { .load-group { animation: none; } }
[data-bs-theme="dark"] .site-svg { --sky-top:#1b2a3d; --sky-bot:#243447; }
[data-bs-theme="dark"] .site-svg circle[fill="#ffd54a"] { opacity: .6; }
.hero-cta { min-width: 0; }
.free-badge { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--slot-green); background: rgba(0,131,0,.10); border: 1px solid rgba(0,131,0,.35); border-radius: 999px; padding: 4px 12px; margin-bottom: 12px; }
.hero-title { font-size: 3rem; margin: 0; letter-spacing: .5px; line-height: 1.05; }
.hero-title .b-1 { color: var(--accent); }
.hero-title .b-2 { color: var(--slot-yellow); }
.hero-sub { font-size: 1.2rem; color: var(--text-secondary); margin: .2em 0 .6em; }
.hero-lead { font-size: 15px; color: var(--text-secondary); line-height: 1.55; margin: 0 0 20px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-btn { font-size: 15px; padding: 11px 22px; }

/* сетка возможностей */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.feature-card { display: block; text-decoration: none; color: inherit; border-radius: 14px; padding: 18px 18px 16px; border: 1.5px solid var(--sect-border, var(--border)); background: var(--sect-bg, var(--surface-1)); transition: transform .12s, box-shadow .12s; }
.feature-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(20,40,70,.12); }
.feature-card .fc-ico { font-size: 30px; margin-bottom: 6px; }
.feature-card h3 { margin: 0 0 6px; font-size: 17px; }
.feature-card p { margin: 0; color: var(--text-secondary); font-size: 13.5px; line-height: 1.5; }

/* шаги «как начать» */
.steps-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.step-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 20px; position: relative; }
.step-no { width: 38px; height: 38px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.step-card h3 { margin: 0 0 6px; font-size: 17px; }
.step-card p { margin: 0; color: var(--text-secondary); font-size: 13.5px; }

/* скриншоты */
.shot { margin: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-1); box-shadow: 0 6px 20px rgba(20,40,70,.08); }
.shot img { display: block; width: 100%; height: auto; }
.shot figcaption { padding: 10px 14px; font-size: 12.5px; color: var(--text-secondary); border-top: 1px solid var(--border); }
.shot.shot-lg { max-width: 900px; margin: 0 auto; }
/* заглушка, если скриншот ещё не снят (onerror) */
.shot.missing img { display: none; }
.shot.missing { position: relative; }
.shot.missing::before { content: "📷  " attr(data-cap); display: block; padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13px; background: repeating-linear-gradient(45deg, rgba(42,120,214,.04), rgba(42,120,214,.04) 12px, transparent 12px, transparent 24px); border-bottom: 1px solid var(--border); }

/* страница-заголовок раздела */
.page-hero { text-align: center; padding: 18px 0 26px; }
.page-hero h1 { font-size: 32px; margin: 0 0 10px; }

/* блоки возможностей (features) */
.feature-block { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: center; padding: 28px 0; border-top: 1px solid var(--gridline); scroll-margin-top: 70px; }
.feature-block .fb-text { min-width: 0; }
.fb-tag { display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); background: rgba(42,120,214,.10); border-radius: 999px; padding: 3px 10px; margin-bottom: 8px; }
.feature-block h2 { font-size: 24px; margin: 0 0 10px; }
.feature-block p { color: var(--text-secondary); font-size: 14.5px; line-height: 1.6; }
.fb-list { margin: 10px 0 0; padding-left: 20px; color: var(--text-secondary); font-size: 13.5px; }
.fb-list li { margin: 5px 0; }
.feature-block .shot { grid-column: 2; }
.feature-block.alt .fb-text { order: 2; }
.feature-block.alt .shot { grid-column: 1; order: 1; }
.feature-block .shot + .shot { margin-top: 14px; }
.cta-strip { text-align: center; background: var(--surface-1); border: 1px solid var(--border); border-radius: 16px; padding: 32px 20px; }

/* обучение */
.toc { margin: 0; padding-left: 22px; columns: 2; }
.toc li { margin: 4px 0; }
.toc a { color: var(--accent); text-decoration: none; }
.lesson { padding: 26px 0; border-top: 1px solid var(--gridline); scroll-margin-top: 70px; }
.lesson-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.lesson-no { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--slot-yellow); color: #3a2c00; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.lesson-head h2 { margin: 0; font-size: 21px; }
.lesson-body { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: center; }
.lesson-body .lesson-text { min-width: 0; }
.lesson.alt .lesson-text { order: 2; }
.lesson-text p { color: var(--text-secondary); font-size: 14.5px; line-height: 1.6; }
code { background: rgba(42,120,214,.10); border-radius: 5px; padding: 1px 6px; font-family: ui-monospace, Consolas, monospace; font-size: .92em; }

/* ==========================================================================
   ПОРТАЛ (регистрация/вход/кабинет)
   ========================================================================== */
.auth-hero, .auth-wrap { text-align: center; }
.auth-hero h1 { font-size: 30px; margin: 6px 0 8px; }
.auth-wrap { display: flex; justify-content: center; padding: 20px 0; }
.auth-box { background: var(--surface-1); border: 1.5px solid rgba(42,120,214,.4); border-radius: 14px; padding: 26px 28px; width: 520px; max-width: 100%; text-align: left; }
.auth-title { margin: 0 0 16px; font-size: 22px; }
.auth-title small { color: var(--text-muted); font-size: 13px; font-weight: 400; }
.auth-form .field input { max-width: none; }
.auth-form .modal-section { margin-bottom: 14px; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.choice-card { text-align: center; }
.choice-card .choice-ico { font-size: 40px; margin-bottom: 6px; }
.choice-card h2 { margin: 0 0 8px; font-size: 20px; }
.choice-card p { color: var(--text-secondary); font-size: 13.5px; min-height: 44px; }

.code-zone { text-align: center; }
.big-code { font-size: 34px; font-weight: 700; letter-spacing: 3px; font-family: ui-monospace, Consolas, monospace; color: var(--slot-yellow); margin: 6px 0; }
.max-steps { margin: 14px 0; padding-left: 20px; }
.max-steps li { margin-bottom: 8px; }

/* ==========================================================================
   ФУТЕР
   ========================================================================== */
.site-footer { flex: none; background: var(--surface-1); border-top: 1px solid var(--border); margin-top: 20px; }
.site-footer-inner { max-width: 1120px; margin: 0 auto; padding: 20px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--text-secondary); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-links a { color: var(--text-secondary); text-decoration: none; }
.footer-links a:hover { color: var(--accent); }

/* ==========================================================================
   АДАПТИВ
   ========================================================================== */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .hero-art { order: 2; }
  .feature-block, .lesson-body { grid-template-columns: 1fr; }
  .feature-block .shot, .feature-block.alt .shot { grid-column: 1; }
  .feature-block.alt .fb-text, .lesson.alt .lesson-text { order: 0; }
  .choice-grid { grid-template-columns: 1fr; }
  .toc { columns: 1; }
}
@media (max-width: 860px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .nav-links { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  main { padding: 18px 14px 40px; }
  .hero-title { font-size: 2.4rem; }
  .section-title { font-size: 22px; }
}
@media (max-width: 480px) {
  .brand .app-version { display: none; }
  .settings-form .field { flex-direction: column; align-items: stretch; gap: 6px; }
  .settings-form .field label { min-width: 0; }
}
