:root {
  color-scheme: light;
  --bg: #eef3f8;
  --panel: rgba(255, 255, 255, 0.88);
  --line: #d5dde8;
  --ink: #132033;
  --muted: #667085;
  --teal: #4f46e5;
  --blue: #7c3aed;
  --red: #e11d48;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Tahoma, sans-serif;
}

button,
select,
a {
  font: inherit;
}

button,
a {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  cursor: pointer;
}

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.report-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 17px;
}

.report-topbar p,
.panel-head span,
.summary-card span {
  color: var(--muted);
  font-size: 12px;
}

.report-nav,
.report-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.report-controls {
  margin: 14px 0;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-controls label {
  font-weight: 800;
}

.report-controls select,
.report-controls input {
  min-height: 36px;
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
}

.report-controls input {
  flex: 1 1 220px;
}

#loadReportBtn,
#refreshBtn {
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
  font-weight: 800;
}

#csvLink {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
  font-weight: 800;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 10px;
}

.metric-card,
.panel,
.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.metric-card {
  padding: 12px;
}

button.metric-card {
  width: 100%;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

button.metric-card:hover,
button.metric-card:focus-visible {
  border-color: #6366f1;
  transform: translateY(-1px);
}

.metric-card strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

.metric-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 270px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 1;
}

td {
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

.side-panel {
  padding: 14px;
}

.summary-blocks {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.summary-card {
  padding: 10px;
}

.summary-card strong {
  display: block;
  font-size: 22px;
}

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  border-radius: 7px;
  padding: 10px 14px;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.22);
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 12px;
  }

  .report-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-controls select,
  .report-controls input,
  .report-controls button,
  .report-controls a {
    width: 100%;
  }
}
