/* Identity colour roles. Keep the key's light, mid and deep gold in one place. */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #161616;
  --surface-raised: #202020;
  --border: #343434;
  --border-strong: #626262;
  --text: #e9e6df;
  --text-muted: #b8b5ae;
  --accent-text: #ecca7d;
  --accent-fill: #e0a526;
  --accent-fill-hover: #ecca7d;
  --accent-selected: #332914;
  --accent-selected-hover: #44351a;
  --focus: #f4d997;
  --info-bg: #192936;
  --info-border: #6488a1;
  --info-text: #c1dcf0;
  --warning-bg: #352519;
  --warning-border: #c2804f;
  --warning-text: #ffd5ae;
  --danger-bg: #3a1818;
  --danger-border: #b64747;
  --danger-text: #ffbebe;
  --danger-fill: #a02a2a;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  background: var(--page);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-card {
  width: calc(100% - 32px);
  max-width: 420px;
  margin: 48px 16px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.app-card h1 {
  font-size: 18px;
  margin-bottom: 16px;
}

.app-card h2 {
  font-size: 14px;
  color: var(--text-muted);
  margin: 16px 0 8px;
}

.app-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.app-field label {
  font-size: 12px;
  color: var(--text-muted);
}

.app-field input {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 8px;
  font-size: 14px;
}

.login-session-choice label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.login-session-choice input[type=checkbox] {
  width: 18px;
  height: 18px;
  padding: 0;
  flex: none;
}

.login-password-controls {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.login-password-controls input {
  width: 100%;
  min-width: 0;
}

.login-password-toggle {
  align-self: flex-end;
  background: none;
  border: 0;
  color: var(--accent-text);
  min-height: 32px;
  padding: 4px 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.login-password-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.app-button {
  background: var(--accent-fill);
  border: none;
  border-radius: 4px;
  color: var(--text);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}

.app-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.app-button.secondary {
  background: var(--surface-raised);
}

.app-button.danger {
  background: var(--danger-fill);
}

.app-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 12px;
  color: var(--danger-text);
  font-size: 13px;
}

.app-notice {
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 12px;
  color: var(--info-text);
  font-size: 13px;
}

.availability-banner {
  display: grid;
  gap: 2px;
}

.app-list {
  list-style: none;
}

.app-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.app-list .app-list-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Logged-in views share a wider shell; login and authorisation stay compact. */
.app-card.logged-in {
  width: min(1200px, 100% - 32px);
  max-width: 1200px;
  min-width: 0;
  margin: 24px 16px;
  padding: clamp(16px, 3vw, 32px);
}

.identity-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.identity-header h1 {
  margin: 0;
  font-size: 24px;
}

.identity-header > span {
  color: var(--text-muted);
  margin-right: auto;
  overflow-wrap: anywhere;
}

.identity-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.identity-tabs button {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
}

.identity-tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent-text);
  background: var(--accent-selected);
}

.identity-tabs button:hover {
  background: var(--accent-selected-hover);
}

.identity-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  gap: 12px;
  margin: 18px 0;
}

.summary-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 18px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.summary-card strong {
  color: var(--text);
  font-size: 26px;
}

.identity-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.identity-filter label {
  flex-basis: 100%;
}

.identity-filter input {
  flex: 1 1 220px;
  min-width: 0;
  background: var(--page);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 10px;
  font: inherit;
}

.identity-filter [role=group] {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.identity-type {
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-inline-end: 0.6em;
}

.identity-wizard {
  display: grid;
  gap: 12px;
  max-width: 680px;
  padding: 16px;
  margin-top: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.identity-wizard label {
  display: block;
}

.identity-wizard input[type=radio] {
  margin-right: 8px;
}

.identity-wizard button {
  justify-self: start;
}

.logged-in .app-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  min-width: 0;
}

.logged-in .app-list li > span:first-child {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.logged-in .app-list-meta {
  overflow-wrap: anywhere;
}

.logged-in p {
  margin: 8px 0;
}

.logged-in h2 {
  font-size: 18px;
  color: var(--text);
  margin: 24px 0 8px;
}

.logged-in .app-field input {
  max-width: 650px;
}

button:focus-visible, a:focus-visible, input:focus-visible, [role=tabpanel]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .app-card.logged-in {
    margin: 12px 8px;
    width: calc(100% - 16px);
    padding: 16px;
  }
  .identity-tabs button {
    flex: 1 1 42%;
    padding: 10px 4px;
  }
  .logged-in .app-list li {
    flex-wrap: wrap;
  }
  .logged-in .app-list li > span:first-child {
    flex-basis: 100%;
  }
  .logged-in .app-list li button {
    flex: 1 1 auto;
  }
}
.identity-context {
  margin: 0 0 20px;
}

.identity-principal {
  color: var(--text);
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.identity-acting {
  padding: 12px 16px;
  border: 2px solid var(--accent-fill);
  border-radius: 6px;
  background: var(--accent-selected);
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.identity-acting.unavailable {
  border-color: var(--warning-border);
  background: var(--warning-bg);
}

/* Branding is shared by task pages and the signed-in header. */
.identity-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  color: var(--accent-text);
  font-weight: 700;
  font-size: 18px;
  line-height: 1.2;
  margin-bottom: 18px;
}

.identity-brand img {
  display: block;
  width: 1.55em;
  height: 1.55em;
  flex: none;
}

.identity-header .identity-brand {
  font-size: inherit;
  margin: 0;
}

.login-layout {
  width: min(100% - 32px, 900px);
  margin: 48px 16px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(0, 420px);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
}

.login-layout .login-card {
  width: 100%;
  margin: 0;
}

.identity-brand-login {
  font-size: clamp(30px, 5vw, 52px);
  margin: 0;
}

.identity-brand-login img {
  width: 1.65em;
  height: 1.65em;
}

@media (max-width: 600px) {
  .login-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    margin: 28px 16px;
  }
  .identity-brand-login {
    font-size: 30px;
    margin-inline: 4px;
  }
}
/* Fixed notices never change document positions. Scroll room is constant. */
body {
  min-height: 100vh;
  padding-bottom: calc(320px + env(safe-area-inset-bottom));
}

.identity-notice-stack {
  position: fixed;
  z-index: 1000;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(360px, 100vw - 32px);
  max-height: min(50vh, 280px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.identity-notice-stack > div {
  pointer-events: none;
}

.identity-notice-stack .availability-banner, .identity-notice-stack .version-banner {
  pointer-events: auto;
  width: 100%;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  overflow-wrap: anywhere;
}

.identity-notice-stack .availability-banner {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
}

.identity-notice-stack .version-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface-raised);
  border: 1px solid var(--accent-fill);
  color: var(--text);
}

.version-banner-reload {
  background: var(--accent-fill);
  color: var(--page);
  border: 0;
  border-radius: 4px;
  padding: 6px 12px;
  min-height: 36px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.version-banner-reload:hover, .app-button:not(:disabled):not(.secondary):not(.danger):hover {
  background: var(--accent-fill-hover);
}

.version-banner-reload:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app-button:not(.danger):not(.secondary) {
  color: var(--page);
  font-weight: 700;
}

.app-button.secondary {
  border: 1px solid var(--border-strong);
}

.app-button.secondary:not(:disabled):hover {
  background: var(--border);
}

.app-button.danger:not(:disabled):hover {
  background: var(--danger-border);
}

.app-button:disabled {
  opacity: 1;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

a:hover, .login-password-toggle:hover {
  color: var(--accent-fill-hover);
}

.identity-tabs button.active {
  color: var(--accent-text);
}

.summary-card:hover {
  border-color: var(--accent-fill);
  background: var(--accent-selected);
  text-decoration: none;
}

.identity-acting.unavailable {
  color: var(--warning-text);
}

input[type=checkbox], input[type=radio] {
  accent-color: var(--accent-fill);
}
