:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --text: #111827;
  --muted: #667085;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --success: #027a48;
  --warning: #b54708;
  --shadow: 0 12px 36px rgba(17, 24, 39, 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);
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: #111827;
  color: #fff;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 15px;
}

.brand small {
  color: #a7b0bd;
}

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

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  background: transparent;
  color: #cdd5df;
  text-align: left;
  cursor: pointer;
}

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

.content {
  padding: 24px;
  min-width: 0;
}

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: #e7f5f2;
  color: var(--accent-strong);
  font-size: 12px;
  white-space: nowrap;
}

.badge.error {
  background: #fef3f2;
  color: var(--danger);
}

.badge.warning {
  background: #fffaeb;
  color: var(--warning);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 16px;
}

.stat-card-wide {
  grid-column: 1 / -1;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  line-height: 1;
  font-weight: 750;
}

.stat-extra {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.panel {
  margin-bottom: 16px;
  overflow: hidden;
}

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

input,
select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  min-width: 180px;
}

input[type="search"] {
  min-width: 320px;
}

.primary-button,
.ghost-button {
  height: 36px;
  border-radius: 7px;
  padding: 0 12px;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #f9fafb;
  font-size: 12px;
  font-weight: 700;
}

td {
  font-size: 13px;
}

tbody tr:hover {
  background: #f8fbfb;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:focus {
  outline: 2px solid rgba(15, 118, 110, 0.34);
  outline-offset: -2px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.lookup-form {
  padding: 16px;
}

.lookup-form h2 {
  margin-bottom: 12px;
}

.lookup-form input,
.lookup-form button {
  width: 100%;
  margin-top: 8px;
}

.json-output {
  margin: 0;
  padding: 16px;
  max-height: 460px;
  overflow: auto;
  background: #0f172a;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.6;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: min(560px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 45px rgba(17, 24, 39, 0.16);
}

.detail-drawer[hidden] {
  display: none;
}

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

.detail-header p {
  margin: 6px 0 0;
  max-width: 380px;
  overflow-wrap: anywhere;
  white-space: normal;
}

.detail-body {
  padding: 16px;
  overflow: auto;
}

.detail-body h3 {
  margin: 18px 0 10px;
  font-size: 14px;
}

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

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

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

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.mini-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

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

.mini-row span:first-child {
  overflow-wrap: anywhere;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #111827;
  color: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .stats-grid,
  .lookup-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  input,
  input[type="search"],
  select,
  .primary-button,
  .ghost-button {
    width: 100%;
    min-width: 0;
  }

  .detail-drawer {
    width: 100vw;
  }

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