/* ==========================================================================
   Feedback Analytics — design system (GOV.UK inspired)
   Light/dark themes, responsive layout, accessible colour and focus states.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg-primary: #f3f2f1;
  --bg-secondary: #ffffff;
  --bg-accent: #f8f9fa;
  --text-primary: #0b0c0c;
  --text-secondary: #505a5f;
  --border-color: #bfc1c3;
  --border-light: #e5e5e5;

  /* Brand / status */
  --gov-blue: #1d70b8;
  --gov-blue-dark: #003078;
  --gov-green: #00703c;
  --gov-red: #d4351c;
  /* Was #f47a24, which scored only 2.76:1 on white and failed the 3:1 minimum
     for large text — on the Accessibility figure, of all places. */
  --gov-orange: #b34700;
  --gov-focus: #ffdd00;

  --priority-high: var(--gov-red);
  --priority-medium: var(--gov-blue);
  --priority-low: #6f777b;

  --chart-line: var(--gov-blue);

  --badge-neutral-bg: #eceded;
  --badge-neutral-text: #383f43;
  --badge-high-bg: #fbebe8;
  --badge-medium-bg: #ebf5fc;
  --badge-low-bg: #eff1f1;

  --tag-access-bg: #fdf0e6;
  --tag-access-text: #8a3700;
  --tag-func-bg: #e8f1f8;
  --tag-func-text: #14538a;

  --delta-up: #7a2e15;
  --delta-down: #005a30;

  --font-sans: "GDS Transport", Arial, Helvetica, sans-serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition-fast: 0.2s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dark {
  --bg-primary: #12161a;
  --bg-secondary: #1a2026;
  --bg-accent: #232a32;
  --text-primary: #f8f9fa;
  --text-secondary: #a9b7c6;
  --border-color: #3b4856;
  --border-light: #2c3743;

  --gov-blue: #4ca3dd;
  --gov-blue-dark: #7cc0ea;
  --gov-green: #3fbf6b;
  --gov-red: #ff6b6b;
  --gov-orange: #ff8a3d;

  --priority-low: #9aa5ad;
  --chart-line: #4ca3dd;

  --badge-neutral-bg: #2c3743;
  --badge-neutral-text: #cdd7e0;
  --badge-high-bg: #48181a;
  --badge-medium-bg: #10344f;
  --badge-low-bg: #262f38;

  --tag-access-bg: #3d2410;
  --tag-access-text: #ffb787;
  --tag-func-bg: #13334c;
  --tag-func-text: #9ed3f5;

  --delta-up: #ffab7d;
  --delta-down: #6fdc9a;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Utilities ---------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--gov-focus);
  color: #000;
  padding: 0.5rem 1rem;
  z-index: 200;
  font-weight: bold;
  border-bottom: 2px solid #000;
}
.skip-link:focus { top: 0; }

.num { text-align: right; }
.strong { font-weight: 700; }
.accent-high { color: var(--gov-red); font-weight: 700; }
.accent-access { color: var(--gov-orange); font-weight: 700; }
.accent-access-text { color: var(--gov-orange); }

.empty-note {
  color: var(--text-secondary);
  font-style: italic;
  margin: 0;
}
.empty-note.centered { text-align: center; padding: 2rem 0; }
.empty-cell { color: var(--text-secondary); text-align: center; }

/* Typography --------------------------------------------------------------- */

h1, h2, h3, h4 { margin-top: 0; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.4rem; margin-bottom: 1rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.5rem; }

:where(button, input, select, textarea, a):focus-visible {
  outline: 3px solid var(--gov-focus);
  outline-offset: 1px;
}

/* Top bar ------------------------------------------------------------------ */

.topbar {
  background-color: #0b0c0c;
  color: #ffffff;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 10px solid var(--gov-blue);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 1rem;
}
.topbar h1 { margin: 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.topbar h1 .badge {
  background-color: var(--gov-blue);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.header-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* Buttons ------------------------------------------------------------------ */

.btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background-color: var(--gov-green); color: #ffffff; }
.btn-primary:hover:not(:disabled) { background-color: #005a30; }

.btn-secondary { background-color: transparent; border-color: var(--border-color); color: var(--text-primary); }
.btn-secondary:hover:not(:disabled) { background-color: var(--bg-accent); }

.topbar .btn-secondary { background-color: #ffffff; color: #0b0c0c; border-color: #ffffff; }
.topbar .btn-secondary:hover:not(:disabled) { background-color: #d8d8d8; border-color: #d8d8d8; }

.btn-dark { background-color: #2c3539; color: #fff; }
.btn-dark:hover:not(:disabled) { background-color: #1e2528; }

.btn-danger { background-color: transparent; border-color: var(--gov-red); color: var(--gov-red); }
.btn-danger:hover:not(:disabled) { background-color: var(--gov-red); color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--gov-blue);
  text-decoration: underline;
  padding: 0.25rem 0.4rem;
}
.btn-ghost:hover:not(:disabled) { background-color: var(--bg-accent); }

.btn-sm { font-size: 0.82rem; padding: 0.3rem 0.6rem; }
.btn-xs { font-size: 0.72rem; padding: 0.1rem 0.4rem; font-weight: 700; }
.btn-block { width: 100%; justify-content: center; margin-top: 0.5rem; }

/* Momentary confirmation after a copy */
.btn.is-copied {
  color: var(--gov-green);
  border-color: var(--gov-green);
  background-color: transparent;
}

.control-divider {
  display: inline-block;
  width: 1px;
  height: 1.4em;
  background: var(--border-color);
  margin: 0 0.15rem;
}

.copy-item-btn { text-decoration: none; border: 1px solid var(--border-color); }
.copy-item-btn:hover { background-color: var(--bg-secondary); text-decoration: underline; }

.file-upload-wrapper { display: inline-block; }
.file-upload-input { display: none; }
.btn-block-wrapper { display: block; }

/* Toasts ------------------------------------------------------------------- */

.toast-region {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(28rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  background: var(--text-primary);
  color: var(--bg-secondary);
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 600;
  border-left: 5px solid var(--gov-green);
}
.toast-error { border-left-color: var(--gov-red); }

/* Layout ------------------------------------------------------------------- */

main { max-width: 1440px; margin: 0 auto; padding: 1.5rem 2rem; }

.hero {
  background-color: var(--bg-secondary);
  border-left: 6px solid var(--gov-blue);
  padding: 1.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.hero h2 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hero-summary { font-size: 1.1rem; line-height: 1.65; }
.hero-summary code {
  padding: 0.1rem 0.35rem;
  background: var(--bg-accent);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  font-weight: 600;
  word-break: break-all;
}

/* KPIs --------------------------------------------------------------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.card-kpi {
  background-color: var(--bg-secondary);
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border-top: 4px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.kpi-title {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.35rem 0;
}
.kpi-value { font-size: 2.1rem; font-weight: 800; line-height: 1; }
.kpi-subtext { font-size: 0.78rem; color: var(--text-secondary); }

.kpi-delta { font-size: 0.75rem; font-weight: 700; margin-top: 0.35rem; min-height: 1rem; }
.kpi-delta.up { color: var(--delta-up); }
.kpi-delta.down { color: var(--delta-down); }
.kpi-delta.flat { color: var(--text-secondary); font-weight: 600; }

.kpi-total { border-top-color: var(--text-secondary); }
.kpi-pages { border-top-color: var(--gov-blue); }
.kpi-pages .kpi-value { color: var(--gov-blue); }
.kpi-accessibility { border-top-color: var(--gov-orange); }
.kpi-accessibility .kpi-value { color: var(--gov-orange); }
.kpi-function { border-top-color: var(--gov-red); }
.kpi-function .kpi-value { color: var(--gov-red); }
.kpi-contact { border-top-color: var(--gov-green); }
.kpi-contact .kpi-value { color: var(--gov-green); }

/* Grid --------------------------------------------------------------------- */

.dashboard-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 1024px) {
  /* minmax(0, …) lets the column shrink below its widest content, so a long
     table or control row scrolls inside its own panel instead of the page. */
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}

.sidebar { display: flex; flex-direction: column; gap: 1.25rem; }
@media (min-width: 1025px) {
  .sidebar {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    padding-bottom: 0.25rem;
  }
}

.card-control {
  background-color: var(--bg-secondary);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.control-group { margin-bottom: 0.9rem; }
.control-group label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.form-input, .form-select {
  width: 100%;
  padding: 0.45rem 0.65rem;
  font-family: inherit;
  font-size: 0.9rem;
  background-color: var(--bg-accent);
  color: var(--text-primary);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast);
}
.form-input:focus, .form-select:focus { border-color: var(--gov-blue); }
.form-select-sm { width: auto; font-size: 0.82rem; padding: 0.25rem 0.45rem; }

.inline-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.storage-note {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.dashboard-main { display: flex; flex-direction: column; gap: 1.5rem; }

/* Panels ------------------------------------------------------------------- */

.panel-card {
  background-color: var(--bg-secondary);
  padding: 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.panel-head h2 { margin-bottom: 0.5rem; }
.panel-head.bordered {
  border-bottom: 1.5px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}
.panel-head.bordered h2 { margin-bottom: 0; }
.panel-head-controls { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.panel-hint { margin-top: -0.5rem; margin-bottom: 1rem; }

/* Charts ------------------------------------------------------------------- */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.25rem;
}
@media (max-width: 520px) { .charts-grid { grid-template-columns: minmax(0, 1fr); } }

.card-chart {
  background-color: var(--bg-secondary);
  padding: 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 320px;
}
.card-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.card-chart-head h2 { font-size: 1.15rem; margin-bottom: 0.75rem; }

.chart-container { position: relative; flex-grow: 1; width: 100%; min-height: 220px; }
.svg-chart { width: 100%; height: 100%; overflow: visible; }

.chart-hint { font-size: 0.75rem; color: var(--text-secondary); margin: 0.5rem 0 0; }
.chart-table { margin-top: 0.75rem; }
.chart-table table { font-size: 0.85rem; }

.chart-grid-line { stroke: var(--border-light); stroke-width: 1; stroke-dasharray: 4, 4; }
.chart-line { fill: none; stroke: var(--chart-line); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-label { fill: var(--text-secondary); font-size: 10px; font-weight: 500; }
.chart-empty { fill: var(--text-secondary); font-size: 13px; }

.chart-dot {
  fill: var(--chart-line);
  stroke: var(--bg-secondary);
  stroke-width: 2;
  cursor: pointer;
  transition: r var(--transition-fast);
}
.chart-dot:hover { r: 7; }
.chart-dot:focus-visible { outline: none; stroke: var(--gov-focus); stroke-width: 4; r: 7; }

.donut-segment { cursor: pointer; transition: opacity var(--transition-fast); }
.donut-segment:hover { opacity: 0.82; }
.donut-segment:focus-visible { outline: 3px solid var(--gov-focus); outline-offset: 2px; }

.donut-high { stroke: var(--gov-red); }
.donut-medium { stroke: var(--gov-blue); }
.donut-low { stroke: var(--priority-low); }
.donut-high-fill { fill: var(--gov-red); }
.donut-medium-fill { fill: var(--gov-blue); }
.donut-low-fill { fill: var(--priority-low); }

.donut-caption { fill: var(--text-secondary); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; }
.donut-figure { fill: var(--text-primary); font-size: 20px; font-weight: 800; }
.donut-legend { fill: var(--text-primary); font-size: 10px; font-weight: 600; }

.chart-tooltip {
  background: var(--text-primary);
  color: var(--bg-secondary);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  z-index: 10;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
}
.chart-tooltip .tooltip-value { font-size: 1rem; font-weight: 800; color: var(--gov-blue); }

/* Theme chips -------------------------------------------------------------- */

.theme-cloud-wrapper { display: flex; flex-wrap: wrap; gap: 0.55rem; padding: 0.25rem 0; }

.issue-themes { display: flex; flex-direction: column; gap: 1.1rem; }
.issue-theme-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.theme-tag {
  background-color: var(--bg-accent);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem;
  border-radius: 50px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.theme-tag:hover { background-color: var(--gov-blue); border-color: var(--gov-blue); color: #fff; }
.theme-tag.active { background-color: var(--gov-blue-dark); border-color: var(--gov-blue-dark); color: #fff; }
.dark .theme-tag:hover, .dark .theme-tag.active { color: #0b0c0c; }
.theme-tag .tag-count {
  font-size: 0.75rem;
  background-color: rgba(0, 0, 0, 0.1);
  padding: 0.05rem 0.35rem;
  border-radius: 10px;
}
.dark .theme-tag .tag-count { background-color: rgba(255, 255, 255, 0.18); }

/* Tables ------------------------------------------------------------------- */

.table-wrapper {
  overflow-x: auto;
  margin-top: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.92rem; }
th {
  background-color: var(--bg-accent);
  color: var(--text-primary);
  font-weight: 700;
  padding: 0.7rem 1rem;
  border-bottom: 2px solid var(--border-color);
}
td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border-light); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background-color: var(--bg-accent); }

.not-a-link { color: var(--text-secondary); word-break: break-word; }
.not-a-link em { font-size: 0.8em; }

/* Feedback cards ----------------------------------------------------------- */

.feedback-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }

.feedback-item {
  border-left: 4px solid var(--border-color);
  background-color: var(--bg-accent);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: var(--shadow-sm);
}
.feedback-item.priority-high { border-left-color: var(--gov-red); }
.feedback-item.priority-medium { border-left-color: var(--gov-blue); }
.feedback-item.priority-low { border-left-color: var(--priority-low); }

.feedback-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.feedback-meta-left { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.feedback-meta-right { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.feedback-url { font-weight: 600; color: var(--gov-blue); text-decoration: none; word-break: break-all; }
.feedback-url:hover { text-decoration: underline; }

.badge-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-high { background-color: var(--badge-high-bg); color: var(--gov-red); border: 1px solid var(--gov-red); }
.badge-medium { background-color: var(--badge-medium-bg); color: var(--gov-blue); border: 1px solid var(--gov-blue); }
.badge-low { background-color: var(--badge-low-bg); color: var(--priority-low); border: 1px solid var(--priority-low); }
.badge-category {
  background-color: var(--badge-neutral-bg);
  color: var(--badge-neutral-text);
  border: 1px solid var(--border-color);
}

.feedback-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.6rem; }
.tag-chip {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
}
.tag-a { background-color: var(--tag-access-bg); color: var(--tag-access-text); }
.tag-f { background-color: var(--tag-func-bg); color: var(--tag-func-text); }

.feedback-text-group { display: flex; flex-direction: column; gap: 0.6rem; }
.feedback-q { font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 0.15rem; }
.feedback-a { font-size: 0.93rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.feedback-contact {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gov-green);
  margin: 0.25rem 0 0;
}

.feedback-triage {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border-color);
}
.feedback-triage .triage-note { flex: 1 1 14rem; font-size: 0.85rem; }

/* Pagination --------------------------------------------------------------- */

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
}
.pagination-controls { display: flex; gap: 0.5rem; }

/* Spinner ------------------------------------------------------------------ */

.spinner-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  z-index: 5;
}
.spinner-wrapper[hidden] { display: none; }
.spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--border-light);
  border-top-color: var(--gov-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Export dialog ------------------------------------------------------------ */

.export-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  max-width: 32rem;
  width: calc(100vw - 2rem);
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
}
.export-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 1.25rem 0;
  padding: 0.85rem;
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.9rem;
}
.checkbox-row input { margin-top: 0.2rem; flex-shrink: 0; }
.pii-warning { display: block; color: var(--text-secondary); font-size: 0.78rem; margin-top: 0.2rem; }

.export-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.copy-fallback-text {
  width: 100%;
  margin: 0.75rem 0 1rem;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  resize: vertical;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

/* Help --------------------------------------------------------------------- */

/* Heading with a contextual "?" beside it. Baseline alignment leaves each
   heading's own margin in charge of spacing, whatever panel it sits in. */
.heading-help { display: flex; align-items: baseline; gap: 0.5rem; }

.help-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 2px solid var(--gov-blue);
  border-radius: 50%;
  background: transparent;
  color: var(--gov-blue);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-0.1em);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.help-link:hover { background-color: var(--gov-blue); color: var(--bg-secondary); }

.help-inline-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--gov-blue);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
  cursor: pointer;
}
.help-inline-link:hover { color: var(--gov-blue-dark); text-decoration-thickness: 3px; }
.export-dialog .help-inline-link { margin: 0.5rem 0 0; }

/* Empty-state guide in the summary */
.start-lead { margin: 0 0 0.5rem; }
.start-steps { margin: 0 0 0.75rem; padding-left: 1.4rem; font-size: 0.98rem; color: var(--text-secondary); }
.start-steps li { margin-bottom: 0.2rem; }

/* Dialog */
.help-dialog {
  max-width: 62rem;
  height: min(46rem, calc(100vh - 2rem));
  padding: 0;
  overflow: hidden;
}
.help-dialog[open] { display: flex; flex-direction: column; }

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1.5px solid var(--border-color);
}
.help-header h2 { margin: 0; }

.help-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 16rem 1fr;
}

.help-nav {
  padding: 1rem;
  border-right: 1px solid var(--border-light);
  background: var(--bg-accent);
  overflow-y: auto;
}
.help-search-label { display: block; font-weight: 700; font-size: 0.85rem; margin-bottom: 0.3rem; }
.help-nav-title {
  margin: 1rem 0 0.4rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.help-topics { list-style: none; margin: 0; padding: 0; }
.help-topic {
  display: block;
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 0;
  border-left: 4px solid transparent;
  background: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}
.help-topic:hover { background: var(--bg-secondary); }
.help-topic[aria-current="true"] {
  border-left-color: var(--gov-blue);
  background: var(--bg-secondary);
  font-weight: 700;
}
.help-empty { padding: 0.45rem 0.6rem; font-size: 0.88rem; color: var(--text-secondary); font-style: italic; }

.help-article {
  padding: 1.5rem 2rem;
  overflow-y: auto;
  line-height: 1.6;
}
.help-article:focus { outline: none; }
.help-article:focus-visible { outline: 3px solid var(--gov-focus); outline-offset: -3px; }
.help-article-title { font-size: 1.5rem; margin-bottom: 0.25rem; }
.help-lead { margin: 0 0 1.25rem; font-size: 1.05rem; color: var(--text-secondary); }
.help-article h4 { font-size: 1.05rem; margin: 1.5rem 0 0.5rem; }
.help-article p { margin: 0 0 0.9rem; }
.help-list, .help-steps { margin: 0 0 1rem; padding-left: 1.4rem; }
.help-list li, .help-steps li { margin-bottom: 0.45rem; }
.help-steps li::marker { font-weight: 700; color: var(--gov-blue); }

.help-callout {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-left: 5px solid var(--gov-blue);
  background: var(--badge-medium-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.help-callout.help-note { border-left-color: var(--gov-orange); background: var(--tag-access-bg); }
.help-callout p { margin: 0; }
.help-callout-label { display: block; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

.help-qa { margin: 0; }
.help-qa dt { font-weight: 700; margin-top: 1rem; }
.help-qa dt:first-child { margin-top: 0; }
.help-qa dd { margin: 0.25rem 0 0; }

.help-related { margin-top: 1.75rem; padding-top: 1rem; border-top: 1px solid var(--border-light); }
.help-related h4 { margin-top: 0; font-size: 0.9rem; color: var(--text-secondary); }
.help-related ul { margin: 0; padding-left: 1.2rem; }
.help-related li { margin-bottom: 0.3rem; }
.help-related-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--gov-blue);
  font-family: inherit;
  font-size: 0.95rem;
  text-decoration: underline;
  cursor: pointer;
}
.help-related-link:hover { color: var(--gov-blue-dark); }

.help-footer {
  margin: 0;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

@media (max-width: 700px) {
  .help-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .help-nav { border-right: 0; border-bottom: 1px solid var(--border-light); max-height: 34vh; }
  .help-article { padding: 1.25rem; }
}

/* Footer ------------------------------------------------------------------- */

.app-footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2rem;
  margin-top: 2rem;
  text-align: center;
}
.footer-content { max-width: 1440px; margin: 0 auto; color: var(--text-secondary); font-size: 0.92rem; }
.footer-content p { margin: 0.5rem 0; }
.footer-link {
  color: var(--gov-blue);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}
.footer-link:hover { color: var(--gov-blue-dark); text-decoration-thickness: 3px; }

/* Print-only appendix ------------------------------------------------------ */

.print-only { display: none; }

/* ==========================================================================
   Print — an executive brief, including every filtered response
   ========================================================================== */

@media print {
  body { background: #fff !important; color: #000 !important; font-size: 10.5pt; }

  .topbar,
  .sidebar,
  .toast-region,
  .pagination,
  .file-upload-wrapper,
  .header-actions,
  .chart-hint,
  .export-dialog,
  .feedback-triage,
  .help-link,
  .help-inline-link,
  .start-steps,
  .btn,
  .panel-head-controls select {
    display: none !important;
  }

  /* The topic and issue chips are <button> elements. The previous stylesheet
     hid every button in print, which silently dropped both panels from the
     saved brief — exactly the summary a reader wants. */
  .theme-tag {
    display: inline-flex !important;
    border: 1px solid #999 !important;
    background: #fff !important;
    color: #000 !important;
  }
  .theme-tag .tag-count { background: #eee !important; }

  main { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
  .dashboard-grid { grid-template-columns: 1fr !important; }
  .kpis { grid-template-columns: repeat(5, 1fr) !important; gap: 0.5cm !important; }

  .hero {
    border-left: 4px solid #000 !important;
    box-shadow: none !important;
    background: #f7f7f7 !important;
    page-break-inside: avoid;
  }

  .card-kpi, .card-chart, .panel-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: #fff !important;
    page-break-inside: avoid;
    margin-bottom: 0.6cm;
  }

  .kpi-value, .kpi-delta { color: #000 !important; }

  /* The screen list is paginated; the appendix below carries the full set. */
  #feedbackList { display: none !important; }

  .chart-table { display: block !important; }
  .chart-table[hidden] { display: block !important; }

  .print-only { display: block !important; }
  #printAppendix { page-break-before: always; }
  #printAppendix h2 { font-size: 14pt; border-bottom: 2px solid #000; padding-bottom: 0.2cm; }

  .print-item {
    page-break-inside: avoid;
    border: 1px solid #ccc;
    border-left: 4px solid #000;
    padding: 0.3cm 0.4cm;
    margin-bottom: 0.4cm;
  }
  .print-item h3 { font-size: 11pt; margin-bottom: 0.1cm; }
  .print-item p { margin: 0.1cm 0; }
  .print-meta { font-size: 9pt; color: #444 !important; font-style: italic; }
  .print-note { border-top: 1px dotted #999; padding-top: 0.1cm; }

  a { color: #000 !important; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; word-break: break-all; }

  body::before {
    content: "FEEDBACK ANALYTICS — INFOZONE REPORT";
    display: block;
    font-size: 13pt;
    font-weight: bold;
    border-bottom: 3px double #000;
    padding-bottom: 0.3cm;
    margin-bottom: 0.6cm;
    text-align: center;
  }
}
