/* In-Call Effectiveness Report: one report on an A4 portrait sheet.
   The sheet is always light, on screen and on paper, so what you see is
   what prints. */

:root {
  --brand: #05932e;          /* bars, rules, headings accent */
  --brand-deep: #046b22;     /* text on white that needs the brand colour */
  --ink: #1b211d;            /* primary text */
  --ink-2: #47524b;          /* secondary text */
  --muted: #68736c;          /* labels, axis text */
  --rule: #d5dbd7;           /* hairlines, grid */
  --panel: #ebeef0;          /* card background (from the original report) */
  --tint: #f6fff4;           /* light brand tint */
  --paper: #ffffff;
  --desk: #e4e8e5;           /* screen background behind the sheet */
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --display: "Outfit", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.4;
}

.muted { color: var(--muted); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- toolbar */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  padding: 12px 16px;
}

.toolbar-inner {
  max-width: 210mm;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-search { flex: 1 1 220px; }
.field-select { flex: 2 1 280px; }

.field label { font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }

.field input,
.field select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #aab3ad;
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
  min-height: 40px;
}

.field input:focus-visible,
.field select:focus-visible,
button:focus-visible,
.bar-hit:focus-visible {
  outline: 2px solid var(--brand-deep);
  outline-offset: 2px;
}

.toolbar-buttons { display: flex; gap: 8px; }

button {
  font: inherit;
  min-height: 40px;
  border-radius: 6px;
  cursor: pointer;
}

.button-main {
  background: var(--brand-deep);
  color: #fff;
  border: 1px solid var(--brand-deep);
  padding: 8px 14px;
  font-weight: 600;
}
.button-main:hover { background: #035a1c; }

.button-quiet {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid #aab3ad;
  width: 40px;
  font-size: 1.25rem;
  line-height: 1;
}
.button-quiet:hover { background: var(--panel); }
.button-quiet:disabled { color: #a9b1ac; cursor: default; background: var(--paper); }

.notice {
  max-width: 210mm;
  margin: 10px auto 0;
  padding: 8px 12px;
  border-left: 4px solid #b26a00;
  background: #fff6e5;
  font-size: 0.875rem;
}

/* ------------------------------------------------------------------ sheet */

.sheet {
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  margin: 20px auto 40px;
  padding: 12mm;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 8px 24px rgba(0, 0, 0, 0.08);
  font-size: 10.5pt;
}

.sample-flag {
  margin: 0 0 10px;
  padding: 6px 10px;
  border: 1px solid #b26a00;
  background: #fff6e5;
  font-size: 9pt;
  font-weight: 600;
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--brand);
}

.logo { height: 22mm; width: auto; display: block; }

.title-block { text-align: right; min-width: 0; }

h1 {
  margin: 0;
  font-size: 18pt;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.report-id { margin: 6px 0 0; font-size: 11pt; font-weight: 600; overflow-wrap: anywhere; }

.label {
  font-size: 8pt;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 6px;
}

/* ---------------------------------------------------------------- context */

.context { margin-top: 12px; }

.context dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 16px;
  padding: 10px 12px;
  background: var(--tint);
  border: 1px solid #d3ead0;
  border-radius: 6px;
}

.context dt {
  font-size: 8pt;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.context dd { margin: 1px 0 0; font-weight: 600; overflow-wrap: anywhere; }

/* ----------------------------------------------------------------- blocks */

.block { margin-top: 16px; }

h2 {
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--rule);
  font-size: 12.5pt;
  font-weight: 600;
  color: var(--brand-deep);
}

.group-title {
  margin: 10px 0 5px;
  font-size: 10.5pt;
  font-weight: 600;
}

.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--panel);
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 14mm;
}

.card h3,
.card h4 {
  margin: 0 0 3px;
  font-size: 8pt;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.card p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.empty { color: var(--muted); }

/* ------------------------------------------------------------------ flags */

.flags {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.flag {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.flag-label { font-weight: 600; }
.flag-value { font-size: 13pt; font-weight: 600; }

/* ------------------------------------------------------------------ chart */

.questions-summary {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 16px;
  align-items: start;
}

.chart-figure { margin: 0; }

.chart-figure figcaption { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }

.stat-value { font-size: 20pt; font-weight: 600; line-height: 1; }
.stat-label { color: var(--ink-2); }

.chart-wrap { position: relative; }

#category-chart { display: block; width: 100%; height: auto; overflow: visible; }

.grid-line { stroke: var(--rule); stroke-width: 1; }
.axis-line { stroke: #aab3ad; stroke-width: 1; }
.tick-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.category-text { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.value-text { fill: var(--ink); font-size: 12px; font-weight: 600; }
.value-text.zero { fill: var(--muted); font-weight: 400; }
.bar { fill: var(--brand); }
.bar-hit { fill: transparent; cursor: default; }
.bar-hit:hover + .bar,
.bar-hit:focus + .bar { fill: var(--brand-deep); }

.chart-tooltip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 0.8125rem;
  line-height: 1.3;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 8px));
}
.chart-tooltip strong { display: block; font-size: 0.9375rem; }

/* ----------------------------------------------------------------- tables */

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

th {
  text-align: left;
  font-size: 8pt;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 5px 8px;
  border-bottom: 1px solid #aab3ad;
}

td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; }

.category-table tfoot td,
.category-table .total td { font-weight: 600; border-bottom: none; border-top: 1px solid #aab3ad; }

.questions-table th:first-child,
.questions-table td:first-child { width: 10mm; color: var(--muted); }
.questions-table th:last-child,
.questions-table td:last-child { width: 38mm; }

/* ----------------------------------------------------------------- footer */

.report-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding-top: 6px;
  border-top: 1px solid var(--rule);
  font-size: 8pt;
  color: var(--muted);
}

/* ----------------------------------------------------------- small screens */

@media screen and (max-width: 700px) {
  .sheet { margin: 0; padding: 16px; min-height: 0; box-shadow: none; font-size: 0.9375rem; }
  .report-header { flex-direction: column; align-items: flex-start; }
  .title-block { text-align: left; }
  .logo { height: 56px; }
  .context dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .questions-summary,
  .cards.two,
  .flags { grid-template-columns: minmax(0, 1fr); }
  .toolbar-buttons { width: 100%; }
  .button-main { flex: 1; }
}

/* ------------------------------------------------------------------ print */

@page {
  size: A4 portrait;
  margin: 12mm 12mm 15mm;

  @bottom-left {
    content: "In-Call Effectiveness Report";
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 8pt;
    color: #68736c;
  }
  @bottom-right {
    content: "Page " counter(page) " of " counter(pages);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 8pt;
    color: #68736c;
  }
}

@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  body { background: #fff; }
  .no-print { display: none !important; }

  .sheet {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }

  /* Keep each piece whole; let long sections run on to the next page. */
  .report-header,
  .context,
  .questions-summary,
  .flags,
  .card,
  tr { break-inside: avoid; }

  h2, h3, .group-title { break-after: avoid; }
  thead { display: table-header-group; }
  .chart-tooltip { display: none !important; }
}

/* Headings and headline figures use the display face shared with the dashboards. */
h1, h2, .stat-value, .flag-value { font-family: var(--display); }
h1 { font-weight: 600; letter-spacing: -0.015em; }

.back-link { align-self: center; color: var(--brand-deep); font-weight: 600; text-decoration: none; white-space: nowrap; }
.back-link:hover { text-decoration: underline; }
