:root {
  --report-border: #cbd9ea;
  --report-surface: #ffffff;
  --report-muted: #5f7089;
  --report-blue: #2155d9;
  --report-green: #087d4b;
}

.report-page { min-height: 100dvh; background: #eef4fb; color: #142139; }
.report-content { width: min(1240px, calc(100% - 32px)); margin: 22px auto; display: grid; gap: 18px; }
.report-panel, .report-results { padding: 22px; border: 1px solid var(--report-border); border-radius: 8px; background: var(--report-surface); }
.section-heading, .results-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2, .results-heading h2 { margin: 4px 0 0; font-size: 1.3rem; }
.eyebrow { display: inline-flex; min-height: 26px; align-items: center; padding: 4px 10px; border: 1px solid #a9c7fb; border-radius: 6px; background: #edf5ff; color: #1644a8; font-size: .74rem; font-weight: 800; }
.report-intro { max-width: 850px; margin: 12px 0 18px; color: var(--report-muted); line-height: 1.55; }
.comparison-flow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 14px; }
.stored-report-wrap { display: grid; gap: 8px; }
.report-file-card { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 112px; padding: 16px; border: 1px dashed #6f97d4; border-radius: 7px; background: #f7faff; cursor: pointer; }
.report-file-card:hover { border-color: #2155d9; background: #eff5ff; }
.report-file-card.has-file { border-style: solid; border-color: #67b88e; background: #effaf4; }
.report-file-card.is-dragging, .gpkg-drop.is-dragging { border-color: #2155d9; border-style: solid; background: #e4efff; box-shadow: 0 0 0 3px rgba(33, 85, 217, .12); }
.report-file-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.gpkg-choice-card { grid-template-columns: 38px minmax(0, 1fr); cursor: default; }
.gpkg-choice-card:hover { border-color: #6f97d4; background: #f7faff; }
.step-number { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #2155d9; color: #fff; font-weight: 900; }
.file-copy { min-width: 0; }
.file-copy strong, .file-copy small { display: block; }
.file-copy small { margin-top: 5px; overflow: hidden; color: var(--report-muted); text-overflow: ellipsis; white-space: nowrap; }
.select-file-button { padding: 8px 11px; border: 1px solid #9eb1c9; border-radius: 5px; background: #fff; color: #28415f; font-size: .8rem; font-weight: 800; }
.flow-arrow { color: #6c7f99; font-size: 1.7rem; }
.source-modes { display: grid; grid-template-columns: 1fr 1fr; margin-top: 16px; padding: 4px; border: 1px solid var(--report-border); border-radius: 6px; background: #f1f5fa; }
.source-mode { min-height: 42px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #263852; font-weight: 800; box-shadow: none; }
.source-mode.active { border-color: #75a6fb; background: #eaf2ff; color: #1649bd; }
.source-panel { margin-top: 12px; padding: 12px; border: 1px solid var(--report-border); border-radius: 6px; background: #f7faff; }
.source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.source-item { display: grid; grid-template-columns: 22px 1fr; align-items: center; min-height: 64px; padding: 9px 12px; border: 1px solid var(--report-border); border-radius: 6px; background: #fff; cursor: pointer; }
.source-item:has(input:checked) { border-color: #2c65e6; background: #eef5ff; }
.source-item input { width: 17px; height: 17px; }
.source-item strong, .source-item small { display: block; }
.source-item small { margin-top: 3px; color: var(--report-muted); }
.gpkg-drop { position: relative; display: grid; min-height: 96px; place-items: center; align-content: center; gap: 5px; border: 1px dashed #6f97d4; border-radius: 6px; color: #174c9b; cursor: pointer; text-align: center; }
.gpkg-drop small { color: var(--report-muted); }
.gpkg-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.gpkg-drop.has-file { border-style: solid; border-color: #67b88e; background: #effaf4; }
.muted { color: var(--report-muted); }
.scope-note { margin-top: 14px; padding: 11px 13px; border-left: 4px solid #e2a72e; background: #fff9e9; color: #704400; line-height: 1.45; }
.report-actions { display: flex; gap: 10px; margin-top: 16px; }
.report-actions button { min-height: 42px; padding: 9px 18px; border-radius: 6px; box-shadow: none; font-weight: 800; }
.primary-action { border: 1px solid var(--report-blue); background: var(--report-blue); color: #fff; }
.secondary-action { border: 1px solid #9eb1c9; background: #fff; color: #28415f; }
.delete-saved-report { min-height: 38px; border: 1px solid #dc2626; border-radius: 6px; background: #fff; color: #b91c1c; font-weight: 800; }
.evolution-toggle { display: flex; align-items: center; gap: 11px; margin-top: 16px; padding: 13px 14px; border: 1px solid #b7a6e8; border-radius: 7px; background: #f6f3ff; color: #47347a; cursor: pointer; }
.evolution-toggle input { width: 19px; height: 19px; accent-color: #6d52b5; }
.evolution-toggle span, .evolution-toggle strong, .evolution-toggle small { display: block; }
.evolution-toggle small { margin-top: 3px; color: var(--report-muted); }
.evolution-previous-panel { border-color: #b7a6e8; background: #faf8ff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.status-message { margin-top: 14px; padding: 12px 14px; border: 1px solid #b9cbe2; border-radius: 6px; background: #f5f8fc; color: #37506e; }
.status-message.success { border-color: #8bd3ae; background: #edfbf4; color: #086b41; }
.status-message.error { border-color: #f1a8a2; background: #fff0ef; color: #9f2017; }
.report-progress { margin-top: 14px; padding: 13px 14px; border: 1px solid #b9cbe2; border-radius: 6px; background: #f5f8fc; color: var(--report-muted); }
.progress-heading { display: grid; grid-template-columns: 22px 48px minmax(0, 1fr) auto; align-items: center; gap: 9px; }
.progress-heading strong { color: #173f8a; font-variant-numeric: tabular-nums; }
.progress-track { height: 10px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: #dbe6f4; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #2155d9, #2d8cf0); transition: width .35s ease; }
.progress-spinner { width: 20px; height: 20px; border: 3px solid #c7d8ee; border-top-color: #2155d9; border-radius: 50%; animation: report-spin .8s linear infinite; }
.cancel-report { min-height: 34px; padding: 7px 12px; border: 1px solid #dc2626; border-radius: 6px; background: #fff; color: #b91c1c; font-size: .78rem; font-weight: 800; box-shadow: none; }
.cancel-report:hover { background: #fee2e2; }
.cancel-report:disabled { opacity: .65; cursor: wait; }
@keyframes report-spin { to { transform: rotate(360deg); } }
.total-changes { padding: 7px 12px; border-radius: 6px; background: #173f8a; color: #fff; }
.report-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.result-card { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--report-border); border-radius: 7px; background: #f9fbfe; }
.result-card.has-changes { border-left: 5px solid #e39b19; }
.result-card.no-changes { border-left: 5px solid #67b88e; }
.result-card.unavailable { border-left: 5px solid #7f8ea3; }
.result-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-title h3 { margin: 0; font-size: 1rem; }
.result-title strong { color: #173f8a; }
.change-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 0; }
.report-balance-counts { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.change-counts div { padding: 9px; border: 1px solid #d7e2ef; border-radius: 5px; background: #fff; text-align: center; }
.change-counts dt { color: var(--report-muted); font-size: .72rem; }
.change-counts dd { margin: 4px 0 0; font-size: 1.2rem; font-weight: 800; }
.download-report { display: flex; width: 100%; height: 40px; min-height: 40px; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid #64748b; border-radius: 6px; background: #64748b; color: #fff; font-size: .86rem; font-weight: 800; line-height: 1; text-decoration: none; box-shadow: none; }
.download-report:hover { border-color: #64748b; background: #64748b; color: #fff; }
.no-change-label { display: flex; min-height: 39px; align-items: center; justify-content: center; border-radius: 6px; background: #e8f5ee; color: #087343; font-weight: 800; }
.report-scope-message { margin: 0; color: var(--report-muted); font-size: .8rem; line-height: 1.4; }

body.dark-theme.report-page { --report-border: #33455f; --report-surface: #111c2e; --report-muted: #aebbd0; background: #091323; color: #edf4ff; }
body.dark-theme .report-file-card, body.dark-theme .result-card, body.dark-theme .source-panel, body.dark-theme .source-modes { background: #0c1727; }
body.dark-theme .report-file-card:hover { background: #17345f; }
body.dark-theme .report-file-card.has-file { background: #123426; }
body.dark-theme .gpkg-choice-card:hover { background: #0c1727; }
body.dark-theme .select-file-button, body.dark-theme .secondary-action, body.dark-theme .change-counts div, body.dark-theme .source-item { background: #111c2e; color: #edf4ff; }
body.dark-theme .source-mode { color: #dce8f8; }
body.dark-theme .source-mode.active, body.dark-theme .source-item:has(input:checked) { background: #17345f; color: #fff; }
body.dark-theme .gpkg-drop { background: #0c1727; }
body.dark-theme .gpkg-drop.has-file { background: #123426; }
body.dark-theme .scope-note { background: #352a13; color: #ffe7a7; }
body.dark-theme .no-change-label { background: #123426; color: #8be0b6; }
body.dark-theme .report-progress { background: #0c1727; }
body.dark-theme .progress-heading strong { color: #9cc0ff; }
body.dark-theme .progress-track { background: #283a52; }
body.dark-theme .cancel-report { border-color: #f87171; background: #3b0a16; color: #fecaca; }
body.dark-theme .delete-saved-report { border-color: #f87171; background: #3b0a16; color: #fecaca; }
body.dark-theme .evolution-toggle, body.dark-theme .evolution-previous-panel { border-color: #68539e; background: #211a38; color: #e3d8ff; }

@media (max-width: 860px) {
  .report-content { width: min(100% - 16px, 1240px); margin: 12px auto; }
  .report-panel, .report-results { padding: 14px; }
  .comparison-flow { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); justify-self: center; }
  .report-cards { grid-template-columns: 1fr; }
  .source-list { grid-template-columns: 1fr; }
  .report-balance-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .report-file-card { grid-template-columns: 36px minmax(0, 1fr); }
  .select-file-button { grid-column: 1 / -1; text-align: center; }
  .report-actions { flex-direction: column; }
  .results-heading { align-items: flex-start; flex-direction: column; }
  .progress-heading { grid-template-columns: 22px 48px minmax(0, 1fr); }
  .cancel-report { grid-column: 1 / -1; width: 100%; }
}
