:root {
  --navy: #0b2a58;
  --blue: #174a8b;
  --teal: #2f6fad;
  --paper: #f4f7fc;
  --ink: #132033;
  --muted: #5d6b7e;
  --line: #d8e1ef;
}

.primary:hover { background: #071e42; }
.secondary { background: #e7f0fb; border-color: #bed1ea; color: #174a8b; }
.ghost { border-color: #c9d5e5; color: #41536f; }
.message { background: #e7f0fb; color: #174a8b; }
.card { box-shadow: 0 4px 18px rgb(11 42 88 / .04); }
label { color: #314665; }
input, select { border-color: #b8c9df; }
input:focus, select:focus { outline-color: #c9daf1; border-color: var(--teal); }
.tabs a { color: #50627c; }
th { background: #f5f8fc; color: #4b607d; }
.link-box { background: #f4f7fc; color: #243b61; }
.chart-tooltip { background: var(--navy); }
.export-dialog::backdrop { background: rgb(11 42 88 / .35); }

.report-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: -4px 0 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--line);
}

.report-context > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 15px;
  background: #fff;
}

.financial-indicators {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 0 0 20px;
}

.financial-indicator {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 88px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(135deg, #fff 0%, #f6f9fe 100%);
}

.financial-indicator span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.financial-indicator strong { font-size: 21px; color: var(--navy); font-variant-numeric: tabular-nums; }
.card-action { width: 100%; text-align: left; font: inherit; cursor: pointer; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.card-action:hover { border-color: var(--teal); box-shadow: 0 5px 14px rgb(11 42 88 / .10); transform: translateY(-1px); }
.card-action:focus-visible { outline: 3px solid #c9daf1; outline-offset: 2px; }
.comparison { margin-top: auto; font-size: 11px; font-weight: 700; line-height: 1.35; }
.comparison.positive { color: #126540; }
.comparison.negative { color: #a23a3a; }
.comparison.neutral { color: var(--muted); }

.quick-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.quick-filter { min-height: 32px; padding: 6px 10px; border: 1px solid #c9d8eb; border-radius: 999px; background: #fff; color: #174a8b; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.quick-filter:hover { border-color: var(--teal); background: #edf4fc; }
.quick-filter.is-active { border-color: var(--teal); background: var(--teal); color: #fff; box-shadow: 0 2px 5px rgb(11 42 88 / .14); }
.quick-filter-status { margin: -4px 0 12px; color: var(--muted); font-size: 12px; font-weight: 700; }

.page-shell { position: relative; }
.report-header { padding-right: 440px; }
.report-top-actions { position: absolute; top: 36px; right: 26px; display: flex; justify-content: flex-end; gap: 8px; }
.report-top-actions .button { min-height: 40px; }
.row-highlight { outline: 3px solid #c9daf1; outline-offset: -3px; background: #f1f6fd; transition: outline-color .5s ease; }

.context-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.data-status { font-size: 11px; font-style: normal; font-weight: 700; }
.data-status.available { color: #126540; }
.data-status.pending { color: #976408; }

.advanced-filters {
  min-width: 142px;
  align-self: end;
}

.advanced-filters summary {
  min-height: 39px;
  padding: 10px 12px;
  border: 1px solid #b8c9df;
  border-radius: 7px;
  color: #314665;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

.advanced-filters summary::-webkit-details-marker { display: none; }
.advanced-filters summary::after { content: "⌄"; float: right; margin-left: 10px; }
.advanced-filters[open] summary { border-color: var(--teal); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.advanced-filter-fields { display: grid; gap: 10px; padding: 12px; border: 1px solid #b8c9df; border-top: 0; border-radius: 0 0 7px 7px; background: #fbfcff; }

th[data-sort]::after {
  content: "↕";
  display: inline-block;
  margin-left: 6px;
  color: #9aabc0;
  font-size: 13px;
}

th[data-sort][aria-sort="ascending"]::after { content: "↑"; color: var(--teal); }
th[data-sort][aria-sort="descending"]::after { content: "↓"; color: var(--teal); }
th[data-sort]:focus-visible, .button:focus-visible, .tabs a:focus-visible, summary:focus-visible {
  outline: 3px solid #c9daf1;
  outline-offset: 2px;
}

.table-wrap { max-height: 68vh; }
.card.table-wrap .table-actions {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 3;
  width: 100%;
  background: #fff;
}
.table-wrap thead th { position: sticky; top: 0; z-index: 1; }
.table-wrap tfoot th,
.table-wrap tfoot td { position: sticky; bottom: 0; z-index: 2; }
.report-summary .table-wrap table th:first-child,
.report-summary .table-wrap table td:first-child {
  position: sticky;
  left: 0;
  background: #fff;
  box-shadow: 2px 0 0 var(--line);
}
.report-summary .table-wrap table thead th:first-child { z-index: 2; background: #f5f8fc; }
.totals-row th,
.totals-row td {
  padding-top: 13px;
  padding-bottom: 13px;
  background: linear-gradient(180deg, #f4f8fe 0%, #e1edf9 100%);
  border-top: 2px solid #8eb2dc;
  border-bottom: 0;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .78);
  color: #0b2a58;
  font-weight: 800;
}
.totals-row th { letter-spacing: .05em; }
.report-summary .table-wrap .totals-row th:first-child {
  z-index: 3;
  background: linear-gradient(180deg, #f4f8fe 0%, #e1edf9 100%);
}
.document-preview-link { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 5px; border: 1px solid #bed1ea; border-radius: 4px; color: var(--blue); font-size: 10px; font-weight: 800; text-decoration: none; vertical-align: middle; }
.document-preview-link:hover { background: #e7f0fb; border-color: var(--teal); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 50%; }

.empty .clear-empty-filters { display: inline-block; margin-left: 8px; color: var(--blue); font-weight: 700; }

@media (max-width: 850px) {
  .report-context { grid-template-columns: 1fr; gap: 1px; }
  .report-context > div { padding: 10px 13px; }
  .advanced-filters { width: 100%; }
  .financial-indicators { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .financial-indicator { min-height: 76px; padding: 12px; }
  .financial-indicator strong { font-size: 17px; }
  .report-header { padding-right: 0; }
  .report-top-actions { position: static; margin: 0 0 16px; flex-wrap: wrap; justify-content: stretch; }
  .report-top-actions .button { flex: 1 1 100%; }
  .advanced-filters summary { width: 100%; }
  .table-wrap { max-height: 62vh; }
  .card.table-wrap .table-actions { width: 100%; }
}

@media print {
  body { background: #fff; font-size: 11px; }
  .page-shell { max-width: none; padding: 0; }
  .tabs, .report-top-actions, .filters, .table-actions, .quick-filters, .chart-card, .export-dialog { display: none !important; }
  .report-header { padding: 0; margin-bottom: 12px; }
  .report-context, .financial-indicators { margin-bottom: 12px; }
  .table-wrap { max-height: none; overflow: visible; border: 0; box-shadow: none; }
  .table-wrap thead th { position: static; }
  .table-wrap tfoot th, .table-wrap tfoot td { position: static; }
  .financial-indicator { min-height: auto; padding: 9px; box-shadow: none; transform: none !important; }
  .comparison { display: none; }
}
