.button,
.icon-button {
  border: 0;
  font-weight: 750;
  transition:
    transform 0.18s,
    box-shadow 0.18s,
    background 0.18s,
    border-color 0.18s,
    opacity 0.18s;
}

.button {
  display: inline-flex;
  max-width: 100%;
  min-height: var(--button-height);
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--button-padding);
  border-radius: var(--button-radius);
  font-size: var(--button-font-size);
  line-height: 1.35;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

.button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.button .action-icon,
.btn .action-icon,
.text-button .action-icon,
.copy .action-icon,
.profile-avatar-menu-item .action-icon,
.link-button .action-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
}

.text-button:has(> .action-icon),
.copy:has(> .action-icon),
.profile-avatar-menu-item:has(> .action-icon),
.link-button:has(> .action-icon) {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.35;
}

.profile-avatar-menu-item:has(> .action-icon) {
  display: flex;
}

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

.button:not(:disabled):active {
  transform: none;
}

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

.button:focus-visible {
  outline: 2px solid var(--form-focus-border);
  outline-offset: 3px;
}

.button-primary {
  color: #fff;
  background: var(--violet-600);
  box-shadow: var(--shadow-sm);
}

.button-primary:disabled {
  color: var(--ink-700);
  border: 1px solid var(--violet-100);
  background: var(--violet-100);
  box-shadow: none;
  opacity: 1;
}

.button-primary:not(:disabled):hover {
  background: var(--violet-700);
  box-shadow: var(--shadow-md);
}

.button-secondary,
.button-outline,
.button-soft {
  color: var(--ink-700);
  border: 1px solid var(--line);
  background: #fff;
}

.button-secondary:not(:disabled):hover,
.button-outline:not(:disabled):hover {
  color: var(--violet-700);
  border-color: #d7d0ff;
  background: var(--violet-50);
}

.button-soft {
  color: var(--violet-700);
  border-color: #ddd6ff;
  background: var(--violet-50);
}

.button-soft:not(:disabled):hover {
  border-color: #cfc4ff;
  background: var(--violet-100);
}

.button-danger {
  color: #fff;
  background: var(--red-600);
  box-shadow: 0 10px 22px rgba(217, 45, 32, 0.18);
}

.button-danger-soft {
  color: var(--red-700);
  border: 1px solid var(--red-100);
  background: var(--red-50);
}

.button-danger-soft:not(:disabled):hover {
  color: #912018;
  border-color: #f9b9b3;
  background: #ffebe9;
}

.button-quiet,
.button-ghost {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--ink-600);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  font-size: 11px;
}

.button-quiet:not(:disabled):hover,
.button-ghost:not(:disabled):hover {
  color: var(--violet-700);
  border-color: #d7d0ff;
  background: var(--violet-50);
}

.button-danger-quiet {
  color: var(--red-700);
}

.button-danger-quiet:not(:disabled):hover {
  color: var(--red-700);
  border-color: var(--red-100);
  background: var(--red-50);
}

.button-block {
  width: 100%;
}

.button-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--ink-600);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.icon-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.icon-button:not(:disabled):hover {
  color: var(--violet-700);
  border-color: var(--violet-500);
  background: var(--violet-50);
}

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

.user-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  flex: 0 0 38px;
  place-items: center;
  color: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: #475467;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  font: 800 12px var(--font-display);
  letter-spacing: 0.04em;
  overflow: hidden;
}

.user-avatar.has-image {
  color: transparent;
  border-color: rgba(15, 23, 42, 0.1);
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.page-heading h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--page-title-size);
  line-height: var(--page-title-line-height);
  color: var(--ink-900);
}

.page-heading p {
  max-width: 680px;
  margin-bottom: 0;
  color: var(--ink-500);
  font-size: var(--page-description-size);
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-animated {
  opacity: 0;
  transform: translateY(13px);
  animation: pageEnter 0.45s var(--ease) forwards;
}

.section-card {
  padding: var(--card-padding);
}

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

.section-heading > div {
  min-width: 0;
}

.section-heading h3 {
  margin: 0 0 8px;
  font-size: var(--section-title-size);
  line-height: 1.35;
}

.section-heading p {
  margin-bottom: 0;
  color: var(--ink-500);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.span-7 {
  grid-column: span 7;
}

.span-5 {
  grid-column: span 5;
}

.span-12 {
  grid-column: 1 / -1;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-content: center;
  align-items: center;
  gap: 8px 16px;
  padding: 20px 22px;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: none;
  transition: border-color 0.18s;
}

.metric-card:hover {
  border-color: var(--line-strong);
}

.metric-card::after {
  content: none;
}

.metric-card > span,
.metric-card > .dashboard-metric-head {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.metric-card > span {
  color: var(--ink-500);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.metric-card > strong {
  display: block;
  grid-column: 2;
  grid-row: 1 / 3;
  margin: 0;
  font: 800 28px var(--font-display);
  line-height: 1.15;
  text-align: right;
  overflow-wrap: anywhere;
}

.metric-card > small {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  color: var(--ink-500);
  font-size: 13px;
  line-height: 1.5;
}

.tab-strip {
  display: flex;
  gap: 6px;
  margin: 4px 0 18px;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  margin-bottom: -1px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-500);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.tab-button + .tab-button {
  margin-left: 18px;
}

.tab-button.active {
  border-bottom-color: var(--accent, var(--ink-900));
  color: var(--ink-900);
}

.tab-count {
  display: inline-flex;
  min-width: 20px;
  justify-content: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-500);
  font-size: 10.5px;
  font-weight: 800;
}

.tab-button.active .tab-count {
  background: var(--ink-900);
  color: var(--surface);
}

.status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--ink-600);
  background: var(--surface-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: capitalize;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-400);
  content: "";
}

.status-badge.active {
  color: var(--green-700);
  background: var(--green-50);
}

.status-badge.active::before {
  background: #12b76a;
}

.quota-detail { opacity: .65; }

.status-badge.inactive,
.status-badge.revoked {
  color: var(--red-700);
  background: var(--red-50);
}

.status-badge.inactive::before,
.status-badge.revoked::before {
  background: var(--red-600);
}

.status-badge.expired {
  color: var(--amber-700);
  background: #fffaeb;
}

.status-badge.pending {
  color: var(--amber-700);
  background: #fffaeb;
}

.status-badge.pending::before {
  background: #f79009;
}

.role-badge {
  display: inline-flex;
  padding: 5px 9px;
  color: var(--violet-700);
  border-radius: 8px;
  background: var(--violet-50);
  font-size: 10px;
  font-weight: 750;
}

.notification-region {
  position: fixed;
  z-index: 2147483647;
  top: max(18px, env(safe-area-inset-top));
  right: 18px;
  display: grid;
  width: min(390px, calc(100vw - 28px));
  gap: 10px;
  pointer-events: none;
}

.notification-region[popover] {
  inset: auto 18px auto auto;
  top: max(18px, env(safe-area-inset-top));
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.notification {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-md);
  animation: toastEnter 0.32s var(--ease) both;
  pointer-events: auto;
}

.notification.is-leaving {
  animation: toastLeave 0.28s var(--ease) forwards;
}

.notification > i {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--violet-600);
}

.notification > i svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.notification.success > i {
  color: var(--green-700);
}

.notification.error > i {
  color: var(--red-600);
}

.notification span {
  color: var(--ink-700);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.45;
}

.notification button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: var(--ink-400);
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition:
    color 0.15s,
    background 0.15s;
}

.notification button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.notification button:hover {
  color: var(--ink-800);
  background: var(--surface-muted);
}

.notification > b {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  transform-origin: left center;
  background: var(--violet-500);
  animation: toastProgress linear forwards;
}

.notification.success > b {
  background: #12b76a;
}

.notification.error > b {
  background: var(--red-600);
}

.notification.is-paused > b {
  animation-play-state: paused;
}

@keyframes toastLeave {
  to {
    opacity: 0;
    transform: translateX(14px) scale(0.97);
  }
}

@keyframes toastProgress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .notification,
  .notification.is-leaving {
    animation: none;
  }

  .notification > b {
    display: none;
  }
}

.empty-state {
  padding: 44px 20px;
  text-align: center;
}

.empty-state-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  color: var(--violet-600);
  border-radius: 17px;
  background: var(--violet-50);
  font: 800 22px var(--font-display);
}

.empty-state h3 {
  margin-bottom: 7px;
  font-size: 16px;
}

.empty-state p {
  max-width: 430px;
  margin: 0 auto 17px;
  color: var(--ink-500);
  font-size: 12px;
  line-height: 1.55;
}

.confirm-dialog,
.form-dialog {
  position: relative;
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  overflow: hidden;
  padding: 0;
  color: var(--ink-900);
  border: 0;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.confirm-dialog[open],
.form-dialog[open] {
  animation: pageEnter 0.25s var(--ease);
}

.confirm-dialog::backdrop,
.form-dialog::backdrop {
  background: rgba(10, 16, 28, 0.62);
  backdrop-filter: blur(5px);
}

.confirm-dialog form,
.dialog-body {
  padding: 25px;
}

.dialog-close-button {
  position: absolute;
  z-index: 2;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink-500);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  cursor: pointer;
  transition:
    background 0.16s var(--ease),
    color 0.16s var(--ease);
}

.dialog-close-button:hover {
  color: var(--ink-900);
  background: var(--line);
}

.dialog-close-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.form-dialog-wide {
  width: min(760px, calc(100vw - 28px));
}

.form-dialog-wide .dialog-body {
  max-height: min(82vh, 900px);
  overflow-y: auto;
}

.form-dialog .dialog-body {
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.dialog-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  color: var(--red-700);
  border-radius: 13px;
  background: var(--red-50);
  font: 800 17px var(--font-display);
}

.confirm-dialog h2,
.form-dialog h2 {
  overflow-wrap: anywhere;
  margin-bottom: 7px;
  font-size: 20px;
}

.confirm-dialog p,
.dialog-intro {
  overflow-wrap: anywhere;
  margin-bottom: 20px;
  color: var(--ink-500);
  font-size: 12px;
  line-height: 1.55;
}

.dialog-actions,
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.error-state {
  padding: 32px;
  color: var(--red-700);
  border: 1px solid var(--red-100);
  border-radius: var(--radius-lg);
  background: var(--red-50);
  text-align: center;
}

.session-expired {
  pointer-events: none;
  cursor: progress;
}

.session-expired::after {
  position: fixed;
  z-index: 200;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  content: "";
}

.form-dialog .form-actions {
  position: sticky;
  z-index: 1;
  bottom: 0;
  margin: 12px -2px 0;
  padding: 12px 2px 2px;
  background: #fff;
}
