/* ── Variables ─────────────────────────────────────────────────── */
:root {
  --bg:           #f1f5f9;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e2e8f0;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --text-inv:     #ffffff;
  --primary:      #3b82f6;
  --primary-dark: #2563eb;
  --success:      #22c55e;
  --success-bg:   #f0fdf4;
  --warning:      #f59e0b;
  --warning-bg:   #fffbeb;
  --danger:       #ef4444;
  --danger-bg:    #fef2f2;
  --info:         #06b6d4;
  --radius:       8px;
  --radius-lg:    12px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --sidebar-w:    260px;
  --header-h:     56px;
}

[data-theme="dark"] {
  --bg:         #0f172a;
  --surface:    #1e293b;
  --surface-2:  #162032;
  --border:     #334155;
  --text:       #f1f5f9;
  --text-muted: #94a3b8;
  --success-bg: #052e16;
  --warning-bg: #431407;
  --danger-bg:  #450a0a;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

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

/* ── Loading ────────────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 12px;
  color: var(--text-muted);
}

.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layout ─────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.sidebar-logo:hover { text-decoration: none; background: var(--surface-2); }
.sidebar-logo .logo-icon { font-size: 20px; }

.sidebar-tester {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}
.sidebar-tester strong { color: var(--text); display: block; }

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-section {
  padding: 6px 16px 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border-radius: 0;
  transition: background .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
[data-theme="dark"] .nav-item.active { background: #1e3a5f; }
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--border);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 10px;
}
.nav-item.active .nav-badge { background: var(--primary); color: #fff; }

.nav-item-sub {
  padding-left: 36px;
  font-size: 13px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Main content */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title { font-weight: 600; flex: 1; font-size: 15px; }

.content {
  padding: 24px;
  flex: 1;
  max-width: 900px;
  width: 100%;
}

/* Mobile header */
.mobile-header {
  display: none;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* ── Home ───────────────────────────────────────────────────────── */
.home-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.home-inner {
  width: 100%;
  max-width: 480px;
}

.home-logo {
  text-align: center;
  margin-bottom: 32px;
}
.home-logo .logo-icon-lg { font-size: 48px; display: block; margin-bottom: 8px; }
.home-logo h1 { font-size: 22px; font-weight: 700; }
.home-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.home-card { margin-bottom: 20px; }

.tester-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.tester-input-row .input { flex: 1; }

.existing-testers {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.existing-testers .label-sm {
  font-size: 12px;
  color: var(--text-muted);
  width: 100%;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.guide-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 20px 16px;
  text-decoration: none;
  color: var(--text);
  border: 2px solid var(--border);
  transition: border-color .15s, transform .15s;
}
.guide-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  text-decoration: none;
}
.guide-card .guide-icon { font-size: 32px; }
.guide-card h3 { font-size: 15px; font-weight: 600; }
.guide-card p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

/* ── Progress bars ──────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .3s ease;
}
.progress-fill.complete { background: var(--success); }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Workflow List ──────────────────────────────────────────────── */
.overview-header {
  margin-bottom: 20px;
}
.overview-header h1 { font-size: 20px; font-weight: 700; }
.overview-header .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.overview-progress {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.overview-progress h3 { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.overview-progress .pct { font-size: 24px; font-weight: 700; }

.workflow-list { display: flex; flex-direction: column; gap: 8px; }

.workflow-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.workflow-item:hover { border-color: var(--primary); box-shadow: var(--shadow-md); text-decoration: none; }
.workflow-item.complete { border-color: var(--success); }

.wf-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}
.workflow-item.complete .wf-num { background: var(--success-bg); border-color: var(--success); color: var(--success); }

.wf-body { flex: 1; min-width: 0; }
.wf-title { font-weight: 500; font-size: 14px; }
.wf-meta { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.wf-progress { width: 80px; flex-shrink: 0; }

/* ── Workflow Detail ─────────────────────────────────────────────── */
.workflow-detail-header {
  margin-bottom: 20px;
}
.workflow-detail-header h1 { font-size: 19px; font-weight: 700; }
.workflow-detail-header .purpose { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.part-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}

.part-header {
  padding: 14px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.part-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.part-title { font-weight: 600; font-size: 14px; }

.part-body { padding: 16px 20px; }

.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 16px;
}
.section-label:first-child { margin-top: 0; }

/* Steps */
.steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.step-item {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  align-items: flex-start;
}
.btn-bug-step {
  flex-shrink: 0;
  margin-left: auto;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 5px;
  opacity: 0;
  transition: opacity 0.15s;
}
.step-item:hover .btn-bug-step {
  opacity: 0.5;
}
.btn-bug-step:hover {
  opacity: 1 !important;
  background: var(--surface-2);
  border-color: var(--border);
}
.step-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  margin-top: 1px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}
.step-num:hover { background: var(--border); }
.step-num-done {
  background: var(--success, #22c55e);
  border-color: var(--success, #22c55e);
  color: #fff;
}
.step-num-done:hover { opacity: 0.8; }
.step-done > span:nth-child(2) { text-decoration: line-through; color: var(--text-muted); }

/* Note / warning callout */
.callout {
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 12px;
  color: var(--text);
}
.callout.info { background: #eff6ff; border-color: var(--primary); }
[data-theme="dark"] .callout.info { background: #1e3a5f; }

/* Checklist / Expected results */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background .1s;
  cursor: pointer;
}
.check-item:hover { background: #eff6ff; border-color: var(--primary); }
[data-theme="dark"] .check-item:hover { background: #1e3a5f; }

.check-item.checked {
  background: var(--success-bg);
  border-color: var(--success);
}

.check-item input[type="checkbox"] {
  width: 16px; height: 16px;
  flex-shrink: 0;
  accent-color: var(--success);
  margin-top: 2px;
  cursor: pointer;
}

.check-text {
  font-size: 14px;
  line-height: 1.5;
  flex: 1;
}
.check-item.checked .check-text {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* Expected results (mobile, no strike-through) */
.expected-item.checked .check-text {
  text-decoration: none;
  color: var(--text);
}
.expected-item.checked { background: var(--success-bg); border-color: var(--success); }

/* Failure points */
.failure-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.failure-item {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.failure-item::before {
  content: "⚠";
  color: var(--warning);
  flex-shrink: 0;
}

/* Preconditions */
.precondition-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.precondition-item {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.precondition-item::before { content: "→"; color: var(--primary); flex-shrink: 0; }

/* Log bug row */
.log-bug-row {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Final Checklist ─────────────────────────────────────────────── */
.final-section {
  margin-bottom: 20px;
}
.final-section-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── Bug Log ─────────────────────────────────────────────────────── */
.bug-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.bug-table-wrap {
  overflow-x: auto;
}
.bug-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.bug-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.bug-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.bug-table tr:hover td { background: var(--surface-2); }
.bug-table tr.bug-resolved td { opacity: 0.5; }
.bug-table tr.bug-resolved td:first-child span { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.bug-table tr.bug-resolved:hover td { opacity: 0.8; }

.bug-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.bug-empty .empty-icon { font-size: 40px; display: block; margin-bottom: 8px; }

/* ── Severity badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-critical { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-high     { background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; }
.badge-medium   { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }
.badge-low      { background: #f0fdf4; color: #166534; border: 1px solid #86efac; }
[data-theme="dark"] .badge-critical { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-high     { background: #431407; color: #fdba74; }
[data-theme="dark"] .badge-medium   { background: #422006; color: #fcd34d; }
[data-theme="dark"] .badge-low      { background: #052e16; color: #86efac; }

/* Type badges */
.badge-bug         { background: #fef2f2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-improvement { background: #eff6ff; color: #1e40af; border: 1px solid #93c5fd; }
[data-theme="dark"] .badge-bug         { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-improvement { background: #1e3a5f; color: #93c5fd; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: none; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost     { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-outline-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.btn-outline-sm:hover { border-color: var(--primary); color: var(--primary); }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 16px;
}
.btn-icon:hover { color: var(--text); background: var(--surface-2); }

/* ── Inputs ──────────────────────────────────────────────────────── */
.input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.input[readonly] { background: var(--surface-2); color: var(--text-muted); cursor: default; }
.textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.form-row { margin-bottom: 12px; }
.form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 500; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.required { color: var(--danger); }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }

.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
}

/* ── Misc ────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 20px; font-weight: 700; flex: 1; }

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { margin: 0 4px; }

.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 13px; }

.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-3 { margin-bottom: 12px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; display: block; margin-bottom: 8px; }

/* Sidebar overlay toggle for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.visible { display: block; }

  .mobile-header { display: flex; }

  .main { margin-left: 0; }

  .content { padding: 16px; }

  .topbar { display: none; }

  .guide-grid { grid-template-columns: 1fr; }
  .form-row.two-col { grid-template-columns: 1fr; }
  .wf-progress { display: none; }

  .bug-table th:nth-child(n+5),
  .bug-table td:nth-child(n+5) { display: none; }
}

/* ── Toast notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  background: #1e293b;
  color: #f1f5f9;
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
  max-width: 320px;
}
.toast.success { background: #15803d; }
.toast.error   { background: #b91c1c; }
@keyframes slideIn {
  from { transform: translateX(80px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Hamburger button ────────────────────────────────────────────── */
.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
