:root {
  color-scheme: light;
  --page: #f4f6f8;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #5b6472;
  --line: #d8dee8;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --blue: #2563eb;
  --red: #b91c1c;
  --green-bg: #dcfce7;
  --green-ink: #166534;
  --red-bg: #fee2e2;
  --red-ink: #991b1b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  min-height: 100vh;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.login-brand,
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
}

.login-brand,
.login-brand:visited,
.login-brand:hover,
.login-brand:focus {
  color: #ffffff;
  text-decoration: none;
}

.sidebar-brand,
.sidebar-brand:visited,
.sidebar-brand:hover,
.sidebar-brand:focus {
  color: #e5e7eb;
  text-decoration: none;
}

.sidebar .sidebar-brand,
.sidebar .sidebar-brand:visited,
.sidebar .sidebar-brand:hover,
.sidebar .sidebar-brand:active,
.sidebar .sidebar-brand:focus {
  color: #e5e7eb;
  text-decoration: none;
}

.sidebar-brand strong {
  color: #e5e7eb;
}

.eyebrow {
  margin: 18px 0 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-panel h1 {
  margin-bottom: 28px;
  font-size: 32px;
  line-height: 1.2;
}

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

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.login-form input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  border-color: var(--teal);
}

.login-form button,
.ghost-button {
  min-height: 42px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.login-form button:hover,
.ghost-button:hover {
  background: var(--teal-dark);
}

.form-error {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  font-size: 14px;
}

.login-aside {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 64px;
  background: #12302f;
  color: #ffffff;
}

.login-aside h2 {
  max-width: 720px;
  font-size: 44px;
  line-height: 1.1;
}

.login-aside p {
  max-width: 680px;
  color: #c9f1ed;
  font-size: 18px;
}

.login-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.login-metrics span {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #e5fffb;
  font-size: 13px;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 18px;
  background: #111827;
  color: #e5e7eb;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px 22px;
}

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

.sidebar-brand small {
  color: #9ca3af;
  font-size: 12px;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.nav-item,
.logout-button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.logout-button {
  margin-top: auto;
  color: #fecaca;
}

.content-shell {
  min-width: 0;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 96px;
  padding: 24px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.content-header .eyebrow {
  margin: 0 0 4px;
}

.content-header h1 {
  margin: 0;
  font-size: 28px;
}

.ghost-button {
  min-width: 82px;
  background: #ffffff;
  color: var(--teal);
}

.ghost-button:hover {
  background: #eff6f4;
}

.content-area {
  padding: 28px 32px 48px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.metric-card,
.data-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.data-panel {
  overflow: hidden;
}

.data-panel + .data-panel {
  margin-top: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

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

.panel-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pager-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.page-size-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.page-size-label select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td code {
  overflow-wrap: anywhere;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  background: var(--green-bg);
  color: var(--green-ink);
}

.badge.fail {
  background: var(--red-bg);
  color: var(--red-ink);
}

.badge.neutral {
  background: #e0f2fe;
  color: #075985;
}

.action-cell {
  white-space: nowrap;
}

.primary-button,
.secondary-button,
.danger-button,
.link-button,
.icon-button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 38px;
  padding: 0 14px;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.primary-button.compact {
  min-height: 34px;
}

.secondary-button {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

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

.capability-test-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.danger-button {
  border: 1px solid var(--red);
  background: var(--red);
  color: #ffffff;
}

.link-button {
  min-height: 28px;
  margin-right: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
}

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

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
}

.empty-state,
.loading-state {
  padding: 28px;
  color: var(--muted);
}

.pagination-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto auto;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.filter-bar input,
.filter-bar select {
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.52);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 51;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: hidden;
  transform: translate(-50%, -50%);
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  max-height: calc(100vh - 180px);
  overflow: auto;
  padding: 18px;
}

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

.modal-copy {
  color: var(--muted);
}

.entity-form {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-row input,
.form-row textarea,
.form-row select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #ffffff;
}

.form-row textarea {
  min-height: 96px;
  resize: vertical;
}

.form-hint,
.subtle-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.subtle-text {
  display: block;
  margin-top: 4px;
}

.contract-preview {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.contract-preview h3 {
  margin: 0;
  font-size: 15px;
}

.readonly-json {
  display: grid;
  gap: 6px;
}

.readonly-json span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.contract-json {
  max-height: 180px;
  margin: 0;
  overflow: auto;
}

.code-frame {
  position: relative;
  min-width: 0;
}

.code-frame .json-view {
  margin: 0;
  padding-right: 48px;
}

.copy-code-button {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(229, 231, 235, 0.28);
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.86);
  color: #d1d5db;
  cursor: pointer;
}

.copy-code-button:hover,
.copy-code-button:focus-visible {
  border-color: rgba(20, 184, 166, 0.7);
  color: #ffffff;
  outline: none;
}

.copy-code-button.is-copied {
  border-color: rgba(20, 184, 166, 0.9);
  background: rgba(15, 118, 110, 0.92);
  color: #ffffff;
}

.copy-code-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.fixed-capability {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.fixed-capability span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.fixed-capability strong,
.fixed-capability code {
  overflow-wrap: anywhere;
}

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

.runtime-summary div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.runtime-summary span,
.runtime-summary strong,
.runtime-summary code {
  display: block;
}

.runtime-summary span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.runtime-summary strong,
.runtime-summary code {
  overflow-wrap: anywhere;
}

.option-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.option-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.option-row strong,
.option-row code,
.name-cell strong,
.name-cell code {
  display: block;
}

.option-row code {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.empty-inline {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.app-capability-list {
  display: grid;
  gap: 8px;
  justify-items: start;
  min-width: 0;
}

.app-capability-row {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  max-width: 100%;
}

.app-capability-row strong,
.app-capability-row code {
  display: block;
}

.app-capability-row span {
  min-width: 0;
}

.app-capability-row code {
  margin-top: 3px;
}

.name-cell {
  min-width: 180px;
}

.name-cell code {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.switch-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 96px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.switch-button.is-on {
  border-color: rgba(15, 118, 110, 0.35);
  background: #ecfdf5;
  color: var(--teal-dark);
}

.switch-button.is-off {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--red);
}

.switch-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.9;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}

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

.detail-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.retention-grid {
  padding: 18px;
  margin-bottom: 0;
}

.detail-grid strong,
.detail-grid code {
  display: block;
}

.detail-grid strong {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.json-view {
  max-height: 260px;
  overflow: auto;
  padding: 14px;
  background: #111827;
  border-radius: 8px;
  color: #e5e7eb;
  font-size: 13px;
  line-height: 1.6;
}

@media (max-width: 860px) {
  .login-shell,
  .app-shell,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .login-panel,
  .login-aside,
  .content-header,
  .content-area {
    padding-left: 20px;
    padding-right: 20px;
  }

  .sidebar {
    min-height: auto;
  }

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

  .logout-button {
    margin-top: 16px;
  }

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

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .runtime-summary {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    overflow-x: visible;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap th,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .table-wrap tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .table-wrap tr {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  .table-wrap td {
    min-width: 0;
    padding: 11px 12px;
    border-bottom: 1px solid #edf0f5;
    overflow-wrap: anywhere;
  }

  .table-wrap td:last-child {
    border-bottom: 0;
  }

  .table-wrap td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
  }

  .action-cell {
    white-space: normal;
  }

  .link-button {
    margin-right: 12px;
    margin-bottom: 4px;
  }

  .switch-button {
    min-width: 0;
  }
}
