:root {
  --ow-brand-blue: #0057b8;
  --ow-brand-navy: #0b1d3a;
  --ow-brand-turquoise: #00d4c6;
  --ow-brand-white: #ffffff;
  --ow-brand-surface: #f5f9fc;
  --ow-brand-border: #d5e1ea;
  --ow-brand-muted: #687c8f;
  --ow-brand-success: #16a05d;
  --ow-brand-danger: #b9362f;
}

header {
  border-bottom-color:
    rgba(0, 87, 184, 0.18) !important;
  box-shadow:
    0 2px 14px
    rgba(11, 29, 58, 0.07);
}

.ow-account-root {
  position: relative;
  z-index: 5500;
  flex: 0 0 auto;
  margin-left: 8px;
  font-family:
    Arial,
    Helvetica,
    sans-serif;
}

.ow-account-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 5px 10px 5px 6px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: var(--ow-brand-navy);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.ow-account-trigger:hover,
.ow-account-trigger[aria-expanded="true"] {
  border-color:
    rgba(0, 87, 184, 0.16);
  background:
    rgba(0, 87, 184, 0.055);
}

.ow-account-trigger:focus-visible {
  outline: 3px solid
    rgba(0, 212, 198, 0.28);
  outline-offset: 2px;
}

.ow-account-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border: 1px solid
    rgba(0, 87, 184, 0.16);
  border-radius: 50%;
  background:
    linear-gradient(
      145deg,
      #f8fbfe,
      #e8f1f8
    );
  color: var(--ow-brand-blue);
}

.ow-account-avatar svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ow-account-online-dot {
  position: absolute;
  right: -1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--ow-brand-success);
  box-shadow:
    0 0 0 1px
    rgba(22, 160, 93, 0.18);
}

.ow-account-trigger-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 190px;
}

.ow-account-trigger-name {
  overflow: hidden;
  color: var(--ow-brand-navy);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ow-account-trigger-meta {
  overflow: hidden;
  margin-top: 2px;
  color: var(--ow-brand-muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ow-account-chevron {
  width: 16px;
  height: 16px;
  margin-left: 2px;
  fill: none;
  stroke: var(--ow-brand-navy);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 160ms ease;
}

.ow-account-trigger[aria-expanded="true"]
.ow-account-chevron {
  transform: rotate(180deg);
}

.ow-account-menu {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  width: min(340px, calc(100vw - 24px));
  overflow: hidden;
  border: 1px solid var(--ow-brand-border);
  border-radius: 18px;
  background: #ffffff;
  box-shadow:
    0 22px 60px
    rgba(11, 29, 58, 0.22);
}

.ow-account-menu[hidden] {
  display: none !important;
}

.ow-account-menu-header {
  position: relative;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  padding: 18px;
  overflow: hidden;
  background:
    linear-gradient(
      135deg,
      var(--ow-brand-navy),
      #123f69
    );
  color: #ffffff;
}

.ow-account-menu-header::after {
  position: absolute;
  right: -18px;
  bottom: -35px;
  width: 130px;
  height: 130px;
  border: 18px solid
    rgba(0, 212, 198, 0.14);
  border-radius: 50%;
  content: "";
}

.ow-account-brand-icon {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 1px solid
    rgba(255, 255, 255, 0.2);
  border-radius: 15px;
  background:
    rgba(255, 255, 255, 0.1);
}

.ow-account-brand-icon img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.ow-account-header-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.ow-account-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  color: var(--ow-brand-turquoise);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ow-account-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ow-brand-turquoise);
  content: "";
  box-shadow:
    0 0 0 4px
    rgba(0, 212, 198, 0.13);
}

.ow-account-menu-name {
  overflow: hidden;
  margin: 0;
  color: #ffffff;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ow-account-menu-role {
  margin-top: 4px;
  color:
    rgba(255, 255, 255, 0.72);
  font-size: 11px;
  font-weight: 700;
}

.ow-account-section {
  padding: 15px 18px;
  border-bottom: 1px solid #e5edf3;
}

.ow-account-section-title {
  margin-bottom: 10px;
  color: var(--ow-brand-muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ow-account-detail {
  display: grid;
  grid-template-columns: 95px minmax(0, 1fr);
  gap: 9px;
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.4;
}

.ow-account-detail:first-of-type {
  margin-top: 0;
}

.ow-account-detail-label {
  color: var(--ow-brand-muted);
  font-weight: 700;
}

.ow-account-detail-value {
  overflow-wrap: anywhere;
  color: var(--ow-brand-navy);
  font-weight: 800;
}

.ow-account-session-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #147044;
}

.ow-account-session-state::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ow-brand-success);
  content: "";
}

.ow-account-actions {
  display: grid;
  gap: 8px;
  padding: 13px;
  background: #f7fafc;
}

.ow-account-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  border: 1px solid var(--ow-brand-border);
  border-radius: 11px;
  background: #ffffff;
  color: var(--ow-brand-navy);
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  text-align: left;
}

.ow-account-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ow-account-action:hover {
  border-color:
    rgba(0, 87, 184, 0.35);
  background:
    rgba(0, 87, 184, 0.04);
}

.ow-account-action.logout {
  color: var(--ow-brand-danger);
}

.ow-account-action:disabled {
  cursor: wait;
  opacity: 0.55;
}

.ow-account-footer {
  padding: 10px 15px;
  border-top: 3px solid
    var(--ow-brand-turquoise);
  color: #8a99a7;
  font-size: 9px;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 820px) {
  body.mobile-ui-active header {
    grid-template-columns:
      minmax(62px, 1fr)
      44px
      auto !important;
  }

  body.mobile-ui-active
  .ow-account-root {
    grid-column: 2;
    margin: 0;
  }

  body.mobile-ui-active
  .mobile-wind-summary {
    grid-column: 3;
  }

  .ow-account-trigger {
    width: 42px;
    min-height: 42px;
    padding: 1px;
    border-radius: 50%;
  }

  .ow-account-avatar {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }

  .ow-account-trigger-copy,
  .ow-account-chevron {
    display: none;
  }

  .ow-account-menu {
    position: fixed;
    top: 62px;
    right: 8px;
    width: min(340px, calc(100vw - 16px));
    max-height:
      calc(100dvh - 140px);
    overflow-y: auto;
  }
}

@media (max-width: 410px) {
  body.mobile-ui-active header {
    grid-template-columns:
      minmax(44px, 1fr)
      42px
      minmax(105px, auto) !important;
  }
}

/* =========================================================
   OptiWake — mobilne konto w nagłówku, poprawka v2
   ========================================================= */

.ow-account-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20010;
  display: block;
  padding: 0;
  border: 0;
  background: rgba(11, 29, 58, 0.18);
  cursor: default;
}

.ow-account-backdrop[hidden] {
  display: none !important;
}

.ow-account-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  cursor: pointer;
}

.ow-account-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.ow-account-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.ow-account-menu {
  z-index: 20020 !important;
}

body.ow-account-open {
  overflow: hidden;
}

body.ow-account-open header {
  z-index: 20000 !important;
}

@media (max-width: 820px) {
  body.mobile-ui-active header {
    position: relative !important;
    z-index: 12000 !important;
    display: grid !important;

    grid-template-columns:
      minmax(0, 1fr)
      44px
      minmax(118px, 142px) !important;

    grid-template-areas:
      "brand account wind" !important;

    align-items: center !important;
    gap: 7px !important;
    min-height: 62px !important;
    padding: 7px 9px !important;
    overflow: visible !important;
  }

  body.mobile-ui-active header > :first-child,
  body.mobile-ui-active header .brand {
    grid-area: brand !important;
    grid-column: auto !important;
    grid-row: 1 !important;
    min-width: 0 !important;
    overflow: hidden;
  }

  body.mobile-ui-active header > :first-child img,
  body.mobile-ui-active header .brand img {
    display: block;
    width: auto;
    max-width: 145px;
    max-height: 46px;
    object-fit: contain;
  }

  body.mobile-ui-active
  header
  .ow-account-root {
    grid-area: account !important;
    grid-column: auto !important;
    grid-row: 1 !important;
    align-self: center !important;
    justify-self: center !important;
    position: relative !important;
    z-index: 12020 !important;
    margin: 0 !important;
  }

  body.mobile-ui-active
  header
  .mobile-wind-summary {
    grid-area: wind !important;
    grid-column: auto !important;
    grid-row: 1 !important;
    align-self: center !important;
    justify-self: end !important;
    position: static !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 142px !important;
    margin: 0 !important;
  }

  body.mobile-ui-active
  .ow-account-menu {
    position: fixed !important;
    top: 68px !important;
    right: 8px !important;
    left: auto !important;
    z-index: 20020 !important;
    width: min(350px, calc(100vw - 16px)) !important;
    max-height: calc(100dvh - 84px) !important;
    overflow-y: auto !important;
  }

  body.mobile-ui-active
  .mobile-trackers-summary,
  body.mobile-ui-active
  .mobile-trackers-button,
  body.mobile-ui-active
  .tracker-legend {
    z-index: 720 !important;
  }

  body.mobile-ui-active
  .leaflet-top,
  body.mobile-ui-active
  .leaflet-bottom,
  body.mobile-ui-active
  .leaflet-control-container {
    z-index: 700 !important;
  }

  body.mobile-ui-active.ow-account-open
  .mobile-trackers-summary,
  body.mobile-ui-active.ow-account-open
  .mobile-trackers-button,
  body.mobile-ui-active.ow-account-open
  .tracker-legend {
    pointer-events: none !important;
  }
}

@media (max-width: 410px) {
  body.mobile-ui-active header {
    grid-template-columns:
      minmax(0, 1fr)
      40px
      minmax(108px, 126px) !important;

    gap: 5px !important;
    padding-right: 6px !important;
    padding-left: 6px !important;
  }

  body.mobile-ui-active
  header
  .ow-account-trigger {
    width: 40px !important;
    min-height: 40px !important;
  }

  body.mobile-ui-active
  header
  .ow-account-avatar {
    flex-basis: 36px !important;
    width: 36px !important;
    height: 36px !important;
  }
}

/* OPTIWAKE_USER_ACCOUNT_PORTAL_CLEAN_V2A */
.ow-account-menu.ow-account-menu-portal-clean-v2a {
  position: fixed !important;
  right: 16px;
  top: 76px;
  z-index: 99990 !important;
  width: min(360px, calc(100vw - 24px));
  max-height: calc(100vh - 88px);
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  box-sizing: border-box !important;
  margin: 0 !important;
  transform: none !important;
  contain: layout paint;
}

.ow-account-action.admin-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 10px 13px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, #0f172a, #12345a);
  color: #ffffff !important;
  text-decoration: none !important;
  font-weight: 900;
  line-height: 1.15;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.ow-account-action.admin-tools[hidden] {
  display: none !important;
}

.ow-account-action.admin-tools small {
  opacity: 0.72;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .ow-account-menu.ow-account-menu-portal-clean-v2a {
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
    max-height: calc(100vh - 92px);
    border-radius: 20px;
  }

  .ow-account-action.admin-tools {
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
  }
}
