:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --text: #e7ecf3;
  --muted: #8b9aad;
  --accent: #3d8bfd;
  --danger: #f85149;
  --success: #3fb950;
  --admin-topbar-h: 60px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, sans-serif; background: var(--bg); color: var(--text); }

.portal-body .layout { display: flex; min-height: 100vh; }
.portal-body .layout.cabinet-layout {
  align-items: stretch;
}
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  padding: 1rem;
  border-right: 1px solid #2d3a4d;
  display: flex;
  flex-direction: column;
}
.cabinet-main-stack {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.cabinet-topnav {
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid #2d3a4d;
  padding: 0.45rem 1rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}
.cabinet-topnav-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.15rem;
  max-width: 1200px;
}
.cabinet-topnav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #c6d8ef;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}
.cabinet-topnav-link:hover {
  background: rgba(61, 139, 253, 0.14);
  border-color: rgba(61, 139, 253, 0.22);
  color: var(--text);
}
.cabinet-topnav-link.is-active {
  color: var(--accent);
  background: rgba(61, 139, 253, 0.16);
  border-color: rgba(61, 139, 253, 0.35);
  font-weight: 600;
}
.cabinet-topnav-link.is-active .icon {
  color: var(--accent);
  opacity: 1;
}
.cabinet-topnav-link--icon-only {
  justify-content: center;
  min-width: 2.25rem;
}
.cabinet-topnav-link--icon-only .icon {
  margin-right: 0;
}
.nav-link--icon-only {
  justify-content: center;
}
.nav-link--icon-only .icon {
  margin-right: 0;
}
.cabinet-main.main {
  flex: 1;
}
.sidebar-nav-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 0.25rem;
}
.nav-sidebar--upper {
  flex: 0 1 auto;
  min-height: 0;
}
.sidebar-footer-block {
  margin-top: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-top: 0.85rem;
  border-top: 1px solid #2d3a4d;
}
.nav-sidebar--lower {
  gap: 0.25rem;
}
.nav-sidebar {
  display: flex;
  flex-direction: column;
}
.cabinet-user-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  background: #141c28;
  border: 1px solid #2d3a4d;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}
.cabinet-user-avatar {
  flex-shrink: 0;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #6e40c9, #4c2d8a);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.cabinet-user-avatar .fa-user {
  font-size: 0.9rem;
  opacity: 0.95;
}
.cabinet-user-text {
  flex: 1;
  min-width: 0;
}
.cabinet-user-name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cabinet-user-email {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}
.cabinet-user-logout {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  color: var(--accent);
  text-decoration: none;
  transition: background 0.14s, color 0.14s;
}
.cabinet-user-logout:hover {
  background: rgba(61, 139, 253, 0.15);
  color: #7eb6ff;
}
.cabinet-logout-fallback {
  margin-top: 0.25rem;
}
.brand { font-weight: 700; margin-bottom: 1rem; }
.brand-cabinet {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.brand-logo {
  max-width: 48px;
  max-height: 48px;
  object-fit: contain;
}
.brand-text { min-width: 0; }
.brand-title { font-weight: 700; }
.brand-caption {
  font-size: 0.85em;
  margin-top: 0.15rem;
  line-height: 1.2;
}
.nav { display: flex; flex-direction: column; gap: 0.25rem; }
.nav-link {
  color: var(--text);
  text-decoration: none;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
}
.nav-link:hover { background: #243044; }
.nav-link.is-active {
  color: var(--accent);
  background: rgba(61, 139, 253, 0.14);
  font-weight: 600;
}
.nav-link.is-active .icon {
  color: var(--accent);
  opacity: 1;
}
.nav-link.muted { color: var(--muted); margin-top: 1rem; }
.nav-divider { height: 1px; background: #2d3a4d; margin: 0.5rem 0; }
.icon { margin-right: 0.35rem; opacity: 0.85; }
.main { flex: 1; padding: 1.5rem; }
.cabinet-page-head { margin-bottom: 1.25rem; }
.cabinet-page-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.cabinet-page-slug { margin: 0; font-size: 0.82rem; }
.cabinet-page-slug code {
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.cabinet-page-body.prose-muted {
  color: var(--muted);
  line-height: 1.55;
  max-width: 42rem;
}
.page h1 { margin-top: 0; }
.flash-list { list-style: none; padding: 0; }
.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 0.5rem; }
.flash-danger { background: #3d1f1f; color: #ffb4ab; }
.flash-success { background: #1f2d1f; color: #9ee080; }
.flash-info { background: #1f283d; color: #aacfff; }

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  padding: 1.5rem;
  border-radius: 10px;
  border: 1px solid #2d3a4d;
}
/* Брендинг ЛК на страницах входа / регистрации */
.auth-brand-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1.15rem;
  text-align: center;
}
.auth-login-logo {
  max-width: 140px;
  max-height: 80px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.auth-login-titles {
  min-width: 0;
  line-height: 1.25;
}
.auth-login-brand {
  font-weight: 700;
  font-size: 1.08em;
}
.auth-login-caption {
  font-size: 0.88em;
  margin-top: 0.2em;
  opacity: 0.88;
}

.auth-card h1 { margin-top: 0; font-size: 1.35rem; }
.auth-card label { display: block; margin-bottom: 1rem; font-size: 0.9rem; color: var(--muted); }
.auth-card input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid #2d3a4d;
  background: var(--bg);
  color: var(--text);
}
.auth-card button {
  width: 100%;
  padding: 0.65rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.auth-footer { margin-top: 1rem; font-size: 0.9rem; }
.auth-footer a { color: var(--accent); }

/* Индикатор сложности пароля (портал + админка) */
.pwd-meter { margin: 0.35rem 0 0.65rem; max-width: 100%; }
.pwd-meter-bars { display: flex; gap: 4px; margin-bottom: 0.3rem; }
.pwd-meter-bars i {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.15s ease;
}
.pwd-meter-bars i.on { background: #b85c5c; }
.pwd-meter--level-3 .pwd-meter-bars i.on,
.pwd-meter--level-4 .pwd-meter-bars i.on { background: #c9a227; }
.pwd-meter--level-5 .pwd-meter-bars i.on { background: #3d9e6a; }
.pwd-meter-text { display: block; font-size: 0.85rem; line-height: 1.35; }
.auth-card .pwd-hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.75rem; }

/* Admin: верхнее меню + область страницы */
.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.admin-body {
  margin: 0;
}
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--admin-topbar-h);
  padding: 0.45rem 0;
  background: linear-gradient(180deg, #161d2a 0%, #121824 100%);
  border-bottom: 1px solid #2a3850;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
.admin-topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  box-sizing: border-box;
}
.admin-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}
.admin-topbar-brand:hover .admin-topbar-title {
  color: var(--accent);
}
.admin-topbar-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 6px;
}
.admin-topbar-titles {
  display: flex;
  flex-direction: column;
  gap: 0.06rem;
  min-width: 0;
}
.admin-topbar-kicker {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7c94;
  line-height: 1.2;
}
.admin-topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.12s;
}
.admin-topbar-tagline {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-topbar-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem 0.15rem;
}
.admin-topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.72rem;
  border-radius: 9px;
  font-size: 0.86rem;
  color: #9fb4ce;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.14s, color 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.admin-topbar-link:hover {
  color: #eaf2ff;
  background: rgba(61, 139, 253, 0.14);
  border-color: rgba(61, 139, 253, 0.22);
}
.admin-topbar-link.active {
  color: #fff;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(61, 139, 253, 0.32), rgba(61, 139, 253, 0.14));
  border-color: rgba(61, 139, 253, 0.45);
  box-shadow: 0 0 0 1px rgba(61, 139, 253, 0.12);
}
.admin-topbar-link--icon-only {
  gap: 0;
  padding: 0.42rem 0.58rem;
  min-width: 2.35rem;
  justify-content: center;
}
.admin-topbar-link--icon-only .admin-topbar-ic {
  font-size: 1rem;
}
.admin-topbar-link--logout {
  margin-left: 0.35rem;
  color: #a8b8cc;
}
.admin-topbar-link--logout:hover {
  color: #ffd0cc;
  background: rgba(248, 81, 73, 0.12);
  border-color: rgba(248, 81, 73, 0.25);
}
.admin-topbar-ic {
  font-size: 0.92rem;
  opacity: 0.9;
  line-height: 1;
}
.admin-page-main {
  flex: 1;
  padding: 1.25rem 1.5rem 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.admin-page-main > .flash:first-child {
  margin-top: 0;
}

/* Общие блоки страниц админки (дашборд, меню ЛК, др.) */
.admin-page-head {
  margin-bottom: 1.1rem;
}
.admin-page-head h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.admin-page-lead {
  margin: 0.35rem 0 0;
  font-size: 0.92rem;
  color: var(--muted);
  max-width: 42rem;
  line-height: 1.45;
}
.admin-card {
  background: linear-gradient(180deg, rgba(21, 31, 44, 0.92), rgba(16, 24, 35, 0.92));
  border: 1px solid #2b3a51;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}
.admin-card-body {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #d6e5f8;
}
.admin-card-body p {
  margin: 0 0 0.75rem;
}
.admin-card-body p:last-child {
  margin-bottom: 0;
}
a.admin-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid #35527a;
  background: #172435;
  color: #dceaff;
}
a.admin-link-btn:hover {
  background: #1d3046;
  border-color: #3e6595;
}
a.admin-link-btn.primary {
  background: linear-gradient(180deg, #1d6dff, #1658cf);
  border-color: #2b73f3;
  color: #fff;
}
.menu-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.86rem;
}
.menu-table th,
.menu-table td {
  border: 1px solid #2b3a51;
  padding: 0.45rem 0.55rem;
  text-align: left;
}
.menu-table th {
  background: #162433;
  color: #c9ddf7;
  font-weight: 600;
}
.menu-table tbody tr:nth-child(2n) {
  background: rgba(17, 26, 39, 0.45);
}
.menu-table code {
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
}
.btn {
  padding: 0.38rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #35527a;
  background: #172435;
  color: var(--text);
  cursor: pointer;
  font-size: 0.86rem;
  transition: background 0.14s, border-color 0.14s;
}
.btn:hover {
  background: #1d3046;
  border-color: #3e6595;
}
