/*
 * FamilyVault app theme
 * Shell parity with vendor/familyvault visual direction using app-specific components.
 */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --color-bg: #0f1319;
  --color-surface: #151b24;
  --color-surface-2: #1b2331;
  --color-surface-3: #222c3c;
  --color-border: #2c384b;
  --color-border-strong: #3a4a63;
  --color-text: #e6ecf7;
  --color-text-muted: #a0aec4;
  --color-text-faint: #7d8ca6;
  --color-primary: #5fc4b8;
  --color-primary-hover: #4cb3a7;
  --color-primary-dim: rgb(95 196 184 / 18%);
  --color-on-primary: #071613;
  --color-on-danger: #1a0609;
  --color-action-primary: #7ee0d4;
  --color-action-secondary: #22384a;
  --color-action-neutral: #1b2331;
  --color-action-danger: #f3a8b2;
  --color-success: #66d4a0;
  --color-success-dim: rgb(102 212 160 / 17%);
  --color-warning: #e6b66b;
  --color-warning-dim: rgb(230 182 107 / 17%);
  --color-danger: #ed8d9a;
  --color-danger-dim: rgb(237 141 154 / 18%);
  --color-info: #78b5f8;
  --color-info-dim: rgb(120 181 248 / 18%);

  --shadow-sm: 0 2px 6px rgb(0 0 0 / 28%);
  --shadow-md: 0 10px 28px rgb(0 0 0 / 35%);
  --shadow-lg: 0 18px 44px rgb(0 0 0 / 44%);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;

  --sidebar-width: 248px;
  --topbar-height: 58px;
  --focus-ring: rgb(95 196 184 / 55%);
  --touch-target-min: 40px;
  --control-gap-inline: 10px;
  --table-mobile-min-column-width: 128px;
  --table-scroll-shadow: inset -16px 0 18px -18px rgb(0 0 0 / 58%);

  --auth-vault-bg-start: #0a1628;
  --auth-vault-bg-mid: #101c30;
  --auth-vault-bg-end: #131f30;
  --auth-vault-glow-rgb: 75, 108, 157;
  --auth-vault-ring-rgb: 89, 117, 158;
  --auth-vault-node-rgb: 138, 161, 198;
  --auth-vault-line-rgb: 94, 120, 157;
  --auth-vault-particle-rgb: 160, 181, 215;
  --auth-vault-gold-rgb: 188, 165, 118;
  --auth-vault-node-alpha: 0.24;
  --auth-vault-line-alpha: 0.1;
  --auth-vault-particle-alpha: 0.18;
  --auth-vault-gold-alpha: 0.15;
  --auth-vault-canvas-opacity: 0.9;
  --auth-stage-bg: oklch(18% 0.033 211);
  --auth-stage-border: oklch(41% 0.043 201);
  --auth-panel-bg: oklch(16% 0.028 211);
  --auth-card-bg: oklch(20% 0.023 208);
  --auth-card-field-bg: oklch(24% 0.023 208);
  --auth-panel-text: oklch(95% 0.017 220);
  --auth-panel-muted: oklch(82% 0.032 216);
  --auth-panel-chip-text: oklch(90% 0.022 218);
  --auth-panel-chip-bg: rgb(255 255 255 / 7%);
  --auth-panel-chip-border: rgb(var(--auth-vault-gold-rgb) / 24%);
  --auth-brass: oklch(74% 0.078 84);
  --auth-brass-muted: oklch(68% 0.052 86);
  --auth-submit-text: oklch(13% 0.022 185);
}

[data-theme="light"] {
  color-scheme: light;
  --color-bg: #f3f6fb;
  --color-surface: #ffffff;
  --color-surface-2: #f4f8fc;
  --color-surface-3: #e9eef6;
  --color-border: #d4dde9;
  --color-border-strong: #c1ccdd;
  --color-text: #172338;
  --color-text-muted: #4f607e;
  --color-text-faint: #74839e;
  --color-primary: #0f8f83;
  --color-primary-hover: #0d7e74;
  --color-primary-dim: rgb(15 143 131 / 12%);
  --color-on-primary: #ffffff;
  --color-on-danger: #ffffff;
  --color-action-primary: #08786f;
  --color-action-secondary: #e7f4f2;
  --color-action-neutral: #f4f8fc;
  --color-action-danger: #b74354;
  --color-success: #198754;
  --color-success-dim: rgb(25 135 84 / 10%);
  --color-warning: #a8680d;
  --color-warning-dim: rgb(168 104 13 / 11%);
  --color-danger: #b74354;
  --color-danger-dim: rgb(183 67 84 / 12%);
  --color-info: #2f6cc5;
  --color-info-dim: rgb(47 108 197 / 12%);

  --shadow-sm: 0 2px 8px rgb(9 30 66 / 8%);
  --shadow-md: 0 12px 30px rgb(9 30 66 / 12%);
  --shadow-lg: 0 22px 48px rgb(9 30 66 / 17%);

  --focus-ring: rgb(15 143 131 / 35%);
  --table-scroll-shadow: inset -16px 0 18px -18px rgb(9 30 66 / 32%);
  --auth-vault-bg-start: #dfe7f4;
  --auth-vault-bg-mid: #d4dfef;
  --auth-vault-bg-end: #cdd8eb;
  --auth-vault-glow-rgb: 90, 124, 170;
  --auth-vault-ring-rgb: 104, 132, 172;
  --auth-vault-node-rgb: 94, 118, 152;
  --auth-vault-line-rgb: 108, 132, 168;
  --auth-vault-particle-rgb: 108, 131, 165;
  --auth-vault-gold-rgb: 158, 134, 90;
  --auth-vault-node-alpha: 0.2;
  --auth-vault-line-alpha: 0.11;
  --auth-vault-particle-alpha: 0.145;
  --auth-vault-gold-alpha: 0.14;
  --auth-vault-canvas-opacity: 0.8;
  --auth-stage-bg: oklch(96% 0.012 232);
  --auth-stage-border: oklch(82% 0.026 222);
  --auth-panel-bg: oklch(23% 0.036 209);
  --auth-card-bg: oklch(98% 0.007 222);
  --auth-card-field-bg: oklch(95% 0.012 224);
  --auth-panel-text: oklch(26% 0.046 218);
  --auth-panel-muted: oklch(43% 0.044 214);
  --auth-panel-chip-text: oklch(38% 0.042 213);
  --auth-panel-chip-bg: oklch(95% 0.014 215);
  --auth-panel-chip-border: oklch(78% 0.036 208);
  --auth-brass: oklch(68% 0.087 82);
  --auth-brass-muted: oklch(42% 0.071 84);
  --auth-submit-text: oklch(98% 0.01 182);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

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

button {
  cursor: pointer;
}

::selection {
  background: var(--color-primary-dim);
  color: var(--color-text);
}

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--color-bg);
}

.app-sidebar {
  position: relative;
  z-index: 25;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  overflow: auto;
  padding-bottom: var(--space-4);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: var(--color-primary);
  background: var(--color-primary-dim);
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.app-brand {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0.02em;
  font-weight: 700;
  color: var(--color-text);
}

.app-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.sidebar-nav {
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidebar-group {
  margin: 0;
}

.sidebar-group h2 {
  margin: 0 0 var(--space-2);
  padding: 0 var(--space-2);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  margin: 2px 0;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.sidebar-link-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: 0.8;
  transition: opacity 180ms ease;
}

.sidebar-link-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link:hover {
  color: var(--color-text);
  background: var(--color-surface-2);
}

.sidebar-link.active {
  color: var(--color-primary);
  background: var(--color-primary-dim);
}

.sidebar-link:hover .sidebar-link-icon,
.sidebar-link.active .sidebar-link-icon {
  opacity: 1;
}

.main-wrapper {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: 0 var(--space-6);
}

.topbar-left {
  min-width: 0;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.notification-dropdown {
  position: relative;
}

.notification-trigger {
  position: relative;
  width: 38px;
}

.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  border: 2px solid var(--color-surface);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-danger);
  color: var(--color-on-danger);
  font-size: 10px;
  font-weight: 700;
}

.notification-menu {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 40;
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.notification-menu-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.notification-menu-header span {
  display: block;
  color: var(--color-text-muted);
  font-size: 12px;
}

.notification-menu-header a {
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: none;
}

.notification-list {
  max-height: 360px;
  overflow: auto;
}

.notification-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.notification-item:last-child {
  border-bottom: 0;
}

.notification-item.is-unread {
  background: var(--color-primary-dim);
}

.notification-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--color-info);
}

.notification-icon--alert {
  background: var(--color-warning);
}

.notification-icon--report {
  background: var(--color-info);
}

.notification-icon--system {
  background: var(--color-success);
}

.notification-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.notification-copy span {
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.notification-copy small {
  color: var(--color-text-faint);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.breadcrumb-item {
  font-size: 13px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.breadcrumb-item.is-page {
  color: var(--color-text);
  font-weight: 600;
}

.breadcrumb-sep {
  color: var(--color-text-faint);
  font-size: 12px;
}

.topbar-btn {
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  border-radius: var(--radius-md);
  min-height: 36px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.topbar-btn:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-3);
}

.theme-toggle-btn .icon-moon,
[data-theme="light"] .theme-toggle-btn .icon-sun {
  display: none;
}

[data-theme="light"] .theme-toggle-btn .icon-moon {
  display: block;
}

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

.nav-button {
  border: 0;
  background: transparent;
  min-height: unset;
  padding: 0;
}

.button_to {
  margin: 0;
}

.button_to .nav-button {
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  border-radius: var(--radius-md);
  min-height: 36px;
  padding: 0 12px;
}

.button_to .nav-button:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-3);
}

.app-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--space-6);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
}

.page-header h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.page-header p {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.flash {
  margin: 0 0 var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
}

.flash-notice {
  color: var(--color-success);
  border-color: var(--color-success);
  background: var(--color-success-dim);
}

.flash-alert {
  color: var(--color-danger);
  border-color: var(--color-danger);
  background: var(--color-danger-dim);
}

.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin: 0 0 var(--space-4);
}

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

.panel h1 {
  font-size: clamp(1.3rem, 1.1rem + 0.7vw, 1.6rem);
}

.panel h2 {
  font-size: 1.05rem;
}

.panel > p,
.panel > form,
.panel > table,
.panel > .table-scroll,
.panel > .pagination-wrapper {
  margin-top: var(--space-3);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.panel-heading p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 13px;
}

.metrics-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: var(--space-4);
}

.metric-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-4);
}

.metric-card h2 {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-value {
  margin: var(--space-2) 0 0;
  font-size: clamp(1.25rem, 1rem + 1vw, 1.7rem);
  font-weight: 600;
  color: var(--color-text);
}

.ai-chat-layout {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  align-items: start;
}

.ai-chat-list,
.ai-chat-panel {
  min-width: 0;
}

.ai-chat-history {
  display: grid;
  gap: var(--space-2);
}

.ai-chat-history-item {
  display: grid;
  gap: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  padding: 10px;
  text-decoration: none;
}

.ai-chat-history-item.active,
.ai-chat-history-item:hover {
  border-color: var(--color-primary);
  background: var(--color-surface-3);
}

.ai-chat-history-item strong,
.ai-chat-history-item span {
  overflow-wrap: anywhere;
}

.ai-chat-history-item span {
  color: var(--color-text-muted);
  font-size: 12px;
}

.ai-message-list {
  display: grid;
  gap: var(--space-3);
  max-height: min(62vh, 720px);
  overflow: auto;
  padding-right: 2px;
}

.ai-message {
  border-left: 3px solid var(--color-border-strong);
  padding-left: var(--space-3);
}

.ai-message--assistant {
  border-left-color: var(--color-primary);
}

.ai-message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: baseline;
  color: var(--color-text-muted);
  font-size: 12px;
}

.ai-message-content {
  margin-top: var(--space-2);
  color: var(--color-text);
}

.ai-message-content p {
  margin: 0 0 var(--space-2);
  overflow-wrap: anywhere;
}

.ai-chat-form {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
}

.filter-form {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.reference-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
}

.reference-tabs a {
  min-height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.reference-tabs a:hover {
  background: var(--color-surface-2);
}

.reference-hidden-form {
  display: none;
}

.reference-table input {
  width: 100%;
  min-width: 120px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  padding: 7px 9px;
}

.form-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

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

.field {
  margin-bottom: var(--space-3);
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  padding: 9px 10px;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field .textarea-code,
textarea.textarea-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.field-check {
  display: flex;
  align-items: flex-start;
  gap: var(--control-gap-inline);
  min-height: var(--touch-target-min);
  color: var(--color-text);
  cursor: pointer;
}

.field-check input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--color-primary);
}

.field-check small {
  display: block;
  color: var(--color-text-muted);
  font-size: 12px;
}

.field small {
  display: block;
  margin-top: 6px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.field-check--compact {
  min-height: 28px;
  align-items: center;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
  outline: none;
}

.actions {
  margin-top: var(--space-3);
}

.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--color-action-primary);
  color: var(--color-on-primary);
  padding: 8px 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  transition: background-color 180ms ease, transform 180ms ease;
}

.btn:hover {
  background: var(--color-primary-hover);
}

.btn--secondary {
  border-color: var(--color-border-strong);
  background: var(--color-action-secondary);
  color: var(--color-text);
}

.btn--secondary:hover,
.btn--neutral:hover {
  background: var(--color-surface-3);
}

.btn--neutral {
  border-color: var(--color-border);
  background: var(--color-action-neutral);
  color: var(--color-text);
}

.btn--danger {
  background: var(--color-action-danger);
  color: var(--color-on-danger);
}

.btn--sm {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.btn:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.stack {
  display: grid;
  gap: var(--space-2);
}

.report-section {
  margin-top: var(--space-5);
}

.report-section h3 {
  margin: 0 0 var(--space-3);
  font-size: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  box-shadow: var(--table-scroll-shadow);
}

.data-table {
  min-width: 720px;
}

thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 12px;
}

tbody td {
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  padding: 11px 12px;
  color: var(--color-text);
  vertical-align: top;
}

tbody tr:hover td {
  background: var(--color-surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody td[colspan] {
  color: var(--color-text-muted);
  text-align: center;
  padding: 16px;
  background: var(--color-surface-2);
}

.empty-state {
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-3);
}

.empty-state a {
  color: var(--color-primary);
  font-weight: 600;
}

.empty-state--compact {
  padding: var(--space-4);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
}

.badge-success {
  border-color: var(--color-success);
  color: var(--color-success);
  background: var(--color-success-dim);
}

.badge-warning {
  border-color: var(--color-warning);
  color: var(--color-warning);
  background: var(--color-warning-dim);
}

.badge-info {
  border-color: var(--color-info);
  color: var(--color-info);
  background: var(--color-info-dim);
}

.badge-neutral {
  color: var(--color-text-muted);
}

.badge-danger {
  border-color: var(--color-danger);
  color: var(--color-danger);
  background: var(--color-danger-dim);
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--color-text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted {
  color: var(--color-text-muted);
}

.text-link {
  color: var(--color-primary);
  font-weight: 700;
  text-decoration: none;
}

.text-link:hover {
  color: var(--color-primary-hover);
}

.command-center-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-5);
  margin: 0 0 var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgb(var(--auth-vault-gold-rgb) / 9%), transparent 34%),
    linear-gradient(145deg, var(--color-surface) 0%, var(--color-surface-2) 100%);
  box-shadow: var(--shadow-sm);
  padding: clamp(20px, 3vw, 32px);
}

.command-center-hero h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.command-center-hero p:not(.eyebrow) {
  max-width: 60rem;
  margin: var(--space-3) 0 0;
  color: var(--color-text-muted);
  font-size: 1rem;
}

.command-center-context {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
  max-width: 430px;
}

.context-chip,
.source-lineage-badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

.context-chip.is-enabled,
.source-lineage-badge {
  border-color: var(--color-primary);
  background: var(--color-primary-dim);
  color: var(--color-primary);
}

.context-chip.is-muted {
  opacity: 0.62;
}

.command-grid {
  display: grid;
  gap: var(--space-4);
  align-items: stretch;
  margin-bottom: var(--space-4);
}

.command-grid--decision-first {
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
}

.command-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.decision-panel,
.wealth-summary-panel,
.insight-panel {
  margin-bottom: 0;
  min-width: 0;
}

.decision-list,
.driver-list,
.performer-list,
.state-list,
.setup-steps {
  display: grid;
  gap: var(--space-3);
}

.decision-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-warning);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-4);
}

.decision-item--reporting {
  border-left-color: var(--color-danger);
}

.decision-item--provider_change {
  border-left-color: var(--auth-brass);
}

.decision-item--ai_commentary,
.decision-item--ai_extraction {
  border-left-color: var(--color-info);
}

.decision-item__main {
  min-width: 0;
}

.decision-item h3 {
  margin: var(--space-2) 0 0;
  font-size: 1rem;
}

.decision-item p {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.decision-item small {
  display: block;
  margin-top: var(--space-2);
  color: var(--color-text-faint);
}

.decision-item__action {
  display: flex;
  justify-content: flex-end;
}

.wealth-summary-value {
  margin: var(--space-2) 0 var(--space-3);
  font-size: 2.8rem;
  line-height: 1.02;
  font-weight: 750;
  letter-spacing: 0;
}

.freshness-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.freshness-strip span {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  padding: var(--space-3);
  overflow-wrap: anywhere;
}

.freshness-strip strong {
  display: block;
  color: var(--color-text);
}

.state-row,
.driver-row,
.performer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-3);
}

.state-row {
  align-items: flex-start;
  justify-content: flex-start;
}

.state-row > div,
.driver-row > div,
.performer-row > div {
  min-width: 0;
}

.state-row strong,
.driver-row strong,
.performer-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.state-row p,
.driver-row span,
.performer-row span {
  display: block;
  margin: 2px 0 0;
  color: var(--color-text-muted);
  font-size: 12px;
}

.driver-row__amount {
  flex: 0 0 auto;
  text-align: right;
  font-weight: 700;
}

.allocation-stack {
  display: grid;
  gap: var(--space-3);
}

.allocation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 42%) auto;
  gap: var(--space-3);
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-3);
}

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

.allocation-row span {
  display: block;
  margin-top: 2px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.allocation-meter {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: var(--color-surface-3);
}

.allocation-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-primary), var(--auth-brass));
}

.amount-positive {
  color: var(--color-success);
}

.amount-negative {
  color: var(--color-danger);
}

.setup-panel {
  margin-bottom: 0;
}

.setup-steps {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.setup-steps > div {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-4);
}

.setup-steps strong {
  display: block;
  margin-top: var(--space-3);
}

.setup-steps p {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.evidence-drawer {
  margin-top: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  overflow: hidden;
}

.evidence-drawer summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  padding: var(--space-3);
  font-weight: 700;
}

.evidence-drawer__hint {
  color: var(--color-primary);
  font-size: 12px;
}

.evidence-drawer__body {
  border-top: 1px solid var(--color-border);
  padding: var(--space-3);
}

.evidence-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
}

.evidence-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
  gap: var(--space-3);
}

.evidence-list dt {
  color: var(--color-text-faint);
  font-weight: 700;
}

.evidence-list dd {
  margin: 0;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: var(--space-2);
  min-height: 150px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  padding: var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  cursor: pointer;
}

.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.dropzone input[type="file"] {
  width: min(100%, 280px);
}

.dropzone strong {
  color: var(--color-text);
}

.dropzone small {
  max-width: 34rem;
}

.dropzone-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--color-primary-dim);
  color: var(--color-primary);
  font-size: 24px;
  line-height: 1;
}

.permission-matrix {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.permission-matrix--compact {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.permission-group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-3);
}

.permission-group legend {
  padding: 0 var(--space-2);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.role-stack {
  display: grid;
  gap: var(--space-4);
}

.role-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  padding: var(--space-4);
}

.role-card-header {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.role-card-header h3,
.role-card-header p {
  margin: 0;
}

.role-card-header p {
  color: var(--color-text-muted);
  margin-top: 4px;
}

.inline-role-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}

.roles-page-header {
  margin-bottom: var(--space-5);
}

.roles-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-5);
}

.roles-summary > div {
  min-width: 0;
  border-right: 1px solid var(--color-border);
  padding: var(--space-4);
}

.roles-summary > div:last-child {
  border-right: 0;
}

.roles-summary span {
  display: block;
  color: var(--color-text-faint);
  font-size: 12px;
  font-weight: 700;
}

.roles-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--color-text);
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.roles-workspace,
.roles-members-section {
  margin-bottom: var(--space-5);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}

.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
}

.section-heading p:not(.eyebrow) {
  max-width: 68ch;
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.role-stack--governance {
  gap: var(--space-5);
}

.role-card--governance {
  overflow: hidden;
  background: var(--color-surface);
  padding: 0;
}

.role-card-header--governance {
  align-items: flex-start;
  margin-bottom: 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: var(--space-5);
}

.role-title-block {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 0;
}

.role-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-md);
  background: oklch(68% 0.08 184 / 16%);
  color: var(--color-primary);
  font-weight: 800;
}

.role-card-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 700;
}

.role-card-meta > span:not(.badge) {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface-2);
  padding: 3px 9px;
}

.role-scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-5);
}

.role-scope-chip,
.role-chip {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.role-scope-chip strong {
  color: var(--color-primary);
}

.role-scope-chip.is-muted {
  opacity: 0.72;
}

.permission-matrix--role-admin {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  align-items: stretch;
  padding: var(--space-4) var(--space-5);
}

.permission-group--role-admin {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.permission-group--role-admin legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: calc(100% - var(--space-4));
  padding: 0 var(--space-2);
}

.permission-group--role-admin legend strong {
  color: var(--color-primary);
  font-size: 11px;
}

.permission-list {
  display: grid;
  gap: 6px;
  margin-top: var(--space-2);
}

.permission-toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: var(--space-2);
  min-height: 54px;
  align-items: start;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 9px;
  color: var(--color-text);
  cursor: pointer;
}

.permission-toggle:hover,
.permission-toggle:focus-within {
  border-color: var(--color-border-strong);
  background: var(--color-surface-3);
}

.permission-toggle.is-selected {
  border-color: var(--color-primary);
  background: var(--color-primary-dim);
}

.permission-toggle input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--color-primary);
}

.permission-toggle strong,
.permission-toggle small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.permission-toggle strong {
  font-size: 13px;
}

.permission-toggle small {
  margin-top: 2px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.role-card-actions,
.role-danger-action {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 var(--space-5) var(--space-5);
}

.role-danger-action {
  padding-top: 0;
}

.permission-readonly-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5) var(--space-5);
}

.permission-readonly-list span {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.roles-members-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.roles-assignment-scroll {
  margin-top: var(--space-3);
}

.roles-assignment-table {
  min-width: 920px;
}

.member-cell {
  display: grid;
  gap: 2px;
}

.member-cell strong,
.member-cell span {
  overflow-wrap: anywhere;
}

.member-cell span {
  color: var(--color-text-muted);
  font-size: 12px;
}

.role-chip-list,
.role-checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.inline-role-form--governance {
  align-items: flex-start;
  justify-content: space-between;
}

.inline-role-form--governance .role-checkbox-list {
  flex: 1 1 280px;
}

.form-divider {
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

.pagination-wrapper {
  margin-top: var(--space-4);
}

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

.pagy a,
.pagy .current,
.pagy .gap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--color-text-muted);
  background: var(--color-surface);
}

.pagy a:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-2);
  color: var(--color-text);
}

.pagy .current {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-dim);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgb(9 12 18 / 48%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 20;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.auth-shell {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(104% 86% at 12% 8%, rgb(var(--auth-vault-gold-rgb) / 18%), transparent 48%),
    radial-gradient(96% 80% at 84% 16%, rgb(var(--auth-vault-glow-rgb) / 18%), transparent 58%),
    linear-gradient(148deg, var(--auth-vault-bg-start) 0%, var(--auth-vault-bg-mid) 48%, var(--auth-vault-bg-end) 100%);
  display: grid;
  place-items: center;
  padding: var(--space-7);
}

.auth-shell::before,
.auth-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.auth-shell::before {
  width: min(1120px, 92vw);
  aspect-ratio: 1 / 1;
  left: 50%;
  top: 52%;
  inset: auto;
  border-radius: 50%;
  z-index: 0;
  background:
    radial-gradient(circle at 50% 46%, rgb(var(--auth-vault-glow-rgb) / 16%) 0%, transparent 58%),
    repeating-radial-gradient(
      circle at 50% 50%,
      transparent 0 26px,
      rgb(var(--auth-vault-ring-rgb) / 20%) 26px 27px,
      transparent 27px 52px
    );
  -webkit-mask-image: radial-gradient(
    circle at 50% 50%,
    rgb(0 0 0 / 74%) 0%,
    rgb(0 0 0 / 74%) 52%,
    rgb(0 0 0 / 22%) 72%,
    transparent 84%
  );
  mask-image: radial-gradient(
    circle at 50% 50%,
    rgb(0 0 0 / 74%) 0%,
    rgb(0 0 0 / 74%) 52%,
    rgb(0 0 0 / 22%) 72%,
    transparent 84%
  );
  opacity: 0.62;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: 50% 50%;
  will-change: transform;
  animation: authVaultRingDrift 44s ease-in-out infinite alternate;
}

.auth-shell::after {
  z-index: 0;
  background:
    radial-gradient(circle at 62% 44%, rgb(var(--auth-vault-gold-rgb) / 16%), transparent 22%),
    radial-gradient(circle at 41% 64%, rgb(var(--auth-vault-gold-rgb) / 10%), transparent 20%),
    linear-gradient(180deg, rgb(255 255 255 / 5%), transparent 28%, transparent 76%, rgb(0 0 0 / 8%));
  opacity: 0.5;
  animation: authVaultGoldDrift 56s ease-in-out infinite alternate;
}

.auth-vault-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  opacity: var(--auth-vault-canvas-opacity);
}

.auth-stage {
  position: relative;
  z-index: 2;
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(320px, 1.08fr) minmax(360px, 0.92fr);
  min-height: 548px;
  border: 1px solid var(--auth-stage-border);
  border-radius: 24px;
  background: var(--auth-stage-bg);
  box-shadow:
    0 28px 80px rgb(3 9 17 / 36%),
    0 1px 0 rgb(255 255 255 / 8%) inset;
  overflow: hidden;
}

.auth-brand-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-7);
  min-width: 0;
  padding: clamp(32px, 5vw, 54px);
  color: var(--auth-panel-text);
  background:
    linear-gradient(154deg, rgb(255 255 255 / 8%), transparent 32%),
    radial-gradient(circle at 22% 18%, rgb(var(--auth-vault-gold-rgb) / 18%), transparent 28%),
    radial-gradient(circle at 82% 78%, rgb(var(--auth-vault-glow-rgb) / 24%), transparent 34%),
    var(--auth-panel-bg);
}

.auth-brand-panel::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgb(var(--auth-vault-gold-rgb) / 22%);
  border-radius: 18px;
  pointer-events: none;
}

.auth-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--auth-brass);
  background: rgb(var(--auth-vault-gold-rgb) / 13%);
  box-shadow: 0 16px 36px rgb(2 8 15 / 24%);
}

.auth-kicker,
.auth-eyebrow {
  margin: 0 0 var(--space-3);
  color: var(--auth-brass-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-brand-title {
  margin: 0;
  color: inherit;
  font-size: 2.8rem;
  line-height: 1.02;
  letter-spacing: 0;
}

.auth-copy {
  max-width: 34rem;
  margin: var(--space-4) 0 0;
  color: var(--auth-panel-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.auth-trust-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.auth-trust-list span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--auth-panel-chip-border);
  border-radius: 999px;
  background: var(--auth-panel-chip-bg);
  color: var(--auth-panel-chip-text);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 650;
}

.auth-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  border-left: 1px solid var(--auth-stage-border);
  background: var(--auth-card-bg);
  box-shadow: none;
  padding: clamp(30px, 4.5vw, 48px);
}

.auth-card h2 {
  margin: 0;
  color: var(--color-text);
  font-size: 1.55rem;
  line-height: 1.18;
  letter-spacing: 0;
}

.auth-form-header {
  margin-bottom: var(--space-6);
}

.auth-form-header p {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
}

.auth-form {
  display: grid;
  gap: var(--space-4);
}

.auth-field {
  margin: 0;
}

.auth-card .field input,
.auth-card .field select,
.auth-card .field textarea {
  max-width: 100%;
  min-height: 46px;
  border-color: var(--auth-stage-border);
  background: var(--auth-card-field-bg);
  padding: 11px 12px;
}

.auth-card .field input::placeholder {
  color: var(--color-text-faint);
}

.auth-card .actions {
  display: flex;
  justify-content: stretch;
  margin: var(--space-1) 0 0;
}

.auth-card .btn,
.auth-card input[type="submit"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid color-mix(in oklch, var(--color-primary), var(--auth-brass) 22%);
  border-radius: 12px;
  background: var(--color-primary);
  color: var(--auth-submit-text);
  padding: 11px 16px;
  font-weight: 750;
  box-shadow: 0 14px 28px rgb(4 20 18 / 18%);
}

.auth-card .btn:hover,
.auth-card input[type="submit"]:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.auth-remember {
  align-items: flex-start;
  min-height: auto;
  margin-top: 2px;
}

.auth-support {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: var(--space-5);
  color: var(--color-text-muted);
  font-size: 12px;
}

.auth-support a {
  color: var(--color-text);
  font-weight: 650;
}

.auth-card .flash {
  margin-bottom: var(--space-5);
}

.state-empty,
.state-loading,
.state-error {
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-4);
  color: var(--color-text-muted);
  margin: var(--space-3) 0;
}

.state-loading {
  position: relative;
  overflow: hidden;
}

.state-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 10%), transparent);
  animation: loadingSweep 1.2s ease-in-out infinite;
}

.state-error {
  border-style: solid;
  border-color: var(--color-danger);
  background: var(--color-danger-dim);
  color: var(--color-danger);
}

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

@keyframes authVaultRingDrift {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
  }

  50% {
    transform: translate(-50%, -50%) rotate(180deg) scale(1.015);
  }

  100% {
    transform: translate(-50%, -50%) rotate(360deg) scale(1.03);
  }
}

@keyframes authVaultGoldDrift {
  0% {
    transform: translate3d(-0.8%, 0.4%, 0);
  }

  50% {
    transform: translate3d(0.6%, -0.6%, 0);
  }

  100% {
    transform: translate3d(1.2%, 0.6%, 0);
  }
}

@media (width <= 1080px) {
  .auth-stage {
    grid-template-columns: 1fr;
    width: min(620px, 100%);
    min-height: 0;
  }

  .auth-brand-panel {
    min-height: 240px;
  }

  .auth-card {
    border-left: 0;
    border-top: 1px solid var(--auth-stage-border);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(290px, 85vw);
    transform: translateX(-102%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow-lg);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .topbar {
    padding: 0 var(--space-4);
  }

  .app-main {
    padding: var(--space-4);
  }

  .command-center-hero,
  .command-grid--decision-first,
  .command-grid--three,
  .command-grid--two,
  .setup-steps {
    grid-template-columns: 1fr;
  }

  .command-center-context {
    justify-content: flex-start;
  }

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

  .roles-summary > div {
    border-bottom: 1px solid var(--color-border);
  }

  .roles-summary > div:nth-child(2n) {
    border-right: 0;
  }

  .roles-summary > div:last-child {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

  .role-card-header--governance {
    display: grid;
  }

  .role-card-meta {
    justify-content: flex-start;
  }
}

@media (width > 1080px) {
  .sidebar-overlay {
    display: none;
  }
}

@media (width <= 780px) {
  .auth-shell {
    align-items: stretch;
    padding: var(--space-4);
  }

  .auth-shell::before {
    width: min(920px, 148vw);
    opacity: 0.54;
  }

  .auth-stage {
    border-radius: 18px;
  }

  .auth-brand-panel {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    min-height: auto;
    padding: var(--space-5) var(--space-6);
    gap: var(--space-3) var(--space-4);
  }

  .auth-brand-panel::before {
    display: none;
  }

  .auth-mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
  }

  .auth-kicker {
    margin-bottom: 4px;
  }

  .auth-brand-title {
    font-size: 1.65rem;
  }

  .command-center-hero h1 {
    font-size: 1.65rem;
  }

  .wealth-summary-value {
    font-size: 2rem;
  }

  .auth-copy {
    display: none;
  }

  .auth-trust-list {
    display: none;
  }

  .auth-card {
    padding: var(--space-6);
  }

  .topbar {
    gap: var(--space-2);
    padding: 0 var(--space-3);
  }

  .topbar-right {
    gap: 6px;
  }

  .breadcrumb-item {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .button_to .nav-button {
    padding: 0 10px;
    font-size: 12px;
  }

  .panel {
    padding: var(--space-4);
  }

  .page-header {
    display: grid;
  }

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

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

  .data-table {
    min-width: max(680px, calc(var(--table-mobile-min-column-width) * 5));
  }

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

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

  .decision-item,
  .state-row,
  .driver-row,
  .performer-row {
    display: grid;
  }

  .decision-item__action,
  .driver-row__amount {
    text-align: left;
    justify-content: flex-start;
  }

  .freshness-strip,
  .allocation-row,
  .evidence-list > div {
    grid-template-columns: 1fr;
  }

  .allocation-meter {
    width: 100%;
  }

  .roles-summary {
    grid-template-columns: 1fr;
  }

  .roles-summary > div,
  .roles-summary > div:nth-child(2n) {
    border-right: 0;
  }

  .roles-summary > div:last-child {
    grid-column: auto;
  }

  .role-card-header--governance,
  .role-scope-list,
  .permission-matrix--role-admin,
  .role-card-actions,
  .role-danger-action,
  .permission-readonly-list,
  .roles-members-section {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .permission-matrix--role-admin {
    grid-template-columns: 1fr;
  }

  .roles-assignment-table {
    min-width: 760px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-vault-canvas {
    opacity: 0.62;
  }

  .auth-shell::before,
  .auth-shell::after {
    animation: none;
  }

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