*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: var(--text-xl);
}

h2 {
  font-size: var(--text-lg);
}

p {
  margin: 0;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-4);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack-tight {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.page {
  width: 100%;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.row-end {
  justify-content: flex-end;
}

/* Skip link: visible only when focused with the keyboard. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 20;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-weight: 600;
}

.skip-link:focus {
  top: var(--space-2);
}

/* `main` is focused after navigation; the content itself needs no ring. */
main:focus {
  outline: none;
  box-shadow: none;
}

/* Login, second step, setup, forced password change */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
}

.corner-controls {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-6) 0 var(--space-12);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

/* App shell */
.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-nav {
  display: flex;
  gap: var(--space-2);
  flex: 1;
}

.app-nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 600;
}

.app-nav a[aria-current="page"] {
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

.app-bar-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.user-name {
  font-weight: 600;
  padding: 0 var(--space-2);
}

@media (max-width: 640px) {
  .app-bar-end {
    width: 100%;
    justify-content: flex-end;
  }

  .user-name {
    margin-right: auto;
    padding-left: 0;
  }
}
