html {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

body {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  min-height: 100vh;
  padding-top: 5px;
  background:
    linear-gradient(118deg, rgba(52, 70, 89, 0.72) 0%, rgba(24, 36, 49, 0.2) 36%, transparent 56%),
    linear-gradient(242deg, rgba(35, 46, 59, 0.48) 0%, transparent 40%),
    linear-gradient(180deg, #202d3a 0%, #111a24 34%, #070b10 68%, #010203 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(196, 211, 226, 0.035) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(0deg, rgba(196, 211, 226, 0.025) 0 1px, transparent 1px 80px),
    linear-gradient(112deg, transparent 18%, rgba(138, 160, 184, 0.12) 42%, transparent 64%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, 0.82) 56%, transparent 100%);
}

body > main,
body > .app-header {
  position: relative;
  z-index: 1;
}

/*
 * All four screens share the original LOCAL dashboard outer frame.
 * Page-specific CSS may style content inside the frame, but it must not
 * redefine the frame width, centering, or the gap below the shared header.
 */
body > main {
  width: min(1280px, calc(100% - 64px)) !important;
  max-width: none !important;
  margin-right: auto !important;
  margin-left: auto !important;
  padding-top: 5px !important;
}

.app-header {
  position: relative;
  display: grid !important;
  grid-template-columns: minmax(250px, 1fr) minmax(330px, auto) minmax(360px, 1fr);
  align-items: center !important;
  gap: 12px;
  min-height: 58px;
  width: min(1280px, calc(100vw - 40px));
  max-width: none;
  margin: 0 auto 10px;
  padding: 8px 10px !important;
  border: 1px solid color-mix(in srgb, var(--line, #303844) 72%, transparent) !important;
  border-radius: 10px !important;
  background: color-mix(in srgb, var(--panel, #11171e) 78%, transparent) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18) !important;
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
}

.app-header-status {
  position: static !important;
  grid-column: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  justify-self: stretch;
  flex-wrap: wrap;
  gap: 5px;
  width: auto !important;
  transform: none !important;
  color: var(--muted, #919aa6);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.app-header-status > span,
.app-header-status .state-pill,
.app-header-status .collector-state {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0 8px;
  border: 1px solid var(--line, #303844);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.app-header-status > span b {
  margin-left: 4px;
  color: var(--text, #e3e7ed);
}

.app-header-time {
  font-variant-numeric: tabular-nums;
}

.app-header-brand {
  grid-column: 2;
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text, #e3e7ed);
  text-decoration: none;
}

.app-header-brand img {
  display: block;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: contain;
}

.app-header-brand strong {
  overflow: hidden;
  font-size: clamp(18px, 1.8vw, 25px);
  font-weight: 950;
  line-height: 1.08;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header-actions {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: stretch;
  gap: 5px;
  min-width: 0;
}

.app-header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.app-header-nav a,
.app-header-action {
  position: static !important;
  display: inline-flex;
  min-width: 0;
  min-height: 30px;
  height: 30px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: 0 !important;
  padding: 0 9px !important;
  transform: none !important;
  border: 1px solid var(--line, #303844) !important;
  border-radius: 7px !important;
  color: var(--muted, #a0a9b5) !important;
  background: rgba(15, 20, 26, 0.78) !important;
  font-family: inherit;
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.app-header-nav a[aria-current="page"] {
  border-color: rgba(230, 184, 77, 0.68) !important;
  color: #f2d38b !important;
  background: rgba(230, 184, 77, 0.1) !important;
}

.app-header-nav a:hover,
.app-header-nav a:focus-visible,
.app-header-action:hover,
.app-header-action:focus-visible {
  border-color: var(--accent, var(--status, #e6b84d)) !important;
  color: var(--text, #fff) !important;
  outline: 2px solid color-mix(in srgb, var(--accent, var(--status, #e6b84d)) 24%, transparent);
  outline-offset: 1px;
}

.app-header-action .theme-icon,
.app-header-board-icon {
  display: block;
  flex: 0 0 12px;
  width: 12px;
  color: var(--accent, var(--status, #e6b84d));
  font-family: inherit;
  font-size: 10px;
  line-height: 1;
  text-align: center;
}

.app-header-board-label {
  font: inherit;
}

.app-header-intro {
  margin: -3px 0 10px;
  color: var(--muted, #919aa6);
  font-size: 11px;
  text-align: center;
}

html[data-theme="light"] .app-header {
  background: rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 8px 24px rgba(31, 38, 48, 0.08) !important;
}

html[data-theme="light"] body {
  background: linear-gradient(180deg, #ffffff 0%, #edf1f5 48%, #dfe5eb 100%);
  background-attachment: fixed;
}

html[data-theme="light"] body::before {
  display: none;
}

html[data-theme="light"] .app-header-nav a,
html[data-theme="light"] .app-header-action,
html[data-theme="light"] .app-header-status > span,
html[data-theme="light"] .app-header-status .state-pill,
html[data-theme="light"] .app-header-status .collector-state {
  background: rgba(255, 255, 255, 0.92) !important;
}

html.board-mode .shell {
  height: auto;
  min-height: 0;
  grid-template-rows: minmax(68px, 0.8fr) minmax(218px, 2.05fr) minmax(178px, 2.35fr);
}

html.board-mode body {
  display: grid;
  grid-template-rows: 75px minmax(0, 1fr);
}

/* Board mode keeps normal scrolling semantics without reserving a visible scrollbar. */
@media (min-width: 901px) and (min-height: 621px) {
  html.board-mode {
    overflow-x: hidden;
    overflow-y: auto;
  }
}

@media (max-width: 1120px) {
  .app-header {
    grid-template-columns: minmax(190px, 1fr) minmax(270px, auto) minmax(310px, 1fr);
    gap: 8px;
  }

  .app-header-brand img { width: 44px; height: 44px; }
  .app-header-brand strong { font-size: clamp(16px, 1.8vw, 21px); }
  .app-header-nav a, .app-header-action { padding: 0 7px !important; font-size: 9px; }
}

@media (max-width: 900px) {
  .app-header {
    width: calc(100vw - 20px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "actions"
      "status";
    gap: 6px;
    min-height: 0;
  }

  .app-header-brand { grid-area: brand; }
  .app-header-actions { grid-area: actions; justify-content: center; }
  .app-header-status { grid-area: status; justify-content: center; }
  .app-header-intro { margin-top: 0; }

}

@media (max-width: 900px), (max-height: 620px) {
  html.board-mode body { display: block; }
  html.board-mode .shell { min-height: 0; }
}

@media (max-width: 520px) {
  .app-header {
    width: calc(100vw - 28px);
    gap: 5px;
    margin-bottom: 7px;
    padding: 6px 5px !important;
  }

  .app-header-brand { gap: 7px; }
  .app-header-brand img { width: 42px; height: 42px; }
  .app-header-brand strong { font-size: 16px; }
  .app-header-actions { width: 100%; gap: 3px; }
  .app-header-nav { flex: 1 1 auto; gap: 3px; }
  .app-header-nav a { flex: 1 1 auto; }
  .app-header-nav a, .app-header-action { min-height: 29px; height: 29px; padding: 0 6px !important; font-size: 8.5px; }
  .app-header-status { gap: 3px; font-size: 8.5px; }
  .app-header-status > span,
  .app-header-status .state-pill,
  .app-header-status .collector-state { min-height: 25px; padding: 0 6px; }

  body > main {
    width: calc(100% - 12px) !important;
    padding-top: 6px !important;
  }
}
