/* ─── Ledger Dashboard — Black & Gold ────────────────────────────
   Surface:        #0c0e12      Gold:           #c9a03c
   Surface Raised: #141820      Gold Light:     #d4b660
   Border:         #1f2736      Gold Dim:       rgba(201,160,60,0.10)
   Navy:           #1a2744      Cream:          #e8e2d8
   Muted:          #6b7a8d
   ────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --navy: #1a2744;
  --navy-light: #243352;
  --brown-deep: #3d2b1f;
  --brown-med: #6b4c3b;
  --gold: #c9a03c;
  --gold-light: #d4b660;
  --gold-dim: rgba(201, 160, 60, 0.10);
  --gold-glow: rgba(201, 160, 60, 0.25);
  --cream: #e8e2d8;
  --cream-dark: #d0c8bb;
  --muted: #6b7a8d;
  --surface: #0c0e12;
  --surface-raised: #141820;
  --surface-solid: #181c24;
  --surface-border: #1f2736;
  --surface-hover: rgba(31, 39, 54, 0.9);
  --text-primary: #e8e2d8;
  --text-secondary: #97a0ad;
  --success: #3cb97a;
  --success-dim: rgba(60, 185, 122, 0.10);
  --danger: #d45555;
  --danger-dim: rgba(212, 85, 85, 0.10);
  --info: #4a8ed4;
  --info-dim: rgba(74, 142, 212, 0.10);
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--surface);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Film-Grain Noise Overlay ───────────────────────── */
.noise-overlay {
  position: fixed;
  inset: 0;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 10000;
}

/* ─── Header ─────────────────────────────────────────── */
.header {
  position: relative;
  background: linear-gradient(180deg, #10131a 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--surface-border);
  padding: 24px 32px;
  overflow: hidden;
}

.header-glow {
  position: absolute;
  top: -40%;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 180px;
  background: radial-gradient(ellipse, rgba(201, 160, 60, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.header-inner {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-banner {
  height: 56px;
  width: auto;
  filter: drop-shadow(0 2px 12px rgba(201, 160, 60, 0.15));
  transition: filter var(--transition);
}

.header-banner:hover {
  filter: drop-shadow(0 4px 20px rgba(201, 160, 60, 0.25));
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ─── Status Orb ─────────────────────────────────────── */
.status-orb {
  position: relative;
  width: 14px;
  height: 14px;
}

.orb-core {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--muted);
  transition: background var(--transition);
}

.orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  opacity: 0.4;
  transition: all var(--transition);
}

.status-orb.running .orb-core {
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

.status-orb.running .orb-ring {
  border-color: var(--gold);
  animation: orbPulse 2s ease-in-out infinite;
}

.status-orb.done .orb-core {
  background: var(--success);
  box-shadow: 0 0 8px rgba(60, 185, 122, 0.4);
}

.status-orb.done .orb-ring {
  border-color: var(--success);
}

@keyframes orbPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.6); opacity: 0; }
}

.status-label {
  font-size: 11px;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
  font-weight: 500;
}

/* ─── Gold Rule ──────────────────────────────────────── */
.gold-rule {
  text-align: center;
  line-height: 0;
  padding: 4px 0;
  background: transparent;
}

.gold-rule-img {
  height: 16px;
  width: auto;
  max-width: 80%;
  opacity: 0.35;
  filter: drop-shadow(0 0 4px rgba(201, 160, 60, 0.1));
}

/* ─── Main Layout ────────────────────────────────────── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px;
}

/* ─── Panels (shared) ────────────────────────────────── */
.panel {
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.panel:hover {
  border-color: rgba(201, 160, 60, 0.12);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.2);
}

.panel-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-icon {
  font-size: 10px;
  opacity: 0.5;
  color: var(--gold);
}

/* ─── Launch Panel ───────────────────────────────────── */
.launch-panel {
  overflow: hidden;
}

.launch-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), var(--gold), var(--gold));
  background-size: 200% 100%;
  animation: shimmer 6s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  margin-bottom: 16px;
  user-select: none;
}

.panel-header:hover .panel-title {
  color: var(--gold-light);
}

.panel-collapse-btn {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 11px;
  cursor: pointer;
  transition: transform var(--transition);
  padding: 4px 8px;
  opacity: 0.5;
}

.panel-collapse-btn.collapsed {
  transform: rotate(-90deg);
}

.panel-body {
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  opacity: 1;
}

.panel-body.collapsed {
  max-height: 0;
  opacity: 0;
}

/* ─── Form ───────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.full { grid-column: span 3; }

.form-group label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}

.form-group input {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:hover {
  border-color: rgba(201, 160, 60, 0.2);
}

.form-group input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-dim);
}

.form-group input::placeholder {
  color: var(--muted);
  opacity: 0.45;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-msg {
  font-size: 12px;
  color: var(--muted);
  margin-left: 4px;
}

.form-msg.ok { color: var(--success); }
.form-msg.err { color: var(--danger); }

/* ─── Buttons ────────────────────────────────────────── */
.btn {
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.4px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

.btn-icon {
  font-size: 10px;
}

.btn-launch {
  background: linear-gradient(135deg, var(--gold), #a88430);
  color: #0c0e12;
  box-shadow: 0 2px 12px rgba(201, 160, 60, 0.25);
}

.btn-launch:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(201, 160, 60, 0.4);
}

.btn-resume {
  background: linear-gradient(135deg, var(--info), #3a78c4);
  color: #fff;
  box-shadow: 0 2px 12px rgba(74, 142, 212, 0.2);
}

.btn-resume:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(74, 142, 212, 0.35);
}

.btn-kill {
  background: linear-gradient(135deg, var(--danger), #b84545);
  color: #fff;
  box-shadow: 0 2px 12px rgba(212, 85, 85, 0.2);
}

.btn-kill:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(212, 85, 85, 0.35);
}

/* ─── Empty State ────────────────────────────────────── */
.empty-state {
  padding: 50px 20px 60px;
  text-align: center;
}

.empty-illustration {
  width: 200px;
  height: auto;
  margin: 0 auto 24px;
  display: block;
  opacity: 0.6;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
  animation: emptyFloat 6s ease-in-out infinite;
}

@keyframes emptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.empty-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.empty-sub {
  font-size: 13px;
  color: var(--muted);
}

#live { display: none; }

/* ─── Action Bar ─────────────────────────────────────── */
.action-bar {
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color var(--transition);
}

.action-bar.active {
  border-color: rgba(201, 160, 60, 0.2);
}

.action-bar.done {
  border-color: rgba(60, 185, 122, 0.2);
}

.action-pulse-ring {
  position: relative;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.action-pulse-core {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--muted);
  transition: background var(--transition);
}

.action-bar.active .action-pulse-core {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
}

.action-bar.active .action-pulse-ring::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--gold);
  animation: orbPulse 2s ease-in-out infinite;
}

.action-bar.done .action-pulse-core {
  background: var(--success);
  box-shadow: 0 0 10px rgba(60, 185, 122, 0.4);
}

.action-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.action-text {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.action-time {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ─── Phase Stepper ──────────────────────────────────── */
.phase-stepper {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: relative;
  margin-bottom: 24px;
  padding: 0 10px;
}

.phase-track {
  position: absolute;
  top: 18px;
  left: 40px;
  right: 40px;
  height: 2px;
  background: var(--surface-border);
  border-radius: 1px;
}

.phase-track-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold));
  border-radius: 1px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px var(--gold-glow);
}

.phase-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1;
  position: relative;
}

.step-node {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--surface-border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.step-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  opacity: 0.3;
  transition: opacity 0.4s ease, filter 0.4s ease;
}

.step-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 600;
  transition: color var(--transition);
}

.phase-step.active .step-node {
  border-color: var(--gold);
  box-shadow: 0 0 20px var(--gold-glow), inset 0 0 10px rgba(201, 160, 60, 0.06);
  animation: stepGlow 2.5s ease-in-out infinite;
}

.phase-step.active .step-icon {
  opacity: 0.9;
  filter: drop-shadow(0 0 4px var(--gold-glow));
}

.phase-step.active .step-label {
  color: var(--gold);
}

@keyframes stepGlow {
  0%, 100% { box-shadow: 0 0 20px var(--gold-glow), inset 0 0 10px rgba(201, 160, 60, 0.06); }
  50% { box-shadow: 0 0 28px rgba(201, 160, 60, 0.35), inset 0 0 14px rgba(201, 160, 60, 0.1); }
}

.phase-step.complete .step-node {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 2px 8px var(--gold-glow);
}

.phase-step.complete .step-icon {
  opacity: 1;
  filter: brightness(0) invert(0.06);
}

.phase-step.complete .step-label {
  color: var(--gold-light);
}

/* ─── Iteration Badge ────────────────────────────────── */
.iteration-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin: -12px 0 20px;
}

.iter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}

.iter-value {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(201, 160, 60, 0.25);
  border-radius: 6px;
  background: var(--gold-dim);
}

/* ─── Hero Stats ─────────────────────────────────────── */
.hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition), transform 0.2s ease, box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Accent left stripe */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: var(--surface-border);
  transition: background var(--transition);
}

.stat-card.accent-gold::before { background: var(--gold); }
.stat-card.accent-navy::before { background: var(--navy-light); }
.stat-card.accent-success::before { background: var(--success); }
.stat-card.accent-brown::before { background: var(--brown-med); }
.stat-card.accent-info::before { background: var(--info); }
.stat-card.accent-danger::before { background: var(--danger); }
.stat-card.accent-gold-alt::before { background: var(--gold); }

.stat-card.accent-gold:hover { border-color: rgba(201, 160, 60, 0.15); }
.stat-card.accent-success:hover { border-color: rgba(60, 185, 122, 0.15); }
.stat-card.accent-navy:hover { border-color: rgba(36, 51, 82, 0.3); }
.stat-card.accent-info:hover { border-color: rgba(74, 142, 212, 0.15); }
.stat-card.accent-brown:hover { border-color: rgba(107, 76, 59, 0.2); }
.stat-card.accent-gold-alt:hover { border-color: rgba(201, 160, 60, 0.2); }

.stat-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
}

.stat-ring {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  opacity: 0.12;
}

.stat-ring svg {
  width: 100%;
  height: 100%;
}

.stat-ring circle {
  fill: none;
  stroke: var(--gold);
  stroke-width: 2;
}

.stat-card.accent-success .stat-ring circle {
  stroke: var(--success);
}

.stat-body {
  flex: 1;
}

.stat-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-weight: 600;
}

.stat-value {
  font-size: 34px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
  font-family: 'EB Garamond', Georgia, serif;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-value-sm {
  font-size: 22px;
}

.stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* ─── Stats Grid ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

/* ─── Split Row ──────────────────────────────────────── */
.split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.split-row > .panel {
  margin-bottom: 0;
}

/* ─── Donut Chart ────────────────────────────────────── */
.donut-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.donut-container {
  position: relative;
  width: 170px;
  height: 170px;
}

.donut-chart {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-bg {
  fill: none;
  stroke: var(--surface-border);
  stroke-width: 18;
  opacity: 0.5;
}

.donut-segment {
  fill: none;
  stroke-width: 18;
  stroke-linecap: butt;
  transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease;
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-total {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.donut-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-top: 2px;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-secondary);
  flex-wrap: wrap;
  justify-content: center;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend span::before {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.legend .l-relevant::before { background: var(--success); }
.legend .l-not-relevant::before { background: var(--muted); }
.legend .l-illegible::before { background: var(--gold); }
.legend .l-error::before { background: var(--danger); }

/* ─── Activity Feed ──────────────────────────────────── */
.activity-feed {
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;
}

.activity-feed::-webkit-scrollbar { width: 4px; }
.activity-feed::-webkit-scrollbar-track { background: transparent; }
.activity-feed::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 2px; }

.activity-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 40px 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 0 9px 18px;
  position: relative;
  border-left: 1px solid var(--surface-border);
  margin-left: 4px;
  animation: activitySlide 0.3s ease-out;
}

@keyframes activitySlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.activity-item::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 13px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface-border);
  border: 1.5px solid var(--surface);
}

.activity-item.latest::before {
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold-glow);
}

.activity-time {
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 65px;
  padding-top: 2px;
}

.activity-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ─── Info Table ─────────────────────────────────────── */
.info-table {
  width: 100%;
  margin-top: 10px;
}

.info-table td {
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(31, 39, 54, 0.5);
  vertical-align: top;
}

.info-table tr:last-child td {
  border-bottom: none;
}

.info-table td:first-child {
  color: var(--muted);
  width: 145px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  padding-top: 9px;
}

/* ─── Log Viewer ─────────────────────────────────────── */
.log-panel {
  overflow: hidden;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--surface-border);
  transition: background var(--transition);
}

.log-header:hover {
  background: rgba(201, 160, 60, 0.02);
}

.log-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.log-file-name {
  font-size: 11px;
  color: var(--muted);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.log-toggle {
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.log-toggle input {
  accent-color: var(--gold);
  cursor: pointer;
}

.btn-log-toggle {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 11px;
  cursor: pointer;
  transition: transform var(--transition);
  padding: 4px 8px;
  opacity: 0.5;
}

.btn-log-toggle.collapsed {
  transform: rotate(-90deg);
}

.log-body {
  transition: max-height 0.4s ease;
  max-height: 600px;
  overflow: hidden;
}

.log-body.collapsed {
  max-height: 0;
}

.log-container {
  height: 400px;
  overflow-y: auto;
  padding: 14px 18px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.7;
  background: rgba(6, 8, 12, 0.8);
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;
}

.log-container::-webkit-scrollbar { width: 4px; }
.log-container::-webkit-scrollbar-track { background: transparent; }
.log-container::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 3px; }

.log-line {
  white-space: pre-wrap;
  word-break: break-all;
  padding: 1px 0;
}

.log-line.log-info { color: #8a94a8; }
.log-line.log-warning { color: var(--gold-light); }
.log-line.log-error { color: #e87070; }
.log-line.log-debug { color: var(--muted); }
.log-line .log-ts { color: #3a4258; }
.log-line .log-level-tag { font-weight: 600; }

/* ─── Toast Notifications ────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--surface-solid);
  border: 1px solid var(--surface-border);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  color: var(--text-primary);
  font-size: 13px;
  animation: toastIn 0.35s ease-out;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  max-width: 340px;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-info { border-left-color: var(--info); }

.toast.toast-out {
  animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

/* ─── Chain Tree Panel ───────────────────────────────── */
.chain-panel {
  overflow: hidden;
}

.chain-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.chain-header .panel-title {
  margin-bottom: 0;
}

.chain-view-toggle {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--surface-border);
}

.btn-view {
  background: none;
  border: none;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.btn-view:hover {
  color: var(--text-secondary);
}

.btn-view.active {
  background: var(--gold-dim);
  color: var(--gold);
}

.btn-refresh-chain {
  background: none;
  border: 1px solid var(--surface-border);
  color: var(--muted);
  font-size: 15px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
}

.btn-refresh-chain:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.chain-body {
  max-height: 600px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;
}

.chain-body::-webkit-scrollbar { width: 4px; }
.chain-body::-webkit-scrollbar-track { background: transparent; }
.chain-body::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 3px; }

.chain-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 40px 0;
}

/* ─── Discovery Tree ────────────────────────────────── */
.tree-node {
  position: relative;
}

.tree-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
  cursor: default;
}

.tree-node-header:hover {
  background: var(--surface-hover);
}

.tree-node-detail {
  padding: 0 10px 4px 30px;
}

.tree-expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 8px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
  cursor: default;
}

.tree-expand.has-children {
  cursor: pointer;
  color: var(--text-secondary);
}

.tree-expand.has-children:hover {
  color: var(--gold);
}

.tree-expand.expanded {
  transform: rotate(90deg);
}

.tree-id {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
}

.tree-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 8px;
}

.tree-badge.status-relevant {
  background: var(--success-dim);
  color: var(--success);
}

.tree-badge.status-not-relevant {
  background: rgba(107, 122, 141, 0.12);
  color: var(--muted);
}

.tree-badge.status-illegible {
  background: var(--gold-dim);
  color: var(--gold);
}

.tree-badge.status-error {
  background: var(--danger-dim);
  color: var(--danger);
}

.tree-badge.status-unknown {
  background: rgba(107, 122, 141, 0.08);
  color: var(--muted);
}

.tree-how-found {
  font-size: 9px;
  color: var(--gold);
  background: var(--gold-dim);
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.tree-date {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tree-type {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tree-parties {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.tree-children {
  padding-left: 20px;
  border-left: 1px solid rgba(31, 39, 54, 0.5);
  margin-left: 9px;
}

.tree-children.collapsed {
  display: none;
}

/* Depth-based accent colors */
.depth-0 > .tree-node-header { border-left: 3px solid var(--gold); padding-left: 12px; }
.depth-1 > .tree-node-header { border-left: 3px solid var(--gold); padding-left: 12px; }
.depth-2 > .tree-node-header { border-left: 3px solid var(--info); padding-left: 12px; }
.depth-3 > .tree-node-header { border-left: 3px solid var(--success); padding-left: 12px; }
.depth-4 > .tree-node-header { border-left: 3px solid var(--brown-med); padding-left: 12px; }
.depth-5 > .tree-node-header { border-left: 3px solid var(--muted); padding-left: 12px; }

/* ─── Title Chain (Timeline) ────────────────────────── */
.title-chain-flow {
  position: relative;
}

.title-chain-card {
  display: flex;
  gap: 14px;
  position: relative;
}

.title-chain-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 20px;
  flex-shrink: 0;
  position: relative;
}

.title-chain-connector {
  width: 2px;
  height: 14px;
  background: var(--surface-border);
}

.title-chain-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--surface-border);
  background: var(--surface);
  flex-shrink: 0;
  z-index: 1;
}

.title-chain-dot.status-relevant {
  border-color: var(--gold);
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold-glow);
}

.title-chain-dot.status-illegible {
  border-color: var(--gold);
  background: var(--gold);
}

.title-chain-card:not(:last-child) .title-chain-line::after {
  content: '';
  position: absolute;
  top: 26px;
  width: 2px;
  bottom: 0;
  background: var(--surface-border);
}

.title-chain-content {
  flex: 1;
  padding: 8px 14px 14px;
  border-radius: var(--radius-sm);
  background: rgba(20, 24, 32, 0.6);
  border: 1px solid var(--surface-border);
  margin-bottom: 4px;
  transition: border-color 0.2s ease;
}

.title-chain-content:hover {
  border-color: rgba(201, 160, 60, 0.15);
}

.title-chain-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.title-chain-parties {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  flex-wrap: wrap;
}

.party-grantor {
  color: var(--text-secondary);
}

.party-arrow {
  color: var(--gold);
  font-size: 13px;
}

.party-grantee {
  color: var(--text-primary);
  font-weight: 500;
}

.title-chain-comments {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  padding-top: 6px;
  border-top: 1px solid rgba(31, 39, 54, 0.4);
}

/* ─── Name List Panel ───────────────────────────────── */
.names-panel {
  overflow: hidden;
}

.names-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.names-header .panel-title {
  margin-bottom: 0;
}

.names-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-left: auto;
}

.names-search {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 6px 12px;
  outline: none;
  transition: border-color var(--transition);
  width: 180px;
}

.names-search:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-dim);
}

.names-search::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

.names-role-filter,
.names-status-filter {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}

.names-role-filter:focus,
.names-status-filter:focus {
  border-color: var(--gold);
}

.names-body {
  max-height: 500px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-border) transparent;
}

.names-body::-webkit-scrollbar { width: 4px; }
.names-body::-webkit-scrollbar-track { background: transparent; }
.names-body::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 3px; }

.names-table {
  width: 100%;
  border-collapse: collapse;
}

.names-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 600;
  padding: 7px 10px;
  border-bottom: 1px solid var(--surface-border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color 0.2s;
}

.names-table th:hover {
  color: var(--gold);
}

.names-table td {
  padding: 7px 10px;
  font-size: 12px;
  border-bottom: 1px solid rgba(31, 39, 54, 0.3);
  vertical-align: middle;
}

.names-td-name {
  font-weight: 500;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
}

.names-td-docs {
  text-align: center;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.names-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 30px 0;
}

.sort-arrow {
  font-size: 9px;
  color: var(--gold);
}

/* Role badges */
.role-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 8px;
}

.role-grantor {
  background: rgba(212, 85, 85, 0.10);
  color: #d47070;
}

.role-grantee {
  background: var(--success-dim);
  color: var(--success);
}

/* Name status badges */
.name-status-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 8px;
}

.name-status-badge.name-searched {
  background: var(--success-dim);
  color: var(--success);
}

.name-status-badge.name-pending {
  background: var(--gold-dim);
  color: var(--gold);
}

.name-status-badge.name-skipped {
  background: rgba(107, 122, 141, 0.12);
  color: var(--muted);
  text-decoration: line-through;
}

/* Row styling */
tr.name-skipped td {
  opacity: 0.5;
}

tr.name-searched td:first-child {
  color: var(--text-secondary);
}

/* Skip button */
.btn-skip {
  background: none;
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-skip:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-dim);
}

.btn-skip.skipped {
  border-color: var(--success);
  color: var(--success);
}

.btn-skip.skipped:hover {
  background: var(--success-dim);
}

/* ─── Footer ─────────────────────────────────────────── */
.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 28px;
}

.footer-rule {
  text-align: center;
  line-height: 0;
  margin-bottom: 16px;
}

.footer-rule .gold-rule-img {
  height: 14px;
  opacity: 0.25;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.footer-mark {
  width: 22px;
  height: 22px;
  opacity: 0.35;
  transition: opacity var(--transition);
}

.footer-mark:hover {
  opacity: 0.6;
}

.footer-text {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.5px;
}

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 900px) {
  .hero-stats { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .split-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .header { padding: 18px 16px; }
  .header-banner { height: 42px; }
  .main { padding: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: span 1; }
  .form-actions { flex-wrap: wrap; }
  .stats-grid { grid-template-columns: 1fr; }
  .phase-stepper { overflow-x: auto; gap: 0; }
  .step-label { font-size: 8px; }
  .step-node { width: 32px; height: 32px; }
  .step-icon { width: 16px; height: 16px; }
  .log-controls { flex-wrap: wrap; gap: 8px; }
  .stat-hero { padding: 16px 18px; }
  .stat-value { font-size: 26px; }
  .chain-header { flex-wrap: wrap; }
  .names-controls { width: 100%; }
  .names-search { width: 100%; }
  .title-chain-parties { flex-direction: column; gap: 2px; }
  .tree-node-header { flex-wrap: wrap; }
}
