:root{
  --bg:#eef1f0;
  --surface:#ffffff;
  --surface-2:#e2e6e4;
  --text:#1b1d1e;
  --text-muted:#5c6260;
  --border:#d7dbd9;
  --accent:#c2811f;
  --accent-ink:#1b1d1e;
  --trust:#2e8c82;
  --success:#3f9142;
  --warning:#c2811f;
  --critical:#c23b2e;
  --critical-bg:#f7e4e1;
  --success-bg:#e3efe3;
  --trust-bg:#e2f0ee;
  --warning-bg:#f5ead6;
  --shadow: 0 1px 2px rgba(20,22,21,.06), 0 6px 16px rgba(20,22,21,.05);
  --font-display:'Bahnschrift','DIN Alternate','Segoe UI Semibold','Arial Narrow',sans-serif;
  --font-body:-apple-system,BlinkMacSystemFont,'Segoe UI','Helvetica Neue',Arial,sans-serif;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#17181a; --surface:#1f2123; --surface-2:#262830; --text:#edeeec; --text-muted:#9ba1a0;
    --border:#34373a; --accent:#e8a23d; --accent-ink:#1b1200; --trust:#4fb7ac; --success:#5cb85f;
    --warning:#e8a23d; --critical:#e8776a; --critical-bg:#3a2220; --success-bg:#1f2e20;
    --trust-bg:#1c2d2b; --warning-bg:#332812;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 20px rgba(0,0,0,.35);
  }
}
*{box-sizing:border-box;}
html{color-scheme:light dark;}
body{
  margin:0; background:var(--bg); color:var(--text); font-family:var(--font-body);
  font-size:15px; line-height:1.45; -webkit-font-smoothing:antialiased;
  padding-bottom:96px;
}
a{color:var(--accent);}
.eyebrow{
  font-family:var(--font-display); font-size:11px; letter-spacing:.08em; text-transform:uppercase;
  color:var(--text-muted); font-weight:600;
}
h1,h2,h3{font-family:var(--font-display); text-wrap:balance; margin:0; letter-spacing:.01em;}

/* ---------- Top bar ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:16px 18px; border-bottom:1px solid var(--border); background:var(--surface);
  position:sticky; top:0; z-index:10;
}
.brand{font-family:var(--font-display); font-weight:700; font-size:18px;}
.brand em{font-style:normal; color:var(--accent);}
.nav-tabs{display:flex; gap:6px;}
.nav-tabs a{
  font-size:12.5px; font-weight:600; padding:7px 12px; border-radius:8px; text-decoration:none;
  color:var(--text-muted); border:1px solid transparent;
}
.nav-tabs a.active{background:var(--surface-2); color:var(--text); border-color:var(--border);}
.install-btn{
  display:flex; align-items:center; justify-content:center; gap:6px; width:100%;
  font-size:13px; font-weight:600; padding:10px 14px; margin:0 0 14px; border-radius:10px;
  border:1px solid var(--accent); color:var(--accent); background:none; cursor:pointer; font-family:inherit;
}
.install-btn:disabled{opacity:0.6; cursor:default;}
.open-hint{
  font-size:12.5px; color:var(--text-muted); background:var(--surface-2); border:1px dashed var(--border);
  border-radius:9px; padding:10px 12px; margin:0 0 14px; line-height:1.6;
}

.page{max-width:640px; margin:0 auto; padding:18px 16px 40px;}

/* ---------- Формы входа/регистрации — фиксированная тёмно-синяя тема (не зависит от
   --bg/--surface и системной светлой/тёмной темы), по прямому референсу Сергея:
   https://codyshop.ru — карточка со вкладками ВХОД/РЕГИСТРАЦИЯ, капсульные поля,
   синяя кнопка. Отдельная палитра ниже, не трогает переменные основного кабинета. ---------- */
.auth-page{
  --a-bg-1:#141a35; --a-bg-2:#1c2350; --a-card:#242c5c; --a-card-2:#1c2350;
  --a-field:rgba(255,255,255,.08); --a-field-border:rgba(255,255,255,.14);
  --a-text:#eef1fb; --a-text-muted:#8790bb; --a-accent:#3b82f6;
  min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center;
  padding:24px 16px; background:linear-gradient(160deg, var(--a-bg-1), var(--a-bg-2));
}
.auth-brand{font-family:var(--font-display); font-weight:700; font-size:22px; margin-bottom:22px; text-align:center; color:var(--a-text);}
.auth-brand em{font-style:normal; color:var(--a-accent);}
.auth-card{
  background:linear-gradient(165deg, var(--a-card), var(--a-card-2));
  border:1px solid rgba(255,255,255,.08); border-radius:22px;
  box-shadow:0 20px 50px rgba(5,8,25,.45); padding:32px 28px; width:100%; max-width:380px;
  color:var(--a-text);
}
.auth-card h1{margin:2px 0 22px; font-size:20px; color:var(--a-text);}
.auth-card .eyebrow{color:var(--a-text-muted);}
.auth-card label.field > span{color:var(--a-text-muted); text-transform:uppercase; font-size:10.5px; letter-spacing:.08em;}
.auth-card select,
.auth-card input:not([type="checkbox"]):not([type="radio"]){
  background:var(--a-field); border:1px solid var(--a-field-border); border-radius:24px;
  color:var(--a-text); padding:13px 20px;
}
.auth-card input::placeholder{color:var(--a-text-muted);}
.auth-card select:focus-visible, .auth-card input:focus-visible{outline:2px solid var(--a-accent); outline-offset:1px;}
.auth-card button.submit{
  width:100%; margin-top:22px; background:var(--a-accent); color:#fff; border-radius:24px;
  border:none; padding:14px; font-weight:700; letter-spacing:.03em; text-transform:uppercase; font-size:13px;
}
.auth-card .checkbox-row label{color:var(--a-text-muted); font-size:12.5px;}
.auth-card .checkbox-row input{accent-color:var(--a-accent);}
.auth-switch{text-align:center; margin-top:18px; font-size:13.5px; color:var(--a-text-muted);}
.auth-switch a{color:var(--a-accent);}
.auth-role-back{display:inline-block; font-size:12.5px; color:var(--a-text-muted); text-decoration:none; margin-bottom:16px;}
.auth-role-back:hover{color:var(--a-accent);}

/* Табы "Вход / Регистрация" — текстовые, с подчёркиванием активной вкладки (как в
   референсе), а не два закрашенных блока. */
.auth-tabs{display:flex; gap:28px; border-bottom:1px solid rgba(255,255,255,.12); margin-bottom:26px;}
.auth-tab{
  background:none; border:none; color:var(--a-text-muted); padding:0 0 12px; margin-bottom:-1px;
  font-family:inherit; font-size:13px; font-weight:700; letter-spacing:.04em; text-transform:uppercase;
  cursor:pointer; border-bottom:2px solid transparent;
}
.auth-tab.active{color:var(--a-text); border-bottom-color:var(--a-accent);}
.auth-panel[hidden]{display:none;}
.auth-error{color:#ff8a80; font-weight:600; margin:0 0 14px; font-size:13.5px;}

/* Экран выбора роли перед входом — 3 равнозначные точки входа в один и тот же
   личный кабинет (принцип "один функционал, разные анкеты", см. память проекта). */
.auth-role-cards{display:flex; flex-direction:column; gap:12px; width:100%; max-width:380px;}
.auth-role-card{
  display:flex; align-items:center; gap:14px;
  background:linear-gradient(165deg, var(--a-card), var(--a-card-2));
  border:1px solid rgba(255,255,255,.08); border-radius:18px;
  box-shadow:0 12px 30px rgba(5,8,25,.35); padding:18px 20px; text-decoration:none; color:var(--a-text);
}
.auth-role-card:hover{border-color:var(--a-accent);}
.auth-role-card .icon{font-size:26px; flex:none;}
.auth-role-card .label{font-weight:700; font-size:15.5px;}
.auth-role-card .hint{font-size:12.5px; color:var(--a-text-muted); margin-top:2px;}

/* ---------- Profile card (header) ---------- */
.profile-card{
  background:var(--surface); border:1px solid var(--border); border-radius:14px;
  box-shadow:var(--shadow); padding:18px 20px; margin-bottom:16px;
}
.profile-head{display:flex; justify-content:space-between; align-items:flex-start; gap:12px; flex-wrap:wrap;}
.profile-head h1{font-size:19px;}
.completeness{margin-top:14px;}
.completeness-row{display:flex; justify-content:space-between; font-size:12px; color:var(--text-muted); margin-bottom:5px;}
.completeness-track{height:7px; background:var(--surface-2); border-radius:99px; overflow:hidden;}
.completeness-fill{height:100%; background:linear-gradient(90deg, color-mix(in srgb, var(--accent) 65%, transparent), var(--accent)); border-radius:99px;}
.hint-line{color:var(--text-muted); font-size:12.5px; margin-top:10px;}

.badge{
  display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border-radius:99px;
  font-size:11.5px; font-weight:600; border:1px solid transparent; white-space:nowrap;
}
.badge.ok{background:var(--success-bg); color:var(--success); border-color:color-mix(in srgb, var(--success) 40%, transparent);}
.badge.warn{background:var(--warning-bg); color:var(--warning); border-color:color-mix(in srgb, var(--warning) 40%, transparent);}
.badge.bad{background:var(--critical-bg); color:var(--critical); border-color:color-mix(in srgb, var(--critical) 40%, transparent);}
.badge.trust{background:var(--trust-bg); color:var(--trust); border-color:color-mix(in srgb, var(--trust) 40%, transparent);}
.badge.neutral{background:var(--surface-2); color:var(--text-muted);}

/* ---------- Accordion sections ---------- */
.section{
  background:var(--surface); border:1px solid var(--border); border-radius:12px;
  box-shadow:var(--shadow); margin-bottom:10px; overflow:hidden;
}
.section summary{
  list-style:none; cursor:pointer; padding:14px 18px; display:flex; align-items:center;
  justify-content:space-between; gap:12px; user-select:none;
}
.section summary::-webkit-details-marker{display:none;}
.section summary .stitle{display:flex; flex-direction:column; gap:3px; min-width:0;}
.section summary .stitle .name{font-weight:700; font-size:14px;}
.section summary .stitle .preview{
  font-size:12.5px; color:var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  max-width:60vw;
}
.section summary .stitle .preview.empty{color:color-mix(in srgb, var(--warning) 80%, var(--text-muted));}
.section .chev{flex:none; color:var(--text-muted); transition:transform .15s ease; font-size:13px;}
.section[open] .chev{transform:rotate(90deg);}
.section .body{padding:2px 18px 18px; border-top:1px solid var(--border);}

/* ---------- Form controls ---------- */
label.field{display:block; margin-top:14px; font-size:13.5px;}
label.field > span{display:block; color:var(--text-muted); font-size:12px; margin-bottom:6px; font-weight:600;}
.req-mark{color:var(--critical);}
select, input[type=text], input[type=number], input[type=email]{
  width:100%; background:var(--bg); border:1px solid var(--border); border-radius:9px;
  padding:10px 12px; color:var(--text); font-size:14.5px; font-family:inherit;
}
select:focus-visible, input:focus-visible{outline:2px solid var(--accent); outline-offset:1px;}
.choice-row{display:flex; gap:8px; flex-wrap:wrap; margin-top:4px;}
.choice-row label{
  flex:1; min-width:88px; text-align:center; background:var(--bg); border:1px solid var(--border);
  border-radius:9px; padding:10px 8px; font-size:13px; font-weight:600; cursor:pointer; user-select:none;
}
.choice-row input{display:none;}
.choice-row label:has(input:checked){background:var(--accent); border-color:var(--accent); color:var(--accent-ink);}
.checkbox-row{display:flex; align-items:center; gap:10px; margin-top:14px; font-size:13.5px; font-weight:600;}
.checkbox-row input{width:19px; height:19px; accent-color:var(--accent);}
.badge-note{color:var(--text-muted); font-size:11.5px; margin-top:6px;}

/* ---------- Save bar ---------- */
.save-bar{
  position:fixed; left:0; right:0; bottom:0; background:var(--surface); border-top:1px solid var(--border);
  padding:12px 16px; display:flex; justify-content:center; box-shadow:0 -6px 16px rgba(20,22,21,.06); z-index:20;
}
.save-bar-inner{max-width:640px; width:100%; display:flex; gap:10px; align-items:center;}
button.submit{
  flex:1; background:var(--accent); color:var(--accent-ink); border:none; border-radius:10px;
  padding:13px; font-size:14.5px; font-weight:700; cursor:pointer; font-family:inherit;
}
button.submit:disabled{opacity:.55; cursor:default;}
#save-toast{font-size:12.5px; color:var(--text-muted); white-space:nowrap;}
#save-toast.ok{color:var(--success); font-weight:600;}
#save-toast.err{color:var(--critical); font-weight:600;}

/* ---------- "Сохраняем…" оверлей — виден, пока идёт запрос, чтобы клик по
   "Сохранить" никогда не выглядел так, будто ничего не произошло ---------- */
.saving-overlay{
  position:fixed; inset:0; background:rgba(10,11,10,.55); backdrop-filter:blur(1px);
  display:none; align-items:center; justify-content:center; z-index:50; opacity:0;
  transition:opacity .15s ease;
}
.saving-overlay.show{display:flex;}
.saving-overlay.visible{opacity:1;}
.saving-card{
  background:var(--surface); border-radius:14px; padding:22px 28px; box-shadow:var(--shadow);
  display:flex; flex-direction:column; align-items:center; gap:12px; max-width:80%;
}
.saving-spinner{
  width:30px; height:30px; border-radius:50%; border:3px solid var(--border);
  border-top-color:var(--accent); animation:saving-spin .8s linear infinite;
}
.saving-card span{font-size:14px; font-weight:600; color:var(--text);}
@keyframes saving-spin{ to{ transform:rotate(360deg); } }
@media (prefers-reduced-motion: reduce){
  .saving-spinner{ animation-duration:2s; }
}

.status-banner{border-radius:10px; padding:10px 14px; margin-bottom:14px; font-size:13px; font-weight:600;}
.status-banner.ok{background:var(--success-bg); color:var(--success);}
.status-banner.pending{background:var(--warning-bg); color:var(--warning);}

/* ---------- Chat with administration ---------- */
.chat{display:flex; flex-direction:column; gap:8px; max-height:320px; overflow-y:auto; margin-bottom:10px; padding-right:2px;}
.bubble{max-width:85%; padding:9px 13px; border-radius:12px; font-size:13.5px; line-height:1.4; white-space:pre-wrap;}
.bubble .time{display:block; font-size:11px; color:var(--text-muted); margin-top:3px;}
.bubble.in{align-self:flex-start; background:var(--surface-2); border-bottom-left-radius:4px;}
.bubble.out{align-self:flex-end; background:color-mix(in srgb, var(--accent) 20%, var(--surface)); border-bottom-right-radius:4px;}
.chat-empty{color:var(--text-muted); font-size:13px;}
.msg-row{display:flex; gap:8px; align-items:flex-start;}
.msg-row textarea{
  flex:1; background:var(--bg); border:1px solid var(--border); border-radius:9px; padding:10px 12px;
  color:var(--text); font-size:14px; font-family:inherit; resize:vertical; min-height:44px;
}
.msg-send{background:var(--accent); color:var(--accent-ink); border:none; border-radius:9px; padding:10px 16px; font-weight:700; cursor:pointer; flex:none; font-family:inherit; font-size:13.5px;}
.msg-send:disabled{opacity:.55; cursor:default;}
