.ui-header {
  --ui-header-surface: color-mix(in srgb, var(--cidti-blue) 82%, var(--cidti-cyan) 18%);
  --ui-header-surface-strong: color-mix(in srgb, var(--cidti-blue) 68%, var(--cidti-cyan) 32%);
  --ui-header-border: color-mix(in srgb, var(--cidti-blue) 58%, var(--cidti-cyan) 42%);
  --ui-header-control-surface: color-mix(in srgb, white 90%, var(--cidti-blue) 10%);
  --ui-header-control-surface-strong: color-mix(in srgb, white 82%, var(--cidti-cyan) 18%);
  --ui-header-control-border: color-mix(in srgb, white 58%, var(--cidti-blue) 42%);
  --ui-header-text: var(--cidti-white);
  --ui-header-muted-text: rgb(255 255 255 / 0.74);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  border-bottom: var(--border-width) solid color-mix(in srgb, var(--ui-header-border) 55%, white);
  background:
    radial-gradient(circle at top right, rgb(51 204 204 / 0.22), transparent 16rem),
    linear-gradient(90deg, rgb(255 255 255 / 0.08), transparent 18rem),
    linear-gradient(135deg, var(--ui-header-surface), var(--ui-header-surface-strong));
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 30px rgb(15 23 42 / 0.12);

  .ui-header__inner {
    display: flex;
    padding: var(--space-3);
  }

  .ui-header__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--ui-header-text);
    font: 700 var(--font-size-2xl) var(--font-secondary);
    text-decoration: none;

    & span {
      letter-spacing: 0.0008em;
    }
  }

  .ui-header__logo {
    width: auto;
    height: 2.4rem;
    border-radius: var(--radius-sm);
    object-fit: contain;
  }

  .ui-header__leading {
    display: flex;
    align-items: center;
    gap: var(--space-4);
  }

  .ui-header__center {
    display: flex;
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
  }

  .dashboard-header__user {
    position: relative;
  }

  .dashboard-header__user-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 3rem;
    border: var(--border-width) solid var(--ui-header-control-border);
    border-radius: var(--radius-pill);
    background: rgb(255 255 255 / 0.14);
    backdrop-filter: blur(10px);
    color: var(--ui-header-text);
    padding: 0.4rem 0.85rem 0.4rem 0.4rem;
    transition:
      border-color var(--transition-fast),
      background var(--transition-fast);
  }

  .dashboard-header__user-button:is(:hover, :focus-visible) {
    border-color: var(--dashboard-accent-ink, var(--ui-header-control-surface-strong));
    background: color-mix(in srgb, var(--ui-header-control-surface-strong) 80%, white);
  }

  .dashboard-header__user-button svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .dashboard-header__user-button:focus-visible,
  .dashboard-header__dropdown a:focus-visible,
  .app-header-actions .ui-button:focus-visible {
    outline: 2px solid #8a3b00;
    outline-offset: 3px;
    box-shadow:
      0 0 0 3px rgb(255 255 255 / 0.92),
      0 0 0 6px rgb(138 59 0 / 0.22);
  }

  .dashboard-header__user-badge {
    display: inline-grid;
    place-items: center;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 50%;
    background: var(--color-brand-primary);
    color: var(--dashboard-button-text, var(--color-text));
    font-size: var(--font-size-sm);
    font-weight: 800;
  }

  .dashboard-header__user-meta {
    display: grid;
    justify-items: start;
    gap: 0.1rem;
  }

  .dashboard-header__user-meta strong {
    color: var(--ui-header-text);
  }

  .dashboard-header__user-meta small {
    color: var(--ui-header-muted-text);
    font-size: var(--font-size-xs);
  }

  .dashboard-header__dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: var(--z-dropdown);
    min-width: 12rem;
    padding: var(--space-2);
  }

  .dashboard-header__dropdown a {
    display: block;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    padding: 0.7rem 0.85rem;
    text-decoration: none;
  }

  .dashboard-header__dropdown a:is(:hover, :focus-visible) {
    background: var(--color-surface-muted);
  }
}

body.has-app-shell-sidebar {
  .ui-header {
    .ui-header__inner {
      align-items: center;
      justify-content: space-between;
      gap: var(--space-4);
    }

    .ui-header__leading {
      gap: var(--space-3);
    }

    .ui-header__brand {
      flex: 0 1 auto;
      min-width: 0;
    }

    .app-header-actions {
      align-items: center;
      justify-content: flex-end;
      margin-inline-start: auto;
    }

    .ui-header__center {
      padding-inline: var(--space-3);
    }
  }
}

@media (max-width: 48rem) {
  .ui-header {
    .ui-header__inner {
      align-items: flex-start;
      flex-direction: column;
    }
  }

  body.has-app-shell-sidebar {
    .ui-header {
      .ui-header__inner {
        align-items: center;
        flex-wrap: wrap;
        gap: var(--space-3);
      }

      .ui-header__leading {
        gap: var(--space-2);
      }

      .ui-header__center {
        order: 3;
        width: 100%;
        flex-basis: 100%;
        justify-content: center;
        padding-inline: 0;
      }

      .app-header-actions {
        justify-content: flex-end;
      }
    }
  }
}
