/* Shared page shell and primary navigation.
   Page-specific colors and controls stay in each page; geometry lives here. */
.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 126px;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  position: relative;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.app-logo {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
}

.app-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.app-title {
  color: var(--text-bright);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
}

.app-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.2px;
}

.header-controls {
  display: contents;
}

:is(.tab-nav, .mode-tabs) {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  padding: 3px;
  background: var(--bar-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

:is(.tab-nav a, .mode-tab) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 5px 11px;
  border-radius: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

:is(.tab-nav a, .mode-tab):hover {
  color: var(--text-bright);
  background: rgba(128, 128, 128, 0.12);
}

.page-tools,
.k-themes {
  width: 126px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.theme-toggle {
  min-width: 34px;
  min-height: 34px;
  padding: 6px 9px;
  background: var(--bar-bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
  color: var(--text-bright);
  border-color: var(--border-hi);
}

:is(.logo-link, .tab-nav a, .mode-tab, .theme-toggle):focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

/* Kyle and Settlement Desk use a readable measure, centered in the full shell. */
.app.app--narrow > :not(.app-header) {
  width: min(800px, 100%);
  margin-right: auto;
  margin-left: auto;
}

@media (max-width: 760px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  :is(.tab-nav, .mode-tabs) {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  :is(.tab-nav a, .mode-tab) {
    flex: 1 1 0;
    min-width: 0;
    padding-right: 6px;
    padding-left: 6px;
    white-space: normal;
  }

  .page-tools,
  .k-themes {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  body {
    padding: 20px 14px 64px;
  }

  .app-header {
    margin-bottom: 24px;
  }

  .app-title {
    font-size: 18px;
  }

  .app.app--narrow > :not(.app-header) {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 380px) {
  .app-subtitle {
    display: none;
  }
}