:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #d9dee7;
  --text: #16202a;
  --muted: #657386;
  --accent: #b9272f;
  --accent-weak: #fff4d6;
  --brand-gold: #f5b51b;
  --danger: #9f2d2d;
}

/* Performance Intelligence command centre */
.command-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 30px;
  justify-content: space-between;
  padding: 8px 4px 16px;
}

.command-heading > div > span,
.command-section-title > div > span,
.command-insights > span {
  color: var(--accent);
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.command-heading h1 {
  color: var(--accent);
  font-size: clamp(24px, 2vw, 34px);
  line-height: 1.1;
  margin: 4px 0 5px;
}

.command-heading p {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.command-heading dl {
  display: flex;
  margin: 0;
}

.command-heading dl div {
  border-left: 1px solid var(--line);
  min-width: 150px;
  padding: 4px 20px;
}

.command-heading dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.command-heading dd {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  margin: 7px 0 0;
}

.command-overview {
  display: grid;
  gap: 0;
  grid-template-columns: minmax(250px, .82fr) minmax(520px, 1.6fr) minmax(260px, .8fr);
  min-height: 340px;
}

.command-overview.client-overview {
  grid-template-columns: minmax(250px, .75fr) minmax(420px, 1.35fr) minmax(260px, .8fr);
  min-height: 280px;
}

.command-overview.client-overview .command-value,
.command-overview.client-overview .command-mix,
.command-overview.client-overview .command-insights {
  min-height: 280px;
}

.reconciliation-status {
  align-items: center;
  background: #fff8e8;
  border-left: 4px solid #cc7a00;
  border-radius: 5px;
  color: #775000;
  display: flex;
  font-size: 11px;
  gap: 8px;
  padding: 8px 11px;
}

.reconciliation-status.reconciled {
  background: #f1faf4;
  border-left-color: #16803b;
  color: #236139;
}

.reconciliation-status.empty {
  background: #f6f7f9;
  border-left-color: #7d8792;
  color: #4d5967;
}

.reconciliation-status span { color: #596778; }

.command-value,
.command-mix,
.command-insights,
.command-activity,
.command-list {
  background: #fff;
  border: 1px solid var(--line);
}

.command-value {
  align-content: center;
  border-left: 4px solid var(--brand-gold);
  border-radius: 8px 0 0 8px;
  display: grid;
  padding: 24px;
}

.command-value > span {
  color: #344152;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.command-value > strong {
  color: var(--accent);
  font-size: clamp(34px, 3vw, 52px);
  line-height: 1;
  margin: 18px 0 12px;
  white-space: nowrap;
}

.command-value > em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.invoice-value-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.invoice-value-grid > div {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  container-type: inline-size;
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 11px 12px;
}

.invoice-value-grid > div.invoice-value-primary {
  background: #fff8e8;
  border-color: #f0d48e;
}

.invoice-value-grid span {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 9px;
  font-weight: 800;
  gap: 5px;
  justify-content: space-between;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.invoice-value-grid strong {
  color: var(--text);
  font-size: clamp(16px, 11cqi, 23px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.025em;
  line-height: 1.1;
  white-space: nowrap;
}

.invoice-value-grid .invoice-value-primary strong {
  color: var(--accent);
  font-size: clamp(19px, 12cqi, 28px);
}

.invoice-value-grid small {
  color: var(--muted);
  font-size: 9px;
}

.invoice-value-grid + em {
  margin-top: 12px;
}

.movement-chip {
  background: #eff8f1;
  border-left: 3px solid #16803b;
  display: grid;
  gap: 3px;
  margin-top: 22px;
  padding: 9px 11px;
}

.movement-chip.down { background: #fff3f3; border-left-color: var(--accent); }
.movement-chip.neutral { background: #f6f7f9; border-left-color: #95a0ad; }
.movement-chip strong { color: var(--text); font-size: 11px; }
.movement-chip span { color: var(--muted); font-size: 9px; }

.info-dot {
  background: transparent;
  border: 1px solid #95a0ad;
  border-radius: 50%;
  color: #657386;
  cursor: help;
  font-size: 10px;
  height: 18px;
  line-height: 16px;
  margin-left: 5px;
  min-height: 0;
  padding: 0;
  width: 18px;
}

.info-dot:hover,
.info-dot:focus-visible,
.info-dot[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  outline: none;
}

.info-dot:focus-visible {
  box-shadow: 0 0 0 3px rgba(185, 39, 47, .18);
}

.info-popover {
  background: #16202a;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(22, 32, 42, .22);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  max-width: min(300px, calc(100vw - 24px));
  padding: 9px 11px;
  position: fixed;
  text-transform: none;
  width: max-content;
  z-index: 1100;
}

.command-mix {
  border-left: 0;
  padding: 20px 24px;
}

.command-section-title {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.command-section-title h2,
.command-insights h2 {
  color: var(--text);
  font-size: 16px;
  margin: 4px 0 0;
}

.command-section-title > small {
  color: var(--muted);
  font-size: 11px;
}

.mix-content {
  align-items: center;
  display: grid;
  gap: 18px;
  grid-template-columns: 280px minmax(220px, 1fr);
  margin-top: 8px;
}

.command-empty {
  align-content: center;
  color: var(--muted);
  display: grid;
  gap: 7px;
  min-height: 260px;
  text-align: center;
}

.command-empty strong { color: var(--text); font-size: 15px; }

.single-service-story {
  align-content: center;
  display: grid;
  gap: 10px;
  min-height: 210px;
  padding: 20px 8%;
}

.single-service-story span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.single-service-story strong {
  color: var(--accent);
  font-size: clamp(24px, 2vw, 34px);
}

.single-service-story p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.mix-canvas-wrap {
  height: 280px;
  position: relative;
  width: 280px;
}

.mix-tooltip {
  background: #16202a;
  border-radius: 6px;
  color: #fff;
  display: grid;
  font-size: 11px;
  gap: 3px;
  min-width: 170px;
  padding: 9px 11px;
  pointer-events: none;
  position: absolute;
  z-index: 2;
}

.mix-tooltip[hidden] { display: none; }
.mix-tooltip span { color: #d9e0e7; }

.mix-legend {
  display: grid;
}

.mix-legend > div {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 10px 1fr auto;
  padding: 12px 0;
}

.mix-legend > div:last-child { border-bottom: 0; }
.mix-swatch { border-radius: 50%; height: 10px; width: 10px; }
.swatch-0 { background: #c5222c; }
.swatch-1 { background: #f5b51b; }
.swatch-2 { background: #7d8792; }
.swatch-3 { background: #33475b; }
.swatch-4 { background: #d9a441; }
.mix-legend span,
.mix-legend b { display: grid; gap: 3px; }
.mix-legend strong,
.mix-legend b { color: var(--text); font-size: 12px; }
.mix-legend b { text-align: right; }
.mix-legend small { color: var(--muted); font-size: 10px; font-weight: 400; }

.mix-adjustments {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 3px;
  grid-template-columns: 1fr auto;
  padding-top: 10px;
}

.mix-adjustments strong,
.mix-adjustments span { color: #8f2630; font-size: 11px; }
.mix-adjustments small { color: var(--muted); font-size: 9px; grid-column: 1 / -1; }

.command-insights {
  background: #fffaf0;
  border-left: 0;
  border-radius: 0 8px 8px 0;
  padding: 22px;
}

.command-insights > div {
  border-top: 1px solid #eadfc8;
  margin-top: 16px;
  padding-top: 16px;
}

.command-insights strong { font-size: 12px; }
.command-insights p { color: #4d5967; font-size: 12px; line-height: 1.45; margin: 6px 0 0; }

.command-metrics {
  background: transparent;
  border: 0;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, 1fr);
}

.command-metrics > div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  gap: 5px;
  padding: 16px 20px;
}

.command-metrics span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.command-metrics strong { color: var(--text); font-size: 18px; }
.command-metrics small { color: var(--muted); font-size: 11px; }

.command-activity,
.command-list {
  border-radius: 8px;
  padding: 16px 18px 0;
}

.activity-flow {
  align-items: center;
  display: grid;
  grid-template-columns: 1fr 60px 1fr 60px 1fr 60px 1fr;
  padding: 30px 24px;
}

.activity-flow > div { display: grid; gap: 7px; text-align: center; }
.activity-flow span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.activity-flow strong { color: var(--text); font-size: 19px; }
.activity-flow i { background: #d8dee6; height: 1px; position: relative; }
.activity-flow i::after { background: #fff; border: 2px solid var(--brand-gold); border-radius: 50%; content: ''; height: 7px; position: absolute; right: -4px; top: -4px; width: 7px; }
.activity-flow .activity-net strong { color: var(--accent); }

.support-status {
  align-items: center;
  background: #f8fafc;
  border-top: 1px solid var(--line);
  color: #596778;
  display: flex;
  font-size: 11px;
  gap: 8px;
  margin: 0 -18px;
  padding: 10px 18px;
}

.support-status strong { color: #b06d00; }
.support-status.ready strong { color: #16803b; }

.command-list .bar-list { padding: 12px 0 16px; }
.report-client-link {
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: inherit;
  cursor: pointer;
  font: inherit;
  min-height: 0;
  padding: 7px 8px;
  text-align: left;
  width: 100%;
}
.report-client-link:hover { background: #fffaf0; }
.report-client-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.command-tables { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.command-tables.single-report-table { grid-template-columns: 1fr; }
.command-list .reports-table { margin: 12px -18px 0; width: calc(100% + 36px); }
.command-list .reports-table tbody tr:hover { background: #fffaf0; }

.report-provenance {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 10px;
  gap: 8px 24px;
  justify-content: center;
  padding: 3px 10px 8px;
}

@media (max-width: 1350px) {
  .command-overview { grid-template-columns: minmax(240px, .8fr) minmax(480px, 1.4fr); }
  .command-insights { border-left: 1px solid var(--line); border-radius: 8px; grid-column: 1 / -1; }
  .command-insights > div { display: inline-block; margin-right: 3%; vertical-align: top; width: 29%; }
}

@media (max-width: 980px) {
  .command-heading { align-items: flex-start; flex-direction: column; }
  .command-heading dl { width: 100%; }
  .command-heading dl div { flex: 1; min-width: 0; }
  .command-overview { grid-template-columns: 1fr; }
  .command-value,
  .command-mix,
  .command-insights { border: 1px solid var(--line); border-radius: 8px; }
  .mix-content { grid-template-columns: 280px 1fr; }
  .command-insights > div { display: block; width: auto; }
  .command-metrics { grid-template-columns: repeat(2, 1fr); }
  .command-metrics > div:nth-child(odd) { border-left: 0; }
  .activity-flow { gap: 12px; grid-template-columns: repeat(2, 1fr); }
  .activity-flow i { display: none; }
  .command-tables { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .command-heading dl { display: grid; grid-template-columns: 1fr; }
  .command-heading dl div { border-left: 0; border-top: 1px solid var(--line); padding-left: 0; }
  .mix-content { grid-template-columns: 1fr; }
  .mix-canvas-wrap { margin: auto; }
  .command-metrics { grid-template-columns: 1fr; }
  .command-metrics > div { border-left: 0; border-top: 1px solid var(--line); }
  .invoice-value-grid { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; }
  .topbar,
  .reports-header .reports-toolbar,
  .busy-overlay,
  dialog { display: none !important; }
  .view,
  .reports-layout,
  .reports-panel,
  .reports-body { display: block !important; height: auto !important; overflow: visible !important; }
  .reports-panel { border: 0; }
  .reports-header { min-height: 0; padding: 0 0 12px; }
  .command-overview { grid-template-columns: .8fr 1.6fr .8fr; }
  .command-tables { break-inside: avoid; }
  .command-overview,
  .command-metrics,
  .command-activity,
  .command-list { break-inside: avoid; }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.login-view {
  align-items: center;
  background: var(--bg);
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  padding: 22px;
  width: min(420px, 100%);
}

.login-panel img {
  height: 72px;
  object-fit: contain;
  object-position: left center;
  width: 280px;
}

.login-panel h1 {
  color: var(--text);
}

.login-panel p {
  color: var(--muted);
  font-size: 13px;
}

.login-panel p.waiting::after {
  animation: waiting-dots 1.2s steps(4, end) infinite;
  content: "";
  display: inline-block;
  min-width: 18px;
  text-align: left;
}

@keyframes waiting-dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75%,
  100% {
    content: "...";
  }
}

.login-panel label {
  display: grid;
  gap: 5px;
}

.login-panel label span {
  color: var(--muted);
  font-size: 12px;
}

.login-panel input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  padding: 9px 10px;
  width: 100%;
}

.login-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(185, 39, 47, 0.12);
}

.login-panel .login-help {
  justify-self: center;
  text-align: center;
}

.login-panel small {
  color: var(--muted);
  font-size: 12px;
}

.reset-fields {
  display: grid;
  gap: 14px;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 3px solid var(--accent);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  min-height: 84px;
  padding: 10px 18px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 16px;
  min-width: 0;
}

.brand img {
  display: block;
  flex: 0 0 auto;
  height: 64px;
  object-fit: contain;
  width: 260px;
}

h1, h2, p {
  margin: 0;
}

h1 {
  color: var(--accent);
  font-size: 20px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
}

.topbar p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  font-size: 13px;
  padding: 8px 10px;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

button:hover {
  background: #941f26;
}

.button-link {
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #ffffff;
  cursor: pointer;
  display: inline-block;
  font-size: 13px;
  padding: 8px 10px;
  text-decoration: none;
}

.button-link:hover {
  background: #941f26;
}

.button-link.secondary {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
}

.button-link.secondary:hover {
  background: #f0f3f7;
}

.topnav {
  display: flex;
  gap: 8px;
}

.nav-button,
.secondary-button {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
}

.nav-button:hover,
.secondary-button:hover {
  background: #f0f3f7;
}

.danger-button {
  background: var(--danger);
  border: 1px solid var(--danger);
  color: #ffffff;
}

.danger-button:hover:not(:disabled) {
  background: #7f2020;
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.nav-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.actions {
  display: flex;
  gap: 8px;
}

.document-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

.layout {
  display: grid;
  gap: 12px;
  grid-template-columns: 320px 390px minmax(520px, 1fr);
  height: calc(100vh - 85px);
  padding: 12px;
}

.layout.client-scoped-layout {
  grid-template-columns: 390px minmax(520px, 1fr);
}

.layout.client-scoped-layout .clients-panel {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 12px;
}

.panel-tools {
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.panel-tools input {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  padding: 8px 9px;
  width: 100%;
}

.panel-tools select {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  margin-bottom: 8px;
  padding: 8px 9px;
  width: 100%;
}

.panel-tools input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(185, 39, 47, 0.12);
}

.search-hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 5px;
}

.document-filter-row {
  display: flex;
  gap: 7px;
}

.document-filter-row input {
  flex: 1 1 auto;
  min-width: 0;
}

.panel-tools .document-filter-row select {
  flex: 0 0 142px;
  margin-bottom: 0;
  width: 142px;
}

.list {
  height: calc(100% - 92px);
  overflow: auto;
}

.clients-panel .list {
  height: calc(100% - 137px);
}

.documents-panel .list {
  height: calc(100% - 113px);
}

.admin-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: 220px 360px minmax(520px, 1fr);
  height: calc(100vh - 85px);
  padding: 12px;
}

.json-viewer-layout {
  display: grid;
  gap: 12px;
  grid-template-columns: 360px minmax(620px, 1fr);
  height: calc(100vh - 85px);
  padding: 12px;
}

.system-health-layout {
  height: calc(100vh - 85px);
  padding: 12px;
}

.reports-layout {
  height: calc(100vh - 85px);
  padding: 12px;
}

.reports-panel {
  height: 100%;
}

.reports-header {
  align-items: center;
  min-height: 64px;
  padding: 9px 12px;
}

.reports-header > div:first-child {
  flex: 0 0 280px;
  min-width: 0;
}

.reports-header p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reports-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.report-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.report-actions #refreshReports {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.reports-toolbar label {
  display: grid;
  gap: 4px;
}

.reports-toolbar label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.reports-toolbar select {
  height: 34px;
  min-width: 150px;
}

.reports-toolbar label:nth-child(2) select {
  min-width: 300px;
  width: 300px;
}

.reports-toolbar input[type="date"] {
  height: 34px;
  width: 135px;
}

.reports-toolbar input[type="month"] {
  height: 34px;
  width: 165px;
  max-width: 100%;
}

.reports-toolbar button { height: 34px; white-space: nowrap; }

.reports-body {
  align-content: start;
  display: grid;
  gap: 12px;
  grid-auto-rows: max-content;
  height: calc(100% - 57px);
  overflow: auto;
  padding: 12px;
}

.report-hero {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 9px;
  color: var(--text);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  min-height: 104px;
  padding: 16px 20px;
}

.report-eyebrow {
  color: var(--accent);
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.report-hero h1 {
  font-size: clamp(20px, 1.6vw, 27px);
  line-height: 1.1;
  margin: 0;
}

.report-hero p {
  color: var(--muted);
  margin: 6px 0 0;
}

.report-hero-stat {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  display: grid;
  flex: 0 0 auto;
  gap: 3px;
  min-width: 250px;
  padding: 12px 16px;
}

.report-hero-stat span,
.report-hero-stat em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.report-hero-stat strong {
  color: var(--accent);
  font-size: 25px;
}

.reports-kpis {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
}

.report-kpi {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 12px;
}

.report-kpi span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.report-kpi strong {
  color: var(--text);
  font-size: 21px;
  line-height: 1.05;
}

.report-kpi em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.reports-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(420px, 1.4fr) minmax(360px, 1fr) minmax(360px, 1fr);
}

.reports-grid-tables {
  grid-template-columns: repeat(2, minmax(420px, 1fr));
}

.reports-grid-tables.single-report-table {
  grid-template-columns: 1fr;
}

.executive-primary {
  grid-template-columns: minmax(560px, 1.65fr) minmax(360px, 1fr);
}

.report-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.report-card-wide {
  min-height: 300px;
}

.report-card-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
}

.report-card-header h3 {
  font-size: 14px;
  margin: 0;
}

.report-card-header span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.trend-chart {
  display: block;
  height: 220px;
  padding: 8px 12px 10px;
  width: 100%;
}

.trend-legend {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 14px;
  padding: 12px 12px 0;
}

.trend-legend span {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.trend-legend strong {
  color: var(--text);
  font-size: 12px;
  margin-left: auto;
}

.legend-line,
.legend-bar {
  display: inline-block;
}

.legend-line {
  background: var(--accent);
  height: 3px;
  width: 22px;
}

.legend-bar {
  background: #fff4d6;
  border: 1px solid #f5b51b;
  border-radius: 3px;
  height: 12px;
  width: 12px;
}

.trend-chart .trend-bars rect {
  fill: #fff4d6;
  stroke: #f5b51b;
}

.trend-grid-line {
  stroke: #d9dee7;
  stroke-width: 1;
}

.trend-chart polyline {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.trend-points circle {
  fill: #ffffff;
  stroke: var(--accent);
  stroke-width: 3;
}

.trend-hit {
  cursor: help;
}

.trend-hit:hover circle {
  fill: var(--accent);
}

.single-day-summary {
  display: grid;
  grid-template-columns: 1.25fr repeat(4, 1fr);
  min-height: 215px;
  padding: 28px 22px;
}

.single-day-summary > div {
  align-content: center;
  border-left: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding: 12px 20px;
}

.single-day-summary > div:first-child {
  border-left: 0;
}

.single-day-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.single-day-summary strong {
  color: var(--text);
  font-size: 20px;
}

.single-day-summary .single-day-date strong {
  color: var(--accent);
}

.trend-axis-label,
.trend-value-label {
  fill: #657386;
  font-size: 11px;
}

.trend-value-label {
  fill: #344152;
  font-weight: 700;
}

.trend-axis-right {
  text-anchor: end;
}

.bar-list {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.bar-row {
  align-items: center;
  display: grid;
  gap: 9px;
  grid-template-columns: 24px minmax(0, 1fr) 92px;
}

.bar-rank {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.bar-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.bar-label {
  align-items: baseline;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 0;
}

.bar-label strong {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-label span {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 11px;
}

.bar-track {
  background: #edf1f5;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.bar-fill {
  background: #f5b51b;
  border-radius: 999px;
  height: 100%;
}

.bar-value {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.reports-table {
  font-size: 12px;
  min-width: 0;
  width: 100%;
}

.reports-table th,
.reports-table td {
  padding: 8px 10px;
}

.reports-table .right {
  text-align: right;
}

.review-board {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  padding: 12px;
}

.review-column {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
  overflow: hidden;
}

.review-column-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 9px 10px;
}

.review-column-header h3 {
  font-size: 13px;
  margin: 0;
}

.review-column-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.review-cards {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.review-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 6px;
  display: grid;
  gap: 4px;
  padding: 9px;
}

.review-card.warning {
  border-left-color: #f5b51b;
}

.review-card.focus {
  border-left-color: var(--accent);
}

.review-card.danger {
  border-left-color: var(--danger);
}

.review-card strong {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.review-card span,
.review-card em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.review-card em {
  color: var(--text);
  font-weight: 700;
}

.chart-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
}

.report-note {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-gold);
  border-radius: 8px;
  color: #344152;
  font-size: 12px;
  line-height: 1.4;
  padding: 10px 12px;
}

.report-note strong {
  color: var(--text);
}

.system-health-panel {
  height: 100%;
}

.system-health-panel .panel-header {
  align-items: flex-start;
}

.system-health-panel .panel-header p {
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0 0;
}

.system-health-body {
  display: grid;
  gap: 12px;
  height: calc(100% - 57px);
  overflow: auto;
  padding: 12px;
}

.health-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.health-grid-wide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.health-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.health-card-title {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.health-card h3 {
  font-size: 14px;
  margin: 0;
}

.health-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.health-card dl div {
  display: grid;
  gap: 3px;
}

.health-card dt {
  color: var(--muted);
  font-size: 11px;
}

.health-card dd {
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
}

.health-card-actions {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}

.status-badge {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
}

.status-badge.ok {
  background: #e4f6e9;
  color: #17622d;
}

.status-badge.bad {
  background: #fde7e9;
  color: #941f26;
}

.health-list,
.health-log {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 7px;
  padding-top: 10px;
}

.health-list div,
.health-log div {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.health-list strong,
.health-list span {
  display: block;
}

.health-list span {
  color: var(--muted);
  margin-top: 2px;
}

.json-table-panel .panel-header {
  align-items: flex-start;
}

.json-table-panel .panel-header p {
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0 0;
}

.json-table-tools {
  display: flex;
  gap: 8px;
}

.json-table-tools input {
  flex: 1 1 auto;
  min-width: 0;
}

.json-table-tools button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.json-horizontal-scroll {
  height: 17px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
}

.json-horizontal-scroll > div {
  height: 1px;
  width: 100%;
}

.json-table {
  height: calc(100% - 109px);
  overflow-x: scroll;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.json-table table {
  min-width: 100%;
  width: max-content;
}

.json-table th,
.json-table td {
  max-width: 340px;
  white-space: nowrap;
}

.json-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.json-sort-button {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
  text-align: left;
  white-space: nowrap;
}

.json-sort-button:hover,
.json-sort-button.active {
  color: var(--accent);
}

.json-limit-notice {
  background: #fff4d6;
  border-bottom: 1px solid var(--line);
  color: #5b4a16;
  font-size: 12px;
  padding: 8px 10px;
  position: sticky;
  top: 0;
  z-index: 2;
}

.admin-menu {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.admin-nav-panel .panel-header {
  align-items: flex-start;
  flex-direction: column;
  gap: 3px;
}

.admin-nav-panel .panel-header span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.admin-tab {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  text-align: left;
}

.admin-tab:hover {
  background: #f0f3f7;
}

.admin-tab.active {
  background: var(--accent-weak);
  border-color: var(--brand-gold);
  box-shadow: inset 4px 0 0 var(--brand-gold);
}

.admin-form {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.admin-form label {
  display: grid;
  gap: 5px;
}

.admin-form label span {
  color: var(--muted);
  font-size: 12px;
}

.admin-form input,
.admin-form select {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  min-width: 0;
  outline: none;
  padding: 8px 9px;
  width: 100%;
}

.admin-form input:focus,
.admin-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(185, 39, 47, 0.12);
}

.form-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.checkbox-field {
  align-items: center;
  display: flex !important;
  gap: 8px !important;
}

.checkbox-field input {
  width: auto;
}

.checkbox-field span {
  color: var(--text) !important;
}

.form-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.form-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  min-height: 16px;
}

.form-status.ok {
  color: #17622d;
}

.form-status.error {
  color: var(--danger);
}

.company-users-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding-top: 12px;
}

.delivery-settings-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
}

.delivery-settings-section .section-header p {
  color: var(--muted);
  font-size: 12px;
  margin: 3px 0 0;
}

.delivery-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.delivery-header-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.delivery-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.delivery-readonly {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 12px;
}

.delivery-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#deliveryActionStatus {
  color: var(--muted);
  font-size: 12px;
}

.section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.section-header-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.compact-button {
  font-size: 12px;
  padding: 5px 8px;
}

.section-header h3 {
  font-size: 14px;
  margin: 0;
}

.section-header span,
.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.company-users-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.company-user-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 9px 10px;
}

.company-user-row:last-child {
  border-bottom: 0;
}

.company-user-row strong,
.company-user-row span {
  display: block;
}

.company-user-row span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.company-user-meta {
  text-align: right;
  white-space: nowrap;
}

.detail-panel .detail-body {
  height: calc(100% - 45px);
}

.item {
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  padding: 10px 12px;
}

.item:hover,
.item.active {
  background: var(--accent-weak);
}

.item.active {
  box-shadow: inset 4px 0 0 var(--brand-gold);
}

.item-title {
  display: flex;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  justify-content: space-between;
}

.client-card-main {
  align-items: flex-start;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) max-content;
}

.client-item .item-title {
  display: block;
  line-height: 1.25;
}

.client-doc-count {
  align-self: center;
  font-size: 13px;
  font-weight: 700;
  justify-self: end;
  line-height: 1.1;
  text-align: right;
}

.item-name {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  margin-top: 5px;
}

.item-meta {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 3px;
  margin-top: 6px;
}

.metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  margin: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 11px;
}

.metric strong {
  display: block;
  font-size: 14px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.metric-wide {
  grid-column: span 2;
}

.detail-body {
  height: calc(100% - 45px);
  overflow: auto;
}

table {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 1500px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f3f7;
  color: #344152;
  position: sticky;
  top: 0;
  z-index: 1;
}

.support-documents-section {
  border-top: 1px solid var(--line);
  margin: 12px;
  padding-top: 12px;
}

.embedded-invoice-section {
  background: #3f444a;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 12px;
  overflow: hidden;
}

.invoice-pdf-toolbar {
  align-items: center;
  background: #2f3338;
  color: #fff;
  display: grid;
  font-size: 12px;
  grid-template-columns: 1fr auto 1fr;
  min-height: 48px;
  padding: 6px 12px;
}

.invoice-pdf-toolbar-group {
  align-items: center;
  display: flex;
  gap: 8px;
}

.invoice-pdf-toolbar-group:nth-child(2) {
  justify-self: center;
}

.invoice-pdf-toolbar-group:last-child {
  justify-self: end;
}

.pdf-tool-button,
.pdf-tool-link {
  align-items: center;
  background: transparent;
  border: 1px solid #68717a;
  border-radius: 4px;
  color: #fff;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 30px;
  min-width: 32px;
  padding: 5px 9px;
  text-decoration: none;
}

.pdf-tool-button:hover:not(:disabled),
.pdf-tool-link:hover {
  background: #4a5158;
  border-color: #98a1aa;
}

.pdf-tool-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.invoice-pdf-stage {
  align-items: flex-start;
  display: flex;
  height: max(620px, calc(100vh - 330px));
  justify-content: center;
  overflow: auto;
  padding: 16px;
  position: relative;
}

.invoice-pdf-stage canvas {
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.38);
  display: block;
  max-width: none;
}

.invoice-pdf-status {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 5px;
  color: var(--text);
  left: 50%;
  margin: 0;
  padding: 10px 14px;
  position: absolute;
  top: 24px;
  transform: translateX(-50%);
  z-index: 1;
}

.statement-view {
  display: grid;
  gap: 12px;
}

.statement-toolbar {
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.statement-toolbar h3 {
  font-size: 16px;
  margin: 0;
}

.statement-toolbar p {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}

.statement-filters {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.statement-filters label {
  display: grid;
  gap: 4px;
}

.statement-filters span {
  color: var(--muted);
  font-size: 11px;
}

.statement-filters input {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  padding: 7px 8px;
}

.statement-body {
  display: grid;
  gap: 10px;
}

.statement-metrics {
  margin-bottom: 0;
}

.statement-table {
  min-width: 980px;
}

.support-documents-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.support-documents-header h3 {
  font-size: 14px;
  margin: 0 0 4px;
}

.support-documents-header p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.support-documents-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.support-document-item {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 8px 10px;
}

.support-document-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 3px;
}

.support-document-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.support-upload-modal {
  max-width: min(620px, 92vw);
  padding: 0;
  width: min(620px, 92vw);
}

.support-upload-dialog {
  margin: 0;
}

.support-upload-dialog-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.support-upload-dialog-body label {
  display: grid;
  gap: 5px;
}

.support-upload-dialog-body span {
  color: var(--muted);
  font-size: 12px;
}

.support-upload-dialog-body input,
.support-upload-dialog-body select {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  padding: 8px;
}

.support-upload-dialog-body p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 12px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: min(900px, 90vw);
  width: 760px;
}

.busy-overlay {
  align-items: center;
  background: rgba(22, 32, 42, 0.28);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 24px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1000;
}

.busy-panel {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(22, 32, 42, 0.18);
  display: flex;
  gap: 14px;
  min-width: min(360px, 92vw);
  padding: 18px;
}

.busy-panel strong {
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.busy-panel p {
  color: var(--muted);
  font-size: 12px;
}

.busy-spinner {
  animation: busy-spin 0.8s linear infinite;
  border: 3px solid #edf1f5;
  border-radius: 50%;
  border-top-color: var(--accent);
  flex: 0 0 auto;
  height: 28px;
  width: 28px;
}

@keyframes busy-spin {
  to {
    transform: rotate(360deg);
  }
}

.pdf-modal {
  height: min(880px, 92vh);
  max-width: min(1180px, 94vw);
  padding: 0;
  width: min(1180px, 94vw);
}

.pdf-modal-header,
.pdf-modal-actions {
  align-items: center;
  background: #ffffff;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 10px 12px;
}

.pdf-modal-header {
  border-bottom: 1px solid var(--line);
}

.pdf-modal-actions {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.pdf-modal iframe {
  border: 0;
  display: block;
  height: calc(92vh - 104px);
  max-height: 776px;
  width: 100%;
}

pre {
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
}

@media (max-width: 1180px) {
  .layout,
  .admin-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .reports-layout {
    height: auto;
  }

  .reports-kpis,
  .reports-grid,
  .reports-grid-tables,
  .review-board {
    grid-template-columns: 1fr;
  }

  .report-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-hero-stat {
    min-width: 0;
    width: 100%;
  }

  .reports-toolbar {
    width: 100%;
  }

  .reports-toolbar label,
  .reports-toolbar label select {
    flex: 1 1 220px;
    min-width: 0;
  }

  .single-day-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .single-day-summary > div:nth-child(odd) {
    border-left: 0;
  }

  .topbar {
    align-items: flex-start;
    gap: 12px;
  }

  .brand img {
    height: 48px;
    width: 196px;
  }

  .panel {
    min-height: 320px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Preserve source-coverage qualifications on screen and in print. */
.report-coverage-note { display: flex; flex-direction: column; gap: 6px; padding: 12px 16px; border: 1px solid #d8a143; border-left: 4px solid #b57913; border-radius: 6px; background: #fff8e9; color: #583d12; font-size: 12px; line-height: 1.5; break-inside: avoid; }

@media screen and (max-width: 980px) {
  .reports-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .reports-header > div:first-child { width: 100%; max-width: none; flex: auto; }
  .reports-header p { white-space: normal; overflow: visible; }
  .reports-toolbar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; gap: 10px; }
  .reports-toolbar label, .reports-toolbar label select, .reports-toolbar label:nth-child(2) select, .reports-toolbar input[type="date"], .reports-toolbar input[type="month"] { width: 100%; min-width: 0; max-width: 100%; }
  .reports-toolbar .report-actions { grid-column: 1 / -1; flex-wrap: wrap; }
  .command-overview.client-overview { grid-template-columns: minmax(0, 1fr); }
}
@media screen and (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; }
  .topnav { flex-wrap: wrap; }
  .reports-layout { min-width: 0; padding: 8px; }
  .reports-panel, .reports-body { min-width: 0; }
  .reconciliation-status { align-items: flex-start; flex-wrap: wrap; }
  .command-value, .command-mix, .command-insights { padding: 16px; min-width: 0; }
  .command-list { overflow-x: auto; }
  .command-section-title { flex-wrap: wrap; }
}

@media print {
  .reports-header { display: block; }
  .reports-header > div:first-child { width: 100%; max-width: none; }
  .reports-header p { white-space: normal; overflow: visible; }
  .reports-body { padding: 8px; }
  .command-overview, .command-overview.client-overview { display: block; min-height: 0; break-inside: auto; }
  .command-value, .command-mix, .command-insights { min-height: 0 !important; width: 100%; padding: 16px; margin-top: 10px; break-inside: avoid; }
  .invoice-value-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mix-content { grid-template-columns: 240px minmax(0, 1fr); gap: 12px; }
  .mix-canvas-wrap, #serviceMixChart { width: 240px !important; height: 240px !important; }
  .command-insights > div { display: block; width: 100%; }
  .command-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 10px; }
  .command-tables { display: block; break-inside: auto; }
  .command-list { margin-top: 10px; }
  .report-provenance { margin-top: 12px; }
  .reports-table tr { break-inside: avoid; }
}

/* Report trust, diagnostics and recovery */
.report-trust-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
.report-trust-grid article { border:1px solid var(--line); border-radius:6px; padding:12px; background:#fff; min-width:0; }
.report-trust-grid span,.report-trust-grid small { display:block; color:var(--muted); font-size:12px; line-height:1.5; }
.report-trust-grid strong { display:block; font-size:14px; margin:5px 0; overflow-wrap:anywhere; }
.report-reconciliation-details { border:1px solid var(--line); border-radius:6px; padding:12px 16px; font-size:12px; }
.report-reconciliation-details summary { cursor:pointer; font-weight:700; }
.report-detail-scroll { overflow-x:auto; }
.report-reconciliation-details p { color:var(--muted); line-height:1.5; }
.report-load-error { border:1px solid var(--danger); border-radius:6px; padding:24px; color:var(--danger); }
@media(max-width:900px) { .report-trust-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:480px) { .report-trust-grid { grid-template-columns:1fr; } }
@media print { .report-trust-grid { grid-template-columns:repeat(4,minmax(0,1fr)); break-inside:avoid; } .report-reconciliation-details { break-inside:auto; } }
/* Client review pack */
.report-review-pack { background:#fffdf7; border:1px solid #e9d8b2; border-top:5px solid var(--accent); border-radius:8px; padding:24px; }
.review-brand { display:flex; justify-content:space-between; align-items:center; gap:20px; }
.review-brand img { width:150px; height:65px; object-fit:contain; }
.review-brand > span { color:var(--accent); font-size:10px; letter-spacing:.12em; font-weight:700; text-align:right; }
.review-brand b { display:block; color:var(--muted); letter-spacing:0; font-size:12px; margin-top:6px; font-weight:400; }
.review-cover-title > span { color:var(--accent); font-size:11px; text-transform:uppercase; letter-spacing:.12em; font-weight:700; }
.review-cover-title { margin:22px 0 14px; }
.review-cover-title h2 { margin:6px 0; font-size:clamp(24px,2.6vw,38px); color:#202d3a; line-height:1.15; }
.review-cover-title p { color:var(--muted); font-size:13px; margin:8px 0; }
.review-period { display:flex; flex-direction:column; gap:6px; font-size:12px; line-height:1.5; }
.review-period span { color:var(--muted); }
.review-headlines { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; border-top:1px solid #e9d8b2; border-bottom:1px solid #e9d8b2; margin:18px 0; padding:18px 0; }
.review-headlines span { display:block; color:var(--muted); font-size:11px; }
.review-headlines strong { display:block; margin-top:8px; font-size:clamp(16px,1.6vw,24px); overflow-wrap:anywhere; }
.review-headlines > div:nth-child(3) strong { color:var(--accent); }
.review-findings { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:18px; }
.review-findings a { display:flex; align-items:flex-start; gap:12px; color:var(--text); text-decoration:none; border-radius:6px; padding:12px; background:#fff; border:1px solid #eee7d7; }
.review-findings a:hover,.review-findings a:focus-visible { outline:2px solid var(--brand-gold); outline-offset:2px; }
.review-number { color:#b57913; font-size:22px; font-weight:700; }
.review-findings strong { font-size:13px; }
.review-findings p { font-size:12px; color:#526170; line-height:1.6; margin:8px 0; }
.review-findings small { font-size:10px; color:var(--accent); font-weight:700; }
.report-review-pack footer { display:flex; flex-wrap:wrap; justify-content:space-between; gap:10px; margin-top:20px; font-size:10px; color:var(--muted); line-height:1.5; }
.report-change-section { padding:20px; border:1px solid var(--line); border-radius:8px; background:#fff; scroll-margin-top:20px; }
.comparison-totals { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-top:16px; }
.comparison-totals > div { padding:14px; background:#f6f7f9; border-radius:6px; }
.comparison-totals span { display:block; font-size:11px; color:var(--muted); line-height:1.5; }
.comparison-totals strong { display:block; margin-top:8px; font-size:20px; overflow-wrap:anywhere; }
.driver-switch { display:flex; gap:6px; }
.driver-switch button { font-size:11px; padding:7px 10px; background:#fff; color:var(--text); border:1px solid var(--line); }
.driver-switch button[aria-pressed=true] { background:var(--accent); border-color:var(--accent); color:#fff; }
#report-driver-chart { overflow-x:auto; }
.report-waterfall { display:block; width:100%; min-width:680px; max-height:350px; margin-top:12px; }
.report-waterfall text { font:11px Arial,sans-serif; fill:#344454; }
.report-waterfall .waterfall-label { font-size:10px; }
.waterfall-total { fill:#263b4a; }
.waterfall-up { fill:#b9272f; }
.waterfall-down { fill:#d79b20; }
.waterfall-zero { stroke:#c5cdd6; stroke-width:1; }
.waterfall-connector { stroke:#8f9da8; stroke-width:1; stroke-dasharray:3 3; }
.driver-explanation,.report-chart-empty { color:var(--muted); font-size:12px; line-height:1.6; }
.driver-data { font-size:12px; margin-top:12px; }
.driver-data summary { cursor:pointer; color:var(--accent); font-weight:700; margin-bottom:10px; }
@media(max-width:900px) { .review-findings { grid-template-columns:1fr; } .review-headlines { grid-template-columns:repeat(2,minmax(0,1fr)); } .review-brand { flex-wrap:wrap; } }
@media(max-width:480px) { .report-review-pack,.report-change-section { padding:16px; } .comparison-totals { grid-template-columns:1fr; } .review-brand > span { text-align:left; } }
@media print {
  .report-review-pack { break-after:page; border:0; border-top:6px solid var(--accent); padding:24px 8px; background:#fff; }
  .review-brand img { width:180px; height:80px; }
  .review-cover-title { margin-top:30px; }
  .review-cover-title h2 { font-size:32px; }
  .review-headlines { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .review-findings { grid-template-columns:1fr; gap:10px; }
  .review-findings a { padding:10px; break-inside:avoid; }
  .review-findings small { display:none; }
  .report-change-section { break-inside:avoid; margin-top:12px; }
  .report-waterfall { min-width:0; width:100%; }
  #report-driver-chart { overflow:visible; }
  .driver-switch { display:none; }
  .comparison-totals strong { font-size:15px; }
  .report-change-section .command-section-title { display:block; }
}
/* The review cover carries the report title and headline metrics. */
#reportsBody > .command-heading { display:none; }
@media print { .reports-header { display:none; } }
/* Keep wide charts inside their own scroller on narrow screens. */
.reports-body { grid-template-columns:minmax(0,1fr); }
.report-review-pack,.report-change-section { min-width:0; overflow-wrap:anywhere; }
.review-findings a > div { min-width:0; }
@media print { .report-waterfall text { font-size:13px; } .report-waterfall .waterfall-label { font-size:12px; } }
.review-number { flex:0 0 32px; white-space:nowrap; }
