:root {
  --primary: #1a3a5c;
  --primary-light: #2a5298;
  --accent: #00a878;
  --accent-dark: #007a58;
  --warning: #e07b00;
  --danger: #c0392b;
  --success: #27ae60;
  --partial: #f39c12;
  --na: #7f8c8d;
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #dde3ea;
  --text: #1c2a38;
  --text-muted: #5a6a7a;
  --shadow: 0 2px 8px rgba(0,0,0,.10);
  --radius: 10px;
  --caf-color: #638cff;
  --dora-color: #ffc107;
  --iso-color: #00796b;
  --nis2-color: #e040fb;
  --nistcsf-color: #ff7043;
  --crma-color: #00d4aa;
  --soc2-color: #0288d1;
}

*, *::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;
}

.container { min-height: 100vh; display: flex; flex-direction: column; }

/* ── HEADER ── */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  padding: 24px 32px 20px;
  position: relative;
}
.header h1 { font-size: 22px; font-weight: 700; }

/* MSP client context bar — only injected when ?mspClient= is present */
.msp-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: -8px -32px 14px;
  padding: 8px 32px;
  background: rgba(0,0,0,0.22);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
  flex-wrap: wrap;
}
.msp-back-link {
  color: #fff;
  text-decoration: none;
  opacity: .85;
  font-weight: 500;
}
.msp-back-link:hover { opacity: 1; text-decoration: underline; }
.msp-context-label { color: rgba(255,255,255,.85); }
.msp-context-label strong { color: #ffd54f; font-weight: 600; margin-left: 4px; }
.subtitle-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.subtitle-row p { font-size: 13px; opacity: .8; }
.home-link {
  background: rgba(255,255,255,.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s;
}
.home-link:hover { background: rgba(255,255,255,.25); }
.user-info {
  position: absolute;
  top: 18px;
  right: 130px;
  font-size: 13px;
  opacity: .85;
}

/* ── SETUP HINT BANNER ── */
.setup-hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: rgba(99, 140, 255, 0.12);
  border: 1px solid rgba(99, 140, 255, 0.35);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 0 32px 0;
  font-size: 13.5px;
  color: #c8d6ff;
  line-height: 1.5;
}
.setup-hint strong { color: #fff; }
.setup-hint-icon { font-size: 16px; margin-top: 1px; flex-shrink: 0; opacity: .8; }
.setup-hint-close {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  color: #8fa8d8;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.setup-hint-close:hover { color: #fff; }
@media (max-width: 600px) {
  .setup-hint { margin: 0 16px; }
}

/* ── MAIN CONTENT ── */
.main { flex: 1; padding: 24px 32px 48px; max-width: 1200px; margin: 0 auto; width: 100%; }

/* ── STATUS CARDS ROW ── */
.status-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.status-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.status-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
}
.status-card.caf::before { background: var(--caf-color); }
.status-card.dora::before { background: var(--dora-color); }
.status-card.iso27001::before { background: var(--iso-color); }
.status-card.nis2::before { background: var(--nis2-color); }
.status-card.nistcsf::before { background: var(--nistcsf-color); }
.status-card.crma::before    { background: var(--crma-color); }
.status-card.soc2::before    { background: var(--soc2-color); }

.status-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.status-card-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.status-card.caf .status-card-title { color: var(--caf-color); }
.status-card.dora .status-card-title { color: #c59600; }
.status-card.iso27001 .status-card-title { color: var(--iso-color); }
.status-card.nis2 .status-card-title { color: var(--nis2-color); }
.status-card.nistcsf .status-card-title { color: #d4521a; }

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.status-badge.achieved { background: #e8f5e9; color: #2e7d32; }
.status-badge.partial { background: #fff3e0; color: #e65100; }
.status-badge.not-achieved { background: #ffebee; color: #c62828; }
.status-badge.no-data { background: #f5f5f5; color: #9e9e9e; }

.score-big {
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.score-big.green { color: var(--success); }
.score-big.amber { color: var(--partial); }
.score-big.red { color: var(--danger); }
.score-big.grey { color: var(--na); }

.score-label { font-size: 13px; color: var(--text-muted); }
.card-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 600;
}
.card-link:hover { text-decoration: underline; }

/* ── NIS2 CROSS-MAP SECTION ── */
.section-title {
  font-size: 18px;
  font-weight: 700;
  margin: 28px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

/* ── CROSS-MAP TABLE ── */
.crossmap-table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 28px;
}
.crossmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.crossmap-table thead th {
  background: var(--primary);
  color: #fff;
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
  white-space: nowrap;
}
.crossmap-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.crossmap-table tbody tr:last-child td { border-bottom: none; }
.crossmap-table tbody tr:hover { background: #f8fafc; }
/* Pin Coverage column to minimum — prevents it being squeezed by wide mapping columns */
.crossmap-table th:last-child,
.crossmap-table td:last-child { white-space: nowrap; width: 1%; }

.mapping-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  margin: 1px 3px 1px 0;
  white-space: nowrap;
}
.mapping-tag.caf  { background: rgba(99,140,255,.12); color: #3b6ae0; }
.mapping-tag.dora { background: rgba(255,193,7,.15);  color: #9a7400; }
.mapping-tag.iso  { background: rgba(0,121,107,.12);  color: #00796b; }
.mapping-tag.crma { background: rgba(0,212,170,.12);  color: #00966e; }
.mapping-tag.ce   { background: rgba(2,136,209,.12);  color: #0277bd; }

.coverage-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.coverage-dot.full { background: var(--success); }
.coverage-dot.partial { background: var(--partial); }
.coverage-dot.none { background: var(--danger); }
.coverage-dot.na { background: var(--na); }

.coverage-text { font-size: 12px; font-weight: 600; }
.coverage-text.full { color: var(--success); }
.coverage-text.partial { color: var(--partial); }
.coverage-text.none { color: var(--danger); }
.coverage-text.na { color: var(--na); }

/* ── DERIVED BADGE ── */
.derived-badge {
  display: inline-block;
  background: #eef1f5;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: 6px;
  letter-spacing: .2px;
}

/* ── NIST CSF BARS ── */
.nistcsf-summary { border-left: 3px solid var(--nistcsf-color); }
.soc2-summary    { border-left: 3px solid var(--soc2-color); }

.soc2-disclaimer {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(2,136,209,.06);
  border: 1px solid rgba(2,136,209,.2);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 14px;
  line-height: 1.5;
}
.soc2-disclaimer-icon { margin-right: 6px; color: var(--soc2-color); }

.soc2-cc-id {
  display: inline-block;
  background: var(--soc2-color);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  letter-spacing: .3px;
}
.soc2-cc-badge {
  display: inline-block;
  background: var(--soc2-color);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}
.soc2-fill.green { background: linear-gradient(90deg, #0277bd, #0288d1); }
.soc2-fill.amber { background: linear-gradient(90deg, #01579b, #0277bd); }
.soc2-fill.red   { background: linear-gradient(90deg, #01407a, #01579b); }
.nistcsf-bar-label { width: 220px !important; }
.nistcsf-fn-id {
  display: inline-block;
  background: rgba(255,112,67,.12);
  color: #d4521a;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 4px;
  letter-spacing: .04em;
}
.nistcsf-fill.green { background: linear-gradient(90deg, #e64a19, #ff7043); }
.nistcsf-fill.amber { background: linear-gradient(90deg, #bf360c, #e64a19); }
.nistcsf-fill.red   { background: linear-gradient(90deg, #b71c1c, #bf360c); }

/* ── NIST CSF TABLE ── */
.nistcsf-fn-badge {
  display: inline-block;
  background: rgba(255,112,67,.12);
  color: #d4521a;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── RADAR CHART ── */
.charts-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}
.chart-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.chart-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}
.chart-card svg { width: 100%; height: auto; }

/* ── GAPS & ACTIONS ── */
.gaps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
.gap-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.gap-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}
.gap-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.gap-item:last-child { border-bottom: none; }
.gap-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.gap-icon.critical { background: var(--danger); }
.gap-icon.strength { background: var(--success); }

/* ── NIS2 SUMMARY BAR ── */
.nis2-summary {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 28px;
}
.nis2-summary h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}
.nis2-bars { display: flex; flex-direction: column; gap: 8px; }
.nis2-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nis2-bar-label {
  width: 200px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nis2-bar-track {
  flex: 1;
  height: 18px;
  background: #eef1f5;
  border-radius: 9px;
  overflow: hidden;
  position: relative;
}
.nis2-bar-fill {
  height: 100%;
  border-radius: 9px;
  transition: width .5s ease;
}
.nis2-bar-fill.green { background: linear-gradient(90deg, #27ae60, #2ecc71); }
.nis2-bar-fill.amber { background: linear-gradient(90deg, #e67e22, #f39c12); }
.nis2-bar-fill.red { background: linear-gradient(90deg, #c0392b, #e74c3c); }
.nis2-bar-fill.grey { background: #bdc3c7; }
.nis2-bar-value {
  font-size: 12px;
  font-weight: 700;
  width: 42px;
  text-align: right;
  flex-shrink: 0;
}

/* ── EXPORT BUTTONS ── */
.export-row {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.export-btn {
  padding: 10px 22px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: transform .15s, box-shadow .15s;
}
.export-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.export-btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
}
.export-btn.secondary {
  background: #fff;
  color: var(--primary);
  border: 2px solid var(--primary);
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; max-width: 500px; margin: 0 auto 20px; }
.empty-state a {
  display: inline-block;
  padding: 10px 24px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

/* ── NO-DATA CARD ── */
.no-data-msg {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}
.no-data-msg a { color: var(--primary-light); font-weight: 600; }

/* ── PRINT-ONLY ELEMENT (hidden on screen) ── */
.print-mapping-statement { display: none; }

/* ── PRINT ── */
@media print {
  /* ── HIDE: nav, page chrome, cross-mapping tables ── */
  #sch-nav-bar,
  .header,
  .setup-hint,
  .home-link,
  .card-link,
  .export-row,
  #cd-section-title-nis2,
  #cd-section-title-nistcsf,
  #cd-section-title-soc2,
  .crossmap-table-wrap { display: none !important; }

  /* Belt-and-braces nav suppression (injected by nav-auth.js after DOMContentLoaded) */
  #sch-nav-bar {
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  /* ── BODY & LAYOUT RESET ── */
  body {
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .main { padding: 8px 0 !important; }

  /* ── STATUS CARDS: 3-col grid; mapping statement spans as divider ── */
  .status-cards {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 12px !important;
    page-break-inside: avoid;
    margin-bottom: 0 !important;
  }
  .print-mapping-statement {
    display: block !important;
    grid-column: 1 / -1 !important;
    text-align: center;
    font-size: 11pt;
    font-weight: 600;
    color: #1a2a3a;
    padding: 10px 0;
    border-top: 1px solid #c8d0da;
    border-bottom: 1px solid #c8d0da;
    margin: 4px 0;
    letter-spacing: 0.01em;
  }
  .status-card {
    box-shadow: none !important;
    border: 1px solid #dde3ea !important;
    padding: 14px !important;
  }
  .status-card::before {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .score-big { font-size: 28px !important; }

  /* ── PAGE BREAKS ── */
  .nis2-summary:first-of-type { break-before: always; }
  .charts-row { break-before: always; }
  .gaps-grid  { break-before: always; }

  /* Prevent breaks mid-element */
  .nis2-summary,
  .chart-card,
  .gap-card { page-break-inside: avoid; }

  /* ── RADAR CHARTS: constrain so 2×2 fits one page ── */
  .charts-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }
  .chart-card svg { max-height: 280px; }

  /* ── TABLE COLOUR PRESERVATION ── */
  .crossmap-table thead th { print-color-adjust: exact; -webkit-print-color-adjust: exact; }

  /* ── BRANDED FOOTER (fixed, appears on every printed page) ── */
  body::after {
    content: "Security Compliance Hub  \2022  securitycompliancehub.io  \2022  Confidential";
    display: block;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    text-align: center;
    font-size: 7.5pt;
    color: #7f8c8d;
    padding: 5px 0;
    border-top: 1px solid #e0e4ea;
    background: #fff;
  }
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .status-cards { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .gaps-grid { grid-template-columns: 1fr; }
  .header { padding: 16px 16px 14px; }
  .header h1 { font-size: 18px; }
  .main { padding: 16px; }
  .user-info { display: none; }
  .nis2-bar-label { width: 120px; font-size: 11px; }
}
