:root {
  --bg: #04100b;
  --card: #082016;
  --card-elevated: #0c2c1f;
  --text: #f3f7f5;
  --muted: #9ab5a8;
  --border: rgba(212, 175, 55, 0.28);
  --border-strong: rgba(212, 175, 55, 0.68);
  --gold: #f3c65f;
  --gold-deep: #d4af37;
  --primary: #f3c65f;
  --primary-text: #06150e;
  --good: #34d399;
  --good-bg: rgba(16, 185, 129, 0.22);
  --warn: #fbbf24;
  --warn-bg: rgba(245, 158, 11, 0.22);
  --bad: #f87171;
  --bad-bg: rgba(220, 38, 38, 0.25);
  --skip: #94a3b8;
  --skip-bg: rgba(148, 163, 184, 0.16);
  --custom: #60a5fa;
  --radius: 14px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.48), inset 0 1px 0 rgba(243, 198, 95, 0.12);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
}

* {
  box-sizing: border-box;
}

/* Classes below set `display`, which would otherwise override the hidden attribute. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(20, 83, 55, 0.65) 0%, rgba(6, 24, 16, 0.85) 55%, #030b07 100%),
    repeating-linear-gradient(
      45deg,
      rgba(212, 175, 55, 0.018) 0px,
      rgba(212, 175, 55, 0.018) 2px,
      transparent 2px,
      transparent 14px
    );
  background-attachment: fixed;
}

/* Elements scrolled into view (run panel, #/console/TC04) stay clear of the sticky header. */
html {
  scroll-padding-top: 84px;
}

a {
  color: var(--gold);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1,
h2,
h3,
h4 {
  line-height: 1.25;
  margin: 0;
  letter-spacing: 0.01em;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  color: var(--gold);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.muted {
  color: var(--muted);
}
.ok {
  color: var(--good);
  font-weight: 700;
}
.ko {
  color: var(--bad);
  font-weight: 700;
}

/* ------------------------------------------------------------ header */

.site-header {
  background: linear-gradient(180deg, #061911 0%, #030d09 100%);
  border-bottom: 1.5px solid var(--border-strong);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.02em;
  text-shadow: 0 2px 10px rgba(243, 198, 95, 0.2);
}
.brand:hover {
  text-decoration: none;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2.5px dashed var(--gold);
  background: radial-gradient(circle at 30% 30%, #ef4444, #991b1b);
  color: #fff;
  font-size: 17px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(12, 44, 31, 0.85);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.btn:hover {
  text-decoration: none;
  border-color: var(--gold);
  background: rgba(212, 175, 55, 0.14);
}
.btn-primary {
  background: linear-gradient(135deg, #f6d365 0%, #d4af37 100%);
  border-color: var(--gold);
  color: #05120c;
  font-weight: 800;
  box-shadow: 0 3px 12px rgba(212, 175, 55, 0.3);
}
.btn-primary:hover {
  filter: brightness(1.08);
  border-color: #fde047;
  background: linear-gradient(135deg, #fde047 0%, #eab308 100%);
}
.btn-gold {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.26) 0%, rgba(212, 175, 55, 0.1) 100%);
  border-color: var(--gold);
  color: var(--gold);
  font-weight: 800;
}
.btn-gold:hover {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.4) 0%, rgba(212, 175, 55, 0.2) 100%);
}
.btn-gold-active {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  border-color: #4ade80;
  color: #ffffff;
  font-weight: 800;
}
.btn-crimson-active {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
  border-color: #f87171;
  color: #ffffff;
  font-weight: 800;
}
.btn-outline-gold {
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(212, 175, 55, 0.4);
  color: var(--muted);
}
.btn-sm {
  padding: 3px 10px;
  font-size: 0.82rem;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}
.btn-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--gold);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.btn-link:hover {
  text-decoration: underline;
}

/* "Running" badge on the header's Run button while a run started here is in progress. */
.run-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border-radius: 99px;
  background: rgba(5, 18, 12, 0.25);
  font-size: 0.75rem;
  font-weight: 700;
}
.run-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
}
.lang-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.lang-switch button + button {
  border-left: 1px solid var(--border);
}
.lang-switch button[aria-pressed='true'] {
  background: var(--gold);
  color: #05120c;
  font-weight: 800;
}

input:not([type='checkbox']):not([type='radio']),
select,
textarea {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: #04140d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 0;
}
textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.5;
}
input[type='checkbox'] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--gold);
  cursor: pointer;
}
[aria-invalid='true'] {
  border-color: var(--bad) !important;
  box-shadow: 0 0 0 1px var(--bad);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--gold) 55%, transparent);
  outline-offset: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner,
  .run-dot::before {
    animation-duration: 3s !important;
  }
}

/* ------------------------------------------------------------ layout */

#app {
  padding-top: 28px;
  padding-bottom: 44px;
}
main > section,
main > .card {
  margin-bottom: 22px;
}

.card {
  background: linear-gradient(180deg, rgba(13, 48, 33, 0.92) 0%, rgba(7, 27, 19, 0.96) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.hero {
  position: relative;
  padding: 24px 26px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 88% 20%, rgba(212, 175, 55, 0.16) 0%, transparent 50%),
    linear-gradient(135deg, #0d3524 0%, #061a12 100%);
  border: 1.5px solid var(--border-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.hero-suits {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(212, 175, 55, 0.14);
  color: var(--gold);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}
.hero h1 {
  font-size: 1.85rem;
  margin-bottom: 8px;
  color: var(--gold);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.lead {
  margin: 0;
  color: var(--text);
  opacity: 0.9;
  max-width: 920px;
}

/* ------------------------------------------------------------ Live Casino Table Arena */

.casino-arena {
  border: 2px solid var(--gold-deep);
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(23, 97, 70, 0.55) 0%, rgba(5, 20, 14, 0.96) 75%);
  padding: 20px;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.6),
    inset 0 0 28px rgba(212, 175, 55, 0.08);
}
.arena-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.arena-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.2);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.arena-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gold);
  margin-bottom: 6px;
}
.arena-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 760px;
}
.arena-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.arena-frame-wrap {
  border: 1.5px solid rgba(212, 175, 55, 0.55);
  border-radius: 14px;
  overflow: hidden;
  background: #04100b;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
}
.live-table-frame {
  display: block;
  width: 100%;
  height: 700px;
  border: 0;
  background: #04100b;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.section-head h2,
.section-title {
  font-size: 1.15rem;
  color: var(--gold);
}
.section-title {
  margin-bottom: 12px;
}

.loading {
  padding: 40px 0;
  text-align: center;
}

.empty {
  text-align: center;
  padding: 40px 20px;
}
.empty h2 {
  margin-bottom: 8px;
  color: var(--gold);
}
.empty p {
  margin: 0 0 16px;
}

/* ------------------------------------------------------------ KPIs (VIP Casino Plaques) */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.kpi {
  position: relative;
  overflow: hidden;
  display: block;
  color: inherit;
  border-top: 3px solid var(--gold-deep);
  background:
    radial-gradient(circle at 100% 0%, rgba(212, 175, 55, 0.14), transparent 55%),
    linear-gradient(180deg, #0d3222 0%, #071b12 100%);
}
.kpi::after {
  position: absolute;
  right: 12px;
  bottom: 4px;
  font-size: 3.4rem;
  line-height: 1;
  opacity: 0.1;
  pointer-events: none;
}
.kpi-plaque-spade::after {
  content: '♠';
  color: var(--gold);
}
.kpi-plaque-heart::after {
  content: '♥';
  color: #f87171;
}
.kpi-plaque-club::after {
  content: '♣';
  color: #34d399;
}
.kpi-plaque-diamond::after {
  content: '♦';
  color: #60a5fa;
}
a.kpi:hover {
  text-decoration: none;
  border-color: var(--gold);
  transform: translateY(-2px);
}
.kpi-label {
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kpi-value {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 4px 0;
  font-variant-numeric: tabular-nums;
}
.kpi-value-sm {
  font-size: 1.2rem;
  padding: 9px 0 8px;
  white-space: nowrap;
}
.kpi-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ------------------------------------------------------------ colors by pass rate */

.rate-text-good {
  color: var(--good);
}
.rate-text-warn {
  color: var(--warn);
}
.rate-text-bad {
  color: var(--bad);
}
.rate-text-na {
  color: var(--gold);
}
.bg-good {
  background: linear-gradient(180deg, #34d399 0%, #059669 100%);
}
.bg-warn {
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
}
.bg-bad {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
}
.bg-na {
  background: linear-gradient(180deg, #f3c65f 0%, #b48618 100%);
}

/* ------------------------------------------------------------ trend */

.trend {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  padding: 12px 10px 0;
  border-radius: 10px 10px 0 0;
  border-bottom: 1.5px solid var(--border-strong);
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.15)),
    linear-gradient(to top, transparent calc(50% - 1px), var(--border) calc(50% - 1px), var(--border) 50%, transparent 50%);
}
.trend .bar {
  flex: 1 1 0;
  max-width: 38px;
  height: var(--h);
  border-radius: 8px 8px 0 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom: 0;
  opacity: 0.9;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: opacity 0.15s, transform 0.15s;
}
.trend .bar:hover {
  opacity: 1;
  transform: scaleY(1.03);
}

/* ------------------------------------------------------------ tables */

.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
}
.table th,
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.table th {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.25);
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
}
tr.clickable {
  cursor: pointer;
}
tr.clickable:hover td {
  background: rgba(212, 175, 55, 0.1);
}

.rate {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}
.rate-bar {
  flex: 1;
  height: 9px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 175, 55, 0.25);
  overflow: hidden;
}
.rate-bar span {
  display: block;
  height: 100%;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--skip-bg);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
  vertical-align: middle;
  white-space: nowrap;
}
.tag-manual {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(96, 165, 250, 0.45);
  color: #93c5fd;
}
.tag-scheduled {
  background: rgba(168, 85, 247, 0.22);
  border-color: rgba(192, 132, 252, 0.45);
  color: #d8b4fe;
}
.tag-warn {
  background: var(--warn-bg);
  border-color: rgba(251, 191, 36, 0.45);
  color: var(--warn);
  margin-left: 6px;
}
.tag-bad {
  background: var(--bad-bg);
  border-color: rgba(248, 113, 113, 0.45);
  color: var(--bad);
}
.tag-blocked {
  margin-left: 6px;
}
.tag-custom {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(96, 165, 250, 0.45);
  color: var(--custom);
  margin-left: 6px;
}

/* ------------------------------------------------------------ run view */

.back {
  display: inline-block;
  margin-bottom: 14px;
  font-weight: 700;
}

.run-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  border-top: 3px solid var(--gold);
}
.run-head > div:first-child {
  flex: 1 1 520px;
  min-width: 0;
}
.run-head h1 {
  font-size: 1.65rem;
  margin-bottom: 12px;
  color: var(--gold);
}
.meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px 24px;
  margin: 0;
}
.meta dt {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.meta dd {
  margin: 0;
  font-weight: 600;
}
.score {
  text-align: right;
  min-width: 180px;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-strong);
}
.score-value {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.score-sub {
  margin: 4px 0;
}

.rounds {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.round-card a {
  white-space: nowrap;
}
.round-card {
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  border-top: 4px solid var(--good);
}
.round-card.round-bad {
  border-top-color: var(--bad);
}
.round-title {
  font-weight: 800;
  color: var(--gold);
}
.round-stats {
  display: flex;
  gap: 12px;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--muted);
}
.legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend .cell {
  width: 24px;
  height: 24px;
  font-size: 0.78rem;
  cursor: default;
}

.matrix {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.925rem;
}
.matrix th,
.matrix td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.matrix thead th {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.84rem;
  vertical-align: bottom;
  background: rgba(0, 0, 0, 0.28);
}
.matrix .round-col a {
  color: var(--gold);
}
.matrix .round-col small {
  display: block;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--muted);
}
.matrix .case-col {
  text-align: left;
  position: sticky;
  left: 0;
  background: #082016;
  z-index: 1;
  min-width: 260px;
  font-weight: 500;
}
.matrix .module-row th {
  text-align: left;
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.2) 0%, rgba(4, 16, 11, 0.85) 100%);
  border-left: 4px solid var(--gold);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding-top: 9px;
  padding-bottom: 9px;
}
.case-id {
  display: inline-block;
  min-width: 48px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold);
}
.case-title {
  cursor: help;
}

/* 3D Baccarat Bead Road Discs for Matrix Cells */
.cell {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.35),
    0 3px 7px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s, box-shadow 0.15s;
}
.matrix tbody tr:not(.module-row):hover th,
.matrix tbody tr:not(.module-row):hover td {
  background: rgba(212, 175, 55, 0.1);
}
button.cell:hover {
  transform: scale(1.15);
  border-color: var(--gold);
}
.cell-passed {
  background: radial-gradient(circle at 30% 30%, #34d399, #059669);
  color: #ffffff;
}
.cell-failed {
  background: radial-gradient(circle at 30% 30%, #f87171, #b91c1c);
  color: #ffffff;
}
.cell-skipped {
  background: radial-gradient(circle at 30% 30%, #64748b, #334155);
  color: #e2e8f0;
}
.cell-none {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  cursor: default;
  box-shadow: none;
}

/* ------------------------------------------------------------ detail dialog */

.detail-dialog {
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
}
.detail-dialog::backdrop {
  background: rgb(15 20 25 / 55%);
}
.dialog-inner {
  padding: 22px;
  display: grid;
  gap: 16px;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.dialog-head h3 {
  font-size: 1.25rem;
  margin: 2px 0 6px;
}
.dialog-inner h4 {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.dialog-inner p {
  margin: 0;
}
.btn-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  align-self: flex-start;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.status {
  font-weight: 700;
}
.status-passed {
  color: var(--good);
}
.status-failed {
  color: var(--bad);
}
.status-skipped {
  color: var(--skip);
}
pre.error {
  margin: 0;
  padding: 12px 14px;
  background: var(--bad-bg);
  color: var(--text);
  border-radius: 8px;
  overflow: auto;
  max-height: 260px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}
.shot {
  display: block;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.data-list {
  margin: 0;
  display: grid;
  gap: 6px;
}
.data-list > div {
  display: flex;
  gap: 4px 12px;
  flex-wrap: wrap;
}
.data-list dt {
  color: var(--muted);
  min-width: 150px;
}
.data-list dd {
  margin: 0;
  font-weight: 500;
}
.param-value {
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--custom) 13%, transparent);
  padding: 0 3px;
  border-radius: 4px;
}

/* ------------------------------------------------------------ home: run in progress */

.running-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  border-left: 4px solid var(--primary);
  padding: 14px 18px;
}
.running-banner:hover {
  text-decoration: none;
  border-color: var(--primary);
}
.running-banner-link {
  margin-left: auto;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
}
.spinner {
  display: inline-block;
  flex: none;
  width: 0.95em;
  height: 0.95em;
  border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ------------------------------------------------------------ test console */

#console-root > section,
#run-panel > section {
  margin-bottom: 20px;
}
.small {
  font-size: 0.85rem;
}
.console-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.console-row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.token-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.token-line .tag-warn {
  margin-left: 0;
}

.module-block + .module-block {
  margin-top: 22px;
}
.module-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 8px;
  border-bottom: 2px solid var(--border);
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.module-name {
  font-weight: 700;
}
.case-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.case-item + .case-item {
  border-top: 1px solid var(--border);
}
.case-item.open {
  background: color-mix(in srgb, var(--primary) 4%, transparent);
}
.case-line {
  display: flex;
  align-items: center;
  gap: 6px 8px;
  padding: 9px 6px;
}
.case-check {
  flex: 1 1 0;
  min-width: 0;
}
.case-check .case-id {
  min-width: 40px;
}
.case-name {
  font-weight: 500;
}
.case-line .tag {
  margin-left: 0;
}
.case-toggle {
  white-space: nowrap;
}
.case-body {
  display: grid;
  gap: 10px;
  padding: 2px 6px 18px 30px;
}
.desc-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.desc-view {
  display: grid;
  gap: 4px;
  justify-items: start;
}
.case-checks {
  margin: 0;
  white-space: pre-line;
}
.save-notice {
  margin: 4px 0 0;
  color: var(--good);
  font-size: 0.85rem;
}
.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px 18px;
}
.param {
  display: grid;
  gap: 4px;
  align-content: start;
}
.param > label {
  font-size: 0.85rem;
  font-weight: 600;
}
.param-control {
  display: flex;
  gap: 8px;
  align-items: center;
}
.param-control input,
.param-control select {
  flex: 1;
}
.param small {
  font-size: 0.78rem;
}
.param-warn {
  color: var(--warn);
}
.param-error {
  color: var(--bad);
  font-weight: 600;
}
p.param-error {
  font-size: 0.9rem;
}
.no-params {
  margin: 0;
  font-size: 0.9rem;
}
.case-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.875rem;
}
.console-foot {
  margin: 16px 0 0;
  font-size: 0.875rem;
}

/* Run bar: stays at the bottom of the window while the case list scrolls. */
.console-bar {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgb(31 35 40 / 16%);
}
.console-summary {
  font-size: 0.9rem;
}
.btn-run {
  padding: 9px 24px;
  font-size: 1rem;
  font-weight: 600;
}

/* ------------------------------------------------------------ run progress panel */

.run-panel {
  border-left: 4px solid var(--primary);
}
.run-panel-done {
  border-left-color: var(--good);
}
.run-panel-bad {
  border-left-color: var(--bad);
}
.run-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 4px;
}
.run-panel-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
}
.run-panel p {
  margin: 4px 0;
}
.run-panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.phases {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 14px 0 6px;
  padding: 0;
}
.phase {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.phase-dot {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
}
.phase-done {
  color: var(--text);
}
.phase-done .phase-dot {
  background: var(--good);
  border-color: var(--good);
  color: #fff;
}
.phase-active {
  color: var(--text);
  font-weight: 600;
}
.phase-active .phase-dot {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.run-result {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 6px 0;
}
.result-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px 3px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
}
.chip:hover {
  border-color: var(--primary);
  text-decoration: none;
}
.chip .case-id {
  min-width: 0;
  margin-right: 3px;
}
.cell-xs {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: 0.62rem;
  cursor: inherit;
}

/* ------------------------------------------------------------ title and description editor */

.desc-editor {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 4%, var(--card));
}
.desc-editor p {
  margin: 0;
}
.desc-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}
.desc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.desc-lang {
  display: grid;
  gap: 4px;
  min-width: 0;
  margin: 0;
  padding: 8px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}
.desc-lang legend {
  padding: 0 4px;
  font-size: 0.85rem;
  font-weight: 700;
}
.desc-lang label {
  margin-top: 4px;
  font-size: 0.82rem;
  font-weight: 600;
}
.desc-lang input {
  width: 100%;
}
.desc-count {
  justify-self: end;
  font-size: 0.75rem;
}
.desc-preview {
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg);
  font-size: 0.85rem;
  white-space: pre-line;
}
.ph-chip {
  padding: 0 6px;
  border: 1px dashed var(--primary);
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  cursor: pointer;
}
.ph-chip:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}
.desc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* ------------------------------------------------------------ token dialog */

.token-dialog {
  width: min(620px, calc(100vw - 32px));
}
.token-steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 22px;
}
.field-label {
  margin-bottom: -10px;
  font-weight: 600;
  font-size: 0.9rem;
}
.token-input {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
}
.token-remember {
  margin-bottom: -10px;
}

/* ------------------------------------------------------------ footer */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 28px 0 36px;
  font-size: 0.925rem;
}
.site-footer h2 {
  font-size: 1rem;
  margin-bottom: 10px;
}
.site-footer ul {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--muted);
}

/* ------------------------------------------------------------ target & bug detection (#/bugs) */

.nav-link[aria-current='page'] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, var(--card));
  font-weight: 600;
}

.stats-note {
  margin: -6px 0 12px;
  font-size: 0.875rem;
}

.tag-target-with-bugs {
  background: var(--warn-bg);
  color: var(--warn);
}
.tag-target-only {
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--warn);
}

.console-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
}
.target-note {
  margin: 10px 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.target-note-na {
  color: var(--warn);
}
.case-item.case-na .case-check {
  opacity: 0.55;
  cursor: not-allowed;
}

.bug-teaser {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  border-left: 4px solid var(--warn);
}
.bug-teaser:hover {
  text-decoration: none;
  border-color: var(--primary);
}
.bug-teaser-icon {
  font-size: 1.4rem;
  line-height: 1;
}
.bug-teaser-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.bug-teaser-stat {
  font-size: 0.85rem;
  color: var(--muted);
}

.bug-note {
  border-left: 4px solid var(--warn);
}
.bug-note p {
  margin: 2px 0;
}

.bug-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}
.bug-badge-caught {
  background: var(--good-bg);
  color: var(--good);
}
.bug-badge-blocked {
  background: var(--warn-bg);
  color: var(--warn);
}
.bug-badge-unclassified {
  background: var(--bad-bg);
  color: var(--bad);
}

.bug-detail-list {
  margin: 6px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
}
.bug-detail-list .bug-badge {
  margin-left: 0;
  margin-right: 4px;
}

.bugs-source {
  margin: 6px 0 0;
  font-size: 0.875rem;
}
.section-hint {
  margin: -4px 0 12px;
  font-size: 0.875rem;
}

.verdict {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-left: 4px solid var(--good);
}
.verdict-bad {
  border-left-color: var(--bad);
}
.verdict p {
  margin: 2px 0;
}
.verdict-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--good-bg);
  color: var(--good);
  font-weight: 800;
}
.verdict-bad .verdict-icon {
  background: var(--bad-bg);
  color: var(--bad);
}
.verdict-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill-caught,
.pill-passed {
  background: var(--good-bg);
  color: var(--good);
}
.pill-blocked {
  background: var(--warn-bg);
  color: var(--warn);
}
.pill-missed,
.pill-unclassified {
  background: var(--bad-bg);
  color: var(--bad);
}
.pill-notRun {
  background: var(--skip-bg);
  color: var(--skip);
}

.sev {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-weight: 700;
}
.sev-high {
  background: var(--bad-bg);
  color: var(--bad);
}
.sev-medium {
  background: var(--warn-bg);
  color: var(--warn);
}
.sev-low {
  background: var(--skip-bg);
  color: var(--skip);
}

.bug-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
}
.bug-key {
  font-size: 0.82rem;
}
.table td.wrap {
  white-space: normal;
  min-width: 220px;
}
.prod-result {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}
.prod-result .case-id {
  min-width: 0;
}
.evidence {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 6px;
}
.evidence-thumb {
  width: 44px;
  height: 28px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.note-message {
  font-size: 0.8rem;
  word-break: break-word;
}

.scope-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.scope-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 4px;
}
.scope-item p {
  margin: 0;
  font-size: 0.875rem;
}
.scope-uncovered {
  border-color: var(--bad);
}
.scope-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.scope-ids {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  color: var(--muted);
  word-spacing: 4px;
}

@media (max-width: 640px) {
  .site-header {
    position: static;
  }
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .kpi {
    padding: 14px;
  }
  .kpi-value {
    font-size: 1.5rem;
  }
  .kpi-value-sm {
    font-size: 0.95rem;
    white-space: normal;
  }
  .hero h1 {
    font-size: 1.4rem;
  }
  .score {
    text-align: left;
  }
  .matrix .case-col {
    min-width: 200px;
  }
  .case-body {
    padding-left: 6px;
  }
  .console-bar {
    bottom: 0;
  }
  .btn-run {
    width: 100%;
    justify-content: center;
  }
  .bug-teaser {
    flex-wrap: wrap;
  }
  .stack-table thead {
    display: none;
  }
  .stack-table,
  .stack-table tbody,
  .stack-table tr,
  .stack-table td {
    display: block;
    width: 100%;
  }
  .stack-table tr {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .stack-table tr:last-child {
    border-bottom: 0;
  }
  .stack-table td {
    padding: 3px 4px;
    border-bottom: 0;
    white-space: normal;
    min-width: 0 !important;
  }
  .stack-table td::before {
    content: attr(data-label) '：';
    color: var(--muted);
    font-weight: 600;
    font-size: 0.82rem;
    margin-right: 4px;
  }
}
