*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

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

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

button {
  border: 0;
}

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

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary-ink);
  box-shadow: var(--shadow-sm);
  transform: translateY(-150%);
  transition: transform .18s ease;
}

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

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

.sidebar {
  position: fixed;
  z-index: 50;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  overflow-y: auto;
  background: var(--sidebar);
  color: var(--sidebar-text);
  scrollbar-width: thin;
  scrollbar-color: #38445a transparent;
}

.brand {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 22px rgba(79, 70, 229, .3);
  font-size: 21px;
  font-weight: 800;
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.15;
}

.brand-copy strong {
  color: #fff;
  font-size: 15px;
  letter-spacing: .12em;
}

.brand-copy span {
  margin-top: 5px;
  color: var(--sidebar-muted);
  font-size: 12px;
  letter-spacing: .02em;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 14px 28px;
}

.nav-group + .nav-group {
  margin-top: 24px;
}

.nav-group-title {
  margin: 0 10px 8px;
  color: var(--sidebar-muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .13em;
}

.nav-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  position: relative;
  display: flex;
  min-height: 43px;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-weight: 540;
  transition: color .15s ease, background .15s ease, transform .15s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, .065);
  color: #fff;
}

.nav-link[aria-current="page"] {
  background: linear-gradient(90deg, rgba(99, 102, 241, .26), rgba(99, 102, 241, .12));
  color: #fff;
}

.nav-link[aria-current="page"]::before {
  position: absolute;
  inset: 9px auto 9px -14px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: #8b85ff;
  content: "";
}

.nav-icon {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  color: var(--sidebar-muted);
}

.nav-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.nav-link[aria-current="page"] .nav-icon,
.nav-link:hover .nav-icon {
  color: #a9b2ff;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 14px 16px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 11px;
  background: rgba(255, 255, 255, .035);
}

.sidebar-footer > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.sidebar-footer strong {
  overflow: hidden;
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer small {
  overflow: hidden;
  margin-top: 1px;
  color: var(--sidebar-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.environment-dot,
.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 14%, transparent);
}

.workspace {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 30px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  backdrop-filter: blur(14px);
}

.topbar-leading,
.topbar-actions,
.user-summary {
  display: flex;
  align-items: center;
}

.topbar-leading {
  min-width: 180px;
  gap: 12px;
}

.topbar-actions {
  min-width: 0;
  gap: 10px;
}

.page-heading {
  min-width: 0;
}

.breadcrumb {
  margin: 0 0 2px;
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: .13em;
}

.page-heading h1 {
  overflow: hidden;
  margin: 0;
  font-size: 19px;
  font-weight: 720;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.global-search {
  position: relative;
  display: flex;
  width: clamp(200px, 24vw, 340px);
  height: 40px;
  align-items: center;
}

.global-search input {
  width: 100%;
  height: 100%;
  padding: 0 52px 0 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
  transition: border .15s ease, box-shadow .15s ease, background .15s ease;
}

.global-search input::placeholder {
  color: var(--text-faint);
}

.global-search input:focus {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.search-icon {
  position: absolute;
  z-index: 1;
  left: 13px;
  color: var(--text-faint);
  font-size: 18px;
  pointer-events: none;
}

.global-search kbd {
  position: absolute;
  right: 9px;
  padding: 2px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-faint);
  font: 9px var(--font-sans);
  pointer-events: none;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: border .15s ease, color .15s ease, background .15s ease;
}

.icon-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
}

.mobile-menu-button {
  display: none;
}

.system-pill {
  display: flex;
  height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 600;
}

.system-pill:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.status-dot--healthy,
.environment-dot.is-development,
.environment-dot.is-production {
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 14%, transparent);
}

.status-dot--degraded,
.environment-dot.is-warning {
  background: var(--warning);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 14%, transparent);
}

.status-dot--down,
.environment-dot.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent);
}

.user-summary {
  max-width: 210px;
  gap: 9px;
  padding-left: 2px;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--primary), #2684c7);
  color: #fff;
  font-size: 12px;
  font-weight: 760;
  letter-spacing: .04em;
}

.user-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.user-copy strong,
.user-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy strong {
  font-size: 12px;
  font-weight: 680;
}

.user-copy small {
  color: var(--text-faint);
  font-size: 10px;
}

.content {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  padding: 28px 30px 48px;
}

.page-stack {
  display: grid;
  gap: 22px;
}

.page-stack > * {
  min-width: 0;
}

.page-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.page-intro h2 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 740;
  letter-spacing: -.035em;
}

.page-intro p {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.page-actions,
.button-row,
.table-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.button {
  display: inline-flex;
  min-height: 39px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 670;
  transition: background .15s ease, border .15s ease, color .15s ease, transform .12s ease;
}

.button:hover:not(:disabled) {
  background: var(--primary-hover);
}

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

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

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

.button--secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.button--quiet {
  background: transparent;
  color: var(--primary-ink);
}

.button--quiet:hover:not(:disabled) {
  background: var(--primary-soft);
}

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

.button--small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 11px;
}

.button-icon {
  display: inline-grid;
  place-items: center;
  font-size: 15px;
  line-height: 1;
}

.button-icon svg,
.quick-action-icon svg {
  width: 16px;
  height: 16px;
}

.button-icon svg,
.quick-action svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.panel,
.detail-card,
.state-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.metric-card {
  position: relative;
  min-height: 132px;
  overflow: hidden;
  padding: 18px;
}

.metric-card--partners,
.metric-card--system {
  --metric-color: var(--primary);
}

.metric-card--customers {
  --metric-color: var(--info);
}

.metric-card--tenants {
  --metric-color: var(--success);
}

.metric-card--deployments {
  --metric-color: var(--warning);
}

.metric-card::after {
  position: absolute;
  right: -28px;
  bottom: -34px;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--metric-color, var(--primary)) 8%, transparent);
  content: "";
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-icon {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--metric-color, var(--primary)) 12%, var(--surface));
  color: var(--metric-color, var(--primary));
  font-size: 16px;
  font-weight: 750;
}

.metric-trend {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 650;
}

.metric-trend.is-positive {
  color: var(--success);
}

.metric-trend.is-warning {
  color: var(--warning);
}

.metric-value {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  font-size: 27px;
  font-weight: 760;
  letter-spacing: -.04em;
}

.metric-label {
  position: relative;
  z-index: 1;
  margin-top: 1px;
  color: var(--text-soft);
  font-size: 11px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, .8fr);
  gap: 14px;
}

.panel {
  min-width: 0;
}

.panel-header,
.table-toolbar {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.panel-subtitle {
  margin: 3px 0 0;
  color: var(--text-faint);
  font-size: 10px;
}

.panel-body {
  padding: 18px;
}

.quick-actions {
  display: grid;
  gap: 8px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  transition: border .15s ease, background .15s ease;
}

.quick-action:hover {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
  background: var(--primary-soft);
}

.quick-action-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface);
  color: var(--primary-ink);
  box-shadow: var(--shadow-xs);
}

.quick-action-copy {
  min-width: 0;
}

.quick-action-copy strong {
  display: block;
  font-size: 11px;
}

.quick-action-copy small {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-action > svg:last-child {
  width: 14px;
  height: 14px;
  margin-left: auto;
  color: var(--text-faint);
}

.distribution-list {
  display: grid;
  gap: 16px;
}

.distribution-row {
  display: grid;
  gap: 7px;
}

.distribution-label {
  display: flex;
  justify-content: space-between;
  color: var(--text-soft);
  font-size: 10px;
}

.distribution-label strong {
  color: var(--text);
  font-size: 11px;
}

.distribution-progress {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--border);
  accent-color: var(--primary);
}

.distribution-progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--border);
}

.distribution-progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--primary);
}

.distribution-progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--primary);
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: var(--bar-color, var(--primary));
}

.table-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.table-toolbar-copy {
  min-width: 0;
}

.table-toolbar-copy strong {
  display: block;
  font-size: 12px;
}

.table-toolbar-copy small {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 10px;
}

.table-filter {
  width: 220px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  outline: 0;
  font-size: 11px;
}

.table-filter:focus {
  border-color: var(--primary);
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--surface-soft);
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 730;
  letter-spacing: .075em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  color: var(--text-soft);
  font-size: 11px;
}

.data-table tbody tr {
  transition: background .12s ease;
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 3.5%, var(--surface));
}

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

.cell-primary {
  color: var(--text);
  font-weight: 650;
}

.cell-stack {
  display: flex;
  min-width: 130px;
  flex-direction: column;
}

.cell-stack strong {
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
}

.cell-stack small {
  overflow: hidden;
  max-width: 280px;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-actions {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  white-space: nowrap;
}

.row-action {
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 10px;
  font-weight: 620;
}

.row-action:hover {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  color: var(--primary-ink);
}

.status-badge,
.scope-badge,
.type-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 9px;
  font-weight: 680;
  white-space: nowrap;
}

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

.status-badge.is-success {
  background: var(--success-soft);
  color: var(--success);
}

.status-badge.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge.is-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-badge.is-info {
  background: var(--info-soft);
  color: var(--info);
}

.table-footer {
  display: flex;
  min-height: 56px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 10px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination button {
  display: grid;
  min-width: 31px;
  height: 31px;
  place-items: center;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 10px;
}

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

.route-loading,
.table-loading,
.empty-state,
.error-state {
  display: grid;
  min-height: 230px;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 28px;
  color: var(--text-soft);
  text-align: center;
}

.state-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--text-faint);
  font-size: 21px;
}

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

.state-title {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 690;
}

.state-message {
  max-width: 520px;
  margin: -6px 0 0;
  color: var(--text-soft);
  font-size: 11px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.skeleton-lines {
  display: grid;
  width: min(440px, 78vw);
  gap: 10px;
}

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--surface-soft), var(--border), var(--surface-soft));
  background-size: 220% 100%;
  animation: shimmer 1.4s ease infinite;
}

.skeleton-line:nth-child(2) { width: 82%; }
.skeleton-line:nth-child(3) { width: 66%; }

@keyframes shimmer {
  to { background-position: -220% 0; }
}

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

.detail-tabs {
  display: flex;
  min-width: 0;
  gap: 4px;
  margin-top: 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.detail-tab {
  position: relative;
  display: inline-flex;
  min-height: 42px;
  flex: 0 0 auto;
  align-items: center;
  padding: 9px 12px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  transition: color .15s ease, background .15s ease;
}

.detail-tab:hover {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  color: var(--primary-ink);
}

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

.detail-tab.is-active {
  color: var(--primary-ink);
}

.detail-tab.is-active::after {
  background: var(--primary);
}

.detail-tab-panel {
  display: grid;
  min-width: 0;
  gap: 14px;
  padding-top: 16px;
}

.detail-card {
  padding: 16px;
}

.detail-card dt {
  margin: 0 0 5px;
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 710;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.detail-card dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 590;
}

.detail-card dd + dt {
  margin-top: 14px;
}

.payload-panel {
  min-width: 0;
  padding: 15px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.payload-panel h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.payload-json {
  max-height: min(52vh, 520px);
  margin: 0;
  padding: 13px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-soft);
  font: 10px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  overflow-wrap: anywhere;
  tab-size: 2;
  white-space: pre-wrap;
}

.audit-filter-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

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

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

.timeline-item::before {
  position: absolute;
  top: 16px;
  bottom: 0;
  left: 6px;
  width: 1px;
  background: var(--border);
  content: "";
}

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

.timeline-dot {
  z-index: 1;
  width: 13px;
  height: 13px;
  margin-top: 3px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 1px var(--border);
}

.timeline-copy strong {
  display: block;
  font-size: 11px;
}

.timeline-copy small {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 9px;
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--info) 22%, var(--border));
  border-radius: 10px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 10px;
}

.callout strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 11px;
}

.callout--warning {
  border-color: color-mix(in srgb, var(--warning) 22%, var(--border));
  background: var(--warning-soft);
  color: var(--warning);
}

.callout--danger {
  border-color: color-mix(in srgb, var(--danger) 22%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

dialog.modal {
  width: min(680px, calc(100vw - 30px));
  max-height: min(880px, calc(100vh - 30px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

dialog.modal::backdrop {
  background: rgba(8, 13, 22, .62);
  backdrop-filter: blur(3px);
}

.modal-shell {
  display: flex;
  max-height: min(880px, calc(100vh - 30px));
  flex-direction: column;
}

.modal-header,
.modal-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
  background: var(--surface-soft);
}

.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 720;
  letter-spacing: -.02em;
}

.modal-description {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 10px;
}

.modal-close {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 18px;
}

.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
}

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

.field {
  display: grid;
  align-content: start;
  gap: 6px;
}

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

.field label,
.field legend {
  color: var(--text);
  font-size: 10px;
  font-weight: 680;
}

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

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  transition: border .15s ease, box-shadow .15s ease;
}

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

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 11%, transparent);
}

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

.field-hint,
.field-error {
  margin: 0;
  color: var(--text-faint);
  font-size: 9px;
}

.field-error {
  color: var(--danger);
}

.lookup-search {
  background: var(--surface-soft) !important;
}

.lookup-search::placeholder {
  color: var(--text-faint);
}

.lookup-search:disabled {
  cursor: wait;
  opacity: .68;
}

.lookup-status {
  display: flex;
  min-height: 20px;
  align-items: center;
  gap: 7px;
  color: var(--text-faint);
  font-size: 9px;
  line-height: 1.4;
}

.lookup-status.is-error {
  color: var(--danger);
}

.lookup-status.is-empty {
  color: var(--warning);
}

.lookup-retry {
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.spinner--small {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border-width: 2px;
}

.form-section-title {
  grid-column: 1 / -1;
  margin: 4px 0 -3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 720;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.wizard-step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: 8px;
  font-weight: 650;
  text-align: center;
}

.wizard-step:not(:last-child)::after {
  position: absolute;
  z-index: 0;
  top: 12px;
  left: calc(50% + 14px);
  width: calc(100% - 28px);
  height: 1px;
  background: var(--border);
  content: "";
}

.wizard-step-number {
  z-index: 1;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-faint);
  font-size: 9px;
}

.wizard-step.is-current,
.wizard-step.is-complete {
  color: var(--primary-ink);
}

.wizard-step.is-current .wizard-step-number,
.wizard-step.is-complete .wizard-step-number {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.wizard-step.is-complete:not(:last-child)::after {
  background: var(--primary);
}

.wizard-pane[hidden] {
  display: none;
}

.conditional-panel {
  padding-top: 2px;
}

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

.wizard-review {
  min-width: 0;
}

.review-list {
  display: grid;
  gap: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.review-row {
  display: grid;
  grid-template-columns: 155px 1fr;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

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

.review-row dt {
  color: var(--text-faint);
  font-size: 9px;
}

.review-row dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--text);
  font-size: 10px;
  font-weight: 620;
}

.toast-region {
  position: fixed;
  z-index: 200;
  right: 18px;
  bottom: 18px;
  display: grid;
  width: min(380px, calc(100vw - 36px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: start;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: 10px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
  animation: toast-in .2s ease;
}

.toast.is-success { border-left-color: var(--success); }
.toast.is-error { border-left-color: var(--danger); }
.toast.is-warning { border-left-color: var(--warning); }

.toast-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 8px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 12px;
  font-weight: 750;
}

.toast.is-success .toast-icon { background: var(--success-soft); color: var(--success); }
.toast.is-error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast.is-warning .toast-icon { background: var(--warning-soft); color: var(--warning); }

.toast-copy strong {
  display: block;
  color: var(--text);
  font-size: 10px;
}

.toast-copy span {
  display: block;
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 9px;
}

.toast-close {
  padding: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 16px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

.auth-failure {
  display: grid;
  min-height: calc(100vh - var(--topbar-height) - 76px);
  place-items: center;
}

.auth-failure .state-card {
  width: min(560px, 100%);
  padding: 32px;
  text-align: center;
}

.auth-failure .state-icon {
  margin: 0 auto 14px;
}

.code-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .92em;
}

.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--text-soft); }
.nowrap { white-space: nowrap; }

/* MARKUR central licensing console */
.licensing-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.licensing-filter-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.licensing-filter-panel--compact {
  grid-template-columns: repeat(2, minmax(180px, 260px));
}

.licensing-filter-field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.licensing-filter-field label {
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.licensing-filter-field .table-filter {
  width: 100%;
}

.license-detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.license-detail-hero h2 {
  margin: 3px 0;
  font-size: 22px;
  letter-spacing: -.025em;
}

.license-detail-hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 11px;
}

.eyebrow {
  color: var(--primary-ink);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.license-detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.resolved-at {
  align-self: center;
  color: var(--text-faint);
  font-size: 9px;
}

.usage-panel,
.resolved-preview,
.plan-builder-section {
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.usage-panel header h3,
.resolved-preview header h3,
.plan-builder-section h3 {
  margin: 0;
  font-size: 13px;
}

.usage-panel header p,
.resolved-preview header p,
.plan-builder-section > p {
  margin: 3px 0 0;
  color: var(--text-soft);
  font-size: 9px;
}

.usage-grid,
.entitlement-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.usage-card,
.entitlement-preview-item {
  display: grid;
  min-width: 0;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
  font-size: 10px;
}

.usage-card.is-over-limit {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: var(--danger-soft);
}

.entitlement-preview-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.entitlement-preview-item span {
  display: grid;
  min-width: 0;
}

.entitlement-preview-item small {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entitlement-preview-item b {
  color: var(--primary-ink);
  font-size: 11px;
}

dialog.modal--wide {
  width: min(960px, calc(100vw - 30px));
}

.licensing-wizard-steps {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.field--action {
  align-content: end;
}

.checkbox-field {
  align-content: center;
  min-height: 40px;
}

.checkbox-field label {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.checkbox-field input {
  width: 17px;
  min-height: 17px;
  flex: 0 0 17px;
  margin: 0;
  padding: 0;
  accent-color: var(--primary);
}

.entitlement-editor {
  display: grid;
  gap: 10px;
}

.entitlement-editor-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) minmax(170px, 1fr) minmax(230px, 1.5fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.entitlement-editor-copy {
  display: grid;
  min-width: 0;
}

.entitlement-editor-copy small {
  color: var(--text-faint);
  font-size: 8px;
}

.entitlement-override-controls {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 8px;
}

.module-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.plan-limit-grid {
  display: grid;
  gap: 9px;
}

.plan-limit-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(130px, .8fr) minmax(130px, 1fr) 130px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
}

.plan-limit-row > small {
  color: var(--text-faint);
  font: 9px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.licensing-timeline .timeline-copy > span {
  display: block;
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 10px;
}

@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .licensing-wizard-steps span:last-child { display: none; }
  .usage-grid, .entitlement-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1240px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .global-search {
    width: 200px;
  }

  .system-pill span:last-child,
  .user-copy {
    display: none;
  }

  .system-pill {
    width: 40px;
    justify-content: center;
    padding: 0;
  }

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

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

  .entitlement-editor-row {
    grid-template-columns: 1fr 1fr;
  }

  .entitlement-editor-row > :last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .sidebar {
    transform: translateX(-102%);
    box-shadow: var(--shadow-lg);
    transition: transform .2s ease;
  }

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

  .sidebar-scrim {
    position: fixed;
    z-index: 45;
    inset: 0;
    background: rgba(8, 13, 22, .58);
  }

  .app-shell.is-sidebar-open .sidebar-scrim {
    display: block;
  }

  .workspace {
    margin-left: 0;
  }

  .mobile-menu-button {
    display: grid;
  }

  .topbar {
    padding-right: 20px;
    padding-left: 20px;
  }

  .content {
    padding-right: 20px;
    padding-left: 20px;
  }

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

  .licensing-wizard-steps span:last-child {
    display: none;
  }

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

@media (max-width: 720px) {
  :root {
    --topbar-height: 68px;
  }

  .topbar {
    min-height: var(--topbar-height);
    gap: 10px;
    padding: 9px 14px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .global-search,
  .user-summary,
  .system-pill {
    display: none;
  }

  .page-heading h1 {
    max-width: 48vw;
    font-size: 16px;
  }

  .content {
    padding: 20px 14px 36px;
  }

  .page-intro {
    flex-direction: column;
    gap: 14px;
  }

  .page-intro h2 {
    font-size: 23px;
  }

  .page-actions {
    width: 100%;
  }

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

  .metrics-grid,
  .detail-grid,
  .form-grid,
  .audit-filter-panel,
  .licensing-filter-panel,
  .usage-grid,
  .entitlement-preview-grid,
  .module-choice-grid {
    grid-template-columns: 1fr;
  }

  .license-detail-hero {
    flex-direction: column;
  }

  .license-detail-actions {
    justify-content: flex-start;
  }

  .entitlement-editor-row,
  .entitlement-override-controls,
  .plan-limit-row {
    grid-template-columns: 1fr;
  }

  .entitlement-editor-row > :last-child {
    grid-column: auto;
  }

  .detail-tabs {
    margin-right: -14px;
    margin-left: -14px;
    padding: 0 8px;
  }

  .detail-tab {
    min-height: 40px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .detail-tab-panel {
    padding-top: 14px;
  }

  .payload-panel {
    padding: 11px;
  }

  .payload-json {
    max-height: 46vh;
    padding: 10px;
  }

  .metric-card {
    min-height: 115px;
  }

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

  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-toolbar-actions,
  .table-filter {
    width: 100%;
  }

  .table-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  dialog.modal {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
    border-radius: 14px;
  }

  .modal-shell {
    max-height: calc(100vh - 18px);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-right: 15px;
    padding-left: 15px;
  }

  .wizard-step span:last-child {
    display: none;
  }

  .review-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}

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