:root {
  --tb-primary: #14478F;
  --tb-primary-dark: #0d3266;
  --tb-secondary: #6BB7E8;
  --tb-accent: #F5A623;
  --tb-surface: #F5F8FC;
  --tb-text: #1A2540;
  --tb-muted: #5a6b85;
  --tb-border: rgba(20, 71, 143, 0.12);
  --tb-good: #16a34a;
  --tb-partial: #F5A623;
  --tb-poor: #dc2626;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #e8edf4;
  color: var(--tb-text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--tb-primary); }
.topbar {
  background: var(--tb-primary-dark);
  color: white;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 0.5rem; }
.topbar-logo { height: 28px; width: auto; }
.topbar .brand-text span { color: var(--tb-secondary); }
.topbar .brand span { color: var(--tb-secondary); }
.topbar nav a { color: rgba(255,255,255,0.85); margin-left: 1.25rem; text-decoration: none; font-size: 0.88rem; font-weight: 500; }
.topbar nav a:hover { color: white; }
.container { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.card {
  background: white;
  border-radius: 10px;
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 12px rgba(20,71,143,0.08);
  border: 1px solid var(--tb-border);
}
.card h1 { font-size: 1.5rem; color: var(--tb-primary); margin-bottom: 0.5rem; }
.card h2 { font-size: 1.15rem; color: var(--tb-primary); margin-bottom: 0.75rem; }
.card p.lead { color: var(--tb-muted); margin-bottom: 1rem; }
.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.flash.success { background: #dcfce7; color: #166534; }
.flash.error { background: #fef2f2; color: #991b1b; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-field { margin-bottom: 0.5rem; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--tb-muted); margin-bottom: 0.35rem; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 0.55rem 0.75rem; border: 1px solid var(--tb-border);
  border-radius: 6px; font-family: inherit; font-size: 0.92rem;
}
.form-field textarea { min-height: 4rem; resize: vertical; }
.triage-grid { display: grid; gap: 0.65rem; margin: 1rem 0; }
.triage-row {
  display: flex; align-items: flex-start; gap: 1rem;
  padding: 0.85rem 1rem; border: 1.5px solid var(--tb-border); border-radius: 8px;
}
.triage-row:hover { border-color: var(--tb-secondary); }
.triage-row .q { flex: 1; font-size: 0.9rem; font-weight: 500; }
.triage-row .yn { display: flex; gap: 0.75rem; flex-shrink: 0; }
.triage-row .yn label { font-size: 0.85rem; display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.btn {
  display: inline-block; padding: 0.6rem 1.15rem; border-radius: 6px;
  font-weight: 600; font-size: 0.88rem; border: none; cursor: pointer;
  text-decoration: none; font-family: inherit;
}
.btn-primary { background: var(--tb-primary); color: white; }
.btn-accent { background: var(--tb-accent); color: var(--tb-primary-dark); }
.btn-secondary { background: var(--tb-surface); color: var(--tb-primary); border: 1px solid var(--tb-border); }
.btn:hover { opacity: 0.92; }
.actions { display: flex; gap: 0.65rem; flex-wrap: wrap; margin-top: 1.25rem; }
.section-card { margin-bottom: 1.5rem; }
.section-card .section-head {
  background: var(--tb-surface); padding: 0.85rem 1rem;
  border-radius: 8px 8px 0 0; border: 1px solid var(--tb-border); border-bottom: none;
}
.section-card .section-head h3 { font-size: 1rem; color: var(--tb-primary); }
.section-card .section-head p { font-size: 0.82rem; color: var(--tb-muted); }
.question-row {
  padding: 1rem; border: 1px solid var(--tb-border); border-top: none;
  background: white;
}
.question-row:last-child { border-radius: 0 0 8px 8px; }
.question-row .q-text { font-size: 0.92rem; margin-bottom: 0.65rem; font-weight: 500; }
.answer-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.answer-options label {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.4rem 0.75rem; border-radius: 999px; border: 1.5px solid var(--tb-border);
  font-size: 0.82rem; cursor: pointer; transition: all 0.15s;
}
.answer-options input { accent-color: var(--tb-primary); }
.answer-options label:has(input:checked) { border-color: var(--tb-primary); background: #eff6ff; font-weight: 600; }
.answer-good:has(input:checked) { border-color: var(--tb-good); background: #f0fdf4; }
.answer-partial:has(input:checked) { border-color: var(--tb-partial); background: #fffbeb; }
.answer-poor:has(input:checked) { border-color: var(--tb-poor); background: #fef2f2; }
.progress-bar {
  height: 8px; background: var(--tb-border); border-radius: 999px; overflow: hidden; margin: 1rem 0;
}
.progress-bar .fill { height: 100%; background: linear-gradient(90deg, var(--tb-primary), var(--tb-secondary)); transition: width 0.3s; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th, table.data td { padding: 0.65rem 0.85rem; text-align: left; border-bottom: 1px solid var(--tb-border); }
table.data th { background: var(--tb-surface); color: var(--tb-primary); font-weight: 700; }
.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 4px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-archived { background: #e5e7eb; color: #374151; }
.preview-banner {
  background: #fffbeb; border: 2px solid var(--tb-accent); border-radius: 10px;
  padding: 1rem 1.25rem; margin-bottom: 1.25rem; font-size: 0.92rem;
}
.completed-banner {
  background: #dcfce7; border: 1px solid #16a34a; border-radius: 8px;
  padding: 0.75rem 1rem; margin-bottom: 1.25rem; font-size: 0.88rem;
}
.tab-nav-card { padding: 1rem 1.25rem; }
.tab-nav { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.tab-btn {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.65rem; border: 1.5px solid var(--tb-border);
  border-radius: 6px; background: white; cursor: pointer;
  font-family: inherit; font-size: 0.78rem; color: var(--tb-muted);
}
.tab-btn.active { border-color: var(--tb-primary); background: #eff6ff; color: var(--tb-primary); font-weight: 600; }
.tab-btn .tab-num {
  width: 1.25rem; height: 1.25rem; border-radius: 50%; background: var(--tb-surface);
  display: flex; align-items: center; justify-content: center; font-size: 0.68rem; font-weight: 800;
}
.tab-btn.active .tab-num { background: var(--tb-primary); color: white; }
.tab-btn.tab-answered { border-color: var(--tb-partial); }
.tab-btn.tab-complete { border-color: var(--tb-good); background: #f0fdf4; }
.tab-btn.tab-complete .tab-num { background: var(--tb-good); color: white; }
.tab-panel.hidden { display: none; }
.hidden { display: none !important; }
.section-head-inline h2 { font-size: 1.15rem; margin-bottom: 0.25rem; }
.section-head-inline p { font-size: 0.88rem; color: var(--tb-muted); margin-bottom: 1rem; }
.q-detail { font-size: 0.88rem; color: var(--tb-text); margin: 0.35rem 0 0.25rem; line-height: 1.45; }
.q-look-for { font-size: 0.82rem; color: var(--tb-muted); margin-bottom: 0.65rem; padding: 0.5rem 0.65rem; background: var(--tb-surface); border-radius: 6px; border-left: 3px solid var(--tb-secondary); }
.q-notes textarea { font-size: 0.85rem; }
.sticky-actions { position: sticky; bottom: 0; z-index: 10; box-shadow: 0 -4px 20px rgba(0,0,0,0.08); }
.hint { font-size: 0.78rem; color: var(--tb-muted); margin-top: 0.65rem; }
.progress-text { font-size: 0.82rem; color: var(--tb-muted); margin-top: 0.35rem; }
.btn-link { background: none; border: none; color: var(--tb-primary); cursor: pointer; font-size: inherit; text-decoration: underline; }
.report-hero {
  background: linear-gradient(135deg, var(--tb-primary-dark), var(--tb-primary));
  color: white; border-radius: 12px; padding: 2rem; margin-bottom: 1.5rem;
}
.report-hero .score-big { font-size: 3.5rem; font-weight: 800; line-height: 1; }
.report-hero .maturity { font-size: 1.25rem; font-weight: 700; color: var(--tb-accent); margin-top: 0.35rem; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.metric { background: white; border-radius: 8px; padding: 1rem; text-align: center; border: 1px solid var(--tb-border); }
.metric-link { text-decoration: none; color: inherit; transition: box-shadow 0.15s, transform 0.15s; display: block; }
.metric-link:hover { box-shadow: 0 4px 16px rgba(20,71,143,0.15); transform: translateY(-2px); }
.metric .val { font-size: 1.75rem; font-weight: 800; color: var(--tb-primary); }
.metric .lbl { font-size: 0.75rem; color: var(--tb-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.chart-caption { font-size: 0.8rem; color: var(--tb-muted); margin: -0.35rem 0 0.5rem; }
.benchmark-explanation { font-size: 0.82rem; color: var(--tb-muted); margin-bottom: 0.85rem; padding: 0.65rem 0.85rem; background: var(--tb-surface); border-radius: 6px; border-left: 3px solid var(--tb-secondary); line-height: 1.45; }
.chart-actions { margin-bottom: 0.85rem; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
.meta-item { background: var(--tb-surface); border-radius: 8px; padding: 0.75rem 0.85rem; border: 1px solid var(--tb-border); }
.meta-lbl { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--tb-muted); margin-bottom: 0.25rem; }
.meta-val { font-size: 0.95rem; font-weight: 600; color: var(--tb-primary); }
.method-list { margin: 0.5rem 0 1.25rem 1.25rem; font-size: 0.9rem; line-height: 1.55; }
.method-list li { margin-bottom: 0.5rem; }
.benchmark-table { margin-bottom: 1.25rem; }
.benchmark-table .total-row { background: var(--tb-surface); }
.source-list { list-style: none; }
.source-item { padding: 1rem; margin-bottom: 0.75rem; border: 1px solid var(--tb-border); border-radius: 8px; background: white; }
.source-title { font-size: 1rem; font-weight: 700; color: var(--tb-primary); text-decoration: none; }
.source-title:hover { text-decoration: underline; }
.source-meta { display: block; font-size: 0.78rem; color: var(--tb-muted); margin: 0.25rem 0 0.5rem; }
.source-use { font-size: 0.88rem; margin-bottom: 0.35rem; }
.source-link { font-size: 0.78rem; word-break: break-all; }
.trust-note { background: linear-gradient(145deg, #f0f6ff, white); }
.chart-wide { grid-column: 1 / -1; }
.section-intro { font-size: 0.88rem; color: var(--tb-muted); margin-bottom: 1rem; }
.findings-list { list-style: none; }
.findings-list .finding-item,
.finding-item {
  padding: 0.85rem 1rem; margin-bottom: 0.5rem; border-radius: 8px;
  border-left: 4px solid var(--tb-partial); background: var(--tb-surface);
  break-inside: avoid;
  page-break-inside: avoid;
}
.finding-item.critical { border-left-color: var(--tb-poor); }
.finding-item.high { border-left-color: var(--tb-partial); }
.finding-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 800; text-transform: uppercase;
  padding: 0.15rem 0.45rem; border-radius: 4px; margin-bottom: 0.35rem;
}
.finding-badge.critical { background: #fef2f2; color: var(--tb-poor); }
.finding-badge.high { background: #fffbeb; color: #92400e; }
.finding-q { font-size: 0.88rem; margin: 0.35rem 0; }
.finding-ans { font-size: 0.82rem; color: var(--tb-muted); }
.finding-rec { font-size: 0.85rem; margin-top: 0.35rem; padding-top: 0.35rem; border-top: 1px dashed var(--tb-border); }
.answer-legend .legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.legend-item { font-size: 0.85rem; padding: 0.65rem 0.85rem; border-radius: 8px; border-left: 4px solid var(--tb-border); }
.legend-item.tone-good { border-left-color: var(--tb-good); background: #f0fdf4; }
.legend-item.tone-partial { border-left-color: var(--tb-partial); background: #fffbeb; }
.legend-item.tone-poor { border-left-color: var(--tb-poor); background: #fef2f2; }
.legend-item.tone-na { border-left-color: var(--tb-muted); background: var(--tb-surface); }
.answer-row {
  padding: 1rem; margin-bottom: 0.65rem; border-radius: 8px;
  border: 1px solid var(--tb-border); border-left-width: 4px;
  break-inside: avoid;
  page-break-inside: avoid;
}
.answer-row.tone-good { border-left-color: var(--tb-good); }
.answer-row.tone-partial { border-left-color: var(--tb-partial); }
.answer-row.tone-poor { border-left-color: var(--tb-poor); }
.answer-row.tone-na { border-left-color: var(--tb-muted); }
.answer-head { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.35rem; }
.answer-badge {
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
  padding: 0.2rem 0.5rem; border-radius: 4px;
}
.answer-badge.tone-good { background: #dcfce7; color: #166534; }
.answer-badge.tone-partial { background: #fef3c7; color: #92400e; }
.answer-badge.tone-poor { background: #fef2f2; color: #991b1b; }
.answer-badge.tone-na { background: #e5e7eb; color: #374151; }
.answer-domain { font-size: 0.78rem; color: var(--tb-muted); }
.answer-q { font-size: 0.92rem; margin-bottom: 0.35rem; }
.answer-detail { font-size: 0.85rem; color: var(--tb-muted); margin-bottom: 0.35rem; }
.answer-meaning { font-size: 0.85rem; }
.answer-rec { font-size: 0.85rem; margin-top: 0.5rem; padding: 0.5rem 0.65rem; background: var(--tb-surface); border-radius: 6px; }
.answer-note { font-size: 0.85rem; margin-top: 0.5rem; padding: 0.5rem 0.65rem; background: #eff6ff; border-radius: 6px; border-left: 3px solid var(--tb-secondary); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
.chart-box { background: white; border-radius: 10px; padding: 1.25rem; border: 1px solid var(--tb-border); }
.chart-box h3 { font-size: 0.95rem; color: var(--tb-primary); margin-bottom: 0.75rem; }
.rec-list { list-style: none; }
.rec-list .rec-item,
.rec-item {
  padding: 0.85rem 1rem; margin-bottom: 0.5rem; border-radius: 8px;
  border-left: 4px solid var(--tb-accent); background: var(--tb-surface);
  break-inside: avoid;
  page-break-inside: avoid;
}
.rec-item.critical { border-left-color: var(--tb-poor); }
.rec-item.high { border-left-color: var(--tb-partial); }
.rec-item strong { display: block; font-size: 0.88rem; color: var(--tb-primary); margin-bottom: 0.25rem; }
.rec-item span { display: block; font-size: 0.85rem; color: var(--tb-muted); }
.service-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.service-card {
  background: linear-gradient(145deg, #f0f6ff, white);
  border: 1px solid var(--tb-border); border-radius: 10px; padding: 1.15rem;
  break-inside: avoid;
  page-break-inside: avoid;
}
.service-card h4 { color: var(--tb-primary); font-size: 0.95rem; margin-bottom: 0.35rem; }
.service-card p { font-size: 0.82rem; color: var(--tb-muted); }
@media (max-width: 768px) {
  .form-grid, .charts { grid-template-columns: 1fr; }
  .triage-row { flex-direction: column; }
  .answer-legend .legend-grid { grid-template-columns: 1fr; }
}
@media print {
  @page {
    size: A4;
    margin: 14mm 12mm 22mm;
  }

  .topbar, .actions, .no-print, .preview-banner, .completed-banner,
  .chart-actions { display: none !important; }

  .metric-link {
    pointer-events: none;
    text-decoration: none;
    color: inherit;
    box-shadow: none;
    transform: none;
  }

  .print-only { display: block !important; }

  body {
    background: white;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .container {
    max-width: none;
    padding: 0 0 18mm;
  }

  /* Keep logical blocks on one page */
  .finding-item,
  .rec-item,
  .service-card,
  .answer-row,
  .legend-item,
  .metric,
  .report-hero,
  .chart-box,
  .benchmark-explanation,
  .tb-report-print-header {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Keep headings with the content that follows */
  .card h2,
  .card h3,
  .chart-box h3,
  .section-intro,
  .finding-badge {
    break-after: avoid;
    page-break-after: avoid;
  }

  /* Allow section cards to break between items, not inside them */
  .card {
    break-inside: auto;
    page-break-inside: auto;
    box-shadow: none;
    border: 1px solid var(--tb-border);
    margin-bottom: 0.85rem;
  }

  .findings-list,
  .rec-list {
    break-inside: auto;
    page-break-inside: auto;
  }

  p, li {
    orphans: 3;
    widows: 3;
  }

  .finding-q,
  .finding-ans,
  .finding-rec,
  .rec-item strong,
  .rec-item span {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .charts {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .metrics {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  table.data tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .tb-report-print-header {
    display: flex !important;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0 0.75rem;
    border-bottom: 2px solid var(--tb-primary);
    margin-bottom: 1rem;
  }

  .tb-report-print-header img { height: 24px; }
  .tb-rpt-brand strong { color: var(--tb-primary); font-size: 11pt; }
  .tb-rpt-brand span { color: var(--tb-secondary); }
  .tb-rpt-tag { display: block; font-size: 8pt; color: var(--tb-muted); font-weight: 600; }
  .tb-rpt-meta { margin-left: auto; font-size: 8pt; color: var(--tb-muted); text-align: right; }

  /* Footer: flow at end of document instead of fixed (avoids overlap/splits) */
  .tb-print-footer {
    position: static;
    margin-top: 1.5rem;
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
.print-only { display: none; }
.report-hero-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(255,255,255,0.2);
}
.report-logo { height: 32px; width: auto; background: white; border-radius: 50%; padding: 3px; }
.report-brand-tag { font-size: 0.78rem; opacity: 0.9; font-weight: 600; letter-spacing: 0.04em; }
.card-brand-row { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 0.5rem; }
.card-brand-logo { height: 36px; width: auto; flex-shrink: 0; }
