:root {
  color-scheme: dark;
  --background: #1a1d24;
  --surface: #222630;
  --surface-elevated: #2b303b;
  --surface-hover: #363d4a;
  --border: #3d4656;
  --border-strong: #526071;
  --primary: #2f80ed;
  --primary-hover: #4091f7;
  --primary-pressed: #1e6bd6;
  --text: #f2f4f7;
  --text-secondary: #aab2c0;
  --text-disabled: #667085;
  --danger: #f97066;
  --success: #32d583;
  --warning: #fdb022;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.24);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  background: var(--background);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(47, 128, 237, 0.13), transparent 27rem),
    var(--background);
}

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

a:hover {
  color: #70abfa;
}

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

h1 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

small,
.text-secondary {
  color: var(--text-secondary);
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid rgba(82, 96, 113, 0.45);
  background: rgba(26, 29, 36, 0.92);
  backdrop-filter: blur(18px);
}

.app-header__inner {
  display: flex;
  width: min(1480px, calc(100% - 32px));
  min-height: 70px;
  margin: 0 auto;
  align-items: center;
  gap: 2rem;
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
}

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

.brand__mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(64, 145, 247, 0.62);
  border-radius: 9px;
  color: white;
  background: linear-gradient(145deg, var(--primary-hover), var(--primary-pressed));
  box-shadow: 0 8px 22px rgba(47, 128, 237, 0.26);
  font-weight: 750;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.2;
}

.brand small {
  margin-top: 0.16rem;
  font-size: 0.69rem;
}

.main-nav {
  display: flex;
  align-self: stretch;
  align-items: stretch;
  gap: 0.25rem;
}

.main-nav a {
  display: flex;
  position: relative;
  padding: 0 0.8rem;
  align-items: center;
  color: var(--text-secondary);
  font-weight: 600;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--text);
}

.main-nav a.active::after {
  position: absolute;
  right: 0.8rem;
  bottom: -1px;
  left: 0.8rem;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--primary);
  content: "";
}

.user-menu {
  display: flex;
  margin-left: auto;
  align-items: center;
  gap: 0.55rem;
}

.user-menu__name {
  margin-right: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.auth-shell {
  display: grid;
  width: min(440px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 2rem 0;
  place-items: center;
}

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

.page-header p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--text-secondary);
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--primary-hover);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.toolbar,
.action-bar,
.button-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.toolbar {
  margin-bottom: 1rem;
}

.action-bar {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(34, 38, 48, 0.94);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.12);
}

.card + .card {
  margin-top: 1rem;
}

.card--form {
  max-width: 620px;
}

.card--wide-form {
  max-width: 820px;
}

.card__header,
.card__body {
  padding: 1.15rem 1.25rem;
}

.card__header {
  display: flex;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card__header h2,
.card__header h3 {
  margin: 0;
}

.card__body > :last-child {
  margin-bottom: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.8fr);
  gap: 1rem;
}

.content-grid + .card {
  margin-top: 1rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem 1.5rem;
}

.detail-item dt,
.definition-list dt {
  margin-bottom: 0.22rem;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}

.detail-item dd,
.definition-list dd {
  margin: 0;
  line-height: 1.5;
}

.definition-list {
  display: grid;
  grid-template-columns: minmax(125px, 0.65fr) minmax(0, 1.35fr);
  margin: 0;
  gap: 0.65rem 1rem;
}

.definition-list dd {
  overflow-wrap: anywhere;
}

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

.form-field {
  min-width: 0;
}

.form-field--full {
  grid-column: 1 / -1;
}

.form-field--spaced,
.subsection-title {
  margin-top: 1rem;
}

label,
.label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.58rem 0.72rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  outline: none;
  color: var(--text);
  background: var(--surface-elevated);
  font: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #63728a;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.18);
}

input[readonly],
input:disabled {
  color: var(--text-secondary);
  background: var(--background);
}

input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--primary);
}

.field-hint {
  margin: 0.4rem 0 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.field-validation-error,
.validation-summary-errors {
  color: #ffaaa4;
}

.field-validation-error {
  display: block;
  margin-top: 0.38rem;
  font-size: 0.8rem;
}

.validation-summary-errors {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(249, 112, 102, 0.45);
  border-radius: 8px;
  background: rgba(249, 112, 102, 0.1);
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 1.2rem;
}

.button,
button {
  display: inline-flex;
  min-height: 40px;
  padding: 0.56rem 0.88rem;
  border: 1px solid var(--primary);
  border-radius: 7px;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: white;
  background: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  line-height: 1.1;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.button:hover,
button:hover {
  border-color: var(--primary-hover);
  color: white;
  background: var(--primary-hover);
}

.button:active,
button:active {
  transform: translateY(1px);
  background: var(--primary-pressed);
}

.button:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(64, 145, 247, 0.4);
  outline-offset: 2px;
}

.button--secondary {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface-elevated);
}

.button--secondary:hover {
  border-color: var(--primary);
  background: var(--surface-hover);
}

.button--ghost {
  border-color: transparent;
  color: var(--text-secondary);
  background: transparent;
}

.button--ghost:hover {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-elevated);
}

.button--danger {
  border-color: rgba(249, 112, 102, 0.58);
  color: #ffd4d1;
  background: rgba(249, 112, 102, 0.13);
}

.button--danger:hover {
  border-color: var(--danger);
  background: rgba(249, 112, 102, 0.24);
}

.button--small {
  min-height: 34px;
  padding: 0.42rem 0.65rem;
  font-size: 0.8rem;
}

button:disabled,
.button:disabled {
  border-color: var(--border);
  color: var(--text-disabled);
  background: var(--surface);
  cursor: not-allowed;
  transform: none;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--text-secondary);
  background: rgba(43, 48, 59, 0.78);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 100ms ease;
}

tbody tr:hover {
  background: rgba(54, 61, 74, 0.52);
}

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

.table-key {
  display: block;
  max-width: 310px;
  overflow: hidden;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.83rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge,
.role-badge {
  display: inline-flex;
  padding: 0.27rem 0.52rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
  background: var(--surface-elevated);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

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

.status-badge--success {
  border-color: rgba(50, 213, 131, 0.32);
  color: var(--success);
  background: rgba(50, 213, 131, 0.08);
}

.status-badge--danger {
  border-color: rgba(249, 112, 102, 0.35);
  color: var(--danger);
  background: rgba(249, 112, 102, 0.08);
}

.status-badge--warning {
  border-color: rgba(253, 176, 34, 0.35);
  color: var(--warning);
  background: rgba(253, 176, 34, 0.08);
}

.role-badge--manager {
  border-color: rgba(47, 128, 237, 0.42);
  color: #9dc8ff;
  background: rgba(47, 128, 237, 0.12);
}

.alert {
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.alert--success {
  border-color: rgba(50, 213, 131, 0.38);
  color: #a6f4c5;
  background: rgba(50, 213, 131, 0.09);
}

.alert--danger {
  border-color: rgba(249, 112, 102, 0.42);
  color: #ffd0cc;
  background: rgba(249, 112, 102, 0.1);
}

.alert--warning {
  border-color: rgba(253, 176, 34, 0.4);
  color: #fedf89;
  background: rgba(253, 176, 34, 0.09);
}

.account-list {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 0.6rem;
  list-style: none;
}

.account-row,
.account-choice {
  display: flex;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  background: var(--surface-elevated);
}

.account-choice {
  cursor: pointer;
}

.account-choice:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
}

.account-choice__main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
}

.account-choice__name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-weight: 650;
  text-overflow: ellipsis;
}

.capacity-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 1rem;
  gap: 0.75rem;
}

.capacity-summary > div {
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-elevated);
}

.capacity-summary strong,
.capacity-summary span {
  display: block;
}

.capacity-summary strong {
  margin-top: 0.15rem;
  font-size: 1.5rem;
}

.reduction-panel[hidden] {
  display: none;
}

.reduction-counter {
  margin: 0.7rem 0;
  color: var(--warning);
  font-weight: 700;
}

.empty-state {
  padding: 1.4rem;
  color: var(--text-secondary);
  text-align: center;
}

.search-field {
  position: relative;
  width: min(390px, 100%);
}

.search-field input {
  padding-left: 2.35rem;
}

.search-field::before {
  position: absolute;
  z-index: 1;
  top: 0.65rem;
  left: 0.8rem;
  color: var(--text-secondary);
  content: "⌕";
  font-size: 1.15rem;
}

.auth-card {
  width: 100%;
  padding: 1.65rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(34, 38, 48, 0.96);
  box-shadow: var(--shadow);
}

.auth-brand {
  margin-bottom: 1.5rem;
  text-align: center;
}

.auth-brand .brand__mark {
  margin: 0 auto 0.85rem;
}

.auth-card .form-field + .form-field {
  margin-top: 0.9rem;
}

.auth-card button {
  width: 100%;
  margin-top: 1.15rem;
}

.mono {
  font-family: Consolas, "SFMono-Regular", monospace;
}

.nowrap {
  white-space: nowrap;
}

form.inline {
  display: inline-flex;
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1rem;
  gap: 1rem;
}

.stat-card {
  display: flex;
  min-height: 145px;
  padding: 1.15rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-direction: column;
  color: var(--text);
  background: linear-gradient(145deg, rgba(43, 48, 59, 0.95), rgba(34, 38, 48, 0.95));
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.12);
}

.stat-card:hover {
  border-color: var(--primary);
  color: var(--text);
}

.stat-card--warning {
  border-color: rgba(253, 176, 34, 0.32);
}

.stat-card--danger {
  border-color: rgba(249, 112, 102, 0.34);
}

.stat-card__label {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
}

.stat-card strong {
  margin: auto 0 0.2rem;
  font-size: 2.35rem;
  line-height: 1;
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.account-action-row {
  display: grid;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 0.9fr);
  align-items: center;
  gap: 0.75rem;
  background: var(--surface-elevated);
}

.account-action-row > div,
.account-row--actions > div {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.account-row--actions small {
  flex-basis: 100%;
}

.restore-form,
.role-form {
  display: flex;
  margin: 0;
  align-items: center;
  gap: 0.45rem;
}

.restore-form select,
.role-form select,
.account-action-row select {
  min-height: 36px;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.role-form select {
  width: 175px;
}

.filter-card {
  margin-bottom: 1rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(5, minmax(130px, 0.75fr));
  align-items: end;
  gap: 0.8rem;
}

.filter-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 0.55rem;
}

.pagination {
  display: flex;
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.otp-input {
  max-width: 220px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  text-align: center;
}

.form-field--otp {
  max-width: 300px;
}

.setup-steps {
  margin: 0 0 1.25rem;
  padding-left: 1.3rem;
  color: var(--text-secondary);
}

.setup-steps li + li {
  margin-top: 0.45rem;
}

.mfa-enrollment-grid {
  display: grid;
  margin-bottom: 1.25rem;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
}

.qr-code-panel {
  display: grid;
  padding: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  justify-items: center;
  gap: 0.75rem;
  text-align: center;
  background: var(--background);
}

.qr-code-frame {
  width: min(100%, 240px);
  padding: 10px;
  border-radius: 8px;
  background: #fff;
}

.mfa-qr-code {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.mfa-manual-setup {
  min-width: 0;
}

.secret-box {
  display: grid;
  padding: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.35rem 0.8rem;
  background: var(--background);
}

.secret-box span {
  grid-column: 1 / -1;
}

.secret-box strong {
  overflow-wrap: anywhere;
  color: var(--warning);
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}

.provisioning-details {
  margin: 0.75rem 0 1.25rem;
  color: var(--text-secondary);
}

.provisioning-details code {
  display: block;
  margin-top: 0.5rem;
  padding: 0.65rem;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: var(--background);
}

@media (max-width: 720px) {
  .mfa-enrollment-grid {
    grid-template-columns: 1fr;
  }
}

.auth-card__footer {
  margin: 1rem 0 0;
  text-align: center;
}

@media (max-width: 1040px) {
  .app-header__inner {
    flex-wrap: wrap;
    padding: 0.75rem 0;
    gap: 0.6rem 1rem;
  }

  .main-nav {
    order: 3;
    width: 100%;
    min-height: 40px;
  }

  .main-nav a {
    padding: 0 0.7rem;
  }

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

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

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

@media (max-width: 720px) {
  .app-header__inner,
  .app-shell {
    width: min(100% - 20px, 1480px);
  }

  .user-menu__name {
    display: none;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .form-field--full {
    grid-column: auto;
  }

  .card__header,
  .card__body {
    padding-right: 0.9rem;
    padding-left: 0.9rem;
  }

  th,
  td {
    padding: 0.7rem;
  }
}

@media (max-width: 520px) {
  .brand small,
  .main-nav a::after {
    display: none;
  }

  .user-menu .button:first-of-type {
    display: none;
  }

  .main-nav {
    overflow-x: auto;
  }

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

  .stats-grid,
  .filter-grid,
  .account-action-row {
    grid-template-columns: 1fr;
  }

  .restore-form,
  .role-form {
    align-items: stretch;
    flex-direction: column;
  }

  .role-form select {
    width: 100%;
  }

  .definition-list {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .definition-list dd + dt {
    margin-top: 0.65rem;
  }
}
