.roles-page {
  min-width: 0;
  color: hsl(var(--foreground));
}

.roles-page > :first-child {
  padding-bottom: 1.15rem;
  border-bottom: 1px solid hsl(var(--border));
}

.roles-page h1 {
  letter-spacing: -0.035em;
}

.roles-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
  min-width: 0;
}

.role-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d8e4ef;
  border-color: #d8e4ef;
  border-radius: 0.8rem;
  background:
    linear-gradient(112deg, rgba(235, 245, 253, 0.62), transparent 55%),
    hsl(var(--card));
  box-shadow: 0 2px 8px rgba(28, 66, 105, 0.045);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.role-card:hover {
  border-color: #b6cfe3;
  box-shadow: 0 8px 20px rgba(28, 66, 105, 0.09);
}

.role-card-header {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 2.75rem;
  align-items: start;
  gap: 0.75rem;
  padding: 1.15rem 1.15rem 0.8rem;
}

.role-card-index {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 0.55rem;
  background: #e7f1f9;
  color: #35658d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.role-card-heading {
  min-width: 0;
  padding-top: 0.08rem;
}

.role-card-title {
  overflow-wrap: anywhere;
  color: #193e61;
  font-size: 1.03rem;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.role-card-description {
  margin-top: 0.35rem;
  color: hsl(var(--muted-foreground));
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.role-card-menu {
  display: flex;
  justify-content: flex-end;
}

.role-actions-trigger {
  width: 2.75rem;
  height: 2.75rem;
  margin: -0.35rem -0.35rem 0 0;
}

.role-action-item {
  min-height: 2.75rem;
  padding: 0.65rem 0.85rem;
}

.role-card-content {
  padding: 0 1.15rem 1.1rem;
}

.role-card-meta {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px solid #e5edf4;
}

.role-internal,
.role-kind {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.38rem;
}

.role-field-label {
  color: #637b90;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.075em;
  line-height: 1.2;
  text-transform: uppercase;
}

.role-internal code {
  max-width: 100%;
  color: #244b6c;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.77rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.role-kind {
  flex: 0 0 auto;
  align-items: flex-end;
}

.roles-page button:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.roles-page > :first-child button {
  min-height: 2.75rem;
  background: #2563eb;
  color: #fff;
}

.roles-page > :first-child > div:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.roles-loading,
.roles-empty {
  display: flex;
  min-height: 8rem;
  align-items: center;
  gap: 1rem;
  padding: 1.35rem;
  border: 1px solid #d8e4ef;
  border-radius: 0.8rem;
  background: #f7fbfe;
  color: #526f88;
  font-size: 0.9rem;
}

.roles-loading-mark {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.7rem;
  background: #e7f1f9;
}

.roles-empty-index {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0.7rem;
  background: #e7f1f9;
  color: #35658d;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.2rem;
}

.roles-empty h2 {
  color: #193e61;
  font-size: 0.95rem;
  font-weight: 650;
}

.roles-empty p {
  margin-top: 0.25rem;
  color: #637b90;
  font-size: 0.82rem;
  line-height: 1.45;
}

.roles-dialog {
  display: flex !important;
  width: min(100vw - 1.5rem, 32rem) !important;
  max-width: 32rem !important;
  max-height: min(88dvh, 48rem) !important;
  flex-direction: column;
  gap: 1rem !important;
  overflow: hidden !important;
  padding: 1.35rem !important;
  border-color: #d5e2ed;
  border-radius: 0.9rem !important;
  background: #fbfdff !important;
}

.roles-dialog > button:last-child {
  z-index: 2;
  top: 0.9rem !important;
  right: 0.9rem !important;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: 0.6rem;
  background: #edf4f9;
  opacity: 1;
}

.roles-dialog-header {
  flex: 0 0 auto;
  padding: 0.1rem 3rem 0.2rem 0;
}

.roles-dialog-header [data-radix-dialog-title] {
  color: #193e61;
  line-height: 1.3;
}

.roles-dialog-header p {
  margin-top: 0.4rem;
  color: #637b90;
  font-size: 0.84rem;
  line-height: 1.45;
}

.roles-dialog-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.15rem 0.15rem 0.1rem 0;
}

.roles-dialog-form > div:last-child {
  position: sticky;
  bottom: -0.1rem;
  z-index: 1;
  margin-top: 0.3rem;
  padding: 0.8rem 0 0.1rem;
  background: #fbfdff;
}

.roles-dialog-form > div:last-child button {
  min-height: 2.75rem;
  background: #2563eb;
  color: #fff;
}

@media (min-width: 640px) {
  .roles-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .roles-dialog {
    width: min(100vw - 3rem, 32rem) !important;
    padding: 1.65rem !important;
  }
}

@media (min-width: 1024px) {
  .roles-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .roles-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.1rem;
  }
}

@media (max-width: 639px) {
  .roles-page > :first-child button { width: 100%; }
}

@media (max-height: 540px) {
  .roles-dialog {
    max-height: 94dvh !important;
    gap: 0.65rem !important;
    padding-top: 0.9rem !important;
    padding-bottom: 0.85rem !important;
  }

  .roles-dialog-header {
    padding-top: 0;
    padding-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .role-card {
    transition: none;
  }

  .role-card:hover {
    transform: none;
  }
}