:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #172235;
  background: #eef3f7;
  --navy: #123552;
  --navy-deep: #09263d;
  --blue: #17649a;
  --blue-soft: #d9eefb;
  --orange: #d68b1f;
  --border: #d2dde6;
  --muted: #5c6c7c;
  --surface: #ffffff;
  --success: #14633e;
  --success-bg: #dff4e9;
  --warning: #775009;
  --warning-bg: #fff0c9;
  --danger: #8b2530;
  --danger-bg: #fde7ea;
  --shadow: 0 8px 26px rgba(18, 53, 82, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
.topbar a { color: #c6e8fc; text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.62; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.65rem 0.85rem;
  color: white;
  background: var(--navy-deep);
  border-radius: 0.35rem;
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.15rem clamp(1rem, 4vw, 3rem);
  color: white;
  background: linear-gradient(120deg, var(--navy-deep), var(--navy));
  border-bottom: 5px solid var(--orange);
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.15rem; font-size: clamp(1.55rem, 3vw, 2.3rem); }
h2 { margin-bottom: 0.75rem; font-size: clamp(1.12rem, 2vw, 1.4rem); }
h3 { margin: 1.35rem 0 0.65rem; font-size: 1rem; }
code {
  padding: 0.1rem 0.25rem;
  color: #143e5d;
  background: #edf3f7;
  border-radius: 0.25rem;
}

.eyebrow {
  margin-bottom: 0.2rem;
  color: #90c7e8;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.eyebrow.dark { color: #55778f; }
.subtitle { margin-bottom: 0; color: #c5deed; }
.target-control {
  display: grid;
  grid-template-columns: auto minmax(7rem, auto);
  gap: 0.35rem 0.65rem;
  align-items: center;
  min-width: min(100%, 21rem);
}
.target-control label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.target-control select {
  padding: 0.5rem 2rem 0.5rem 0.6rem;
  border: 0;
  border-radius: 0.4rem;
  font-weight: 800;
}
.target-control .badge, .control-note { grid-column: 1 / -1; }
.control-note { color: #c5deed; font-size: 0.74rem; }

main {
  max-width: 1800px;
  margin: 0 auto;
  padding: 1.2rem clamp(0.8rem, 3vw, 2.5rem) 3rem;
}
.section-card, .control-panel, .workspace {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  box-shadow: var(--shadow);
}
.section-card { padding: 1.1rem; }
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.section-heading > h2, .section-heading > div > h2 { margin-bottom: 0; }
.section-note, .hint, .muted { color: var(--muted); }
.section-note { margin: 0.35rem 0 0.9rem; }
.hint { margin: 0.7rem 0 0; font-size: 0.84rem; line-height: 1.45; }

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 0.8rem;
}
.status-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-left: 5px solid #91a4b3;
  border-radius: 0.6rem;
  background: #fbfdfe;
}
.status-card.selected {
  border-left-color: var(--blue);
  box-shadow: inset 0 0 0 1px #b8d8ec;
}
.status-card-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}
.status-card-heading h3 { margin: 0; font-size: 1.25rem; }
.status-details {
  display: grid;
  grid-template-columns: minmax(7.5rem, 0.45fr) minmax(0, 1fr);
  gap: 0.36rem 0.7rem;
  margin: 0.85rem 0 0;
}
.status-details dt, .detail-grid dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.status-details dd, .detail-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}
.status-warning, .status-error {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: 0.4rem;
  font-size: 0.84rem;
}
.status-warning { color: var(--warning); background: var(--warning-bg); }
.status-error { color: var(--danger); background: var(--danger-bg); }

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.badge-neutral { color: #15344d; background: var(--blue-soft); }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.45rem; }

.console-layout {
  display: grid;
  grid-template-columns: minmax(15rem, 20rem) minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}
.control-panel, .workspace { padding: 1.05rem; min-width: 0; }
.control-panel { align-self: start; }
.control-section {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}
label { display: block; margin-bottom: 0.35rem; font-weight: 750; }
input, textarea, .control-panel select {
  width: 100%;
  padding: 0.68rem 0.75rem;
  color: inherit;
  background: white;
  border: 1px solid #91a4b3;
  border-radius: 0.4rem;
}
.control-panel textarea { resize: vertical; font-family: Consolas, monospace; font-size: 0.8rem; }
.id-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem; }
.inline-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem; align-items: stretch; }
.check-control { display: flex; gap: 0.45rem; align-items: center; margin: 0.7rem 0; font-weight: 650; }
.check-control input { width: auto; }
.scenario-controls { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }
.button-row { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.control-panel select { margin-bottom: 0.7rem; background: white; }
input:focus, select:focus, button:focus-visible, pre:focus {
  outline: 3px solid rgba(23, 100, 154, 0.35);
  outline-offset: 2px;
}
.button {
  border: 0;
  border-radius: 0.4rem;
  font-weight: 800;
}
.button.primary {
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.68rem 0.75rem;
  color: white;
  background: var(--blue);
}
.button.primary:hover:not(:disabled) { background: #0f527f; }
.button.secondary {
  padding: 0.56rem 0.72rem;
  color: #174568;
  background: #e5f1f8;
  border: 1px solid #b9d4e4;
}
.button.compact { width: auto; margin: 0; font-size: 0.82rem; }

.search-results {
  display: grid;
  gap: 0.35rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}
.search-result-button, .table-link {
  padding: 0;
  color: #0d5b90;
  background: transparent;
  border: 0;
  font-weight: 750;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}
.search-result-button {
  width: 100%;
  padding: 0.55rem;
  background: #f4f8fb;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  text-decoration: none;
}

.entity-tabs {
  display: grid;
  gap: 0.32rem;
  margin-top: 1.3rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}
.entity-tabs button {
  width: 100%;
  padding: 0.55rem 0.65rem;
  color: #25465e;
  background: #f2f6f9;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  font-weight: 750;
  text-align: left;
}
.entity-tabs button[aria-selected="true"] {
  color: white;
  background: var(--navy);
}

.message {
  margin-bottom: 1rem;
  padding: 0.7rem 0.8rem;
  color: #304b60;
  background: #eef5f9;
  border-left: 4px solid #7ba8c4;
  border-radius: 0.35rem;
}
.message[data-tone="success"] {
  color: var(--success);
  background: var(--success-bg);
  border-left-color: var(--success);
}
.message[data-tone="warning"] {
  color: var(--warning);
  background: var(--warning-bg);
  border-left-color: var(--warning);
}
.message[data-tone="danger"] {
  color: var(--danger);
  background: var(--danger-bg);
  border-left-color: var(--danger);
}

.entity-header {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.entity-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.entity-title-row h2 { margin-bottom: 0.25rem; font-size: 1.6rem; }
.entity-description { margin-bottom: 0; color: var(--muted); }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.8rem; color: var(--muted); font-size: 0.8rem; }
.breadcrumbs span + span::before { content: "/"; margin-right: 0.35rem; color: #98a8b5; }
.entity-panel > h2 { margin-bottom: 1rem; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
}
.detail-grid dt, .detail-grid dd {
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
}
.detail-grid dt { background: #f3f7fa; }
.detail-grid dd { background: white; }
.detail-grid > :nth-last-child(-n+2) { border-bottom: 0; }
.count { color: var(--muted); font-size: 0.84rem; font-weight: 750; }
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
}
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
caption {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
th, td {
  padding: 0.62rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th {
  color: #42586a;
  background: #edf3f7;
  font-size: 0.7rem;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfd; }
.trace-cell, .break-value, .path-link { overflow-wrap: anywhere; word-break: break-word; }
.list-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}
.list-grid section {
  padding: 0.8rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
}
.list-grid h3 { margin-top: 0; }
.list-grid ul { margin-bottom: 0; padding-left: 1.2rem; }

pre {
  max-height: 32rem;
  margin: 0;
  padding: 0.85rem;
  overflow: auto;
  color: #dcecf7;
  background: #10283b;
  border-radius: 0.45rem;
  font: 0.8rem/1.48 Consolas, "SFMono-Regular", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.inspector-grid { margin-bottom: 1rem; }
.entity-detail {
  margin-top: 1rem;
  padding: 0.9rem;
  background: #fffaf0;
  border: 1px solid #e5ce9e;
  border-radius: 0.55rem;
}

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

@media (max-width: 900px) {
  .console-layout { grid-template-columns: 1fr; }
  .entity-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .entity-tabs button { text-align: center; }
}

@media (max-width: 700px) {
  .topbar, .section-heading, .entity-title-row { align-items: stretch; }
  .topbar { display: block; }
  .target-control { margin-top: 1rem; }
  .status-grid, .list-grid { grid-template-columns: 1fr; }
  .badge-row { justify-content: flex-start; }
}

@media (max-width: 520px) {
  main { padding-inline: 0.55rem; }
  .section-card, .control-panel, .workspace { padding: 0.8rem; border-radius: 0.5rem; }
  .section-heading { display: block; }
  .section-heading .button { margin-top: 0.55rem; }
  .detail-grid { grid-template-columns: minmax(7.5rem, 0.8fr) minmax(0, 1.2fr); }
  .entity-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-card-heading { display: block; }
  .status-card-heading .button { margin-top: 0.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
