:root {
  --color-brand: #4a1a5c;
  --color-brand-deep: #5b1e73;
  --color-ink: #1e293b;
  --color-muted: #64748b;
  --color-paper: #ffffff;
  --color-canvas: #f5f5f7;
  --color-line: #e2e8f0;
  --color-line-strong: #cbd5e1;
  --color-focus: #7c3aed;
  --color-success: #059669;
  --color-success-soft: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-soft: #fffbeb;
  --color-danger: #dc2626;
  --color-danger-soft: #fef2f2;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --content-width: 75rem;
  --reading-width: 34rem;
  --radius-small: 0.375rem;
  --radius-default: 0.625rem;
  --radius-large: 1rem;
  --shadow-card: 0 8px 24px rgb(30 41 59 / 6%);
  --shadow-header: 0 4px 6px -2px rgb(30 41 59 / 18%);
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 0;
  margin: 0;
  background: var(--color-canvas);
  color: var(--color-ink);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--color-brand-deep);
  text-decoration-thickness: 0.1em;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--color-brand);
}

h1,
h2,
h3,
h4,
p,
ul,
ol {
  overflow-wrap: anywhere;
}

h1,
h2,
h3,
h4 {
  color: var(--color-ink);
  line-height: 1.2;
}

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 750;
}

h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 750;
}

p {
  margin: 0;
}

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

button,
input,
select,
textarea {
  border-radius: var(--radius-small);
}

button,
select,
input[type='checkbox'],
input[type='radio'] {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

button,
.button-link {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  padding: 0.625rem 1rem;
  background: var(--color-brand-deep);
  color: var(--color-paper);
  cursor: pointer;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

button:hover,
.button-link:hover {
  background: var(--color-brand);
  color: var(--color-paper);
}

button:active,
.button-link:active {
  transform: translateY(1px);
}

button.button--secondary,
.button-link.button--secondary {
  border-color: var(--color-line-strong);
  background: var(--color-paper);
  color: var(--color-brand-deep);
}

button.button--secondary:hover,
.button-link.button--secondary:hover {
  border-color: var(--color-brand-deep);
  background: #faf7fc;
  color: var(--color-brand);
}

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

button.button--danger:hover,
.button-link.button--danger:hover {
  background: #b91c1c;
}

button.button--quiet,
.button-link.button--quiet {
  min-height: 2.25rem;
  border-color: transparent;
  padding: 0.375rem 0.625rem;
  background: transparent;
  color: var(--color-brand-deep);
}

button.button--quiet:hover,
.button-link.button--quiet:hover {
  background: #f4ecf8;
  color: var(--color-brand);
}

button.button--small,
.button-link.button--small {
  min-height: 2.25rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.875rem;
}

button.button--block,
.button-link.button--block {
  width: 100%;
}

button.button--danger-outline,
.button-link.button--danger-outline {
  border-color: #fecaca;
  background: var(--color-paper);
  color: var(--color-danger);
}

button.button--danger-outline:hover,
.button-link.button--danger-outline:hover {
  border-color: var(--color-danger);
  background: var(--color-danger-soft);
  color: #b91c1c;
}

input,
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--color-line-strong);
  padding: 0.625rem 0.75rem;
  background: var(--color-paper);
  color: var(--color-ink);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-focus);
  outline: none;
  box-shadow: 0 0 0 3px rgb(124 58 237 / 18%);
}

input[type='checkbox'],
input[type='radio'] {
  width: 1.2rem;
  min-height: 1.2rem;
  accent-color: var(--color-brand-deep);
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  transform: translateY(-200%);
  border-radius: var(--radius-small);
  padding: 0.75rem 1rem;
  background: var(--color-paper);
  color: var(--color-brand);
  box-shadow: var(--shadow-card);
}

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

.site-header {
  position: sticky;
  z-index: 40;
  top: 0;
  color: var(--color-paper);
  background: linear-gradient(110deg, var(--color-brand), var(--color-brand-deep));
  box-shadow: var(--shadow-header);
}

.site-header__inner {
  display: flex;
  width: min(100%, var(--content-width));
  min-height: 4.5rem;
  margin: 0 auto;
  align-items: center;
  gap: var(--space-5);
  padding: 0.75rem 1.5rem;
}

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

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

.brand__mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.25rem;
  object-fit: cover;
  background: var(--color-paper);
}

.brand__wordmark {
  display: grid;
  gap: 0.05rem;
}

.brand__name {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.brand__tagline {
  color: rgb(255 255 255 / 78%);
  font-size: 0.68rem;
  letter-spacing: 0.01em;
}

.primary-nav {
  display: flex;
  min-width: 0;
  flex: 1;
  align-self: stretch;
  align-items: center;
  gap: 0.125rem;
  overflow-x: auto;
}

.primary-nav a {
  display: inline-flex;
  min-height: 2.75rem;
  flex: 0 0 auto;
  align-items: center;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0.7rem;
  color: rgb(255 255 255 / 82%);
  font-size: 0.86rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav a:hover,
.primary-nav a[aria-current='page'] {
  border-bottom-color: var(--color-paper);
  color: var(--color-paper);
}

.header-account {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-3);
}

.header-account__identity {
  display: grid;
  gap: 0.1rem;
  min-width: 0;
  text-align: right;
}

.header-account__login {
  max-width: 11rem;
  overflow: hidden;
  color: var(--color-paper);
  font-size: 0.875rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-account__role {
  color: rgb(255 255 255 / 70%);
  font-size: 0.7rem;
}

.header-account .button--quiet {
  border-color: rgb(255 255 255 / 35%);
  color: var(--color-paper);
}

.header-account .button--quiet:hover {
  border-color: rgb(255 255 255 / 60%);
  background: rgb(255 255 255 / 12%);
  color: var(--color-paper);
}

.demo-banner {
  border-bottom: 1px solid #fde68a;
  padding: 0.45rem 1rem;
  background: var(--color-warning-soft);
  color: #92400e;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-align: center;
}
.app-shell {
  min-height: 100vh;
}

.page-content {
  width: min(100%, var(--content-width));
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

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

.page-heading__copy {
  display: grid;
  gap: 0.4rem;
}

.page-heading__copy p,
.section-heading p,
.card__description,
.muted {
  color: var(--color-muted);
}

.page-heading__actions,
.form-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.page-heading__actions {
  justify-content: flex-end;
}

.eyebrow {
  margin: 0;
  color: var(--color-brand-deep);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  line-height: 1.2;
  text-transform: uppercase;
}

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

.section-heading__copy {
  display: grid;
  gap: 0.35rem;
}

.card-grid {
  display: grid;
  gap: var(--space-5);
}

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

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

.card {
  min-width: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-default);
  background: var(--color-paper);
  box-shadow: var(--shadow-card);
}

.card__header,
.card__body,
.card__footer {
  padding: var(--space-5);
}

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--color-line);
}

.card__body + .card__body,
.card__footer {
  border-top: 1px solid var(--color-line);
}

.card__header--stack {
  display: grid;
}

.card__title {
  display: grid;
  gap: 0.35rem;
}

.card__description {
  font-size: 0.9rem;
}

.card--accent {
  border-top: 3px solid var(--color-brand-deep);
}

.card--danger {
  border-color: #fecaca;
}

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

.stack--tight {
  gap: var(--space-3);
}

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

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

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

.field {
  display: grid;
  gap: 0.4rem;
}

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

.field label,
.fieldset legend {
  color: var(--color-ink);
  font-size: 0.82rem;
  font-weight: 750;
}

.field__hint {
  color: var(--color-muted);
  font-size: 0.78rem;
}

.required {
  color: var(--color-danger);
}

fieldset {
  min-width: 0;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-small);
  padding: var(--space-4);
}

fieldset + fieldset {
  margin-top: var(--space-4);
}

.fieldset legend {
  padding: 0 0.35rem;
}

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding-top: 0.4rem;
}

.checkbox-field label {
  font-weight: 600;
}

.checkbox-field__copy {
  display: grid;
  gap: 0.15rem;
}

.form-error {
  margin: 0;
  border-left: 4px solid var(--color-danger);
  border-radius: var(--radius-small);
  padding: 0.75rem 1rem;
  background: var(--color-danger-soft);
  color: #991b1b;
  font-weight: 650;
}

.form-error ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}

.notice {
  display: grid;
  gap: 0.25rem;
  border: 1px solid var(--color-line);
  border-left-width: 4px;
  border-radius: var(--radius-small);
  padding: 0.8rem 1rem;
  background: var(--color-paper);
}

.notice--success {
  border-color: #a7f3d0;
  border-left-color: var(--color-success);
  background: var(--color-success-soft);
  color: #065f46;
}

.notice--warning {
  border-color: #fde68a;
  border-left-color: var(--color-warning);
  background: var(--color-warning-soft);
  color: #92400e;
}

.notice--danger {
  border-color: #fecaca;
  border-left-color: var(--color-danger);
  background: var(--color-danger-soft);
  color: #991b1b;
}

.notice__title {
  font-weight: 750;
}

.notice__copy {
  color: inherit;
  font-size: 0.9rem;
}

.tabs {
  display: flex;
  gap: 0.15rem;
  margin-bottom: var(--space-5);
  overflow-x: auto;
  border-bottom: 1px solid var(--color-line);
}

.tabs a {
  display: inline-flex;
  min-height: 2.75rem;
  flex: 0 0 auto;
  align-items: center;
  border-bottom: 3px solid transparent;
  padding: 0.55rem 0.9rem;
  color: var(--color-muted);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover,
.tabs a[aria-current='page'] {
  border-bottom-color: var(--color-brand-deep);
  color: var(--color-brand-deep);
}

.entity-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-muted);
  font-size: 0.875rem;
}

.badge {
  display: inline-flex;
  min-height: 1.55rem;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  background: #f1f5f9;
  color: var(--color-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
  white-space: nowrap;
}

.badge--brand {
  background: #f4ecf8;
  color: var(--color-brand-deep);
}

.badge--success {
  background: #d1fae5;
  color: #065f46;
}

.badge--warning {
  background: #fef3c7;
  color: #92400e;
}

.badge--danger {
  background: #fee2e2;
  color: #991b1b;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

caption {
  margin-bottom: var(--space-3);
  color: var(--color-muted);
  font-size: 0.82rem;
  text-align: left;
}

th,
td {
  min-width: 8rem;
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--color-line);
  vertical-align: top;
  text-align: left;
}

th {
  color: var(--color-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr:hover {
  background: #faf7fc;
}

td:first-child,
th:first-child {
  padding-left: 0;
}

td:last-child,
th:last-child {
  padding-right: 0;
}

.table-primary {
  display: grid;
  gap: 0.2rem;
  color: var(--color-ink);
  font-weight: 700;
}

.table-secondary {
  color: var(--color-muted);
  font-size: 0.8rem;
}

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

.empty-state {
  display: grid;
  justify-items: start;
  gap: var(--space-3);
  border: 1px dashed var(--color-line-strong);
  border-radius: var(--radius-small);
  padding: var(--space-6);
  background: #fafbfc;
}

.empty-state h3 {
  font-size: 1rem;
}

.empty-state p {
  max-width: 42rem;
  color: var(--color-muted);
}

.empty-state--center {
  justify-items: center;
  text-align: center;
}

.detail-hero {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  border-radius: var(--radius-default);
  padding: clamp(1.25rem, 4vw, 2rem);
  background: linear-gradient(135deg, #f4ecf8, #ffffff 60%);
  box-shadow: var(--shadow-card);
}

.detail-hero__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.detail-hero__copy {
  display: grid;
  gap: 0.45rem;
}

.detail-hero__copy p {
  color: var(--color-muted);
}

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

.definition-list div {
  display: grid;
  gap: 0.2rem;
}

.definition-list dt {
  color: var(--color-muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.definition-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.audit-row {
  display: grid;
  gap: 0.25rem;
}

.audit-row__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  color: var(--color-muted);
  font-size: 0.8rem;
}

.audit-row__changes {
  margin: 0.35rem 0 0;
  color: var(--color-muted);
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.danger-zone {
  border-color: #fecaca;
  background: #fffafa;
}

.danger-zone .card__header {
  border-bottom-color: #fecaca;
}

.danger-zone h2,
.danger-zone h3 {
  color: #991b1b;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background:
    radial-gradient(circle at 12% 12%, rgb(91 30 115 / 10%), transparent 32rem), var(--color-canvas);
}

.auth-card {
  display: grid;
  width: min(100%, 56rem);
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-large);
  background: var(--color-paper);
  box-shadow: 0 20px 50px rgb(30 41 59 / 11%);
}

.auth-card__aside {
  display: grid;
  align-content: space-between;
  gap: var(--space-6);
  padding: clamp(1.5rem, 5vw, 2.5rem);
  color: var(--color-paper);
  background: linear-gradient(145deg, var(--color-brand), var(--color-brand-deep));
}

.auth-card__aside h1,
.auth-card__aside h2,
.auth-card__aside p {
  color: var(--color-paper);
}

.auth-card__aside h1 {
  margin-top: var(--space-6);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.auth-card__aside p {
  color: rgb(255 255 255 / 80%);
}

.auth-card__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-paper);
  font-weight: 800;
  text-decoration: none;
}

.auth-card__brand img {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.35rem;
  background: var(--color-paper);
}
.auth-card__content .auth-card__brand {
  color: var(--color-brand-deep);
}

.auth-card__content .auth-card__brand:hover {
  color: var(--color-brand);
}

.auth-card__content {
  display: grid;
  align-content: center;
  gap: var(--space-5);
  padding: clamp(1.5rem, 5vw, 3rem);
}

.auth-card__content h2 {
  font-size: 1.55rem;
}

.auth-card__heading {
  display: grid;
  gap: 0.45rem;
}

.auth-card__heading p {
  color: var(--color-muted);
}

.error-panel {
  width: min(100%, 34rem);
  grid-template-columns: 1fr;
}

.error-code {
  color: var(--color-brand-deep);
  font-size: 3.5rem;
  font-weight: 850;
  line-height: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 980px) {
  .site-header__inner {
    flex-wrap: wrap;
    gap: 0.65rem var(--space-4);
    padding-block: 0.7rem;
  }

  .primary-nav {
    order: 3;
    flex-basis: 100%;
    min-height: 2.55rem;
  }

  .site-header__inner {
    min-height: 0;
  }

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

@media (max-width: 720px) {
  .page-content {
    padding: 1.25rem 1rem 3rem;
  }

  .page-heading {
    display: grid;
  }

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

  .card-grid--two,
  .card-grid--three,
  .form-grid,
  .form-grid--three,
  .definition-list {
    grid-template-columns: 1fr;
  }

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

  .detail-hero__top {
    display: grid;
  }

  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-card__aside {
    gap: var(--space-4);
    padding: 1.5rem;
  }

  .auth-card__aside h1 {
    margin-top: 0;
  }

  .auth-card__content {
    padding: 1.5rem;
  }
}

@media (max-width: 520px) {
  .site-header__inner {
    padding-inline: 1rem;
  }

  .header-account__identity {
    display: none;
  }

  .brand__tagline {
    display: none;
  }

  .page-heading__actions,
  .page-heading__actions > *,
  .form-actions,
  .form-actions > *,
  .inline-actions > * {
    width: 100%;
  }

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

  .table-actions > * {
    width: auto;
  }
}
