:root {
  color-scheme: light;
  --brand: #5757c7;
  --brand-strong: #4444a8;
  --brand-soft: #eeeeff;
  --brand-faint: #f7f6ff;
  --ink: #17161d;
  --ink-soft: #383741;
  --muted: #626170;
  --subtle: #878694;
  --canvas: #f4f3f8;
  --surface: #ffffff;
  --surface-muted: #f8f7fa;
  --surface-strong: #efedf3;
  --line: #e3e1e8;
  --line-strong: #d5d2dc;
  --success: #147a4b;
  --success-soft: #e9f6ef;
  --warning: #a86107;
  --warning-soft: #fff4df;
  --danger: #bd3d3d;
  --danger-soft: #fff0ef;
  --info: #35659b;
  --info-soft: #edf4fb;
  --neutral-soft: #f0eff3;
  --shadow-card: 0 16px 40px rgba(53, 48, 78, 0.065);
  --shadow-float: 0 28px 90px rgba(42, 36, 74, 0.16);
  --radius-input: 12px;
  --radius-card: 20px;
  --radius-hero: 26px;
  --header-height: 72px;
  --content-width: 1480px;
  --focus: 0 0 0 3px rgba(87, 87, 199, 0.26);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
}

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

html {
  min-width: 320px;
  background: var(--canvas);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% -10%, rgba(255, 224, 204, 0.46), transparent 28rem),
    radial-gradient(circle at 93% 2%, rgba(176, 168, 255, 0.28), transparent 32rem),
    radial-gradient(circle at 72% 100%, rgba(176, 202, 255, 0.18), transparent 36rem),
    var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  touch-action: manipulation;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 12px;
  padding: 10px 14px;
  transform: translateY(-140%);
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.button:focus-visible,
.icon-button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.connection-banner {
  position: fixed;
  z-index: 90;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border: 1px solid #efd8a6;
  border-radius: 12px;
  background: #fff9e9;
  color: #764e0b;
  box-shadow: var(--shadow-card);
  font-size: 14px;
  font-weight: 650;
}

/* Authentication */
.auth-view {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  justify-items: center;
  padding: 48px 20px max(40px, env(safe-area-inset-bottom));
}

.auth-card {
  position: relative;
  width: min(500px, calc(100vw - 40px));
  overflow: hidden;
  padding: 38px 40px 34px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-float), inset 0 1px 0 rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}

.auth-card::before {
  position: absolute;
  top: -110px;
  right: -90px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(176, 168, 255, 0.24), transparent 68%);
  content: "";
  pointer-events: none;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 15px;
}

.brand-lockup--auth {
  position: relative;
  min-height: auto;
  margin-bottom: 54px;
}

.brand-wordmark {
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.brand-divider {
  width: 1px;
  height: 16px;
  background: var(--line-strong);
}

.brand-context {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.eyebrow {
  margin-bottom: 9px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.auth-copy {
  position: relative;
}

.auth-copy h1 {
  margin-bottom: 12px;
  font-size: clamp(32px, 8vw, 44px);
  font-weight: 760;
  line-height: 1.12;
  letter-spacing: -1.2px;
}

.auth-description {
  max-width: 36em;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
  text-wrap: pretty;
}

.auth-form {
  position: relative;
}

.auth-assurance {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.auth-assurance p {
  margin: 0;
}

.assurance-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border: 2px solid rgba(20, 122, 75, 0.18);
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.auth-footnote {
  margin: 18px 0 0;
  color: var(--subtle);
  font-size: 12px;
}

/* Controls */
.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field label,
.filter-field label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea,
.filter-field input,
.filter-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input,
.filter-field input,
.filter-field select {
  padding: 0 13px;
}

.field textarea {
  min-height: 112px;
  padding: 11px 13px;
  resize: vertical;
  line-height: 1.55;
}

.field input:hover,
.field textarea:hover,
.filter-field input:hover,
.filter-field select:hover {
  border-color: #bbb7c5;
}

.field input:focus,
.field textarea:focus,
.filter-field input:focus,
.filter-field select:focus {
  border-color: var(--brand);
  outline: none;
}

.field-hint,
.field-meta {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
}

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.field-meta .field-hint {
  flex: 1;
}

.form-error {
  margin: 12px 0 0;
  padding: 11px 13px;
  border-left: 3px solid var(--danger);
  border-radius: 6px 10px 10px 6px;
  background: var(--danger-soft);
  color: #8e2d2d;
  font-size: 13px;
}

.button,
.icon-button,
.admin-menu-button,
.menu-action,
.tab-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 740;
  transition: transform 150ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

.button:disabled,
.icon-button:disabled,
.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.button--wide {
  width: 100%;
}

.button--primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(87, 87, 199, 0.22);
}

.button--primary:hover:not(:disabled) {
  background: var(--brand-strong);
}

.button--secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
}

.button--secondary:hover:not(:disabled) {
  border-color: #bbb7c5;
  background: var(--surface-muted);
}

.button--danger {
  background: var(--danger);
  color: #fff;
}

.button--danger:hover:not(:disabled) {
  background: #9f3030;
}

.button--quiet {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: transparent;
  transition: background 160ms ease, transform 150ms ease;
}

.icon-button:hover {
  background: var(--surface-strong);
}

.icon-button:active {
  transform: scale(0.96);
}

.text-button {
  min-height: 36px;
  padding: 0;
  background: transparent;
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 750;
}

.text-button:hover:not(:disabled) {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* App shell */
.app-shell {
  min-height: 100dvh;
}

.app-header {
  position: sticky;
  z-index: 40;
  top: 0;
  min-height: var(--header-height);
  border-bottom: 1px solid rgba(222, 219, 228, 0.82);
  background: rgba(250, 249, 252, 0.82);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
}

.header-inner {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(220px, 1fr);
  min-height: var(--header-height);
  align-items: center;
  gap: 24px;
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  padding: 0 28px;
}

.primary-navigation {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(224, 221, 230, 0.9);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.primary-navigation a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 15px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
  transition: background 160ms ease, color 160ms ease, transform 150ms ease;
}

.primary-navigation a:hover {
  color: var(--ink);
}

.primary-navigation a:active {
  transform: scale(0.98);
}

.primary-navigation a[aria-current="page"] {
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: 0 4px 14px rgba(56, 49, 87, 0.08);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 14px;
}

.system-health {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px var(--warning-soft);
}

.system-health[data-state="healthy"] .health-dot {
  background: var(--success);
  box-shadow: 0 0 0 4px var(--success-soft);
}

.system-health[data-state="error"] .health-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px var(--danger-soft);
}

.admin-menu-wrap {
  position: relative;
}

.admin-menu-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 4px 8px 4px 5px;
  border-radius: 13px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.admin-menu-button:hover {
  background: rgba(255, 255, 255, 0.74);
}

.admin-initial {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 800;
}

.admin-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.admin-menu p {
  margin: 0;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--subtle);
  font-size: 12px;
}

.menu-action {
  width: 100%;
  min-height: 40px;
  margin-top: 6px;
  padding: 0 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.menu-action:hover {
  background: var(--danger-soft);
}

.mobile-menu-button {
  display: none;
}

.menu-lines,
.menu-lines::before,
.menu-lines::after {
  display: block;
  width: 19px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.menu-lines {
  position: relative;
}

.menu-lines::before {
  position: absolute;
  top: -6px;
}

.menu-lines::after {
  position: absolute;
  top: 6px;
}

.main-content {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  padding: 36px 28px max(64px, env(safe-area-inset-bottom));
}

.route-content {
  min-height: calc(100dvh - var(--header-height) - 100px);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.page-heading h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 760;
  line-height: 1.12;
  letter-spacing: -1.1px;
}

.page-heading p {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  text-wrap: pretty;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.page-actions > input,
.page-actions > select {
  min-width: 180px;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);
  background: var(--surface);
  color: var(--ink);
}

.page-actions > input:focus,
.page-actions > select:focus {
  border-color: var(--brand);
  outline: none;
}

.freshness {
  color: var(--subtle);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Cards and dashboard */
.card {
  border: 1px solid rgba(225, 222, 231, 0.9);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.card--elevated {
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric-card {
  min-height: 142px;
  padding: 20px 20px 18px;
  border: 1px solid rgba(227, 224, 233, 0.92);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
}

.metric-card--lead {
  position: relative;
  grid-column: span 2;
  overflow: hidden;
  background:
    radial-gradient(circle at 90% 12%, rgba(176, 168, 255, 0.28), transparent 14rem),
    rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-card);
}

.metric-label {
  margin-bottom: 17px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.metric-value {
  margin-bottom: 6px;
  font-size: 29px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: -0.8px;
  font-variant-numeric: tabular-nums;
}

.metric-card--lead .metric-value {
  font-size: clamp(38px, 5vw, 52px);
  letter-spacing: -1.5px;
}

.metric-note {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 20px;
  margin-top: 20px;
}

/* Security and passkeys */
.backup-passkey-notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  padding: 21px 22px;
  overflow: hidden;
  border: 1px solid rgba(189, 181, 239, 0.72);
  border-radius: var(--radius-card);
  background:
    radial-gradient(circle at 92% -80%, rgba(154, 141, 255, 0.32), transparent 18rem),
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(245, 243, 255, 0.96));
  box-shadow: var(--shadow-card);
}

.backup-passkey-icon,
.add-passkey-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 16px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(87, 87, 199, 0.22);
  font-size: 25px;
  font-weight: 620;
}

.backup-passkey-copy .eyebrow {
  margin-bottom: 3px;
}

.backup-passkey-copy h2 {
  margin-bottom: 4px;
  font-size: 17px;
  font-weight: 770;
  letter-spacing: -0.25px;
}

.backup-passkey-copy > p:last-child {
  max-width: 78ch;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.backup-passkey-action {
  white-space: nowrap;
}

.security-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin-bottom: 20px;
  padding: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 87% 5%, rgba(169, 160, 255, 0.32), transparent 20rem),
    radial-gradient(circle at 0% 100%, rgba(220, 239, 255, 0.5), transparent 22rem),
    rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-card);
}

.security-hero-mark {
  display: grid;
  width: 66px;
  height: 66px;
  place-items: center;
  border: 1px solid rgba(101, 92, 191, 0.18);
  border-radius: 22px;
  background: linear-gradient(145deg, #6c68d8, #4746b1);
  box-shadow: 0 15px 34px rgba(77, 72, 177, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 27px;
  font-weight: 800;
}

.security-hero-copy {
  min-width: 0;
}

.security-status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  margin-bottom: 10px;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 11px;
  font-weight: 780;
}

.security-status-pill[data-tone="attention"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.security-hero-copy h2 {
  margin-bottom: 6px;
  font-size: 21px;
  font-weight: 770;
  letter-spacing: -0.4px;
}

.security-hero-copy p {
  max-width: 68ch;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.security-hero-facts {
  display: flex;
  align-items: stretch;
  gap: 1px;
  overflow: hidden;
  border: 1px solid rgba(216, 212, 226, 0.88);
  border-radius: 16px;
  background: rgba(216, 212, 226, 0.88);
}

.security-fact {
  display: grid;
  min-width: 128px;
  align-content: center;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.82);
}

.security-fact strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 770;
}

.security-fact small {
  color: var(--subtle);
  font-size: 10px;
}

.security-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.72fr);
  align-items: start;
  gap: 20px;
}

.security-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 20px);
  display: grid;
  gap: 20px;
}

.security-panel {
  min-width: 0;
  padding: 22px;
}

.credential-count {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 4px 10px;
  border-radius: 9px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 11px;
  font-weight: 780;
}

.passkey-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}

.passkey-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  min-height: 102px;
  padding: 17px 18px;
  background: var(--surface);
  transition: background 160ms ease;
}

.passkey-item:hover {
  background: var(--brand-faint);
}

.passkey-device-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(199, 195, 222, 0.65);
  border-radius: 14px;
  background: linear-gradient(145deg, #f7f6ff, #eae8fb);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 820;
}

.passkey-main {
  min-width: 0;
}

.passkey-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.passkey-title-row h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 760;
}

.passkey-state {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 2px 7px;
  border-radius: 7px;
  background: var(--neutral-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 740;
}

.passkey-state[data-backed-up="true"] {
  background: var(--success-soft);
  color: var(--success);
}

.passkey-main > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.passkey-main .passkey-last-used {
  margin-top: 3px;
  color: var(--subtle);
  font-size: 11px;
}

.button--small {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 12px;
}

.remove-passkey-button:not(:disabled) {
  border-color: #ebcfcd;
  color: var(--danger);
}

.add-passkey-panel {
  background:
    radial-gradient(circle at 100% 0%, rgba(176, 168, 255, 0.2), transparent 13rem),
    rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-card);
}

.add-passkey-heading {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
}

.add-passkey-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 21px;
}

.add-passkey-heading h2 {
  margin-bottom: 3px;
  font-size: 17px;
  font-weight: 770;
}

.add-passkey-heading p {
  margin: 0;
  color: var(--subtle);
  font-size: 11px;
}

.add-passkey-field {
  margin-bottom: 16px;
}

.security-inline-note {
  margin: 12px 0 0;
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.55;
  text-align: center;
}

.security-guidance .panel-header {
  margin-bottom: 16px;
}

.security-rule-list {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.security-rule-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.security-rule-index {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 10px;
  font-weight: 800;
}

.security-rule-list strong,
.security-rule-list small {
  display: block;
}

.security-rule-list strong {
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: 12px;
}

.security-rule-list small {
  color: var(--subtle);
  font-size: 10px;
}

.modal-card--compact {
  width: 100%;
}

.security-confirmation-note {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px;
  border: 1px solid #efd8a6;
  border-radius: 12px;
  background: #fff9e9;
  color: #76500d;
}

.security-confirmation-note p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}

.security-confirmation-icon {
  display: grid;
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: var(--warning);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
}

.panel {
  min-width: 0;
  padding: 22px;
}

.panel--wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.panel-header h2,
.panel-header h3 {
  margin-bottom: 5px;
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -0.2px;
}

.panel-header p {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
}

.breakdown-list {
  display: grid;
  gap: 16px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(130px, 2fr) auto;
  align-items: center;
  gap: 14px;
}

.breakdown-label {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 670;
}

.breakdown-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--subtle);
}

.breakdown-dot--brand,
.breakdown-dot--duplicate {
  background: var(--brand);
}

.breakdown-dot--created,
.breakdown-dot--healthy,
.breakdown-dot--resolved {
  background: var(--success);
}

.breakdown-dot--review,
.breakdown-dot--unparsed,
.breakdown-dot--pending,
.breakdown-dot--processing {
  background: var(--warning);
}

.breakdown-dot--error,
.breakdown-dot--failed {
  background: var(--danger);
}

.breakdown-dot--ignored,
.breakdown-dot--neutral,
.breakdown-dot--skipped,
.breakdown-dot--dismissed {
  background: var(--subtle);
}

.breakdown-value {
  min-width: 58px;
  color: var(--muted);
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--brand);
}

progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-strong);
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--brand);
}

progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--brand);
}

.health-table-wrap,
.data-table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.health-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.health-table th,
.data-table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #faf9fb;
  color: var(--subtle);
  text-align: left;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 780;
  letter-spacing: 0.02em;
}

.health-table td,
.data-table td {
  padding: 14px;
  border-bottom: 1px solid #efedf2;
  color: var(--ink-soft);
  vertical-align: middle;
}

.health-table tr:last-child td,
.data-table tr:last-child td {
  border-bottom: 0;
}

.health-table tbody tr:hover,
.data-table tbody tr:hover {
  background: var(--brand-faint);
}

.data-table th {
  position: sticky;
  z-index: 1;
  top: 0;
}

.table-row-button {
  cursor: pointer;
}

.table-row-button:focus-within {
  background: var(--brand-faint);
  box-shadow: inset 3px 0 0 var(--brand);
}

.row-open-button {
  width: 100%;
  min-width: 170px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.row-open-button strong,
.primary-cell {
  display: block;
  margin-bottom: 3px;
  font-weight: 720;
}

.secondary-cell {
  display: block;
  max-width: 40ch;
  overflow: hidden;
  color: var(--subtle);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.number-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.exception-list {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}

.exception-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 15px;
  border: 0;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease;
}

.exception-item:hover {
  background: var(--brand-faint);
}

.exception-copy {
  min-width: 0;
}

.exception-copy strong {
  display: block;
  margin-bottom: 3px;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exception-copy span,
.exception-time {
  color: var(--subtle);
  font-size: 12px;
}

/* Status */
.status-badge,
.source-badge,
.priority-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status--created,
.status--resolved,
.status--healthy,
.status--accepted {
  background: var(--success-soft);
  color: var(--success);
}

.status--review,
.status--unparsed,
.status--pending,
.status--processing {
  background: var(--warning-soft);
  color: var(--warning);
}

.status--error,
.status--failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.status--duplicate,
.status--ai {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.status--ignored,
.status--dismissed,
.status--neutral,
.status--skipped {
  background: var(--neutral-soft);
  color: #64626b;
}

.source-badge {
  background: var(--info-soft);
  color: var(--info);
}

.priority-badge[data-priority="high"] {
  background: var(--danger-soft);
  color: var(--danger);
}

.priority-badge[data-priority="medium"] {
  background: var(--warning-soft);
  color: var(--warning);
}

.priority-badge[data-priority="low"] {
  background: var(--neutral-soft);
  color: var(--muted);
}

/* Filters and lists */
.filter-card {
  margin-bottom: 16px;
  padding: 18px;
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.8fr) repeat(5, minmax(130px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.filter-field {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.list-card {
  overflow: hidden;
}

.list-toolbar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.list-summary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.list-summary strong {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pagination .button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
}

.event-card-list {
  display: none;
}

.event-card {
  display: grid;
  gap: 11px;
  width: 100%;
  padding: 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.event-card:last-child {
  border-bottom: 0;
}

.event-card:active {
  background: var(--brand-faint);
}

.event-card-top,
.event-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.event-card-preview {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.event-card-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
  color: var(--subtle);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  max-width: 100%;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.tab-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
  white-space: nowrap;
}

.tab-button:hover {
  color: var(--ink);
}

.tab-button[aria-selected="true"] {
  background: var(--surface);
  color: var(--brand-strong);
  box-shadow: 0 4px 14px rgba(56, 49, 87, 0.08);
}

/* Learning */
.learning-list {
  display: grid;
  gap: 14px;
}

.learning-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  padding: 22px;
}

.learning-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.learning-heading h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 760;
}

.learning-description {
  max-width: 72ch;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  text-wrap: pretty;
}

.learning-metrics {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.learning-metric {
  color: var(--subtle);
  font-size: 12px;
}

.learning-metric strong {
  margin-right: 4px;
  color: var(--ink-soft);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.decision-diff {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  max-width: 620px;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--surface-muted);
  font-size: 13px;
}

.decision-side span {
  display: block;
  margin-bottom: 3px;
  color: var(--subtle);
  font-size: 11px;
}

.decision-side strong {
  display: block;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-arrow {
  color: var(--brand);
  font-weight: 800;
}

.learning-actions {
  display: flex;
  min-width: 142px;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* Users */
.user-cell {
  display: flex;
  min-width: 190px;
  align-items: center;
  gap: 11px;
}

.user-monogram {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
}

.user-copy strong,
.user-copy span {
  display: block;
}

.user-copy span {
  color: var(--subtle);
  font-size: 11px;
}

.user-card-list {
  display: none;
}

.user-card {
  display: grid;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.user-card:last-child {
  border-bottom: 0;
}

.user-card-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--line);
}

.user-card-metrics > span {
  display: grid;
  gap: 2px;
  padding: 10px;
  background: var(--surface-muted);
}

.user-card-metrics strong {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.user-card-metrics small {
  color: var(--subtle);
  font-size: 11px;
}

/* Drawer and trace */
dialog {
  padding: 0;
  border: 0;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(22, 18, 35, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.drawer-dialog {
  width: min(760px, 100vw);
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0 0 0 auto;
  overflow: hidden;
  background: transparent;
}

.drawer-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  border-left: 1px solid rgba(218, 214, 225, 0.95);
  background: #f8f7fa;
  box-shadow: -22px 0 70px rgba(29, 24, 50, 0.13);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 28px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.drawer-header h2,
.modal-header h2 {
  margin-bottom: 5px;
  font-size: 24px;
  font-weight: 760;
  letter-spacing: -0.5px;
}

.drawer-subtitle {
  margin: 0;
  color: var(--subtle);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.close-button {
  font-size: 24px;
  font-weight: 400;
}

.drawer-body {
  overflow-y: auto;
  padding: 24px 28px max(44px, env(safe-area-inset-bottom));
}

.detail-skeleton {
  display: grid;
  gap: 16px;
}

.detail-section {
  margin-bottom: 18px;
  padding: 20px;
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-section-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 760;
}

.detail-section-header p {
  margin: 4px 0 0;
  color: var(--subtle);
  font-size: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--line);
}

.detail-field {
  min-width: 0;
  padding: 13px;
  background: var(--surface);
}

.detail-field dt {
  margin-bottom: 4px;
  color: var(--subtle);
  font-size: 11px;
}

.detail-field dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
}

.trace-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.trace-step {
  position: relative;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 12px;
  padding-bottom: 22px;
}

.trace-step:last-child {
  padding-bottom: 0;
}

.trace-step:not(:last-child)::after {
  position: absolute;
  top: 20px;
  bottom: 2px;
  left: 9px;
  width: 2px;
  border-radius: 999px;
  background: var(--line);
  content: "";
}

.trace-node {
  position: relative;
  z-index: 1;
  width: 20px;
  height: 20px;
  border: 5px solid var(--success-soft);
  border-radius: 50%;
  background: var(--success);
}

.trace-step[data-state="failed"] .trace-node,
.trace-step[data-state="error"] .trace-node {
  border-color: var(--danger-soft);
  background: var(--danger);
}

.trace-step[data-state="skipped"] .trace-node {
  border-color: var(--neutral-soft);
  background: var(--subtle);
}

.trace-step[data-state="pending"] .trace-node,
.trace-step[data-state="processing"] .trace-node {
  border-color: var(--warning-soft);
  background: var(--warning);
}

.trace-copy h4 {
  margin: 0 0 4px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 760;
}

.trace-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.trace-meta {
  color: var(--subtle);
  text-align: right;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.comparison-table {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.comparison-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) minmax(0, 1fr);
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.comparison-row:last-child {
  border-bottom: 0;
}

.comparison-row > * {
  min-width: 0;
  padding: 11px 12px;
  background: var(--surface);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.comparison-row--header > * {
  background: #faf9fb;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 750;
}

.comparison-label {
  color: var(--muted);
  font-weight: 680;
}

.comparison-final[data-changed="true"] {
  background: var(--brand-faint);
  color: var(--brand-strong);
  font-weight: 720;
}

.sms-preview,
.sms-raw {
  margin: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f7f6f8;
  color: var(--ink-soft);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.72;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sms-raw {
  border-color: #e4cfcd;
  background: #fff8f7;
}

.sensitive-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 12px 0 0;
  color: var(--subtle);
  font-size: 11px;
}

.sensitive-note::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--warning);
  content: "";
}

/* Modal */
.modal-dialog {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  border-radius: 24px;
  background: transparent;
}

.modal-card {
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow-float);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.modal-description {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* State surfaces */
.state-card {
  display: grid;
  min-height: 280px;
  place-content: center;
  justify-items: center;
  padding: 40px 24px;
  text-align: center;
}

.state-mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 16px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 19px;
  font-weight: 800;
}

.state-card[data-state="error"] .state-mark {
  background: var(--danger-soft);
  color: var(--danger);
}

.state-card h2,
.state-card h3 {
  margin-bottom: 8px;
  font-size: 18px;
}

.state-card p {
  max-width: 48ch;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.skeleton,
.skeleton-line {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #eae8ee;
}

.skeleton {
  min-height: 142px;
}

.skeleton-line {
  height: 14px;
}

.skeleton::after,
.skeleton-line::after {
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.68), transparent);
  animation: shimmer 1.3s infinite;
  content: "";
}

@keyframes shimmer {
  to { transform: translateX(100%); }
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(380px, calc(100vw - 36px));
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink-soft);
  box-shadow: var(--shadow-float);
  font-size: 13px;
  font-weight: 650;
  animation: toast-in 180ms ease-out;
}

.toast[data-tone="error"] {
  border-color: #efcfcc;
  background: #fff8f7;
  color: var(--danger);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1180px) {
  .header-inner {
    grid-template-columns: auto 1fr auto;
  }

  .filter-form {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .filter-field--search {
    grid-column: span 2;
  }

  .filter-actions {
    justify-content: flex-end;
  }

  .security-layout {
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.8fr);
  }
}

@media (max-width: 920px) {
  .header-inner {
    grid-template-columns: 1fr auto auto;
    gap: 8px;
    padding-right: 18px;
    padding-left: 18px;
  }

  .mobile-menu-button {
    display: inline-grid;
    grid-column: 2;
    grid-row: 1;
  }

  .primary-navigation {
    position: absolute;
    z-index: 45;
    top: calc(100% + 8px);
    right: 18px;
    left: 18px;
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 8px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-float);
  }

  .primary-navigation[data-open="true"] {
    display: grid;
  }

  .primary-navigation a {
    justify-content: center;
  }

  .primary-navigation a[data-nav="security"] {
    grid-column: 1 / -1;
  }

  .header-actions {
    grid-column: 3;
  }

  .system-health span:last-child,
  .admin-menu-button > span:last-child {
    display: none;
  }

  .metric-grid,
  .skeleton-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .panel--wide {
    grid-column: auto;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .security-hero {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .security-hero-facts {
    grid-column: 1 / -1;
  }

  .security-layout {
    grid-template-columns: 1fr;
  }

  .security-sidebar {
    position: static;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  }
}

@media (max-width: 720px) {
  .main-content {
    padding: 26px 16px max(48px, env(safe-area-inset-bottom));
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 22px;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-field--search,
  .filter-actions {
    grid-column: 1 / -1;
  }

  .filter-actions .button {
    flex: 1;
  }

  .events-table-wrap,
  .users-table-wrap {
    display: none;
  }

  .event-card-list,
  .user-card-list {
    display: block;
  }

  .list-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .pagination {
    width: 100%;
  }

  .pagination .button {
    flex: 1;
  }

  .learning-card {
    grid-template-columns: 1fr;
  }

  .learning-actions {
    justify-content: flex-start;
  }

  .decision-diff {
    grid-template-columns: 1fr;
  }

  .diff-arrow {
    transform: rotate(90deg);
    justify-self: start;
  }

  .drawer-dialog {
    width: 100vw;
  }

  .drawer-shell {
    border-left: 0;
  }

  .drawer-header,
  .drawer-body {
    padding-right: 18px;
    padding-left: 18px;
  }

  .comparison-row {
    grid-template-columns: 84px minmax(0, 1fr) minmax(0, 1fr);
  }

  .backup-passkey-notice {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .backup-passkey-action {
    grid-column: 1 / -1;
    width: 100%;
  }

  .security-sidebar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .auth-card {
    padding: 30px 24px 26px;
    border-radius: 24px;
  }

  .brand-lockup--auth {
    margin-bottom: 42px;
  }

  .brand-context,
  .brand-divider {
    display: none;
  }

  .header-inner .brand-context,
  .header-inner .brand-divider {
    display: none;
  }

  .metric-grid,
  .skeleton-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric-card--lead {
    grid-column: 1 / -1;
  }

  .metric-card {
    min-height: 128px;
    padding: 17px;
  }

  .metric-value {
    font-size: 24px;
  }

  .panel,
  .filter-card {
    padding: 16px;
  }

  .filter-form {
    grid-template-columns: 1fr;
  }

  .filter-field--search,
  .filter-actions {
    grid-column: auto;
  }

  .breakdown-row {
    grid-template-columns: minmax(82px, 1fr) minmax(100px, 1.4fr) auto;
    gap: 9px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .trace-step {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .trace-meta {
    grid-column: 2;
    text-align: left;
  }

  .comparison-table {
    overflow-x: auto;
  }

  .comparison-row {
    min-width: 460px;
  }

  .modal-card {
    padding: 22px 18px;
  }

  .modal-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-actions .button {
    width: 100%;
  }

  .security-hero {
    grid-template-columns: 1fr;
    padding: 22px 18px;
  }

  .security-hero-mark {
    width: 54px;
    height: 54px;
    border-radius: 18px;
  }

  .security-hero-facts {
    grid-column: auto;
    width: 100%;
  }

  .security-fact {
    min-width: 0;
    flex: 1;
  }

  .security-panel {
    padding: 17px;
  }

  .passkey-item {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 15px;
  }

  .remove-passkey-button {
    grid-column: 2;
    justify-self: start;
  }
}

@media (max-width: 360px) {
  .metric-grid,
  .skeleton-grid {
    grid-template-columns: 1fr;
  }

  .metric-card--lead {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
