/* Каркас сайта: верхняя панель, боковое меню, область контента. */

/* ── Верхняя панель ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex; align-items: center;
  background: var(--topbar-bg); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__brand {
  width: var(--sidebar-w); flex-shrink: 0; height: 100%;
  display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px;
  border-right: 1px solid var(--line);
}
/* Логотип ABC.Stats: щит со столбиками (static/img/logo.svg) и название */
.topbar__logo { display: flex; align-items: center; gap: 10px; flex-shrink: 0; text-decoration: none; }
.topbar__logo img { width: 30px; height: 30px; display: block; }
.topbar__name { font: 800 17px var(--fh); color: var(--hi); letter-spacing: -.01em; white-space: nowrap; }
.topbar__name span { color: var(--acc); }
/* Выбор этапа — сразу правее блока с логотипом */
.topbar__stage { display: flex; align-items: center; flex: 1 1 auto; min-width: 0; padding: 0 12px 0 16px; }
.topbar__title {
  font: var(--fh-w) 14px var(--fh); color: var(--hi);
  text-transform: var(--caps); letter-spacing: var(--caps-ls);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Выбор этапа в шапке */
.stage-select { position: relative; flex: 1; min-width: 0; display: flex; }
.stage-select__btn {
  display: flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px; margin-left: -4px;
  border: none; border-radius: var(--radius-sm); background: none; cursor: pointer;
  font: var(--fh-w) 13px var(--fh); color: var(--hi); white-space: nowrap; letter-spacing: -.01em;
}
.stage-select__btn:hover, .stage-select__btn[aria-expanded="true"] { background: var(--panel2); }
.stage-select__btn span { overflow: hidden; text-overflow: ellipsis; }
.stage-select__btn .fa-hourglass-half { display: none; color: var(--acc); font-size: 13px; }
.stage-select__btn .fa-caret-down { font-size: 11px; color: var(--dim); }
.stage-menu {
  position: absolute; top: calc(100% + 10px); left: -8px; z-index: 120; width: 300px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
}
.stage-menu__title { padding: 6px 10px 8px; font-size: 12px; color: var(--dim); }
.stage-menu__item {
  display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 8px 10px;
  border: none; border-radius: var(--radius-sm); background: none; cursor: pointer; text-align: left;
}
.stage-menu__item:hover { background: var(--panel2); }
.stage-menu__item b { font: 600 14px var(--fb); color: var(--hi); }
.stage-menu__item span { font-size: 12.5px; color: var(--dim); }
.stage-menu__item.is-active { background: var(--acc-soft); }
.stage-menu__item.is-active b::after { content: ' ✓'; color: var(--acc); }

.topbar__burger {
  display: none; margin-left: 12px;
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: none; color: var(--text); cursor: pointer; font-size: 15px;
}
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 4px; padding: 0 16px; }

.topbar__item {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border: none; border-radius: var(--radius-sm); background: none; cursor: pointer;
  color: var(--text); font: 500 13px var(--fb); white-space: nowrap; transition: .15s;
}
.topbar__item:hover { color: var(--hi); background: var(--panel2); }
.topbar__item .fa-caret-down { font-size: 11px; color: var(--dim); }
.topbar__item--accent { color: var(--acc); }

/* Переключатель светлой/тёмной темы: бегунок закрывает неактивную иконку */
.theme-switch {
  position: relative; width: 52px; height: 26px; margin-right: 8px; padding: 0 7px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: 99px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer;
  font-size: 11px; color: var(--dim); transition: border-color .15s;
}
.theme-switch:hover { border-color: var(--dim); }
.theme-switch .fa-moon { color: var(--acc); }
.theme-switch::after {
  content: ''; position: absolute; top: 3px; left: 29px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--panel); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .2s;
}
.theme-switch[aria-checked="true"]::after { left: 3px; }
.theme-switch[aria-checked="true"] .fa-moon { color: var(--dim); }
.theme-switch[aria-checked="true"] .fa-sun { color: var(--acc); }

/* Аккаунт в шапке */
.account { position: relative; }
.topbar__item.is-signed-in { color: var(--hi); font-weight: 600; }
.account__menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 120; width: 220px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
}
.account__who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line2); }
.account__who b { color: var(--hi); }
.account__who span { font-size: 12.5px; color: var(--dim); }
.account__action {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: none; border-radius: var(--radius-sm); background: none; cursor: pointer;
  color: var(--text); font: 500 14px var(--fb); text-align: left;
}
.account__action:hover { background: var(--panel2); color: var(--hi); }

/* Меню языка */
.lang-menu { width: 180px; }
.lang-menu .account__action { margin-top: 0; }
.lang-menu .account__action b { width: 22px; color: var(--dim); font-size: 12px; }
.lang-menu .account__action.is-active { color: var(--acc); }
.lang-menu .account__action.is-active b { color: var(--acc); }

/* Окно входа */
.login-overlay {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px;
  background: var(--overlay); backdrop-filter: blur(3px);
}
.login-overlay[hidden] { display: none; }
.login {
  position: relative; width: min(360px, 100%); padding: 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); animation: fadeUp .15s ease;
}
.login__close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel2);
  color: var(--text); cursor: pointer;
}
.login__close:hover { color: var(--hi); border-color: var(--dim); }
.login__title { margin-bottom: 18px; font: var(--fh-w) 19px var(--fh); color: var(--hi); }
.login__field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--dim); }
.login__field input {
  height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--hi); font: 400 14px var(--fb); outline: none;
}
.login__field input:focus { border-color: var(--acc); }
.login__error { margin: -4px 0 12px; font-size: 13px; color: var(--loss); }
.login__hint { margin: -2px 0 14px; font-size: 12px; line-height: 1.45; color: var(--dim); }
.login__submit { width: 100%; justify-content: center; height: 38px; }
.login__submit:disabled { opacity: .6; cursor: default; }

/* ── Боковое меню ── */
.sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 90;
  width: var(--sidebar-w); overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 10px 0 12px;
  display: flex; flex-direction: column;
}
.sidebar > nav { flex: 1 0 auto; }
/* Низ меню: «Предложения / исправления» */
.sidebar__foot { padding-top: 10px; margin-top: 10px; border-top: 1px solid var(--line2); }
.nav { list-style: none; }
.nav__link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; margin: 1px 8px; border-radius: var(--radius-sm);
  color: var(--text); font: 500 14px var(--fb); transition: .12s;
}
.nav__link:hover { color: var(--hi); background: var(--panel2); }
.nav__link .fa-solid:first-child { width: 16px; text-align: center; color: var(--dim); font-size: 13px; }
.nav__link:hover .fa-solid:first-child { color: var(--hi); }
.nav__chevron { margin-left: auto; font-size: 10px; color: var(--dim); }

.nav__link.is-active { background: var(--acc-soft); color: var(--hi); font-weight: 600; }
.nav__link.is-active::before {
  content: ''; position: absolute; left: -8px; top: 6px; bottom: 6px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--acc);
}
.nav__link.is-active .fa-solid:first-child { color: var(--acc); }

/* ── Контент ── */
.content {
  margin-left: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 28px) 32px 64px;
  min-height: 100vh;
}
.content__inner { max-width: 1440px; margin: 0 auto; }

/* Заголовок страницы */
.page-head {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line);
}
.page-head h1 { font: var(--fh-w) 21px var(--fh); color: var(--hi); text-transform: var(--caps); letter-spacing: var(--caps-ls); }
.page-head__sub { margin-left: 8px; font: 500 15px var(--fb); color: var(--dim); }
.page-head .btn { margin-left: auto; }

.spinner {
  width: 30px; height: 30px; margin: 40px auto;
  border: 3px solid var(--line); border-top-color: var(--acc); border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* Заголовок раздела внутри страницы */
.section-title {
  font: var(--fh-w) 17px var(--fh); color: var(--hi);
  text-transform: var(--caps); letter-spacing: var(--caps-ls);
  padding-bottom: 12px; margin-bottom: 18px; border-bottom: 1px solid var(--line);
}

/* Уведомление «раздел в разработке» */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 300;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: var(--radius-sm);
  background: var(--hi); color: var(--bg);
  font-weight: 600; font-size: 13px; transition: .25s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.sidebar-backdrop { display: none; }

/* ── Адаптив ── */
@media (max-width: 900px) {
  .topbar__brand { width: auto; border-right: none; padding-right: 0; }
  .topbar__burger { display: inline-grid; place-items: center; }
  .topbar__label { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 80;
    background: var(--overlay);
  }
  .content { margin-left: 0; padding: calc(var(--topbar-h) + 20px) 16px 40px; }
}
@media (max-width: 560px) {
  .topbar__title { display: none; }
  .stage-select__btn span { display: none; }       /* на телефоне — только значок этапа */
  .stage-select__btn .fa-hourglass-half { display: inline; }
  .stage-menu { width: min(300px, calc(100vw - 24px)); }
  .topbar__actions { padding: 0 8px; gap: 0; }
  .topbar__name { display: none; }               /* на телефоне — только щит */
  .topbar__stage { padding: 0 4px 0 8px; }
  .topbar__item { padding: 8px; }
}
