:root {
  --navy: #0f2044;
  --navy-2: #1a3260;
  --navy-3: #243c7a;
  --red: #c0202e;
  --red-2: #e02535;
  --off: #f4f6fb;
  --white: #ffffff;
  --border: #d0d8ea;
  --text: #0f2044;
  --muted: #5a6a8a;
  --green: #0a8a5c;
  --orange: #c97a00;
  --purple: #6d28d9;
  --blue: #1e5fd4;
  --cyan: #0284c7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--off);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

.report-header {
  background: var(--navy);
  color: var(--white);
  padding: 34px 56px 30px;
  border-bottom: 4px solid var(--red);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.agency-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
  flex: 0 0 auto;
}

.eyebrow {
  color: #88a7d3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.eyebrow.small {
  color: var(--muted);
}

h1,
h2 {
  margin: 5px 0 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 22px;
}

.sub {
  margin-top: 4px;
  color: #9ab5da;
  font-size: 14px;
  font-weight: 300;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.year-label {
  color: #88a7d3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

select {
  min-width: 130px;
  height: 38px;
  border: 1px solid #36517f;
  border-radius: 6px;
  background: var(--navy-2);
  color: var(--white);
  padding: 0 12px;
}

.header-stats {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.stat {
  min-width: 92px;
  text-align: center;
}

.stat-num {
  font-family: Consolas, "DM Mono", monospace;
  font-size: 27px;
  font-weight: 700;
  line-height: 1;
}

.stat-lbl {
  margin-top: 5px;
  color: #88a7d3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.stat-divider {
  width: 1px;
  min-height: 38px;
  background: #2a3f6a;
}

.import-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--navy-2);
  padding: 14px 56px;
  border-bottom: 1px solid #2a3f6a;
}

.import-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.import-left label {
  color: #9ab5da;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.import-btn,
.ghost-btn,
.close-btn {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.import-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  background: var(--red);
  color: var(--white);
  padding: 8px 18px;
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.import-btn:hover {
  background: var(--red-2);
}

.import-btn[disabled] {
  cursor: wait;
  opacity: .72;
}

.btn-icon {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid rgba(255, 255, 255, .75);
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
}

#csv-input {
  display: none;
}

.import-status {
  min-height: 20px;
  color: #77d89d;
  font-size: 12px;
  font-weight: 700;
}

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 38px 56px 80px;
}

section + section {
  margin-top: 42px;
}

.sec-label {
  margin-bottom: 15px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  gap: 10px;
}

.kpi {
  min-height: 112px;
  background: var(--white);
  border-radius: 8px;
  border-top: 3px solid var(--border);
  padding: 17px 12px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

.kpi-n {
  font-family: Consolas, "DM Mono", monospace;
  font-size: 33px;
  font-weight: 700;
  line-height: 1;
}

.kpi-cat {
  min-height: 30px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.kpi-pct {
  color: #9ba9c1;
  font-size: 11px;
}

.kpi.ems { border-color: var(--blue); }
.kpi.ems .kpi-n { color: var(--blue); }
.kpi.alarm { border-color: var(--orange); }
.kpi.alarm .kpi-n { color: var(--orange); }
.kpi.assist { border-color: var(--green); }
.kpi.assist .kpi-n { color: var(--green); }
.kpi.fire { border-color: var(--red); }
.kpi.fire .kpi-n { color: var(--red); }
.kpi.rescue { border-color: var(--purple); }
.kpi.rescue .kpi-n { color: var(--purple); }
.kpi.outside { border-color: #4d7c0f; }
.kpi.outside .kpi-n { color: #4d7c0f; }
.kpi.drone { border-color: var(--cyan); }
.kpi.drone .kpi-n { color: var(--cyan); }

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

.table-shell {
  overflow: auto;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr {
  background: var(--navy);
}

th,
td {
  padding: 12px 13px;
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--white);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

th:first-child,
td:first-child {
  text-align: left;
}

tbody tr {
  border-bottom: 1px solid var(--border);
}

tbody tr:nth-child(even) {
  background: #f9fafd;
}

tbody tr:hover {
  background: #edf2ff;
  cursor: pointer;
}

td {
  font-family: Consolas, "DM Mono", monospace;
}

td:first-child {
  color: var(--navy);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  font-weight: 800;
}

tfoot tr {
  background: #e8edf8;
  color: var(--navy);
  font-weight: 900;
}

.side-panel,
.current-month,
.trend-chart,
.rank-list,
.upload-list {
  min-width: 0;
}

.current-month {
  background: var(--white);
  border-left: 5px solid var(--red);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

.current-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.current-total {
  margin-top: 4px;
  color: var(--red);
  font-family: Consolas, "DM Mono", monospace;
  font-size: 54px;
  font-weight: 800;
  line-height: 1;
}

.current-sub {
  color: var(--muted);
  font-size: 12px;
}

.mini-list,
.rank-list,
.upload-list {
  display: grid;
  gap: 8px;
}

.mini-list {
  margin-top: 20px;
}

.mini-item,
.rank-item,
.upload-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  background: #f7f9fd;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 12px;
}

.mini-item strong,
.rank-item strong {
  color: var(--red);
  font-family: Consolas, "DM Mono", monospace;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe3f2;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--navy-3);
}

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 24px;
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
  align-items: end;
  gap: 9px;
  min-height: 250px;
  background: var(--white);
  border-radius: 8px;
  padding: 18px 16px 14px;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

.line-chart {
  background: var(--white);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

.line-chart-plot {
  width: 100%;
  overflow-x: auto;
}

.line-chart svg {
  display: block;
  min-width: 720px;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: #dbe3f2;
  stroke-width: 1;
}

.chart-axis {
  stroke: #8fa1bf;
  stroke-width: 1.5;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.line-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend-item span {
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

.activity-heatmap {
  background: var(--white);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

.heatmap-scroll {
  overflow-x: auto;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: 54px repeat(24, minmax(28px, 1fr));
  gap: 4px;
  min-width: 820px;
  align-items: center;
}

.heat-hour,
.heat-day {
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
  text-align: center;
}

.heat-day {
  text-align: right;
  padding-right: 6px;
}

.heat-cell {
  display: grid;
  place-items: center;
  min-height: 26px;
  border-radius: 4px;
  background: rgba(192, 32, 46, var(--heat));
  color: var(--navy);
  font-family: Consolas, "DM Mono", monospace;
  font-size: 10px;
  font-weight: 800;
}

.trend-col {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  gap: 7px;
  min-width: 0;
  height: 214px;
  text-align: center;
}

.trend-bar {
  width: 100%;
  min-height: 4px;
  border-radius: 5px 5px 0 0;
  background: var(--red);
}

.trend-value {
  color: var(--navy);
  font-family: Consolas, "DM Mono", monospace;
  font-size: 12px;
  font-weight: 800;
}

.trend-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.rank-list {
  background: var(--white);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

.rank-item {
  grid-template-columns: auto 1fr minmax(60px, .6fr);
}

.aid-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.aid-card {
  background: var(--white);
  border-left: 5px solid var(--border);
  border-radius: 8px;
  padding: 23px 26px;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

.aid-card.given {
  border-color: var(--red);
}

.aid-card.received {
  border-color: var(--navy-3);
}

.aid-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.aid-num {
  margin-top: 4px;
  font-family: Consolas, "DM Mono", monospace;
  font-size: 44px;
  font-weight: 800;
  line-height: 1;
}

.aid-card.given .aid-num {
  color: var(--red);
}

.aid-card.received .aid-num {
  color: var(--navy-3);
}

.aid-desc {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.upload-list {
  background: var(--white);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 1px 4px rgba(15, 32, 68, .07);
}

.upload-item {
  grid-template-columns: 1fr auto;
}

.upload-meta {
  color: var(--muted);
  font-size: 11px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(15, 32, 68, .55);
  padding: 24px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: min(1060px, 100%);
  max-height: 90vh;
  overflow: hidden;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(15, 32, 68, .4);
}

.modal-hdr {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 22px 26px;
  border-bottom: 1px solid var(--border);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.month-pill {
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 900;
}

.ghost-btn {
  min-height: 32px;
  background: #e8edf8;
  color: var(--navy);
  padding: 6px 12px;
  font-size: 12px;
}

.close-btn {
  width: 34px;
  height: 34px;
  background: var(--navy);
  color: var(--white);
  font-size: 18px;
  line-height: 1;
}

.modal-body {
  max-height: calc(90vh - 94px);
  overflow: auto;
  padding: 24px 26px 28px;
}

.modal-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 22px;
}

.modal-kpi {
  min-height: 74px;
  border-radius: 8px;
  background: #f7f9fd;
  padding: 12px;
  text-align: center;
}

.modal-kpi .value {
  color: var(--red);
  font-family: Consolas, "DM Mono", monospace;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.modal-kpi .label {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.modal-section-title {
  margin: 22px 0 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border-radius: 6px;
  background: #f7f9fd;
  padding: 7px 11px;
  font-size: 12px;
}

.chip strong {
  margin-right: 6px;
  color: var(--red);
  font-family: Consolas, "DM Mono", monospace;
}

.incident-table {
  min-width: 760px;
}

.cat-badge {
  display: inline-block;
  min-width: 92px;
  border-radius: 999px;
  background: #e8edf8;
  color: var(--navy);
  padding: 4px 9px;
  text-align: center;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cat-badge.ems { color: var(--blue); background: #edf4ff; }
.cat-badge.alarm { color: var(--orange); background: #fff7e8; }
.cat-badge.assist { color: var(--green); background: #ebfbf4; }
.cat-badge.fire { color: var(--red); background: #fff0f1; }
.cat-badge.rescue { color: var(--purple); background: #f5f0ff; }
.cat-badge.outside { color: #4d7c0f; background: #f4fae9; }
.cat-badge.drone { color: var(--cyan); background: #edf9ff; }

.empty {
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .report-header,
  .import-bar,
  main {
    padding-left: 24px;
    padding-right: 24px;
  }

  .header-top,
  .summary-grid,
  .charts-grid,
  .aid-row {
    grid-template-columns: 1fr;
  }

  .header-top {
    display: grid;
  }

  .kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .report-header,
  .import-bar,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .header-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
  }

  .stat-divider {
    display: none;
  }

  h1 {
    font-size: 24px;
  }

  .kpi-row {
    grid-template-columns: 1fr;
  }

  .modal-hdr {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-row {
    align-items: flex-start;
  }

  .agency-logo {
    width: 58px;
    height: 58px;
  }
}
