html {
  position: relative;
  min-height: 100%;
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  min-height: 100vh;
  margin-bottom: 72px;
  background: #f6f7f9;
  color: #1f2937;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem rgba(37, 99, 235, 0.35);
}

.app-nav {
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}

.navbar-actions,
.language-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-actions {
  flex-wrap: wrap;
}

.language-switcher {
  margin-inline-end: 12px;
  padding: 3px;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  background: #f8fafc;
}

.language-switcher form {
  margin: 0;
}

.language-option {
  min-height: 32px;
  padding: 4px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
}

.language-option:hover,
.language-option:focus-visible {
  background: #e9eef5;
  color: #1f2937;
}

.language-option.active {
  background: #1f2937;
  color: #fff;
}

.language-option:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.app-main {
  padding-top: 28px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-header h1,
.auth-panel h1,
.surface h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 1.05;
}

.surface h2,
.surface h1 {
  font-size: 1.35rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.metric-card,
.surface,
.branding-card,
.auth-panel {
  border: 1px solid #dde3ea;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.metric-card {
  min-height: 112px;
  padding: 18px;
}

.metric-card span {
  display: block;
  color: #64748b;
  font-size: 0.85rem;
}

.metric-card strong {
  display: block;
  margin-top: 16px;
  font-size: 1.35rem;
}

.surface {
  padding: 24px;
}

.surface.narrow {
  max-width: 560px;
  margin: 0 auto;
}

.endpoint-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.endpoint-grid code {
  display: block;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  white-space: normal;
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 220px);
  place-items: center;
  padding: 28px 0;
}

.auth-panel {
  width: min(100%, 460px);
  padding: 32px;
  border-top: 5px solid var(--brand-color, #2563eb);
}

.brand-logo {
  display: block;
  max-width: 180px;
  max-height: 72px;
  margin-bottom: 22px;
  object-fit: contain;
}

.stacked-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.client-secret-alert {
  display: grid;
  gap: 8px;
}

.client-secret-alert > code {
  display: block;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: #1f2937;
  overflow-wrap: anywhere;
}

.client-secrets-surface {
  display: grid;
  gap: 22px;
}

.client-secrets-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.client-secrets-heading p {
  max-width: 68ch;
  margin: 6px 0 0;
  color: #475569;
}

.client-secret-disclosure {
  display: flex;
  align-items: center;
  gap: 10px;
}

.client-secret-disclosure code {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: #1f2937;
  overflow-wrap: anywhere;
}

.client-secret-create-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  max-width: 720px;
}

.client-secret-create-form .btn {
  margin-bottom: 24px;
}

.client-secret-list {
  border-top: 1px solid #e2e8f0;
}

.client-secret-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, auto) auto;
  align-items: center;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid #e2e8f0;
}

.client-secret-identity {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.client-secret-identity span {
  color: #475569;
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.client-secret-hint {
  color: #334155;
  white-space: nowrap;
}

.client-secret-empty {
  display: grid;
  gap: 4px;
  padding: 20px 0 4px;
  color: #475569;
}

.client-secret-empty strong {
  color: #1e293b;
}

.btn-primary {
  --bs-btn-bg: var(--brand-color, #2563eb);
  --bs-btn-border-color: var(--brand-color, #2563eb);
  --bs-btn-hover-bg: #1d4ed8;
  --bs-btn-hover-border-color: #1d4ed8;
}

.scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 24px;
}

.scope-list span {
  padding: 6px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand-color, #2563eb) 12%, white);
  color: #1f2937;
  font-size: 0.85rem;
  font-weight: 600;
}

.branding-list {
  display: grid;
  gap: 18px;
}

.branding-card {
  padding: 20px;
  border-left: 5px solid var(--brand-color, #2563eb);
}

.branding-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.branding-preview img,
.logo-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: contain;
  background: #f8fafc;
}

.logo-placeholder {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--brand-color, #2563eb);
  font-size: 1.4rem;
  font-weight: 700;
}

.branding-preview code {
  display: block;
  margin-top: 4px;
  color: #64748b;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.pill-list,
.role-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-list span,
.role-checklist label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 600;
}

.pill-list.compact span {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 0.78rem;
}

.role-checklist input {
  margin: 0;
}

.client-kind-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.client-kind-picker label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
}

.client-kind-picker input {
  margin: 0;
}

.client-list {
  display: grid;
  gap: 14px;
}

.scope-admin-list {
  display: grid;
  gap: 12px;
}

.scope-row {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.scope-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.scope-summary code {
  display: block;
  margin-top: 5px;
  color: #64748b;
  overflow-wrap: anywhere;
}

.scope-row-label {
  display: block;
  margin-bottom: 7px;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.scope-actions {
  justify-self: start;
}

.scope-edit-form {
  display: grid;
  gap: 12px;
}

.scope-edit-form .btn {
  justify-self: start;
}

.scope-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.client-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.36fr) minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.client-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.client-summary code {
  display: block;
  margin-top: 5px;
  color: #64748b;
  overflow-wrap: anywhere;
}

.client-detail-grid {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) minmax(160px, 1.4fr) repeat(2, minmax(88px, 0.6fr));
  gap: 14px;
}

.client-detail-grid > div > span {
  display: block;
  margin-bottom: 7px;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.client-detail-grid > div > strong {
  display: block;
  font-size: 1.15rem;
}

.user-list {
  display: grid;
  gap: 14px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.user-role-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: 60px;
  line-height: 60px;
  background: #fff;
}

@media (max-width: 640px) {
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-panel,
  .surface,
  .branding-card {
    padding: 20px;
  }

  .admin-grid,
  .client-row,
  .client-detail-grid,
  .scope-edit-grid,
  .user-row {
    grid-template-columns: 1fr;
  }

  .user-role-form {
    align-items: flex-start;
    flex-direction: column;
  }

  .client-secrets-heading,
  .client-secret-disclosure {
    align-items: stretch;
    flex-direction: column;
  }

  .client-secret-create-form,
  .client-secret-row {
    grid-template-columns: 1fr;
  }

  .client-secret-create-form .btn {
    width: 100%;
    margin-bottom: 0;
  }

  .client-secret-row form,
  .client-secret-row .btn {
    width: 100%;
  }

  .navbar-actions {
    align-items: stretch;
    flex-direction: column;
    padding-block: 12px;
  }

  .language-switcher {
    align-self: flex-start;
    margin-inline-end: 0;
  }

  .auth-navigation {
    gap: 8px;
  }
}
