/* ===== Page setup ========================================================= */
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-Medium.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-SemiBold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --color-fail: #D63648;
  --color-fail-bg: #FDF0F0;
  --color-warn: #E89441;
  --color-warn-bg: #FFF4E6;
  --color-pass: #2E9E5F;
  --color-pass-bg: #EFF8F1;
  --color-info: #3B82F6;
  --color-info-bg: #EFF6FF;
  --color-muted: #6B7280;
  --color-muted-bg: #F5F5F5;
  --color-border: #E5E7EB;
  --color-text: #1A1A1A;
  --color-text-muted: #6B7280;
  --color-text-faint: #9CA3AF;
  --color-card-bg: #FFFFFF;
  --color-page-bg: #FFFFFF;
}

@page {
  size: A4;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: "Inter", system-ui, sans-serif;
  color: var(--color-text);
  background: var(--color-page-bg);
  font-size: 10px; line-height: 1.5;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.page {
  padding: 0 14mm;
  page-break-after: always;
  position: relative;
}
.page:last-child { page-break-after: auto; }

h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 28px; }
h2 { font-size: 18px; margin-bottom: 12px; }
h3 { font-size: 12px; font-weight: 600; }

.page-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 16px;
}
.page-header .scan-date { font-size: 9px; color: var(--color-text-muted); }

/* ===== Icons ============================================================== */
.icon { width: 18px; height: 18px; stroke: currentColor; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 26px; height: 26px; }
.icon-xl { width: 38px; height: 38px; }

/* ===== Cards ============================================================== */
.card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 14px 16px;
}

/* ===== Title page ========================================================= */
.title-page {
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; text-align: center;
  min-height: 257mm;
}
.title-brand { font-size: 36px; color: var(--color-fail); font-weight: 700; letter-spacing: -0.5px; }
.title-subtitle { font-size: 12px; color: var(--color-text-muted); margin-top: 6px; }
.title-divider { width: 48px; height: 3px; background: var(--color-fail); margin: 32px auto; }
.title-label { font-size: 10px; color: var(--color-text-faint); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 10px; }
.title-target { font-size: 20px; font-weight: 600; margin-bottom: 16px; }
.title-url {
  font-family: "Courier New", monospace;
  background: var(--color-fail-bg);
  border: 1px solid var(--color-fail);
  color: var(--color-fail);
  padding: 6px 14px; border-radius: 4px;
  font-size: 12px;
}
.title-meta {
  margin-top: auto;
  font-size: 10px; color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 14px; width: 100%;
}

/* ===== Hero (overview) ==================================================== */
.hero {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; align-items: center;
  border: 1px solid var(--color-warn);
  background: var(--color-warn-bg);
  border-radius: 10px;
  padding: 18px 22px;
  margin-bottom: 6px;
}
.hero.risk-high   { border-color: var(--color-fail); background: var(--color-fail-bg); }
.hero.risk-med    { border-color: var(--color-warn); background: var(--color-warn-bg); }
.hero.risk-low    { border-color: var(--color-pass); background: var(--color-pass-bg); }
.hero-left { display: flex; align-items: center; gap: 14px; }
.hero-icon-wrap {
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
}
.hero-icon-wrap .icon { width: 40px; height: 40px; }
.hero-label { font-size: 11px; color: var(--color-text-muted); }
.hero-level { font-size: 28px; font-weight: 700; line-height: 1.1; margin: 2px 0; }
.hero-sub { font-size: 10px; color: var(--color-text-muted); }
.hero-right { display: flex; align-items: center; gap: 14px; justify-content: flex-end; }
.hero-fines { text-align: right; }
.hero-fines .label { font-size: 10px; color: var(--color-text-muted); }
.hero-fines .range { font-size: 16px; font-weight: 700; color: var(--color-fail); line-height: 1.3; }
.hero-footnote { font-size: 9px; color: var(--color-text-faint); margin: 6px 0 18px; display: flex; gap: 6px; align-items: center; }

.risk-high  { color: var(--color-fail); }
.risk-med   { color: var(--color-warn); }
.risk-low   { color: var(--color-pass); }

/* ===== Gauge ============================================================== */
.gauge { width: 100px; height: 68px; position: relative; }
.gauge-labels { display: flex; justify-content: space-between; font-size: 8px; color: var(--color-text-muted); margin-top: 2px; }
.gauge-labels .active { font-weight: 700; color: var(--color-text); }

/* ===== Profile grid ======================================================= */
.profile-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin: 18px 0;
}
.profile-tile {
  border: 1px solid var(--color-border);
  border-radius: 8px; padding: 12px;
  display: flex; gap: 10px; align-items: flex-start;
}
.profile-tile .icon { color: var(--color-fail); }
.profile-tile .label { font-size: 10px; color: var(--color-text-muted); }
.profile-tile .value { font-size: 13px; font-weight: 600; margin-top: 2px; }
.profile-tile .value.positive { color: var(--color-pass); }
.profile-tile .value.negative { color: var(--color-fail); }

/* ===== Fines table ======================================================== */
.fines-table { width: 100%; border-collapse: collapse; font-size: 10px; margin-top: 8px; }
.fines-table thead { background: var(--color-muted-bg); color: var(--color-text-muted); }
.fines-table th, .fines-table td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.fines-table .fine-amount { color: var(--color-fail); font-weight: 600; white-space: nowrap; }
.fines-table .fine-note {
  margin-top: 3px;
  font-size: 9px;
  line-height: 1.35;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: normal;
}
.fines-total-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--color-fail-bg); border-radius: 8px;
  padding: 12px 16px; margin-top: 12px;
  font-size: 11px;
}
.fines-total-bar .icon { color: var(--color-fail); }
.fines-total-bar .total {
  margin-left: auto; color: var(--color-fail); font-weight: 700; font-size: 13px;
}

/* ===== Action plan ======================================================== */
.action-section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin: 24px 0 12px;
}
.action-pill {
  background: var(--color-fail); color: #fff;
  padding: 6px 14px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.action-card {
  display: grid;
  grid-template-columns: 40px 2fr 1fr 2fr;
  gap: 14px; align-items: stretch;
  margin-bottom: 10px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}
.action-num {
  background: var(--color-fail); color: #fff;
  font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.action-cell { padding: 12px 14px; }
.action-cell .title { font-weight: 600; font-size: 10px; margin-bottom: 4px; }
.action-cell .body { color: var(--color-text-muted); font-size: 10px; }
.action-cell.fine-cell { background: var(--color-fail-bg); }
.action-cell.fine-cell .amount {
  color: var(--color-fail);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}
.action-cell.fine-cell .fine-note {
  color: var(--color-text-muted);
  font-size: 9px;
  line-height: 1.5;
}
.action-cell.fine-cell .fine-article {
  margin-top: 4px;
  color: var(--color-text-muted);
  font-size: 9px;
  line-height: 1.35;
}

/* ===== Violations — legend ================================================ */
.status-legend {
  display: grid; grid-template-columns: 1fr 1fr;
  column-gap: 24px; row-gap: 12px;
  padding: 16px 18px;
  border: 1px solid var(--color-border); border-radius: 8px;
  margin-bottom: 18px;
}
.status-legend-item { display: flex; gap: 10px; align-items: flex-start; }
.status-legend-item .icon { margin-top: 1px; }
.status-legend-item .label { font-weight: 600; font-size: 11px; }
.status-legend-item .desc { font-size: 9px; color: var(--color-text-muted); }

.status-fail { color: var(--color-fail); }
.status-warn { color: var(--color-warn); }
.status-pass { color: var(--color-pass); }
.status-info { color: var(--color-info); }
.status-muted { color: var(--color-muted); }
.status-partial { color: #009FB1; }
.status-nodata { color: var(--color-text); }

/* ===== Violations — group header ========================================== */
.group-section { margin-top: 22px; }
.group-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.group-header .group-icon {
  width: 36px; height: 36px; background: var(--color-muted-bg);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
}
.group-header .group-meta { flex: 1; }
.group-header .group-meta .title { font-size: 14px; font-weight: 700; }
.group-header .group-meta .desc { font-size: 10px; color: var(--color-text-muted); }
.group-header .group-count { color: var(--color-fail); font-size: 11px; font-weight: 600; }

/* ===== Finding card ======================================================= */
/* ===== Pagination guards ================================================= */
.action-card,
.sec-card,
.next-card,
.gap-card,
.group-header,
.passed-stat,
.passed-chip,
.hero,
.fines-total-bar,
.disclaimer {
  page-break-inside: avoid;
  break-inside: avoid;
}
.group-section { break-inside: auto; }
.group-header + .finding { break-before: avoid; }
h2, h3, .next-section-title { break-after: avoid; }

.finding {
  border: 1px solid var(--color-border);
  border-left-width: 4px;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 10px;
  page-break-inside: avoid;
  break-inside: avoid;
  display: grid;
  grid-template-columns: 26px 1fr 180px;
  gap: 12px;
}
.finding-FAIL { border-left-color: var(--color-fail); }
.finding-WARNING { border-left-color: var(--color-warn); }
.finding-PARTIAL_PASS { border-left-color: var(--color-muted); }
.finding-INSUFFICIENT_DATA { border-left-color: var(--color-info); }
.finding-AI_FLAG_REQUIRING_REVIEW { border-left-color: var(--color-info); }
.finding-icon-circle {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
}
.finding-icon-circle .icon { width: 18px; height: 18px; }
.finding-icon-circle.status-FAIL { color: var(--color-fail); }
.finding-icon-circle.status-WARNING { color: var(--color-warn); }
.finding-icon-circle.status-PARTIAL_PASS { color: var(--color-muted); }
.finding-icon-circle.status-INSUFFICIENT_DATA { color: var(--color-info); }
.finding-icon-circle.status-AI_FLAG_REQUIRING_REVIEW { color: var(--color-info); }
.finding-icon-circle.status-TIMEOUT { color: var(--color-muted); }
.finding-icon-circle.status-ERROR { color: var(--color-muted); }
.finding-body .title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.finding-body .reason { font-size: 10px; color: var(--color-text-muted); margin-bottom: 8px; line-height: 1.5; }
.finding-fine-badge {
  display: inline-block; background: var(--color-fail-bg);
  color: var(--color-fail); font-size: 10px; font-weight: 600;
  padding: 4px 10px; border-radius: 4px; margin-bottom: 8px;
}
.evidence-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 10px; }
.evidence-list li {
  display: flex; gap: 8px; align-items: flex-start;
  margin-bottom: 4px; color: var(--color-text);
}
.evidence-list .check { color: var(--color-pass); }
.evidence-list .cross { color: var(--color-fail); }

.finding-aside {
  background: var(--color-muted-bg);
  border-radius: 6px; padding: 10px 12px; font-size: 10px;
  align-self: start;
}
.finding-aside .title { font-weight: 700; margin-bottom: 4px; }
.finding-aside.variant-danger { background: var(--color-fail-bg); }
.finding-aside.variant-danger .title { color: var(--color-fail); }
.finding-status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600;
}

/* ===== Security archive toggle ============================================ */
.sec-archive { margin: 24px 0 18px; }
.sec-archive-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 14px 18px;
  background: #FAFAFA;
  border: 1px solid var(--color-border);
  border-radius: 10px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--color-text);
  text-align: left; transition: background .15s, border-color .15s;
  line-height: 1.3;
}
.sec-archive-toggle:hover { background: #F3F4F6; border-color: var(--color-text-muted); }
.sec-archive-toggle .icon { width: 18px; height: 18px; flex: 0 0 auto; color: var(--color-text-muted); opacity: 1; }
.sec-archive-chevron {
  width: 14px; height: 14px; flex: 0 0 auto;
  margin-left: auto; transition: transform .2s; color: var(--color-text-muted);
}
.sec-archive-toggle.is-open .sec-archive-chevron { transform: rotate(180deg); }
.sec-archive-body { padding-top: 16px; }

/* ===== Security page ====================================================== */
.sec-hero {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 14px; align-items: center;
  background: var(--color-fail-bg); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 18px;
}
.sec-hero .icon-wrap {
  width: 40px; height: 40px; background: var(--color-fail);
  border-radius: 8px; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.sec-hero .text .title { font-weight: 700; font-size: 13px; }
.sec-hero .text .desc { font-size: 10px; color: var(--color-text-muted); }
.sec-hero .level { text-align: right; }
.sec-hero .level .label { font-size: 9px; color: var(--color-text-muted); }
.sec-hero .level .value { font-weight: 700; color: var(--color-fail); font-size: 14px; }

.sec-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 22px;
}
.sec-card { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.sec-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.sec-card-header .title { font-weight: 700; font-size: 12px; }
.sec-chip {
  font-size: 9px; padding: 3px 8px; border-radius: 12px;
  font-weight: 600; white-space: nowrap;
}
.sec-chip.warn { background: var(--color-warn-bg); color: var(--color-warn); }
.sec-chip.pass { background: var(--color-pass-bg); color: var(--color-pass); }
.sec-chip.partial { background: var(--color-muted-bg); color: var(--color-text-muted); }
.sec-list { list-style: none; padding: 0; margin: 0; font-size: 10px; }
.sec-list li {
  display: flex; gap: 8px; align-items: flex-start;
  margin-bottom: 4px;
}
.sec-list .dot-ok { color: var(--color-pass); }
.sec-list .dot-bad { color: var(--color-fail); }
.sec-more { font-size: 9px; color: var(--color-text-muted); margin-top: 4px; }
.sec-rec {
  margin-top: auto;
  background: var(--color-warn-bg);
  border-radius: 6px; padding: 10px 12px;
  font-size: 10px;
}
.sec-rec .label { color: var(--color-warn); font-weight: 700; margin-bottom: 2px; }

/* ===== Passed summary ===================================================== */
.passed-summary {
  display: grid; grid-template-columns: auto repeat(4, 1fr);
  gap: 10px; align-items: center;
  margin-bottom: 14px;
}
.passed-stat {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--color-border);
  border-radius: 8px; min-width: 0;
}
.passed-stat .icon { color: var(--color-pass); width: 30px; height: 30px; }
.passed-stat .label { font-size: 11px; font-weight: 600; }
.passed-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--color-border); border-radius: 8px;
}
.passed-chip .icon { color: var(--color-pass); }
.passed-chip .label { font-size: 10px; color: var(--color-text-muted); }
.passed-chip .ratio { font-size: 12px; font-weight: 700; }

.passed-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.passed-table thead { background: var(--color-muted-bg); color: var(--color-text-muted); }
.passed-table th, .passed-table td {
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--color-border);
}
.passed-table .status-ok { color: var(--color-pass); font-weight: 600; }
.passed-table td .icon { color: var(--color-pass); vertical-align: middle; margin-right: 6px; }

/* ===== Gap / Next steps =================================================== */
.gap-hero {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 14px; align-items: center;
  background: var(--color-warn-bg); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 14px;
}
.gap-hero .icon-wrap {
  width: 40px; height: 40px; background: var(--color-warn);
  border-radius: 8px; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.gap-hero .text .title { font-weight: 700; font-size: 13px; }
.gap-hero .level .value { font-weight: 700; color: var(--color-warn); font-size: 14px; }

.tabs {
  display: flex; gap: 24px; border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px; padding-left: 6px;
}
.tab { padding: 8px 0; font-size: 11px; color: var(--color-text-muted); }
.tab.active {
  color: var(--color-warn); font-weight: 700;
  border-bottom: 2px solid var(--color-warn);
}
.gap-card {
  padding: 18px 20px;
  margin-bottom: 16px;
}
.gap-card .title { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.gap-card .sub { font-size: 10px; color: var(--color-text-muted); margin-bottom: 12px; }
.gap-card .gap-items {
  margin: 0;
}
.gap-card .gap-item {
  margin: 0;
  color: var(--color-text);
  font-size: 10px;
  line-height: 1.5;
}
.gap-card .gap-item + .gap-item { margin-top: 6px; }
.gap-card .gap-extra {
  margin: 6px 0 0;
  padding-left: 16px;
}
.gap-card .registry-check-help {
  margin: 14px 0 0;
  color: var(--color-text);
  font-size: 10px;
  line-height: 1.55;
}
.gap-card .registry-check-help strong { font-weight: 700; }
.gap-card .registry-check-help a {
  color: var(--color-accent, #2563eb);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}

.next-section-title { font-size: 18px; font-weight: 700; margin: 20px 0 12px; }
.next-card {
  display: grid; grid-template-columns: 52px auto 1fr;
  gap: 12px; align-items: center;
  padding: 16px; margin-bottom: 8px;
}
.next-card .icon-wrap {
  width: 40px; height: 40px; background: var(--color-fail-bg);
  border-radius: 6px; color: var(--color-fail);
  display: flex; align-items: center; justify-content: center;
}
.next-card .num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--color-fail); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.next-card .body .title { font-weight: 700; font-size: 12px; margin-bottom: 3px; }
.next-card .body .desc { font-size: 10px; color: var(--color-text-muted); line-height: 1.5; }

.disclaimer {
  border: 1px solid var(--color-warn); background: var(--color-warn-bg);
  border-radius: 8px; padding: 14px 16px;
  display: grid; grid-template-columns: 24px 1fr;
  gap: 10px; font-size: 10px; color: var(--color-text-muted); line-height: 1.6;
  margin-top: 18px;
}
.disclaimer .icon { color: var(--color-warn); }
.disclaimer strong { color: var(--color-text); display: block; margin-bottom: 4px; }
