/* Excel-style report styling shared by the four demo reports. */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Calibri', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  color: #1f2328;
  background: #eef0f2;
  overflow-x: hidden;
}

/* Line under the demo badge: what this is, and where the data comes from */
.demo-meta { font-size: 12px; color: #5b6472; margin-left: 6px; }
.demo-intro .demo-title { font-size: 17px; }

/* Workbook frame */
.excel-container {
  background: #fff;
  border: 1px solid #c6c9cd;
  margin: 12px;
  min-width: 0;
}

.excel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 14px;
  background: #f3f3f3;
  border-bottom: 2px solid #217346;
}
.excel-title { margin: 0; font-size: 16px; font-weight: 700; color: #185c37; }
.excel-sub { font-size: 12px; color: #5b6472; font-weight: 400; margin-left: 6px; }

.excel-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.excel-controls label { font-size: 12px; font-weight: 600; color: #3b4350; }
.excel-controls .ctl { display: inline-flex; align-items: center; gap: 5px; }
.excel-controls select,
.excel-controls input[type="search"] {
  font: inherit; font-size: 13px;
  padding: 4px 8px; height: 30px;
  border: 1px solid #b9bdc2; border-radius: 2px; background: #fff; color: #1f2328;
  min-width: 0;
}
.excel-controls input[type="search"] { width: 190px; }
.btn {
  font: inherit; font-size: 13px; font-weight: 600;
  height: 30px; padding: 0 12px;
  border: 1px solid #185c37; border-radius: 2px;
  background: #217346; color: #fff; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #185c37; }
.btn.secondary { background: #fff; color: #185c37; }
.btn.secondary:hover { background: #e9f3ed; }
.btn:focus-visible, select:focus-visible, input:focus-visible, th[data-sort]:focus-visible, .toggle:focus-visible {
  outline: 2px solid #1f4fa3; outline-offset: 1px;
}
.seg { display: inline-flex; border: 1px solid #185c37; border-radius: 2px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; height: 28px; padding: 0 10px; border: 0; background: #fff; color: #185c37; cursor: pointer; }
.seg button[aria-pressed="true"] { background: #217346; color: #fff; font-weight: 600; }
.seg button + button { border-left: 1px solid #185c37; }

/* KPI strip: a row of summary "cells" */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border-bottom: 1px solid #d4d4d4;
}
.kpi { padding: 8px 14px; border-right: 1px solid #e1e1e1; min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi-label { font-size: 12px; color: #5b6472; }
.kpi-value { font-size: 20px; font-weight: 700; color: #1f2328; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 11px; color: #6b7280; }
.kpi.alert .kpi-value { color: #9c0006; }

/* Legend for conditional formatting */
.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
  padding: 6px 14px; font-size: 12px; color: #3b4350;
  border-bottom: 1px solid #e1e1e1; background: #fafafa;
}
.legend strong { font-weight: 600; }
.swatch { display: inline-block; width: 14px; height: 12px; vertical-align: -1px; margin-right: 5px; border: 1px solid; }
.swatch.red { background: #ffc7ce; border-color: #9c0006; }
.swatch.amber { background: #ffeb9c; border-color: #9c6500; }
.swatch.green { background: #c6efce; border-color: #006100; }

.result-line { padding: 6px 14px; font-size: 12px; color: #5b6472; }

/* Grid tables */
.excel-table-wrapper { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.excel-table th {
  background: #217346; color: #fff;
  font-weight: 600; font-size: 12px; text-align: left;
  padding: 6px 8px;
  border: 1px solid #1a5c37;
  white-space: nowrap;
  vertical-align: bottom;
}
.excel-table th[data-sort] { cursor: pointer; user-select: none; }
.excel-table th[data-sort]:hover { background: #185c37; }
.excel-table th[data-sort]::after { content: '\2195'; opacity: .45; margin-left: 4px; font-size: 11px; }
.excel-table th[aria-sort="ascending"]::after { content: '\25B2'; opacity: 1; font-size: 9px; }
.excel-table th[aria-sort="descending"]::after { content: '\25BC'; opacity: 1; font-size: 9px; }
.excel-table td {
  padding: 5px 8px;
  border: 1px solid #e1e1e1;
  white-space: nowrap;
  color: #1f2328;
}
.excel-table tbody tr:nth-child(even) td { background: #fafbfa; }
.excel-table tbody tr:hover td { background: #eef6f1; }
.excel-table .number { text-align: right; }
.excel-table .center { text-align: center; }
.excel-table .muted { color: #6b7280; }
.excel-table .wrap { white-space: normal; min-width: 250px; }
.excel-table .wrap-sm { white-space: normal; min-width: 120px; }
.excel-table tfoot td, .excel-table tr.total-row td {
  font-weight: 700; background: #e2efda !important; border-top: 2px solid #217346;
}
.excel-table .empty { text-align: center; color: #6b7280; padding: 18px; white-space: normal; }
.neg { color: #9c0006; }

/* Conditional formatting (Excel's built-in red / yellow / green fills) */
.cf-red { background: #ffc7ce !important; color: #9c0006 !important; }
.cf-amber { background: #ffeb9c !important; color: #7a4f00 !important; }
.cf-green { background: #c6efce !important; color: #006100 !important; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 2px; font-size: 12px; font-weight: 600; }

/* Pivot tables */
.pivot-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; padding: 12px 14px; }
.pivot-grid > section { min-width: 0; }
.pivot-grid h2, .section-title { font-size: 14px; color: #185c37; margin: 0 0 6px; }
.pivot-wide { padding: 0 14px 14px; }
.pivot-table tr.group-header td { background: #e2efda; font-weight: 600; }
.pivot-table tr.child td:first-child { padding-left: 30px; }
.toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-right: 6px; padding: 0;
  border: 1px solid #7a8a80; background: #fff; color: #185c37;
  font: 700 12px/1 Arial, sans-serif; cursor: pointer; vertical-align: -2px;
}

/* Footer note */
.excel-foot { padding: 8px 14px 10px; font-size: 12px; color: #5b6472; border-top: 1px solid #e1e1e1; }

@media (max-width: 900px) {
  .pivot-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .excel-container { margin: 8px; }
  .excel-header { padding: 8px 10px; }
  .excel-controls { width: 100%; }
  .excel-controls .ctl { flex: 1 1 140px; }
  .excel-controls .ctl select { flex: 1; width: 100%; }
  .excel-controls input[type="search"] { flex: 1 1 160px; width: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 6px 10px; border-bottom: 1px solid #eee; }
  .kpi-value { font-size: 17px; }
  .legend, .result-line, .excel-foot { padding-left: 10px; padding-right: 10px; }
  .pivot-grid { padding: 10px; }
  .pivot-wide { padding: 0 10px 10px; }
  .excel-table { font-size: 12px; }
  .excel-table th, .excel-table td { padding: 4px 6px; }
  .demo-meta { display: block; margin: 4px 0 0; }
}
