:root {
  --color-canvas: #f5f7fa;
  --color-surface: #ffffff;
  --color-sidebar: #111827;
  --color-sidebar-muted: #93a0b4;
  --color-text: #172033;
  --color-text-muted: #667085;
  --color-text-soft: #8a94a6;
  --color-border: #d8dee9;
  --color-border-soft: #e9edf3;
  --color-accent: #3155d9;
  --color-accent-hover: #2547be;
  --color-accent-soft: #eef3ff;
  --color-success: #147d64;
  --color-success-soft: #eaf7f3;
  --color-warning: #a15c07;
  --color-warning-soft: #fff6e8;
  --color-danger: #b42318;
  --color-danger-hover: #931c14;
  --color-danger-soft: #fff0ee;
  --color-info-bg: #eef3ff;
  --shadow-float: 0 18px 50px rgb(23 32 51 / 16%);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  color: var(--color-text);
  background: var(--color-canvas);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--color-canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--color-canvas);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.55;
}

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

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

button {
  border: 0;
}

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

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

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

.skip-link {
  position: fixed;
  z-index: 200;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  transform: translateY(-150%);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
}

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

:focus-visible {
  outline: 3px solid rgb(49 85 217 / 35%);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.auth-mode {
  overflow-x: hidden;
  background: #f3f6fb;
}

.auth-mode .sidebar,
.auth-mode .topbar,
.auth-mode .sidebar-scrim {
  display: none;
}

.auth-mode .app-frame {
  padding-left: 0;
}

.auth-mode main {
  min-height: 100vh;
}

.auth-page {
  position: relative;
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 10%, rgb(49 85 217 / 10%), transparent 30rem),
    radial-gradient(circle at 88% 88%, rgb(20 125 100 / 8%), transparent 28rem),
    #f5f7fb;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0.42;
  background-image:
    linear-gradient(rgb(23 32 51 / 5%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(23 32 51 / 5%) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, #000, transparent 84%);
  pointer-events: none;
}

.auth-header,
.auth-footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.auth-header {
  min-height: 76px;
  padding: 0 40px;
  border-bottom: 1px solid rgb(216 222 233 / 75%);
  background: rgb(255 255 255 / 62%);
  backdrop-filter: blur(16px);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.auth-brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 10px;
  background: var(--color-sidebar);
  color: #aebdff;
  box-shadow: 0 8px 20px rgb(17 24 39 / 18%);
}

.auth-brand-mark svg {
  width: 22px;
  height: 22px;
}

.auth-brand strong,
.auth-brand small {
  display: block;
}

.auth-brand strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.auth-brand small {
  color: var(--color-text-muted);
  font-size: 11px;
}

.auth-main {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 640px);
  margin: 0 auto;
  align-content: center;
  justify-items: center;
  padding: 56px 24px 44px;
}

.auth-card {
  width: min(100%, 472px);
  padding: 40px;
  border: 1px solid rgb(216 222 233 / 90%);
  border-radius: 16px;
  background: rgb(255 255 255 / 96%);
  box-shadow:
    0 24px 70px rgb(23 32 51 / 12%),
    0 2px 8px rgb(23 32 51 / 4%);
  text-align: center;
}

.auth-card--status {
  padding-top: 48px;
  padding-bottom: 44px;
}

.auth-card-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 20px;
  place-items: center;
  border: 1px solid #d9e2ff;
  border-radius: 14px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.auth-card-icon--danger {
  border-color: #ffd5d0;
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.auth-card-icon svg {
  width: 24px;
  height: 24px;
}

.auth-eyebrow {
  margin: 0 0 8px;
  color: var(--color-accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.auth-card h1 {
  margin: 0;
  color: var(--color-text);
  font-size: clamp(25px, 4vw, 30px);
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.auth-intro {
  max-width: 380px;
  margin: 14px auto 26px;
  color: var(--color-text-muted);
  font-size: 14px;
}

.auth-security-note {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  margin-bottom: 20px;
  padding: 14px;
  border: 1px solid #d9e2ff;
  border-radius: 10px;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  text-align: left;
}

.auth-security-note--muted {
  border-color: var(--color-border-soft);
  background: var(--color-canvas);
  color: var(--color-text-muted);
}

.auth-security-note svg {
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.auth-security-note strong,
.auth-security-note span {
  display: block;
}

.auth-security-note strong {
  color: var(--color-text);
  font-size: 13px;
}

.auth-security-note span {
  margin-top: 2px;
  color: var(--color-text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-login-button {
  width: 100%;
  min-height: 46px;
  justify-content: center;
}

.auth-login-button svg {
  width: 17px;
  height: 17px;
  margin-left: auto;
}

.auth-help {
  margin: 16px 0 0;
  color: var(--color-text-soft);
  font-size: 11px;
}

.auth-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 18px;
  margin-top: 24px;
  color: var(--color-text-muted);
  font-size: 11px;
}

.auth-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.auth-meta svg {
  width: 13px;
  height: 13px;
  color: var(--color-success);
  stroke-width: 2.2;
}

.auth-footer {
  min-height: 60px;
  padding: 0 40px;
  color: var(--color-text-soft);
  font-size: 11px;
}

.auth-spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 22px;
  border: 3px solid #dfe5f2;
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: auth-spin 800ms linear infinite;
}

.auth-progress {
  height: 4px;
  margin: 4px 0 20px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--color-border-soft);
}

.auth-progress span {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: var(--color-accent);
  animation: auth-progress 900ms ease-in-out infinite;
}

@keyframes auth-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes auth-progress {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(245%);
  }
}

.sidebar {
  position: fixed;
  z-index: 40;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  background: var(--color-sidebar);
  color: #fff;
}

.brand {
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid rgb(255 255 255 / 8%);
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 9px;
  background: rgb(255 255 255 / 7%);
  color: #9fb2ff;
}

.brand-mark svg {
  width: 21px;
  height: 21px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: -2px;
  color: var(--color-sidebar-muted);
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  padding: 20px 12px;
}

.sidebar-nav a {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: #c5cddd;
  font-weight: 500;
  transition:
    background 150ms ease,
    color 150ms ease;
}

.sidebar-nav a:hover {
  background: rgb(255 255 255 / 6%);
  color: #fff;
}

.sidebar-nav a.is-active {
  background: rgb(82 112 225 / 20%);
  color: #fff;
}

.sidebar-nav a.is-active svg {
  color: #9fb2ff;
}

.sidebar-footer {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgb(255 255 255 / 8%);
}

.environment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  color: #c5cddd;
  font-size: 12px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

.status-dot--neutral {
  color: #a8b3c5;
}

.status-dot--success {
  color: var(--color-success);
}

.status-dot--warning {
  color: var(--color-warning);
}

.status-dot--danger {
  color: var(--color-danger);
}

.user-menu {
  display: grid;
  grid-template-columns: 34px 1fr 18px;
  gap: 10px;
  width: 100%;
  min-height: 50px;
  align-items: center;
  padding: 8px;
  border-radius: var(--radius-md);
  background: transparent;
  color: #fff;
  text-align: left;
  cursor: pointer;
}

.user-menu:hover {
  background: rgb(255 255 255 / 6%);
}

.user-menu strong,
.user-menu small {
  display: block;
  max-width: 138px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu strong {
  font-size: 12px;
  font-weight: 600;
}

.user-menu small {
  color: var(--color-sidebar-muted);
  font-size: 11px;
}

.user-menu svg {
  width: 16px;
  height: 16px;
  color: var(--color-sidebar-muted);
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #3155d9;
  font-size: 11px;
  font-weight: 700;
}

.app-frame {
  min-height: 100vh;
  padding-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--color-border-soft);
  background: rgb(255 255 255 / 95%);
  backdrop-filter: blur(10px);
}

.breadcrumb {
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.environment-badge,
.badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.environment-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  content: "";
}

.icon-button,
.mobile-menu,
.copy-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.icon-button:hover,
.mobile-menu:hover,
.copy-button:hover {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.icon-button {
  position: relative;
}

.notification-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 6px;
  height: 6px;
  border: 1px solid #fff;
  border-radius: 50%;
  background: var(--color-danger);
}

.mobile-menu {
  display: none;
}

main {
  min-height: calc(100vh - var(--topbar-height));
}

.page {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 32px;
}

.page--form {
  width: min(100%, 1120px);
}

.page--secret {
  width: min(100%, 960px);
}

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

.page-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.page-header h1,
.page-header h2,
.section-title {
  margin: 0;
  letter-spacing: -0.02em;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 650;
  line-height: 1.3;
}

.page-header p {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--color-text-muted);
}

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

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.button svg {
  width: 17px;
  height: 17px;
}

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

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

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

.button--secondary:hover,
.button--ghost:hover {
  border-color: #bdc6d5;
  background: #f9fafb;
}

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

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

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

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

.button--danger-outline:hover {
  background: var(--color-danger-soft);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

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

.stat-card,
.card {
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.stat-card {
  min-height: 132px;
  padding: 20px;
}

.stat-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
}

.stat-card__icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.stat-card__icon svg {
  width: 18px;
  height: 18px;
}

.stat-card__value {
  margin-top: 16px;
  font-size: 25px;
  font-weight: 680;
  letter-spacing: -0.03em;
}

.stat-card__meta {
  margin-top: 3px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  overflow: hidden;
}

.card-header {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--color-border-soft);
}

.card-header h2,
.card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}

.card-header p {
  margin: 2px 0 0;
  color: var(--color-text-muted);
  font-size: 12px;
}

.card-body {
  padding: 20px;
}

.action-list,
.timeline,
.activity-list {
  display: grid;
}

.action-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border-soft);
}

.action-item:first-child {
  padding-top: 0;
}

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

.action-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.action-icon--danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.action-icon svg {
  width: 17px;
  height: 17px;
}

.action-item strong,
.timeline-item strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.action-item small,
.timeline-item small {
  display: block;
  margin-top: 2px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.text-link {
  border-radius: 4px;
  color: var(--color-accent);
  font-weight: 600;
}

.text-link:hover {
  text-decoration: underline;
}

.timeline {
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
  padding-bottom: 18px;
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-item::before {
  position: absolute;
  top: 14px;
  bottom: -2px;
  left: 5px;
  width: 1px;
  background: var(--color-border);
  content: "";
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  position: relative;
  z-index: 1;
  width: 11px;
  height: 11px;
  margin-top: 4px;
  border: 3px solid #dfe6fb;
  border-radius: 50%;
  background: var(--color-accent);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th,
.data-table td {
  height: 52px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border-soft);
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  height: 42px;
  background: #fafbfc;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
}

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

.data-table tbody tr[data-client-id] {
  cursor: pointer;
}

.data-table tbody tr[data-client-id]:hover td {
  background: #fafbfe;
}

.client-cell strong,
.client-cell code {
  display: block;
}

.client-cell strong {
  font-size: 13px;
  font-weight: 650;
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.client-cell code {
  margin-top: 2px;
  color: var(--color-text-muted);
}

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

.badge--success {
  border-color: #b7dfd3;
  background: var(--color-success-soft);
  color: var(--color-success);
}

.badge--neutral {
  background: #f4f6f8;
  color: #596579;
}

.badge--warning {
  border-color: #f0d3a7;
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.badge--danger {
  border-color: #f0b7b1;
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scope-chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid #d6def8;
  border-radius: var(--radius-sm);
  background: #f4f6ff;
  color: #344b9f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border-soft);
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

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

.search-field svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

.search-field input {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px 8px 38px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}

.select {
  min-height: 38px;
  padding: 7px 32px 7px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  padding: 48px 20px;
  text-align: center;
}

.empty-state__icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.empty-state h2 {
  margin: 0;
  font-size: 17px;
}

.empty-state p {
  max-width: 380px;
  margin: 6px auto 18px;
  color: var(--color-text-muted);
}

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

.form-stack {
  display: grid;
  gap: 16px;
}

.form-section {
  padding: 24px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.form-section h2 {
  margin: 0;
  font-size: 17px;
}

.form-section > p {
  margin: 4px 0 22px;
  color: var(--color-text-muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

.field:first-of-type {
  margin-top: 0;
}

.field label,
.field-label {
  font-size: 13px;
  font-weight: 600;
}

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

.field-error {
  color: var(--color-danger);
  font-size: 12px;
}

.input,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}

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

.input:focus,
.textarea:focus,
.search-field input:focus,
.select:focus {
  border-color: var(--color-accent);
  outline: 3px solid rgb(49 85 217 / 15%);
}

.input[aria-invalid="true"] {
  border-color: var(--color-danger);
}

.advanced-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 0;
  background: transparent;
  color: var(--color-accent);
  font-weight: 600;
  cursor: pointer;
}

.advanced-toggle svg {
  width: 16px;
  height: 16px;
}

.advanced-panel {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: #f8f9fb;
}

.scope-groups {
  display: grid;
  gap: 18px;
}

.scope-group {
  padding: 16px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
}

.scope-group h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.scope-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  padding: 10px 0;
  cursor: pointer;
}

.scope-option + .scope-option {
  border-top: 1px solid var(--color-border-soft);
}

.scope-option input {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  accent-color: var(--color-accent);
}

.scope-option code {
  display: block;
  color: #304482;
  font-weight: 650;
}

.scope-option small {
  display: block;
  margin-top: 3px;
  color: var(--color-text-muted);
}

.summary-card {
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
  padding: 22px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.summary-card h2 {
  margin: 0 0 18px;
  font-size: 16px;
}

.summary-list {
  display: grid;
  gap: 15px;
  margin: 0;
}

.summary-list div {
  display: grid;
  gap: 3px;
}

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

.summary-list dd {
  margin: 0;
  font-weight: 600;
}

.summary-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border-soft);
}

.alert {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid #ccd8ff;
  border-radius: var(--radius-md);
  background: var(--color-info-bg);
  color: #2f468e;
}

.alert--warning {
  border-color: #f0d3a7;
  background: var(--color-warning-soft);
  color: #754000;
}

.alert--danger {
  border-color: #f0b7b1;
  background: var(--color-danger-soft);
  color: #8e1c13;
}

.alert svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.alert strong {
  display: block;
  margin-bottom: 2px;
}

.alert p {
  margin: 0;
  color: inherit;
  font-size: 12px;
}

.success-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.success-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--color-success-soft);
  color: var(--color-success);
}

.credential-card {
  margin-top: 20px;
  padding: 22px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.credential-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border-soft);
}

.credential-row:first-child {
  padding-top: 0;
}

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

.credential-label {
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 600;
}

.credential-value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
}

.secret-actions {
  display: flex;
  gap: 6px;
}

.code-block {
  position: relative;
  margin-top: 20px;
  overflow: auto;
  border: 1px solid #273449;
  border-radius: var(--radius-md);
  background: #111827;
  color: #e8edf5;
}

.code-block pre {
  margin: 0;
  padding: 18px 58px 18px 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.code-block .copy-button {
  position: absolute;
  top: 10px;
  right: 10px;
  border-color: rgb(255 255 255 / 14%);
  color: #cbd5e1;
}

.acknowledgement {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 22px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: #f8f9fb;
  cursor: pointer;
}

.acknowledgement input {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--color-accent);
}

.secret-page-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 7px;
}

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

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--color-border);
}

.tab {
  position: relative;
  min-width: max-content;
  padding: 11px 14px;
  background: transparent;
  color: var(--color-text-muted);
  font-weight: 600;
  cursor: pointer;
}

.tab::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: transparent;
  content: "";
}

.tab.is-active {
  color: var(--color-accent);
}

.tab.is-active::after {
  background: var(--color-accent);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.metric-panel {
  padding: 20px;
}

.metric-panel__label {
  color: var(--color-text-muted);
  font-size: 12px;
}

.metric-panel__value {
  margin-top: 5px;
  font-size: 17px;
  font-weight: 650;
}

.details-card {
  margin-top: 16px;
}

.definition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 32px;
}

.definition-grid div {
  min-width: 0;
}

.definition-grid dt {
  margin-bottom: 4px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.definition-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.danger-zone {
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid #edc6c1;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.danger-zone__header {
  padding: 18px 20px;
  border-bottom: 1px solid #f2d8d5;
}

.danger-zone__header h2 {
  margin: 0;
  color: var(--color-danger);
  font-size: 16px;
}

.danger-zone__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
}

.danger-zone__row + .danger-zone__row {
  border-top: 1px solid var(--color-border-soft);
}

.danger-zone__row strong {
  display: block;
  font-size: 13px;
}

.danger-zone__row p {
  margin: 3px 0 0;
  color: var(--color-text-muted);
  font-size: 12px;
}

.scope-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.change-list {
  display: grid;
  gap: 8px;
  min-height: 44px;
}

.change-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.change-sign {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 5px;
  font-family: ui-sans-serif, sans-serif;
  font-weight: 700;
}

.change-row--add .change-sign {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.change-row--remove .change-sign {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.secrets-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.secrets-header h2 {
  margin: 0;
  font-size: 17px;
}

.secrets-header p {
  margin: 4px 0 0;
  color: var(--color-text-muted);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
}

.text-button {
  padding: 4px 6px;
  border-radius: 5px;
  background: transparent;
  color: var(--color-accent);
  font-weight: 600;
  cursor: pointer;
}

.text-button:hover {
  background: var(--color-accent-soft);
}

.text-button--danger {
  color: var(--color-danger);
}

.text-button--danger:hover {
  background: var(--color-danger-soft);
}

.activity-list {
  padding: 0 20px;
}

.activity-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border-soft);
}

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

.activity-symbol {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.activity-symbol svg {
  width: 17px;
  height: 17px;
}

.activity-row strong {
  display: block;
  font-size: 13px;
}

.activity-row p {
  margin: 2px 0 0;
  color: var(--color-text-muted);
  font-size: 12px;
}

.activity-time {
  color: var(--color-text-muted);
  font-size: 12px;
}

.filter-summary {
  padding: 8px 16px;
  border-bottom: 1px solid var(--color-border-soft);
  background: #fafbfc;
  color: var(--color-text-muted);
  font-size: 12px;
}

.dialog-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(17 24 39 / 55%);
}

.dialog {
  width: min(100%, 500px);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-float);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 20px 0;
}

.dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-header p {
  margin: 5px 0 0;
  color: var(--color-text-muted);
}

.dialog-body {
  padding: 20px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border-soft);
}

.dialog-close {
  margin: -4px -4px 0 0;
}

.diff-panel {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 14px;
  border-radius: var(--radius-md);
  background: #f8f9fb;
}

.toast-region {
  position: fixed;
  z-index: 150;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 40px));
}

.toast {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 13px 14px;
  border: 1px solid #b7dfd3;
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: 0 10px 35px rgb(23 32 51 / 14%);
}

.toast svg {
  width: 18px;
  height: 18px;
  color: var(--color-success);
}

.toast button {
  padding: 0;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
}

.mobile-client-list {
  display: none;
}

.client-card {
  padding: 16px;
  border-bottom: 1px solid var(--color-border-soft);
  cursor: pointer;
}

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

.client-card__top,
.client-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.client-card__id {
  display: block;
  margin: 5px 0 12px;
  color: var(--color-text-muted);
}

.client-card__meta {
  color: var(--color-text-muted);
  font-size: 12px;
}

.sidebar-scrim {
  position: fixed;
  z-index: 35;
  inset: 0;
  background: rgb(17 24 39 / 55%);
}

@media (max-width: 1199px) {
  :root {
    --sidebar-width: 72px;
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand > span:last-child,
  .sidebar-nav span,
  .sidebar-footer .environment-row,
  .user-menu > span:nth-child(2),
  .user-menu > svg {
    display: none;
  }

  .sidebar-nav a {
    justify-content: center;
    padding: 0;
  }

  .sidebar-footer {
    justify-items: center;
    padding-inline: 8px;
  }

  .user-menu {
    display: grid;
    width: 44px;
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 5px;
  }

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

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

  .form-layout,
  .scope-editor-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
  }
}

@media (max-width: 767px) {
  :root {
    --sidebar-width: 240px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
  }

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

  .brand {
    justify-content: flex-start;
    padding: 0 20px;
  }

  .brand > span:last-child,
  .sidebar-nav span,
  .sidebar-footer .environment-row,
  .user-menu > span:nth-child(2),
  .user-menu > svg {
    display: initial;
  }

  .sidebar-nav a {
    justify-content: flex-start;
    padding: 0 12px;
  }

  .sidebar-footer {
    justify-items: stretch;
    padding-inline: 12px;
  }

  .user-menu {
    display: grid;
    width: 100%;
    grid-template-columns: 34px 1fr 18px;
    justify-items: stretch;
    padding: 8px;
  }

  .app-frame {
    padding-left: 0;
  }

  .topbar {
    padding: 0 16px;
  }

  .mobile-menu {
    display: inline-grid;
    margin-left: -6px;
  }

  .breadcrumb {
    flex: 1;
    margin-left: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .environment-badge {
    display: none;
  }

  .auth-header {
    min-height: 68px;
    padding: 0 18px;
  }

  .auth-header .environment-badge {
    display: inline-flex;
  }

  .auth-main {
    padding: 36px 16px 28px;
  }

  .auth-card,
  .auth-card--status {
    padding: 30px 22px;
    border-radius: 14px;
  }

  .auth-card h1 {
    font-size: 25px;
  }

  .auth-meta {
    display: grid;
    justify-content: start;
    gap: 8px;
  }

  .auth-footer {
    min-height: 54px;
    padding: 0 18px;
  }

  .page {
    padding: 22px 16px 92px;
  }

  .page-header {
    display: grid;
    gap: 16px;
    margin-bottom: 22px;
  }

  .page-header h1 {
    font-size: 24px;
  }

  .page-actions {
    justify-content: stretch;
  }

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

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

  .stat-card {
    min-height: 112px;
  }

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

  .card-header {
    padding-inline: 16px;
  }

  .card-body {
    padding: 16px;
  }

  .action-item {
    grid-template-columns: 34px 1fr;
  }

  .action-item .text-link {
    grid-column: 2;
  }

  .desktop-table {
    display: none;
  }

  .mobile-client-list {
    display: block;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-group,
  .search-field,
  .select {
    width: 100%;
  }

  .select {
    flex: 1;
  }

  .form-layout,
  .scope-editor-layout {
    grid-template-columns: 1fr;
  }

  .form-section {
    padding: 18px 16px;
  }

  .summary-card {
    position: static;
    order: 2;
  }

  .summary-actions {
    position: fixed;
    z-index: 25;
    right: 0;
    bottom: 0;
    left: 0;
    display: flex;
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 -8px 24px rgb(23 32 51 / 8%);
    backdrop-filter: blur(10px);
  }

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

  .credential-row {
    grid-template-columns: 1fr auto;
    gap: 7px 12px;
  }

  .credential-label {
    grid-column: 1 / -1;
  }

  .secret-actions {
    align-self: start;
  }

  .secret-page-actions .button {
    width: 100%;
  }

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

  .danger-zone__row,
  .secrets-header {
    align-items: stretch;
    flex-direction: column;
  }

  .danger-zone__row .button,
  .secrets-header .button {
    width: 100%;
  }

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

  .activity-time {
    grid-column: 2;
  }

  .dialog-backdrop {
    align-items: end;
    padding: 0;
  }

  .dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
