:root {
  --cw-shell-bg: #06182b;
  --cw-shell-line: rgba(56, 189, 248, .17);
  --cw-shell-text: #f5fbff;
  --cw-shell-muted: #91a9bd;
  --cw-shell-cyan: #32d9f5;
}

.cw-shell-enabled { padding-top: 90px !important; }
.cw-menu-open { overflow: hidden !important; }

.cw-unified-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10000;
  height: 90px;
  color: var(--cw-shell-text);
  background: rgba(6, 24, 43, .97);
  border-bottom: 1px solid var(--cw-shell-line);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .24);
  backdrop-filter: blur(20px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.cw-unified-header-inner {
  width: min(1600px, calc(100% - 32px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cw-unified-brand {
  flex: 0 0 auto;
  min-width: 200px;
  height: 62px;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 6px 12px 6px 6px;
  border: 1px solid rgba(132, 210, 255, .22);
  border-radius: 18px;
  color: var(--cw-shell-text);
  background: rgba(255,255,255,.025);
  text-decoration: none;
  transition: border-color .18s ease, background .18s ease;
}
.cw-unified-brand:hover { border-color: rgba(126, 220, 255, .72); background: rgba(40, 172, 237, .07); }
.cw-unified-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 15px;
  object-fit: cover;
  background: linear-gradient(145deg, #64d9ff 0%, #2a9cf4 54%, #3868ee 100%);
  border: 1px solid rgba(150, 228, 255, .35);
  box-shadow: 0 8px 24px rgba(44, 153, 255, .3), inset 0 1px rgba(255, 255, 255, .2);
}
.cw-unified-brand strong { display: block; font-size: 20px; font-weight: 950; line-height: 1.05; letter-spacing: -.035em; }
.cw-unified-brand small { display: block; margin-top: 5px; color: #63dfff; font-size: 10px; font-weight: 750; }

.cw-unified-main-nav { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 7px; }
.cw-unified-main-nav a,
.cw-unified-services summary,
.cw-unified-services nav a,
.cw-unified-account > a,
.cw-unified-account > button,
.cw-unified-mobile-panel a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid rgba(100, 148, 187, .13);
  border-radius: 16px;
  color: #dce8f2;
  background: rgba(13, 38, 63, .72);
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.cw-unified-main-nav a:hover,
.cw-unified-main-nav a.is-active,
.cw-unified-services summary:hover,
.cw-unified-services summary.is-active,
.cw-unified-services nav a:hover,
.cw-unified-services nav a.is-active,
.cw-unified-mobile-panel a:hover,
.cw-unified-mobile-panel a.is-active {
  color: #fff;
  border-color: rgba(50, 217, 245, .48);
  background: linear-gradient(135deg, rgba(18, 91, 146, .8), rgba(9, 45, 78, .92));
}
.cw-unified-services { position: relative; flex: 0 0 auto; }
.cw-unified-services summary { cursor: pointer; list-style: none; }
.cw-unified-services summary::-webkit-details-marker { display: none; }
.cw-unified-services summary::after { content: "⌄"; margin-left: 8px; color: #7ddfff; }
.cw-unified-services[open] summary { border-color: rgba(50, 217, 245, .5); background: rgba(17, 79, 123, .8); }
.cw-unified-services nav {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 235px;
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--cw-shell-line);
  border-radius: 20px;
  background: rgba(4, 20, 37, .995);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
}
.cw-unified-services nav a { width: 100%; justify-content: flex-start; }

.cw-unified-account { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.cw-session-loading {
  min-width: 144px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid rgba(50, 217, 245, .14);
  border-radius: 15px;
  color: #8ba9bd;
  background: rgba(10, 43, 70, .42);
  font-size: 12px;
  font-weight: 800;
}
.cw-session-loading i {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(114, 223, 255, .22);
  border-top-color: #72dfff;
  border-radius: 50%;
  animation: cw-session-spin .75s linear infinite;
}
@keyframes cw-session-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cw-session-loading i { animation: none; } }
.cw-unified-account .cw-unified-login { color: #061522; background: #fff; border-color: rgba(255, 255, 255, .7); }
.cw-unified-account .cw-unified-notifications,
.cw-unified-account .cw-unified-logout { position: relative; width: 50px; min-width: 50px; height: 50px; padding: 0; color: #72dfff; background: rgba(10, 43, 70, .88); border-color: rgba(50, 217, 245, .18); }
.cw-unified-account svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cw-unified-notifications b { position: absolute; right: -4px; top: -5px; min-width: 19px; height: 19px; padding: 0 4px; display: grid; place-items: center; border-radius: 999px; color: white; background: #ef4444; font-size: 10px; }
.cw-unified-account .cw-unified-admin { min-height: 50px; color: #ffd9e0; background: rgba(107, 44, 66, .35); border-color: rgba(255, 123, 151, .28); }
.cw-unified-account .cw-unified-user { min-width: 236px; height: 62px; justify-content: flex-start; padding: 7px 12px; color: #72e7ff; background: linear-gradient(135deg,rgba(10,43,70,.96),rgba(11,50,79,.8)); border-color: rgba(50, 217, 245, .24); }
.cw-unified-avatar { width: 42px; height: 42px; margin-right: 9px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 14px; background: rgba(0, 11, 25, .58); font-size: 19px; }
.cw-unified-user-copy { min-width: 0; flex: 1; }
.cw-unified-user-copy > span { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.cw-unified-user-copy strong { overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.cw-unified-user-copy em { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; color: #d7fff0; background: rgba(45, 170, 122, .2); font-size: 9px; font-style: normal; }
.cw-unified-user-copy small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; color: #ff9aaa; font-size: 10px; }
.cw-unified-account .cw-unified-logout { color: #f4f8fb; cursor: pointer; }
.cw-unified-account > a:hover,
.cw-unified-account > button:hover { transform: translateY(-1px); border-color: rgba(94, 214, 255, .45); filter: brightness(1.08); }

.cw-notification-panel {
  position: fixed;
  top: 80px;
  right: max(16px, calc((100vw - 1600px) / 2 + 16px));
  width: min(420px, calc(100vw - 24px));
  max-height: min(650px, calc(100dvh - 96px));
  overflow: hidden;
  border: 1px solid rgba(71, 203, 255, .26);
  border-radius: 22px;
  color: #eaf7ff;
  background: rgba(4, 20, 37, .995);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .62);
}
.cw-notification-panel[hidden] { display: none !important; }
.cw-notification-head,
.cw-notification-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(13, 44, 71, .78);
}
.cw-notification-head { border-bottom: 1px solid rgba(71, 203, 255, .14); }
.cw-notification-head > span { display: grid; gap: 3px; }
.cw-notification-head strong { font-size: 16px; }
.cw-notification-head small { color: #8ea9bd; font-size: 11px; }
.cw-notification-head button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(130, 199, 236, .16);
  border-radius: 11px;
  color: #ccefff;
  background: rgba(255,255,255,.035);
  cursor: pointer;
  font-size: 20px;
}
.cw-notification-list {
  max-height: min(500px, calc(100dvh - 215px));
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cw-notification-list > a,
.cw-notification-list > div:not(.cw-notification-empty) {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 11px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(86, 154, 199, .1);
  color: inherit;
  background: transparent;
  text-decoration: none;
  transition: background .16s ease;
}
.cw-notification-list > a:hover { background: rgba(27, 128, 184, .13); }
.cw-notification-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: #30d8f4;
  box-shadow: 0 0 15px rgba(48, 216, 244, .7);
}
.cw-notification-dot.is-read { background: #496276; box-shadow: none; }
.cw-notification-copy { min-width: 0; display: grid; gap: 4px; }
.cw-notification-copy strong { overflow: hidden; text-overflow: ellipsis; color: #f5fbff; font-size: 13px; }
.cw-notification-copy span { color: #b7cad8; font-size: 12px; line-height: 1.45; }
.cw-notification-copy small { color: #7691a7; font-size: 10px; }
.cw-notification-empty { display: grid; gap: 6px; padding: 34px 24px; text-align: center; }
.cw-notification-empty span { color: #8da6ba; font-size: 12px; line-height: 1.5; }
.cw-notification-foot { border-top: 1px solid rgba(71, 203, 255, .14); }
.cw-notification-foot button,
.cw-notification-foot a {
  border: 0;
  color: #75e5ff;
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}
.cw-notification-foot button:disabled { color: #60778a; cursor: default; }

.cw-unified-menu { display: none; align-items: center; justify-content: center; gap: 4px; width: 48px; height: 48px; padding: 11px; border: 1px solid rgba(50, 217, 245, .24); border-radius: 15px; background: rgba(10, 43, 70, .92); }
.cw-unified-menu span { display: block; width: 5px; height: 5px; border-radius: 50%; background: #eaf8ff; }
.cw-unified-mobile-panel { display: none; }

/* У дочерних сервисов остаётся одна общая шапка. */
.cw-shell-enabled .app-shell { width: min(1600px, calc(100% - 32px)); }
.cw-shell-enabled .app-shell > .topbar,
.cw-shell-enabled .shell > .topbar,
.cw-generic .topbar { display: none !important; }
.cw-shell-enabled .stream-main > .topbar .top-actions { display: none !important; }
.cw-shell-enabled .stream-sidebar { top: 90px; height: calc(100vh - 90px); }
.cw-shell-enabled .login-layout { min-height: calc(100vh - 90px); }
.cw-generic .shell { padding-top: 0; }

@media (max-width: 1480px) and (min-width: 1281px) {
  .cw-unified-header-inner { gap: 7px; }
  .cw-unified-brand { min-width: 174px; }
  .cw-unified-main-nav { gap: 5px; }
  .cw-unified-main-nav a, .cw-unified-services summary { padding: 0 10px; font-size: 12px; }
  .cw-unified-account .cw-unified-admin { display: none; }
  .cw-unified-account .cw-unified-user { min-width: 205px; }
}

@media (max-width: 1100px) {
  .cw-unified-header-inner { width: min(100% - 28px, 1600px); }
  .cw-unified-brand { min-width: 0; margin-right: auto; }
  .cw-unified-main-nav, .cw-unified-services, .cw-unified-account { display: none; }
  .cw-unified-menu { display: flex; }
  .cw-unified-header.is-open { height: 100dvh; overflow-y: auto; background: rgba(3, 17, 31, .998); }
  .cw-unified-header.is-open .cw-unified-header-inner { height: auto; min-height: 100%; display: grid; grid-template-columns: 1fr auto; align-content: start; padding: 14px 0 28px; }
  .cw-unified-header.is-open .cw-unified-mobile-panel { grid-column: 1 / -1; display: block; padding-top: 12px; }
  .cw-unified-mobile-panel nav { display: grid; gap: 8px; }
  .cw-unified-mobile-panel a { width: 100%; min-height: 48px; justify-content: flex-start; }
  .cw-unified-mobile-title { margin: 20px 0 10px; color: #8ba4b8; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
  .cw-unified-mobile-account { display: grid; gap: 8px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--cw-shell-line); }
  .cw-unified-mobile-account .cw-session-loading { width: 100%; }
  .cw-unified-mobile-user { display: flex !important; align-items: center; }
  .cw-unified-mobile-user > span:last-child { display: grid; gap: 4px; }
  .cw-unified-mobile-user small { color: #8edfff; }
  .cw-unified-mobile-notifications {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border: 1px solid rgba(50, 217, 245, .2);
    border-radius: 16px;
    color: #dce8f2;
    background: rgba(13, 38, 63, .72);
    font: inherit;
    font-size: 13px;
    font-weight: 850;
  }
  .cw-unified-mobile-notifications b { min-width: 23px; padding: 3px 7px; border-radius: 999px; color: #fff; background: #ef4444; font-size: 10px; }
  .cw-unified-mobile-admin { color: #ffd5dc !important; border-color: rgba(255, 123, 151, .25) !important; background: rgba(107, 44, 66, .28) !important; }
  .cw-notification-panel { top: 78px; right: 10px; width: calc(100vw - 20px); max-height: calc(100dvh - 88px); }
  .cw-notification-list { max-height: calc(100dvh - 205px); }
}

@media (max-width: 640px) {
  .cw-shell-enabled { padding-top: 72px !important; }
  .cw-unified-header { height: 72px; }
  .cw-unified-header-inner { width: calc(100% - 20px); }
  .cw-unified-brand { height: 54px; padding: 5px 10px 5px 5px; border-radius: 16px; }
  .cw-unified-brand strong { font-size: 17px; }
  .cw-unified-brand small { font-size: 9px; }
  .cw-unified-mark { width: 42px; height: 42px; border-radius: 13px; }
  .cw-unified-menu { width: 44px; height: 44px; }
  .cw-shell-enabled .app-shell { width: min(100% - 20px, 1600px); }
  .cw-shell-enabled .stream-sidebar { top: 72px; height: auto; }
  .cw-shell-enabled .login-layout { min-height: calc(100vh - 72px); }
  .cw-notification-panel { top: 78px; }
}
