:root {
  --paper: #f3f6f7;
  --surface: #ffffff;
  --ink: #14232b;
  --muted: #61717a;
  --line: #cbd5da;
  --steel: #1b5c82;
  --steel-dark: #123f59;
  --amber: #c87524;
  --red: #a83d3d;
  --green: #257055;
  --shadow: 0 16px 48px rgba(20, 35, 43, 0.09);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

[hidden] {
  display: none !important;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(27, 92, 130, 0.035) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--paper);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }

:focus-visible {
  outline: 3px solid rgba(27, 92, 130, .35);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 8px;
  left: 8px;
  transform: translateY(-160%);
  padding: 10px 14px;
  color: #fff;
  background: var(--steel-dark);
}
.skip-link:focus { transform: none; }

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 32px;
  padding: 30px clamp(20px, 4vw, 64px) 24px;
  color: #fff;
  background: var(--ink);
  border-bottom: 5px solid var(--steel);
}

.eyebrow, .section-label {
  margin: 0 0 7px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.eyebrow { color: #9bc1d6; }
.section-label { color: var(--steel); }

h1, h2 {
  margin: 0;
  font-family: "Avenir Next Condensed", "Arial Narrow", sans-serif;
  font-stretch: condensed;
  letter-spacing: -.02em;
}
h1 { font-size: clamp(1.7rem, 4vw, 3.1rem); font-weight: 650; }
h2 { font-size: clamp(1.35rem, 2.4vw, 2rem); }

.session-state {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 5px;
  color: #d7e0e4;
  font-size: .88rem;
  white-space: nowrap;
}
.signal { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(37, 112, 85, .25); }
.signal--locked { background: var(--amber); box-shadow: 0 0 0 4px rgba(200, 117, 36, .24); }

.shell { padding: clamp(20px, 4vw, 56px); }

.access-card {
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(360px, 1.2fr);
  gap: clamp(28px, 6vw, 88px);
  max-width: 1040px;
  margin: 8vh auto 0;
  padding: clamp(28px, 5vw, 64px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 7px solid var(--steel);
  box-shadow: var(--shadow);
}
.access-card p { max-width: 50ch; color: var(--muted); line-height: 1.6; }
.access-card label, .filters label { display: block; margin-bottom: 8px; color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.access-row { display: flex; gap: 10px; }
.access-row input, select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcfc;
  border: 1px solid #aebbc1;
  border-radius: 3px;
}
button {
  min-height: 44px;
  padding: 10px 17px;
  color: #fff;
  font-weight: 700;
  background: var(--steel);
  border: 1px solid var(--steel);
  border-radius: 3px;
}
button:hover { background: var(--steel-dark); border-color: var(--steel-dark); }
.form-error { min-height: 1.5em; margin: 9px 0 0 !important; color: var(--red) !important; }

.workspace {
  display: grid;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1500px;
  margin: 0 auto;
}
.ledger, .detail {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.ledger { align-self: start; position: sticky; top: 20px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.ledger-head, .detail-head, .body-toolbar, .retry-bar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.ledger-head { padding: 24px 22px 18px; border-bottom: 1px solid var(--line); }
.quiet-button { min-height: 36px; padding: 7px 11px; color: var(--steel); background: transparent; border-color: #9bb2bf; }
.quiet-button:hover { color: #fff; }
.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}
.filter-field { min-width: 0; }
.filters select { min-height: 40px; }
.history { min-height: 120px; margin: 0; padding: 0; list-style: none; overflow: auto; }
.history button {
  width: 100%;
  padding: 17px 22px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #e3e9ec;
  border-radius: 0;
}
.history button:hover, .history button[aria-current="true"] { background: #eaf2f6; }
.history strong, .history small { display: block; }
.history strong { margin: 5px 0; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .82rem; overflow-wrap: anywhere; }
.history small { color: var(--muted); }
.history-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.load-more { margin: 14px 22px 20px; }
.empty-state { padding: 28px 22px; color: var(--muted); }

.detail { min-height: 720px; padding: clamp(24px, 4vw, 48px); }
.detail-empty { max-width: 520px; margin: 18vh auto 0; text-align: center; color: var(--muted); }
.detail-empty h2 { margin-bottom: 10px; color: var(--ink); }
.detail-head { align-items: start; padding-bottom: 25px; border-bottom: 1px solid var(--line); }
.detail-head h2 { overflow-wrap: anywhere; }
.status-chip {
  display: inline-flex;
  padding: 6px 9px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .72rem;
  font-weight: 800;
  color: var(--steel-dark);
  background: #dfeef5;
  border: 1px solid #a9c8d8;
}
.status-chip[data-status="SUCCEEDED"] { color: #185a40; background: #e1f0e9; border-color: #a7cfbd; }
.status-chip[data-status="FAILED"] { color: #842d2d; background: #f8e3e3; border-color: #dbaaaa; }
.status-chip[data-status="PROCESSING"], .status-chip[data-status="RETRY_WAIT"] { color: #77400e; background: #faeadb; border-color: #dfb986; }
.status-chip[data-status="HTTP_2XX"], .status-chip[data-status="AUTHENTICATED"] { color: #185a40; background: #e1f0e9; border-color: #a7cfbd; }
.status-chip[data-status="HTTP_4XX"], .status-chip[data-status="HTTP_5XX"], .status-chip[data-status="UNAUTHENTICATED"] { color: #842d2d; background: #f8e3e3; border-color: #dbaaaa; }
.status-chip[data-status="PENDING"] { color: #77400e; background: #faeadb; border-color: #dfb986; }

.process-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 32px 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--line);
}
.process-rail li { position: relative; min-height: 110px; padding: 18px; border-right: 1px solid var(--line); }
.process-rail li:last-child { border-right: 0; }
.process-rail span { display: block; margin-bottom: 17px; color: #809099; font-family: ui-monospace, monospace; font-size: .7rem; }
.process-rail strong, .process-rail small { display: block; }
.process-rail strong { font-size: .86rem; }
.process-rail small { margin-top: 5px; color: var(--muted); }
.process-rail li[data-state="done"] { box-shadow: inset 0 4px var(--green); }
.process-rail li[data-state="active"] { box-shadow: inset 0 4px var(--amber); }
.process-rail li[data-state="failed"] { box-shadow: inset 0 4px var(--red); }
.process-rail li[data-state="idle"] { box-shadow: inset 0 4px #aebbc1; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin: 0 0 30px; background: var(--line); border: 1px solid var(--line); }
.facts div { min-width: 0; padding: 16px; background: var(--surface); }
.facts dt { color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.facts dd { margin: 6px 0 0; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .82rem; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); }
.tab { color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; }
.tab:hover { color: var(--ink); background: #eef3f5; }
.tab.is-active { color: var(--steel-dark); border-bottom-color: var(--steel); }
.tab-panel { padding-top: 22px; }
.event-list { margin: 0; padding: 0; list-style: none; }
.event-list li { display: grid; grid-template-columns: 145px 1fr; gap: 18px; padding: 13px 0; border-bottom: 1px solid #e3e9ec; }
.event-list time { color: var(--muted); font-family: ui-monospace, monospace; font-size: .76rem; }
.event-list strong, .event-list small { display: block; }
.event-list small { margin-top: 4px; color: var(--muted); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid #dce4e8; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.empty-table-row td { padding: 24px 10px; color: var(--muted); text-align: center; }
.telemetry-note { margin-bottom: 14px; color: var(--muted); }
.body-toolbar p { color: var(--muted); }
pre { max-height: 460px; padding: 20px; overflow: auto; color: #dce7ec; background: #1a282f; border-left: 5px solid var(--steel); white-space: pre-wrap; overflow-wrap: anywhere; }
.retry-bar { margin-top: 28px; padding: 18px; background: #fbefe3; border: 1px solid #e0b88e; }
.retry-bar p { margin: 4px 0 0; color: #6d5035; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; padding: 14px 18px; color: #fff; background: var(--ink); border-left: 5px solid var(--steel); box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .ledger { position: static; max-height: none; }
  .history { max-height: 360px; }
  .process-rail { grid-template-columns: repeat(2, 1fr); }
  .process-rail li:nth-child(2) { border-right: 0; }
  .process-rail li:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .masthead { align-items: start; flex-direction: column; }
  .shell { padding: 14px; }
  .access-card { grid-template-columns: 1fr; margin-top: 16px; }
  .access-row { flex-direction: column; }
  .filters { grid-template-columns: 1fr; }
  .detail { min-height: 520px; }
  .detail-head, .retry-bar { align-items: start; flex-direction: column; }
  .process-rail { grid-template-columns: 1fr; }
  .process-rail li { border-right: 0; border-bottom: 1px solid var(--line); }
  .process-rail li:last-child { border-bottom: 0; }
  .facts { grid-template-columns: 1fr; }
  .event-list li { grid-template-columns: 1fr; gap: 5px; }
}

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