:root {
  color-scheme: light;
  --background: #f5f5f2;
  --surface: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d8dde5;
  --primary: #1a3c6e;
  --primary-hover: #12305d;
  --success: #16794b;
  --warning: #9a6700;
  --danger: #b42318;
}

* { box-sizing: border-box; }

html { background: var(--background); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--background);
  font-family: Avenir, "Avenir Next", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button, input, select, textarea, pre, code { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 max(24px, calc((100vw - 1040px) / 2));
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

header a { color: var(--text); font-size: 17px; font-weight: 700; text-decoration: none; }

main { width: min(1040px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 72px; }

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 32px; line-height: 1.2; letter-spacing: -.02em; }
h2 { margin-bottom: 0; font-size: 20px; line-height: 1.3; }
.page-heading p, .api-heading p { margin-bottom: 0; color: var(--muted); }

.hero-dial {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.hero-dial strong { display: none; }
.hero-dial small { font-size: 12px; font-weight: 700; text-transform: none; }
.hero-dial.online { color: var(--success); border-color: #9bd5ba; }
.hero-dial.blocked { color: var(--danger); border-color: #f0b4ae; }

.panel {
  margin-bottom: 24px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.heading-actions, .primary-actions, .api-submit-row, .dialog-actions { display: flex; align-items: center; gap: 10px; }

.primary-button, .secondary-button, .api-presets button {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 5px;
  font-weight: 600;
}
.primary-button { color: #fff; background: var(--primary); border: 1px solid var(--primary); }
.primary-button:hover:not(:disabled) { background: var(--primary-hover); }
.secondary-button, .api-presets button { color: var(--text); background: var(--surface); border: 1px solid var(--line); }
.secondary-button:hover:not(:disabled), .api-presets button:hover { border-color: #98a2b3; }

.poll-indicator { color: var(--muted); font-size: 12px; }
.poll-indicator.online { color: var(--success); font-weight: 700; }

.status-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 24px 0;
  padding: 1px;
  background: var(--line);
  list-style: none;
}
.signal-node { display: flex; align-items: center; gap: 10px; min-height: 74px; padding: 14px; background: var(--surface); }
.signal-node strong, .signal-node small { display: block; }
.signal-node strong { font-size: 13px; }
.signal-node small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.node-light { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: #98a2b3; }
.signal-node.ok .node-light { background: var(--success); }
.signal-node.warn .node-light { background: var(--warning); }
.signal-node.bad .node-light { background: var(--danger); }

.message, .blocker { margin-bottom: 18px; padding: 11px 13px; color: var(--muted); background: #f8fafc; border-left: 3px solid #98a2b3; }
.message.good, .blocker.good { color: var(--success); border-color: var(--success); }
.message.bad, .blocker.bad { color: var(--danger); border-color: var(--danger); }

.primary-actions { margin-bottom: 24px; }
.ignition { display: flex; text-align: left; }
.ignition small, .ignition strong { display: block; }
.ignition small { font-size: 10px; font-weight: 400; }
.ignition strong { font-size: 13px; }
.button-led { width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 50%; }

.readouts { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border: 1px solid var(--line); }
.readouts div { min-width: 0; padding: 13px; border-right: 1px solid var(--line); }
.readouts div:last-child { border-right: 0; }
.readouts dt { color: var(--muted); font-size: 11px; }
.readouts dd { margin: 5px 0 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

.event-log { margin-top: 18px; color: var(--muted); font-size: 12px; }
.event-log summary { cursor: pointer; }
.event-title { display: flex; justify-content: flex-end; padding: 10px 0; }
.event-title button { padding: 0; color: var(--muted); background: transparent; border: 0; font-size: 12px; }
.event-log ol { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.event-log li { display: grid; grid-template-columns: 66px 1fr; }

.api-heading { margin-bottom: 20px; }
.api-presets { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.api-presets button { min-height: 34px; padding: 0 11px; font-size: 12px; font-weight: 500; }

.api-console { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; }
.api-console label { display: grid; gap: 5px; }
.api-console label > span { color: var(--muted); font-size: 11px; }
.api-console input, .api-console select, .api-console textarea {
  width: 100%;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.api-console input, .api-console select { min-height: 42px; }
.api-console textarea { resize: vertical; }
.api-body-label, .api-submit-row { grid-column: 1 / -1; }
#apiStatus { color: var(--muted); font-size: 12px; }
#apiResponse { min-height: 150px; max-height: 480px; margin: 14px 0 0; padding: 14px; overflow: auto; color: var(--text); background: #f8fafc; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.note { margin: 10px 0 0; color: var(--muted); font-size: 12px; }

footer { padding: 20px; color: var(--muted); border-top: 1px solid var(--line); text-align: center; font-size: 12px; }

dialog { width: min(460px, calc(100vw - 32px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 20px 60px rgba(16, 24, 40, .18); }
dialog::backdrop { background: rgba(16, 24, 40, .32); }
dialog form { position: relative; padding: 28px; }
.dialog-close { position: absolute; top: 12px; right: 15px; color: var(--muted); background: transparent; border: 0; font-size: 22px; }
dialog p { color: var(--muted); }
dialog label { display: block; margin: 20px 0 5px; font-size: 12px; }
dialog input { width: 100%; min-height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 4px; }
.dialog-actions { margin-top: 14px; }

@media (max-width: 760px) {
  main { width: min(100% - 24px, 1040px); padding-top: 34px; }
  .panel { padding: 20px; }
  .status-list, .readouts { grid-template-columns: 1fr 1fr; }
  .readouts div:nth-child(2) { border-right: 0; }
  .readouts div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 520px) {
  header { padding: 0 16px; }
  .page-heading, .section-heading { align-items: flex-start; }
  .status-list, .readouts, .api-console { grid-template-columns: 1fr; }
  .primary-actions { align-items: stretch; flex-direction: column; }
  .readouts div { border-right: 0; border-bottom: 1px solid var(--line); }
  .readouts div:last-child { border-bottom: 0; }
  .api-body-label, .api-submit-row { grid-column: auto; }
}

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