.instance-label {
  display: inline-flex;
  max-width: 240px;
  min-height: 24px;
  padding: 2px 9px;
  align-items: center;
  border-radius: 999px;
  overflow: hidden;
  background: var(--instance-color, #ffffff);
  color: var(--instance-foreground, #111827);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body {
  background-color: var(--instance-background, #ffffff) !important;
}

body::before {
  content: "";
  position: fixed;
  z-index: 1000;
  inset: 0 0 auto;
  height: 5px;
  background: var(--instance-color, #ffffff);
  pointer-events: none;
}

.schwab-status-banner {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  width: 100%;
  margin: 0 0 14px;
  padding: 13px 14px;
  border: 1px solid #fca5a5;
  border-left: 5px solid #dc2626;
  border-radius: 9px;
  background: #fef2f2;
  color: #7f1d1d;
  box-shadow: 0 2px 8px rgb(127 29 29 / 8%);
}

.schwab-status-banner[hidden] {
  display: none;
}

.schwab-status-banner[data-level="warning"] {
  border-color: #fcd34d;
  border-left-color: #d97706;
  background: #fffbeb;
  color: #78350f;
  box-shadow: 0 2px 8px rgb(120 53 15 / 8%);
}

.schwab-status-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}

.schwab-status-banner[data-level="warning"] .schwab-status-icon {
  background: #d97706;
}

.schwab-status-content {
  min-width: 0;
  font-size: 13px;
  line-height: 1.45;
}

.schwab-status-content strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.schwab-status-time {
  margin-top: 3px;
  color: #991b1b;
  font-size: 12px;
}

.schwab-status-banner[data-level="warning"] .schwab-status-time {
  color: #92400e;
}

.schwab-status-details {
  margin-top: 5px;
}

.schwab-status-details summary {
  width: fit-content;
  cursor: pointer;
  font-size: 12px;
}

.schwab-status-details code {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 11px;
}

.schwab-status-retry {
  padding: 6px 10px;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.schwab-status-retry:hover {
  background: rgb(255 255 255 / 55%);
}

.schwab-status-retry:disabled {
  cursor: wait;
  opacity: 0.65;
}

.hdr {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

.hdr h1 {
  margin: 0;
  font-size: 22px;
}

.hdr .sub {
  margin-top: 6px;
  color: var(--muted, #6b7280);
  font-size: 13px;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-title-group {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.navlink {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 999px;
  text-decoration: none;
  color: #111827;
  background: #fff;
  font-size: 13px;
  font-weight: 400;
}

.navlink:hover {
  background: #f3f4f6;
}

.navlink.active {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.app-header-shell {
  max-width: 2000px;
  margin: 18px auto 0;
  padding: 0 14px;
}

@media (max-width: 640px) {
  .schwab-status-banner {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .schwab-status-retry {
    grid-column: 2;
    justify-self: start;
  }

  .topnav {
    flex-direction: column;
    align-items: flex-start;
    gap: 9px;
  }

  .header-title-group {
    flex-wrap: wrap;
  }

  .nav {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    padding: 1px 0 5px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .navlink {
    display: inline-flex;
    min-height: 38px;
    padding: 0 12px;
    flex: 0 0 auto;
    align-items: center;
    scroll-snap-align: start;
  }

  .hdr h1 {
    font-size: 20px;
  }

  .hdr .sub {
    font-size: 12px;
    line-height: 1.4;
  }
}
