/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1.25rem;
}

.tab-btn {
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: 10px 10px 0 0;
  background: rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.45);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.95);
  color: #1a1a2e;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.preset-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.25rem;
}

/* User info box */
.user-info {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: #f8f8fc;
  border-radius: 8px;
  font-size: 0.85rem;
}

.user-info .stat {
  color: #666;
}

.user-info .stat strong {
  color: #1a1a2e;
}

.warning-box {
  margin: 0.25rem 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.12);
  color: #7c2d12;
  font-size: 0.85rem;
  line-height: 1.35;
}

.warning-box strong {
  font-weight: 700;
}

/* ── Search bar ───────────────────────────────────────────── */

.debug-searchbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem 0.5rem 0.85rem;
  margin-bottom: 0.65rem;
  border: 1px solid #dbe2ef;
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.debug-searchbar:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.14);
}

.debug-search-icon {
  flex: none;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: #94a3b8;
  stroke-width: 2;
  stroke-linecap: round;
}

.debug-search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  color: #0f172a;
}

.debug-search-input::placeholder {
  color: #94a3b8;
}

.debug-fields {
  position: relative;
  flex: none;
}

.debug-fields-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #f8fafc;
  color: #475569;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.debug-fields-btn:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.debug-fields-btn[aria-expanded="true"] {
  background: #eef2ff;
  border-color: #6366f1;
  color: #4338ca;
}

.debug-fields-chevron {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  transition: transform 0.15s;
}

.debug-fields-btn[aria-expanded="true"] .debug-fields-chevron {
  transform: rotate(180deg);
}

.debug-fields-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(340px, 80vw);
  padding: 0.85rem;
  border: 1px solid #ddd;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  z-index: 210;
}

.debug-fields-title {
  margin-bottom: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.debug-fields-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}

.debug-field-chip {
  padding: 0.28rem 0.55rem;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.76rem;
  cursor: pointer;
}

.debug-field-chip span {
  color: #94a3b8;
  font-family: inherit;
}

.debug-field-chip:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}

.debug-fields-hint {
  font-size: 0.78rem;
  line-height: 1.5;
  color: #64748b;
}

.debug-fields-hint code {
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: #f1f5f9;
  font-size: 0.74rem;
}

/* ── Filter row: segmented controls + function combo + limit ─── */

.debug-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.debug-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.debug-filter-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.debug-filter-function {
  min-width: 200px;
}

.debug-filter-limit input {
  width: 76px;
  padding: 0.4rem 0.55rem;
  border: 1px solid #dbe2ef;
  border-radius: 7px;
  font: inherit;
  font-size: 0.85rem;
}

.debug-select-hidden {
  display: none;
}

.debug-segment {
  display: inline-flex;
  padding: 2px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f1f5f9;
}

.debug-segment-btn {
  padding: 0.32rem 0.65rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.debug-segment-btn:hover {
  color: #1a1a2e;
}

.debug-segment-btn.active {
  background: #fff;
  color: #4338ca;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

/* ── Severity chips ───────────────────────────────────────── */

.debug-buckets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.debug-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.7rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.debug-chip-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.75;
}

.debug-chip-error {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}

.debug-chip-warning {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.debug-chip-audit {
  background: rgba(99, 102, 241, 0.14);
  color: #4338ca;
}

.debug-chip-info {
  background: rgba(100, 116, 139, 0.14);
  color: #475569;
}

.debug-chip-noise {
  background: rgba(100, 116, 139, 0.08);
  color: #64748b;
}

/* Off = filtered out. Declared after the colour variants so it wins on source
   order alone — same specificity, no !important needed. Kept legible instead
   of ghosted, so the count stays readable. */
.debug-chip.off {
  background: transparent;
  color: #94a3b8;
  border-color: #dbe2ef;
  text-decoration: line-through;
}

.debug-meta {
  font-size: 0.82rem;
  color: #64748b;
  margin-bottom: 0.5rem;
}

.debug-log-output {
  margin: 0;
  min-height: 360px;
  max-height: 56vh;
  overflow: auto;
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px solid #dbe2ef;
  background: #f8fafc;
  color: #0f172a;
  font-size: 12px;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.debug-placeholder {
  padding: 1rem;
  color: #64748b;
  font-size: 0.85rem;
  font-family: inherit;
}

.debug-row {
  padding: 0.22rem 0.5rem 0.22rem 0.6rem;
  border-left: 3px solid transparent;
  border-radius: 3px;
}

.debug-row + .debug-row {
  margin-top: 1px;
}

.debug-row-error {
  border-left-color: #dc2626;
  background: rgba(220, 38, 38, 0.06);
}

.debug-row-warning {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.07);
}

.debug-row-audit {
  border-left-color: #6366f1;
  background: rgba(99, 102, 241, 0.06);
}

.debug-row-info {
  border-left-color: #cbd5e1;
}

.debug-row-noise {
  border-left-color: transparent;
  opacity: 0.6;
}

.debug-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.debug-time {
  color: #64748b;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.debug-type {
  min-width: 74px;
  color: #475569;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.debug-status {
  padding: 0 0.35rem;
  border-radius: 4px;
  background: rgba(100, 116, 139, 0.16);
  font-size: 11px;
  font-weight: 700;
}

.debug-row-error .debug-status {
  background: rgba(220, 38, 38, 0.18);
  color: #b91c1c;
}

.debug-message {
  flex: 1 1 320px;
  overflow-wrap: anywhere;
}

.debug-field {
  margin-left: 1.4rem;
  color: #475569;
  overflow-wrap: anywhere;
}

.debug-field-key {
  display: inline-block;
  min-width: 90px;
  margin-right: 0.4rem;
  color: #94a3b8;
}

body.theme-dark .debug-searchbar {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.04);
}

body.theme-dark .debug-searchbar:focus-within {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}

body.theme-dark .debug-search-input {
  color: #e2e8f0;
}

body.theme-dark .debug-search-icon {
  stroke: #64748b;
}

body.theme-dark .debug-fields-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.3);
  color: #cbd5e1;
}

body.theme-dark .debug-fields-btn:hover,
body.theme-dark .debug-fields-btn[aria-expanded="true"] {
  background: rgba(129, 140, 248, 0.16);
  border-color: #818cf8;
  color: #c7d2fe;
}

body.theme-dark .debug-fields-popover {
  background: #111827;
  border-color: rgba(148, 163, 184, 0.3);
}

body.theme-dark .debug-field-chip {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.3);
  color: #cbd5e1;
}

body.theme-dark .debug-field-chip:hover {
  background: rgba(129, 140, 248, 0.16);
  border-color: #818cf8;
  color: #c7d2fe;
}

body.theme-dark .debug-fields-hint code {
  background: rgba(255, 255, 255, 0.08);
}

body.theme-dark .debug-segment {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.3);
}

body.theme-dark .debug-segment-btn {
  color: #94a3b8;
}

body.theme-dark .debug-segment-btn:hover {
  color: #e2e8f0;
}

body.theme-dark .debug-segment-btn.active {
  background: rgba(15, 23, 42, 0.9);
  color: #c7d2fe;
}

body.theme-dark .debug-filter-limit input {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.04);
  color: #e2e8f0;
}

body.theme-dark .debug-meta {
  color: #94a3b8;
}

body.theme-dark .debug-log-output {
  border-color: rgba(148, 163, 184, 0.35);
  background: #0b1220;
  color: #e2e8f0;
}

body.theme-dark .debug-placeholder,
body.theme-dark .debug-time,
body.theme-dark .debug-type,
body.theme-dark .debug-field {
  color: #94a3b8;
}

body.theme-dark .debug-field-key {
  color: #64748b;
}

body.theme-dark .debug-chip-error {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
}

body.theme-dark .debug-chip-warning {
  background: rgba(251, 191, 36, 0.18);
  color: #fcd34d;
}

body.theme-dark .debug-chip-audit {
  background: rgba(129, 140, 248, 0.2);
  color: #a5b4fc;
}

body.theme-dark .debug-chip-info,
body.theme-dark .debug-chip-noise {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

body.theme-dark .debug-chip.off {
  border-color: rgba(148, 163, 184, 0.35);
  color: #64748b;
}

body.theme-dark .debug-row-error {
  background: rgba(248, 113, 113, 0.1);
}

body.theme-dark .debug-row-warning {
  background: rgba(251, 191, 36, 0.1);
}

body.theme-dark .debug-row-audit {
  background: rgba(129, 140, 248, 0.12);
}

body.theme-dark .debug-row-info {
  border-left-color: rgba(148, 163, 184, 0.3);
}

body.theme-dark .debug-row-error .debug-status {
  background: rgba(248, 113, 113, 0.22);
  color: #fca5a5;
}


.testdata-embed-frame {
  width: 100%;
  height: min(70vh, 760px);
  border: 1px solid #dbe2ef;
  border-radius: 10px;
  background: #fff;
}

body.theme-dark .tab-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
}

body.theme-dark .tab-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

body.theme-dark .tab-btn.active {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
}

body.theme-dark .user-info {
  background: rgba(255, 255, 255, 0.06);
}

body.theme-dark .user-info .stat,
body.theme-dark .user-info .stat strong {
  color: #cbd5e1;
}

body.theme-dark .warning-box {
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.14);
  color: #fef3c7;
}

body.theme-dark .testdata-embed-frame {
  border-color: rgba(148, 163, 184, 0.35);
  background: #0b1220;
}

.logs-toolbar {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.6fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.logs-toolbar .form-group {
  margin-bottom: 0;
}

.round-list {
  border: 1px solid #dbe2ef;
  border-radius: 8px;
  overflow: hidden;
}

.round-columns,
.round-head {
  display: grid;
  grid-template-columns: 18px 150px minmax(80px, 0.8fr) minmax(17ch, 1.2fr) 80px 90px 110px 72px;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.8rem;
}

.round-columns {
  padding: 0.5rem 0.75rem;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.round-row + .round-row {
  border-top: 1px solid #e6ebf5;
}

.round-head {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}

.round-head:hover {
  background: #f8fafc;
}

.round-row.open .round-head {
  background: #eef2ff;
}

.round-caret {
  color: #94a3b8;
  transition: transform 0.15s;
}

.round-row.open .round-caret {
  transform: rotate(90deg);
}

.round-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-id-copy {
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: copy;
  text-decoration: underline dotted rgba(100, 116, 139, 0.6);
  text-underline-offset: 3px;
}

.round-id-copy:hover {
  color: #4f46e5;
  text-decoration: underline solid currentColor;
}

.round-win.has-win {
  color: #15803d;
  font-weight: 600;
}

.round-flag {
  font-size: 0.7rem;
  color: #64748b;
}

.round-detail {
  padding: 0.75rem;
  background: #f8fafc;
  border-top: 1px solid #e6ebf5;
}

.round-detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.round-steps-summary {
  margin: 0 0 0.6rem;
  font-size: 0.8rem;
  color: #475569;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.round-json {
  margin: 0;
  max-height: 44vh;
  overflow: auto;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid #dbe2ef;
  background: #fff;
  color: #0f172a;
  font-size: 12px;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre;
  word-break: normal;
}

body.theme-dark .round-list {
  border-color: rgba(148, 163, 184, 0.35);
}

body.theme-dark .round-columns {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

body.theme-dark .round-row + .round-row {
  border-top-color: rgba(148, 163, 184, 0.22);
}

body.theme-dark .round-head:hover {
  background: rgba(255, 255, 255, 0.05);
}

body.theme-dark .round-row.open .round-head {
  background: rgba(99, 102, 241, 0.18);
}

body.theme-dark .round-id-copy {
  text-decoration-color: rgba(148, 163, 184, 0.6);
}

body.theme-dark .round-id-copy:hover {
  color: #a5b4fc;
}

body.theme-dark .round-win.has-win {
  color: #4ade80;
}

body.theme-dark .round-flag,
body.theme-dark .round-steps-summary {
  color: #94a3b8;
}

body.theme-dark .round-detail {
  background: rgba(255, 255, 255, 0.04);
  border-top-color: rgba(148, 163, 184, 0.22);
}

body.theme-dark .round-json {
  border-color: rgba(148, 163, 184, 0.35);
  background: #0b1220;
  color: #e2e8f0;
}

@media (max-width: 700px) {
  .tabs {
    overflow-x: auto;
    padding-bottom: 0.2rem;
  }

  .debug-searchbar {
    flex-wrap: wrap;
  }

  .debug-search-input {
    flex-basis: 100%;
    order: -1;
    margin-bottom: 0.3rem;
  }

  .debug-filters {
    gap: 0.6rem;
  }

  .logs-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .round-columns {
    display: none;
  }

  .round-head {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.6rem;
  }

  .testdata-embed-frame {
    height: 64vh;
  }
}
