/* One opaque, borderless island; safe area belongs to the shell, not its buttons. */
body.panel-shell > header.signed-in,
body.panel-shell header.vm-unified-header {
  --island-top: max(8px, env(safe-area-inset-top, 0px));
  --island-side: max(8px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  display: grid !important;
  --island-status-width: clamp(82px, 24vw, 104px);
  --island-button-width: clamp(56px, 16vw, 68px);
  grid-template-columns: var(--island-status-width) minmax(0, 1fr) var(--island-button-width) !important;
  grid-template-rows: 56px !important;
  align-items: stretch !important;
  gap: 4px !important;
  position: fixed;
  top: 0; right: 0; left: 0; bottom: auto;
  width: 100%; max-width: none !important;
  margin: 0 !important;
  padding: var(--island-top) var(--island-side) 8px !important;
  box-sizing: border-box;
  border: 0 !important;
  border-radius: 0 !important;
  background: #111827 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  filter: none !important;
  z-index: 5;
  isolation: isolate;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header)::before {
  content: "";
  position: absolute;
  inset: var(--island-top) var(--island-side) 8px;
  background: #1e293b;
  border-radius: 16px;
  pointer-events: none;
  z-index: -1;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header).has-employee-preview {
  grid-template-columns: var(--island-status-width) minmax(0, 1fr) repeat(2, var(--island-button-width)) !important;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > :is(.mobile-connection, .panel-section-title, .vm-header-title, .panel-account-menu, .employee-preview-button, .panel-back) {
  position: relative !important;
  inset: auto !important;
  grid-row: 1 !important;
  align-self: stretch !important; justify-self: stretch !important;
  width: auto !important; min-width: 0 !important; max-width: none !important;
  height: 56px !important; min-height: 56px !important; max-height: 56px !important;
  margin: 0 !important; padding: 0 8px !important;
  box-sizing: border-box !important;
  border: 0 !important;
  border-radius: 16px !important;
  background: transparent !important; color: #f8fafc;
  box-shadow: none !important; transform: none !important;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > .mobile-connection {
  grid-column: 1 !important;
  display: flex; justify-content: center; gap: 6px;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header) .mobile-connection-copy {font-size: 10px; line-height: 1.2; min-width: 0;}
body.panel-shell :is(header.signed-in, header.vm-unified-header) .mobile-connection-bars {display: none;}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > :is(.panel-section-title, .vm-header-title, .panel-account-menu) {
  grid-column: 2 !important; display: flex; align-items: center; justify-content: center;
  font-size: 16px !important; line-height: 1.15; text-align: center; overflow-wrap: anywhere;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > .panel-back {
  grid-column: -2 / -1 !important;
  display: grid; place-items: center;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > .employee-preview-button {grid-column: 3 !important;}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > .employee-preview-button,
body.panel-shell :is(header.signed-in, header.vm-unified-header) > .panel-back[aria-label^="Wstecz"] {
  place-self: center !important;
  width: 44px !important; height: 44px !important; min-height: 44px !important;
  border-radius: 50% !important; padding: 0 !important;
  background: var(--button-bg, #334155) !important; color: #fff;
  border: 1px solid var(--field-border) !important;
  font-size: 14px; font-weight: 600;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > .employee-preview-button[aria-pressed="true"] {background: #b91c1c !important;}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > button:active {
  background: #334155 !important;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > button:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: -3px;
}
body.panel-shell :is(header.signed-in, header.vm-unified-header) > [hidden] {
  display: none !important;
}
body.panel-shell > header.signed-in[hidden],
body.panel-shell > header[hidden] + .panel-header-space {display: none !important;}
.panel-header-space { flex: none; pointer-events: none; }

/* WebKit standalone samples the top edge separately from normal Safari.
   Use a real, opaque fixed element present before login; not a pseudo-element.
   12px exceeds WebKit's thin-border exclusion (10px). Keep all controls below it.
   Source: WebCore/page/LocalFrameView.cpp, fixedContainerEdges. */
#vm-standalone-top-edge { display: none; }
@media (display-mode: standalone) {
  #vm-standalone-top-edge {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: max(12px, env(safe-area-inset-top, 0px));
    background: #111827;
    opacity: 1;
    pointer-events: auto;
    z-index: 2147483646;
    border: 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  body.panel-shell > header.signed-in,
  body.panel-shell header.vm-unified-header {
    --island-top: max(12px, env(safe-area-inset-top, 0px));
  }
  @supports (-webkit-touch-callout: none) {
    body.panel-shell > header.signed-in,
    body.panel-shell header.vm-unified-header {
      /* Keep the interactive row below the faded top half of the 56px island. */
      --island-top: calc(max(12px, env(safe-area-inset-top, 0px)) + 32px);
    }
  }
}
