:root {
  color-scheme: light;
  --bg: #eef2f4;
  --sidebar: #12171c;
  --sidebar-2: #1a2229;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --text: #172027;
  --muted: #66737c;
  --border: #dce3e7;
  --teal: #0f766e;
  --teal-2: #e4f3f1;
  --amber: #b7791f;
  --amber-2: #fff4db;
  --danger: #b42318;
  --danger-2: #ffe7e3;
  --shadow: 0 18px 45px rgba(19, 31, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

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

.sidebar {
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #f9fbfb;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: #9ee2db;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  letter-spacing: 0;
}

.brand small {
  color: #9daab2;
  margin-top: 2px;
  font-size: 12px;
}

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

.nav-item {
  border: 0;
  background: transparent;
  color: #c7d0d5;
  text-align: left;
  border-radius: 8px;
  padding: 11px 12px;
  cursor: pointer;
  font-size: 14px;
}

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

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  direction: rtl;
}

.sidebar-note span {
  color: #9ee2db;
  font-weight: 700;
  font-size: 13px;
}

.sidebar-note p {
  color: #c7d0d5;
  margin: 8px 0 0;
  line-height: 1.8;
  font-size: 12px;
}

.main {
  padding: 26px;
  display: grid;
  gap: 20px;
  align-content: start;
  direction: rtl;
}

.topbar,
.workbench,
.lower-grid {
  direction: ltr;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
  direction: rtl;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

input,
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.topbar input {
  width: min(34vw, 360px);
  height: 42px;
  padding: 0 14px;
}

.button,
.icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0;
}

.button {
  min-height: 42px;
  padding: 0 14px;
}

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

.button.secondary {
  background: #202a31;
  color: #ffffff;
}

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

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  direction: ltr;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.registry-panel,
.inspector,
.topics-panel,
.permission-panel,
.plan-panel,
.contract-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  background: #fbfcfd;
  font-weight: 700;
}

tr {
  cursor: pointer;
}

tr:hover td,
tr.selected td {
  background: #f4faf9;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.chip.teal,
.status-chip {
  background: var(--teal-2);
  color: var(--teal);
  border-color: #b7ded9;
}

.chip.amber {
  background: var(--amber-2);
  color: var(--amber);
  border-color: #f0d396;
}

.chip.danger {
  background: var(--danger-2);
  color: var(--danger);
  border-color: #f3b6ad;
}

.inspector {
  padding-bottom: 16px;
}

.policy-list {
  margin: 0;
  padding: 4px 16px 12px;
}

.policy-list div {
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.policy-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.policy-list dd {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.5;
}

.compact-form,
.permission-form {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.compact-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

textarea {
  resize: vertical;
  padding: 10px;
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  direction: ltr;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 16px;
}

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

.runtime-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.runtime-panel select {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 0 10px;
}

.contract-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  direction: ltr;
}

.contract-row {
  display: grid;
  gap: 7px;
  padding: 13px 16px;
  border-inline-end: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.contract-row strong {
  font-size: 13px;
}

.contract-row small {
  color: var(--muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.action-row .row-actions {
  display: flex;
  gap: 8px;
}

.action-row .button {
  min-height: 32px;
  padding: 0 10px;
  width: auto;
}

.topic-list {
  display: grid;
}

.topic-row,
.permission-row {
  display: grid;
  gap: 6px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  direction: rtl;
}

.topic-row:last-child,
.permission-row:last-child {
  border-bottom: 0;
}

.topic-row strong,
.permission-row strong {
  font-size: 14px;
}

.topic-row span,
.permission-row span,
.muted-label {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.permission-form {
  padding-top: 16px;
}

.permission-form input,
.permission-form textarea {
  width: 100%;
  padding: 10px 12px;
}

.permission-list {
  border-top: 1px solid var(--border);
  max-height: 220px;
  overflow: auto;
}

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

  .sidebar {
    display: none;
  }

  .workbench,
  .lower-grid,
  .runtime-grid,
  .contract-list,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions,
  .topbar input {
    width: 100%;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .button {
    width: 100%;
  }

  .main {
    padding: 18px;
    overflow: hidden;
  }

  table {
    min-width: 640px;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 25px;
  }

  .main {
    padding: 14px;
  }

  .metric-grid {
    gap: 10px;
  }

  .metric {
    padding: 14px;
  }

  th,
  td {
    padding: 11px 12px;
  }

  table {
    min-width: 560px;
  }

  .chip {
    font-size: 11px;
    max-width: 180px;
  }

  .policy-list dd {
    overflow-wrap: anywhere;
  }
}
