.strategy-cabinet-link,
.strategy-theme-toggle {
  min-height: 42px;
  border: 1px solid transparent;
  color: inherit;
  cursor: pointer;
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.strategy-cabinet-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 0 12px;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted, #9aa7b7);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.strategy-cabinet-link:hover,
.strategy-cabinet-link:focus-visible {
  border-color: rgba(203, 167, 104, 0.24);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-main, #f5f7fa);
  transform: translateY(-1px);
}

.strategy-header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.topbar.app-header .strategy-theme-toggle {
  position: static !important;
  right: auto !important;
  bottom: auto !important;
  z-index: auto !important;
  display: grid !important;
  place-items: center;
  width: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  padding: 0 !important;
  border: 1px solid transparent !important;
  border-radius: 12px !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 17px !important;
}

.topbar.app-header .strategy-theme-toggle:hover,
.topbar.app-header .strategy-theme-toggle:focus-visible {
  border-color: rgba(203, 167, 104, 0.22) !important;
  background: rgba(255, 255, 255, 0.05) !important;
  transform: translateY(-1px);
}

.account-logout-dialog {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
}

.account-logout-dialog[hidden] {
  display: none !important;
}

.account-logout-dialog__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(2, 7, 15, 0.68);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.account-logout-dialog__card {
  position: relative;
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid rgba(159, 178, 198, 0.17);
  border-radius: 24px;
  background: rgba(13, 22, 35, 0.98);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.48);
}

.account-logout-dialog__card h2 {
  margin: 11px 0 8px;
  font-size: 27px;
}

.account-logout-dialog__card p {
  margin: 0;
  color: var(--text-muted, #9aa7b7);
  line-height: 1.55;
}

.account-logout-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.account-logout-dialog__actions > button {
  min-width: 108px;
  min-height: 44px;
  border-radius: 13px;
}

.strategy-logout-confirm {
  border: 1px solid rgba(210, 116, 101, 0.28);
  background: rgba(201, 104, 90, 0.12);
  color: #efaea3;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.strategy-logout-confirm:hover,
.strategy-logout-confirm:focus-visible {
  border-color: rgba(210, 116, 101, 0.40);
  background: rgba(201, 104, 90, 0.18);
}

body.is-account-dialog-open {
  overflow: hidden;
}

body.theme-light .strategy-cabinet-link {
  color: #4f6374;
}

body.theme-light .strategy-cabinet-link:hover,
body.theme-light .strategy-cabinet-link:focus-visible {
  background: rgba(48, 75, 99, 0.06);
  color: #162536;
}

body.theme-light .account-logout-dialog__card {
  border-color: rgba(90, 116, 138, 0.17);
  background: rgba(250, 252, 253, 0.98);
  box-shadow: 0 25px 75px rgba(35, 53, 69, 0.18);
}

@media (max-width: 1100px) {
  .topbar.app-header .brand-copy > span,
  .topbar.app-header .brand-copy > small {
    display: none;
  }
}

@media (max-width: 768px) {
  html,
  body {
    min-width: 0;
    max-width: 100%;
  }

  .topbar.app-header.app-header-sticky {
    display: flex !important;
    align-items: center !important;
    width: calc(100% - 20px) !important;
    min-width: 0 !important;
    height: 66px !important;
    min-height: 66px !important;
    max-height: 66px !important;
    margin: 8px 10px 10px !important;
    padding: 8px !important;
    gap: 5px !important;
    border-radius: 20px !important;
  }

  .topbar.app-header .brand-logo-wrap {
    order: 1;
    display: inline-flex !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px !important;
    border-radius: 14px !important;
  }

  .topbar.app-header .brand-logo {
    width: 26px !important;
    height: 26px !important;
  }

  .topbar.app-header .brand-copy {
    order: 2;
    display: flex !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    gap: 2px !important;
  }

  .topbar.app-header .brand-name {
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(10px, 3vw, 13px) !important;
    line-height: 1.05 !important;
    letter-spacing: 0.08em !important;
    text-overflow: ellipsis;
    white-space: nowrap !important;
  }

  .topbar.app-header .brand-copy > span,
  .topbar.app-header .brand-copy > small {
    display: block !important;
    max-width: 100%;
    overflow: hidden;
    font-size: clamp(7px, 2.1vw, 9px) !important;
    line-height: 1.15 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .strategy-cabinet-link {
    order: 0;
    min-height: 40px;
    padding: 0 9px;
    border-color: rgba(203, 167, 104, 0.16);
    font-size: 11px;
  }

  .topbar.app-header .system-live-status {
    display: none !important;
  }

  .topbar.app-header .system-live-meta,
  .topbar.app-header .demo-preview-badge,
  .topbar.app-header .dashboard-refresh-retry {
    display: none !important;
  }

  .strategy-header-actions {
    order: 3;
    gap: 3px;
  }

  .strategy-header-actions .strategy-theme-toggle {
    order: 1;
  }

  .topbar.app-header .strategy-theme-toggle,
  body.is-telegram-mini-app .topbar.app-header .strategy-theme-toggle {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    border-radius: 12px !important;
  }

  .account-logout-dialog {
    align-items: end;
    padding:
      12px
      max(12px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .account-logout-dialog__card {
    width: 100%;
    padding: 23px;
    border-radius: 22px;
  }

  .account-logout-dialog__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .account-logout-dialog__actions > button {
    width: 100%;
    min-width: 0;
  }

  body.is-telegram-mini-app .topbar.app-header.app-header-sticky {
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding:
      calc(8px + env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      8px
      max(8px, env(safe-area-inset-left)) !important;
    border-radius: 0 !important;
  }
}

@media (max-width: 360px) {
  .strategy-cabinet-link {
    gap: 4px;
    padding: 0 7px;
    font-size: 10px;
  }

  .topbar.app-header .system-live-main {
    font-size: 9px !important;
  }

  .topbar.app-header .strategy-theme-toggle,
  body.is-telegram-mini-app .topbar.app-header .strategy-theme-toggle {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 40px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .strategy-cabinet-link,
  .strategy-theme-toggle {
    transition: none;
  }
}
