:root {
      color-scheme: light;
      --bg: #f7f8fb;
      --panel: #ffffff;
      --ink: #172033;
      --muted: #69758a;
      --line: #dde3ee;
      --blue: #2563eb;
      --green: #047857;
      --amber: #b45309;
      --red: #b91c1c;
      --violet: #6d28d9;
      --shadow: 0 12px 32px rgba(23, 32, 51, 0.09);
    }
    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    body {
      margin: 0;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: var(--bg);
      color: var(--ink);
    }
    header {
      padding: 18px 28px 14px;
      border-bottom: 1px solid var(--line);
      background: var(--panel);
    }
    .header-main {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 18px;
    }
    .eyebrow {
      margin: 0 0 3px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 780;
      letter-spacing: 0.04em;
      text-transform: uppercase;
    }
    h1 { margin: 0; font-size: 23px; font-weight: 760; letter-spacing: 0; }
    .header-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-top: 11px;
      min-height: 26px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 680;
    }
    .meta-chips {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      min-width: 0;
    }
    .live-status,
    .source-line {
      display: inline-flex;
      align-items: center;
      min-height: 24px;
      padding: 2px 8px;
      border: 1px solid #c7d2fe;
      border-radius: 999px;
      background: #eef2ff;
      color: #3346a3;
      font-weight: 760;
    }
    .live-status {
      justify-content: center;
      min-width: 58px;
    }
    .disclaimer-chip {
      display: inline-flex;
      align-items: center;
      min-height: 24px;
      padding: 2px 8px;
      border: 1px solid #fed7aa;
      border-radius: 999px;
      background: #fff7ed;
      color: #9a3412;
      font-weight: 780;
    }
    .source-line {
      border-color: var(--line);
      background: #f8fafc;
      color: var(--muted);
    }
    .source-line[data-state="missing"],
    .live-status[data-state="error"] {
      border-color: #fed7aa;
      background: #fff7ed;
      color: #9a3412;
    }
    .guide-link {
      flex: 0 0 auto;
      color: var(--blue);
      font-weight: 760;
      text-decoration: none;
    }
    .guide-link:hover { text-decoration: underline; }
    .live-bar {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 10px;
      justify-content: flex-end;
    }
    .refresh-button {
      min-height: 34px;
      padding: 6px 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--blue);
      font-size: 12px;
      font-weight: 760;
      cursor: pointer;
    }
    .refresh-button:hover { background: #eff6ff; }
    .refresh-button:disabled { cursor: progress; opacity: 0.7; }
    .live-toggle {
      display: inline-flex;
      grid-template-columns: none;
      align-items: center;
      gap: 7px;
      min-height: 34px;
      font-size: 12px;
      font-weight: 760;
      color: var(--muted);
    }
    .live-toggle input {
      width: auto;
      min-height: 0;
      padding: 0;
      margin: 0;
    }
    .live-status {
      font-size: 12px;
      font-weight: 680;
    }
    .load-control,
    .history-control,
    .language-control {
      display: inline-flex;
      grid-template-columns: none;
      align-items: center;
      gap: 7px;
      min-height: 34px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 760;
    }
    .load-control select,
    .history-control select,
    .language-control select {
      width: auto;
      min-width: 104px;
      min-height: 34px;
      padding: 5px 8px;
      font-size: 12px;
    }
    .history-control select {
      min-width: 156px;
    }
    .language-control select {
      min-width: 118px;
    }
    main { padding: 22px 28px 36px; }
    .filters {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
      gap: 12px;
      margin-bottom: 18px;
    }
    label { display: grid; gap: 6px; font-size: 12px; font-weight: 680; color: var(--muted); }
    input, select {
      width: 100%;
      min-height: 38px;
      padding: 7px 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--ink);
      font: inherit;
    }
    .filter-status {
      color: var(--muted);
      font-size: 11px;
      font-weight: 720;
      line-height: 1.2;
      overflow-wrap: anywhere;
    }
    .filter-status:empty {
      display: none;
    }
    .filter-status[data-state="active"] {
      color: var(--blue);
    }
    .filter-status[data-state="error"] {
      color: var(--red);
    }
    .cards {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 12px;
      margin-bottom: 18px;
    }
    .card {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      padding: 14px;
      box-shadow: var(--shadow);
    }
    .card span { display: block; color: var(--muted); font-size: 12px; font-weight: 680; }
    .card strong { display: block; margin-top: 7px; font-size: 22px; }
    #allowanceImpact { white-space: pre-line; line-height: 1.18; }
    .insights-panel {
      margin-bottom: 18px;
    }
    .insights-panel[hidden] {
      display: none;
    }
    .insights-layout {
      display: grid;
      grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.8fr);
      gap: 16px;
      padding: 14px;
    }
    .section-heading,
    .preset-heading {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 12px;
    }
    .section-heading h2,
    .preset-heading h2 {
      margin: 0;
      padding: 0;
      border: 0;
      font-size: 15px;
    }
    .section-heading p,
    .preset-heading p {
      margin: 4px 0 0;
      color: var(--muted);
      font-size: 12px;
      font-weight: 680;
      line-height: 1.35;
    }
    .insight-cards {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 10px;
    }
    .insight-card {
      display: grid;
      align-content: start;
      min-height: 172px;
      padding: 13px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfe;
    }
    .insight-card[data-severity="high"] {
      border-color: #fecaca;
      background: #fff7f7;
    }
    .insight-card[data-severity="medium"] {
      border-color: #fed7aa;
      background: #fffaf0;
    }
    .insight-card[data-severity="review"] {
      border-color: #bfdbfe;
      background: #f7fbff;
    }
    .insight-card h3 {
      margin: 0;
      font-size: 14px;
      line-height: 1.2;
    }
    .insight-card strong {
      display: block;
      margin: 9px 0 5px;
      font-size: 24px;
      letter-spacing: 0;
    }
    .insight-card p {
      margin: 0;
      color: var(--muted);
      font-size: 12px;
      font-weight: 650;
      line-height: 1.35;
    }
    .insight-card-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 10px;
    }
    .severity-chip,
    .preset-chip {
      display: inline-flex;
      align-items: center;
      min-height: 22px;
      padding: 2px 8px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: var(--panel);
      color: var(--muted);
      font-size: 11px;
      font-weight: 780;
      white-space: nowrap;
    }
    .severity-chip.high {
      border-color: #fecaca;
      background: #fef2f2;
      color: var(--red);
    }
    .severity-chip.medium {
      border-color: #fed7aa;
      background: #fff7ed;
      color: var(--amber);
    }
    .severity-chip.review {
      border-color: #bfdbfe;
      background: #eff6ff;
      color: var(--blue);
    }
    .insight-action {
      width: max-content;
      max-width: 100%;
      margin-top: 12px;
      padding: 0;
      border: 0;
      background: transparent;
      color: var(--blue);
      font-size: 12px;
      font-weight: 780;
      text-align: left;
      cursor: pointer;
    }
    .insight-action:hover,
    .preset-clear:hover {
      text-decoration: underline;
    }
    .preset-panel {
      min-width: 0;
    }
    .preset-clear {
      min-height: 28px;
      padding: 4px 8px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--blue);
      font-size: 12px;
      font-weight: 760;
      cursor: pointer;
    }
    .preset-status {
      margin-bottom: 10px;
      padding: 8px 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfe;
      color: var(--muted);
      font-size: 12px;
      font-weight: 680;
    }
    .preset-list {
      display: grid;
      gap: 8px;
    }
    .preset-card {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 10px;
      align-items: center;
      min-height: 68px;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfe;
      color: var(--ink);
      text-align: left;
      cursor: pointer;
    }
    .preset-card[aria-pressed="true"] {
      border-color: #bfdbfe;
      background: #eff6ff;
    }
    .preset-copy b {
      display: block;
      font-size: 13px;
      line-height: 1.2;
    }
    .preset-copy span {
      display: block;
      margin-top: 4px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 650;
      line-height: 1.32;
    }
    .grid {
      display: grid;
      grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
      gap: 16px;
      align-items: start;
    }
    section {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: 8px;
      overflow: hidden;
      box-shadow: var(--shadow);
    }
    .detail-section {
      position: sticky;
      top: 14px;
      max-height: calc(100dvh - 28px);
      display: flex;
      flex-direction: column;
    }
    section h2 {
      margin: 0;
      padding: 14px 16px;
      border-bottom: 1px solid var(--line);
      font-size: 15px;
    }
    table { width: 100%; border-collapse: collapse; font-size: 13px; }
    th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
    th { color: var(--muted); font-size: 12px; background: #fbfcfe; position: sticky; top: 0; }
    tr:hover { background: #eff6ff; }
    .call-row {
      cursor: pointer;
    }
    .call-row:focus-visible,
    .thread-row:focus-visible,
    .thread-call-row:focus-visible {
      outline: 2px solid var(--blue);
      outline-offset: -2px;
      background: #eff6ff;
    }
    button {
      font: inherit;
    }
    .sort-header {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      max-width: 100%;
      min-height: 24px;
      padding: 0;
      border: 0;
      background: transparent;
      color: inherit;
      font-size: inherit;
      font-weight: 760;
      cursor: pointer;
    }
    th.num .sort-header {
      width: 100%;
      justify-content: flex-end;
    }
    th[data-sort-active="true"] .sort-header {
      color: var(--ink);
    }
    .sort-indicator {
      display: inline-block;
      min-width: 12px;
      color: var(--blue);
      font-size: 11px;
    }
    .table-tools {
      display: grid;
      grid-template-columns: auto 1fr auto;
      align-items: center;
      gap: 12px;
      padding: 12px 16px;
      border-bottom: 1px solid var(--line);
      background: #fbfcfe;
    }
    .segmented {
      grid-row: 1;
      grid-column: 1;
      display: inline-flex;
      gap: 2px;
      padding: 3px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #eef2f8;
    }
    .segmented button {
      min-width: 82px;
      min-height: 30px;
      border: 0;
      border-radius: 6px;
      background: transparent;
      color: var(--muted);
      font-size: 12px;
      font-weight: 760;
      cursor: pointer;
    }
    .segmented button[aria-pressed="true"] {
      background: var(--panel);
      color: var(--ink);
      box-shadow: 0 1px 4px rgba(23, 32, 51, 0.12);
    }
    .table-caption {
      grid-row: 2;
      grid-column: 1 / span 3;
      min-width: 0;
      color: var(--muted);
      font-size: 12px;
      font-weight: 680;
      line-height: 1.4;
      margin-top: 4px;
    }
    .table-actions {
      grid-row: 1;
      grid-column: 2;
      display: inline-flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      min-width: 0;
      white-space: nowrap;
    }
    .toolbar-button {
      min-height: 30px;
      padding: 4px 9px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--blue);
      font-size: 12px;
      font-weight: 760;
      cursor: pointer;
    }
    .toolbar-button:hover {
      background: #eff6ff;
    }
    .action-status {
      min-width: 62px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 720;
    }
    .pager {
      grid-row: 1;
      grid-column: 3;
      display: inline-flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 680;
      white-space: nowrap;
    }
    .pager[hidden] {
      display: none;
    }
    .pager-button {
      min-height: 30px;
      padding: 4px 9px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--blue);
      font-size: 12px;
      font-weight: 760;
      cursor: pointer;
    }
    .pager-button:disabled {
      cursor: not-allowed;
      color: var(--muted);
      opacity: 0.55;
    }
    .num { text-align: right; font-variant-numeric: tabular-nums; }
    .metric-stack {
      display: inline-flex;
      flex-direction: column;
      align-items: flex-end;
      gap: 2px;
      line-height: 1.15;
    }
    .metric-sub {
      color: var(--muted);
      font-size: 11px;
      font-weight: 720;
    }
    .time-cell {
      display: grid;
      gap: 2px;
      min-width: 104px;
      line-height: 1.2;
    }
    .time-date {
      color: var(--ink);
      font-weight: 680;
      white-space: nowrap;
    }
    .time-clock {
      color: var(--muted);
      font-size: 12px;
      white-space: nowrap;
    }
    .pill {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      max-width: 100%;
      min-height: 22px;
      padding: 2px 8px;
      border-radius: 999px;
      background: #e0ecff;
      color: #184fc5;
      font-weight: 680;
      font-size: 12px;
      line-height: 1.08;
      white-space: nowrap;
    }
    .model-pill {
      width: max-content;
      max-width: min(132px, 100%);
      min-width: 0;
      overflow: hidden;
    }
    .flags {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      justify-content: flex-end;
    }
    .flag {
      display: inline-flex;
      min-height: 20px;
      align-items: center;
      padding: 1px 7px;
      border-radius: 999px;
      background: #f5e8ff;
      color: var(--violet);
      font-size: 11px;
      font-weight: 680;
      white-space: nowrap;
    }
    .thread-row {
      cursor: pointer;
    }
    .thread-row[aria-expanded="true"] {
      background: #f8fbff;
    }
    .thread-row.spawned-thread {
      background: #fcfdff;
    }
    .thread-row.spawned-thread td:nth-child(2) {
      border-left: 3px solid #bfdbfe;
      padding-left: 18px;
    }
    .thread-title {
      display: flex;
      gap: 8px;
      align-items: center;
      min-width: 0;
    }
    .thread-toggle {
      flex: 0 0 auto;
      display: inline-grid;
      place-items: center;
      width: 22px;
      height: 22px;
      border: 1px solid var(--line);
      border-radius: 999px;
      background: var(--panel);
      color: var(--blue);
      font-size: 13px;
      font-weight: 820;
    }
    .thread-meta {
      display: grid;
      gap: 2px;
      min-width: 0;
    }
    .thread-name {
      font-weight: 760;
      overflow-wrap: anywhere;
    }
    .thread-subtle {
      color: var(--muted);
      font-size: 12px;
    }
    .thread-relation {
      color: var(--blue);
      font-weight: 720;
    }
    .child-cell {
      padding: 0;
      background: #f8fafd;
    }
    .thread-call-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 12px;
    }
    .thread-call-table th {
      position: static;
      background: #eef3fb;
    }
    .thread-call-table td, .thread-call-table th {
      padding: 8px 10px;
    }
    .thread-call-table tr:last-child td {
      border-bottom: 0;
    }
    .empty-state {
      padding: 18px 16px;
      color: var(--muted);
      text-align: center;
    }
    .detail {
      flex: 1 1 auto;
      padding: 14px 16px;
      min-height: 280px;
      overflow-x: hidden;
      overflow-y: scroll;
      scrollbar-gutter: stable;
      scrollbar-width: thin;
      scrollbar-color: #94a3b8 #eef2f8;
      color: var(--muted);
      line-height: 1.45;
    }
    .detail::-webkit-scrollbar {
      width: 10px;
    }
    .detail::-webkit-scrollbar-track {
      background: #eef2f8;
      border-left: 1px solid var(--line);
    }
    .detail::-webkit-scrollbar-thumb {
      background: #94a3b8;
      border: 2px solid #eef2f8;
      border-radius: 999px;
    }
    .detail::-webkit-scrollbar-thumb:hover {
      background: #64748b;
    }
    .detail dl { display: grid; grid-template-columns: minmax(120px, 0.6fr) minmax(0, 1fr); gap: 8px 14px; margin: 0; }
    .detail dt { font-weight: 720; color: var(--ink); }
    .detail dd { margin: 0; overflow-wrap: anywhere; }
    .detail-stack {
      display: grid;
      gap: 12px;
    }
    .detail-card {
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfe;
    }
    .detail-card.primary {
      border-color: #bfdbfe;
      background: #f7fbff;
    }
    .detail-card h3 {
      margin: 0 0 10px;
      color: var(--ink);
      font-size: 14px;
      line-height: 1.25;
    }
    .detail-card p {
      margin: 0;
      color: var(--muted);
      font-size: 12px;
      font-weight: 650;
      line-height: 1.4;
    }
    .detail-kv {
      display: grid;
      grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1fr);
      gap: 8px 12px;
      margin: 0;
      font-size: 12px;
    }
    .detail-kv dt {
      color: var(--muted);
      font-weight: 720;
    }
    .detail-kv dd {
      color: var(--ink);
      font-weight: 680;
    }
    .detail-collapse {
      border: 1px solid var(--line);
      border-radius: 8px;
      background: #fbfcfe;
    }
    .detail-collapse summary {
      min-height: 38px;
      padding: 9px 11px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 760;
      cursor: pointer;
    }
    .detail-collapse-body {
      padding: 0 11px 11px;
    }
    .timeline-list {
      display: grid;
      gap: 10px;
    }
    .timeline-item {
      display: grid;
      grid-template-columns: minmax(72px, 0.35fr) minmax(0, 1fr);
      gap: 10px;
      padding-bottom: 10px;
      border-bottom: 1px solid var(--line);
    }
    .timeline-item:last-child {
      padding-bottom: 0;
      border-bottom: 0;
    }
    .timeline-time {
      color: var(--muted);
      font-size: 11px;
      font-weight: 760;
      line-height: 1.25;
    }
    .timeline-title {
      color: var(--ink);
      font-size: 12px;
      font-weight: 760;
      line-height: 1.25;
    }
    .timeline-meta {
      margin-top: 5px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 650;
      line-height: 1.35;
    }
    .signal-strip {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      margin-top: 7px;
    }
    .mini-bar {
      height: 7px;
      overflow: hidden;
      border-radius: 999px;
      background: #e5eaf3;
    }
    .mini-bar span {
      display: block;
      height: 100%;
      border-radius: 999px;
      background: var(--blue);
    }
    .mini-bar span.low { background: var(--green); }
    .mini-bar span.medium { background: var(--amber); }
    .mini-bar span.high { background: var(--red); }
    .context-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 14px;
      padding-top: 12px;
      border-top: 1px solid var(--line);
    }
    .context-button {
      min-height: 32px;
      padding: 6px 10px;
      border: 1px solid var(--line);
      border-radius: 8px;
      background: var(--panel);
      color: var(--blue);
      font-size: 12px;
      font-weight: 760;
      cursor: pointer;
    }
    .context-button:hover { background: #eff6ff; }
    .context-button:disabled {
      cursor: not-allowed;
      opacity: 0.62;
      background: var(--panel);
    }
    .context-button.secondary { color: var(--muted); }
    .context-result {
      margin-top: 12px;
      padding-top: 12px;
      border-top: 1px solid var(--line);
    }
    .context-note { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
    .context-entry {
      margin: 10px 0;
      border: 1px solid var(--line);
      border-radius: 8px;
      overflow: hidden;
      background: #fbfcfe;
    }
    .context-entry-header {
      display: flex;
      justify-content: space-between;
      gap: 10px;
      padding: 8px 10px;
      border-bottom: 1px solid var(--line);
      color: var(--muted);
      font-size: 12px;
      font-weight: 720;
    }
    .context-entry pre {
      margin: 0;
      padding: 10px;
      max-height: 360px;
      overflow: auto;
      white-space: pre-wrap;
      overflow-wrap: anywhere;
      color: var(--ink);
      font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    }
    .to-top {
      position: fixed;
      right: 18px;
      bottom: 18px;
      z-index: 4;
      min-height: 38px;
      padding: 8px 12px;
      border: 1px solid #c7d2fe;
      border-radius: 999px;
      background: var(--panel);
      color: var(--blue);
      box-shadow: var(--shadow);
      font-size: 12px;
      font-weight: 780;
      cursor: pointer;
      opacity: 0;
      pointer-events: none;
      transform: translateY(10px);
      transition: opacity 160ms ease, transform 160ms ease;
    }
    .to-top[data-visible="true"] {
      opacity: 1;
      pointer-events: auto;
      transform: translateY(0);
    }
    .to-top:hover { background: #eff6ff; }
    .to-top:active { transform: translateY(1px); }
    @media (max-width: 980px) {
      .filters, .cards, .grid, .insights-layout, .insight-cards { grid-template-columns: 1fr; }
      main, header { padding-left: 16px; padding-right: 16px; }
      table { font-size: 12px; }
      th, td { padding: 8px; }
      .header-main { flex-direction: column; }
      .header-meta { align-items: flex-start; flex-direction: column; }
      .live-bar { justify-content: flex-start; width: 100%; }
      .detail-section { position: static; max-height: none; }
      .detail { max-height: none; }
      .table-tools { align-items: stretch; grid-template-columns: 1fr; }
      .segmented, .table-actions, .pager, .table-caption { grid-row: auto; grid-column: auto; }
      .segmented, .segmented button { width: 100%; }
      .pager, .load-control, .language-control, .table-actions { justify-content: space-between; width: 100%; }
      .action-status { min-width: 0; }
      .preset-card { grid-template-columns: 1fr; }
    }
