:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #d9e2ec;
  --text: #16202a;
  --muted: #5f6c7b;
  --accent: #2457c5;
  --accent-dark: #183f95;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page-shell {
  min-height: 100vh;
  padding: 1.1rem 1.25rem 1.25rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.page-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.tool-panels {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex: 0 1 auto;
}

.filter-panel,
.control-panel {
  position: sticky;
  top: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.75rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
}

.filter-panel {
  width: min(320px, 100%);
  flex: 0 0 320px;
}

.control-panel {
  width: min(340px, 100%);
  flex: 0 0 340px;
}

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2 {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.2rem;
  font-size: 1.35rem;
}

h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-title {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.panel-hint,
.filter-result {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.filter-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.65rem 0 0.45rem;
}

.filter-summary strong {
  font-size: 0.95rem;
}

.reset-filter {
  width: auto;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
}

.reset-filter:hover:not(:disabled) {
  background: #eef4ff;
  color: var(--accent);
}

.reset-filter:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.range-slider {
  position: relative;
  height: 1.5rem;
  margin: 0.35rem 0 0.25rem;
}

.range-track,
.range-fill {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 0.35rem;
  border-radius: 999px;
  transform: translateY(-50%);
}

.range-track {
  background: #e3ebf5;
}

.range-fill {
  background: linear-gradient(90deg, var(--accent), #6c91ea);
}

.range-input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
}

.range-input::-webkit-slider-runnable-track {
  height: 0.35rem;
  background: transparent;
}

.range-input::-moz-range-track {
  height: 0.35rem;
  background: transparent;
}

.range-input::-webkit-slider-thumb {
  width: 1rem;
  height: 1rem;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
}

.range-input::-moz-range-thumb {
  width: 1rem;
  height: 1rem;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
  pointer-events: auto;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  align-items: start;
}

.control-hint {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.controls label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.controls span {
  font-weight: 600;
}

.selection-field {
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdff;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.selection-field.active {
  border-color: var(--accent);
  background: #eef4ff;
  box-shadow: 0 0 0 2px rgba(36, 87, 197, 0.12);
}

.date-nav {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 2rem;
  gap: 0.35rem;
  align-items: center;
}

select,
input,
button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  font: inherit;
}

select,
input {
  padding: 0.5rem 0.55rem;
  background: #fff;
}

button {
  padding: 0.75rem 0.9rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  border: none;
}

button:hover {
  background: var(--accent-dark);
}

.nav-arrow {
  width: 2rem;
  min-width: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
}

.nav-arrow:hover:not(:disabled) {
  background: #eef4ff;
  color: var(--accent);
}

button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.nav-arrow:disabled {
  background: #f8fafc;
  color: var(--muted);
  cursor: not-allowed;
}

.status {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.content {
  min-width: 0;
}

.table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead {
  background: #eef4ff;
}

th,
td {
  padding: 0.78rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 0.92rem;
}

tbody tr:hover {
  background: #fafcff;
}

td:first-child,
th:first-child {
  width: 3.5rem;
  white-space: nowrap;
}

td:nth-child(2),
th:nth-child(2) {
  width: 10rem;
}

td:nth-child(3),
th:nth-child(3) {
  width: 7.5rem;
  white-space: nowrap;
}

td:nth-child(5),
th:nth-child(5) {
  width: 7.5rem;
}

td:first-child,
td:nth-child(3),
th:first-child,
th:nth-child(3) {
  text-align: right;
}

td:nth-child(2),
td:nth-child(4),
th:nth-child(2),
th:nth-child(4) {
  overflow-wrap: anywhere;
}

.lead-cell {
  position: relative;
}

.lead-cell.lead-overflow::after {
  content: '';
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: 0.3rem;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.15), rgba(220, 38, 38, 0.8));
  pointer-events: none;
}

.lead-text {
  max-height: 10rem;
  overflow: auto;
  white-space: normal;
  line-height: 1.45;
  font-size: 0.92rem;
}

.lead-text p {
  margin: 0 0 0.45rem;
}

.lead-text p:last-child {
  margin-bottom: 0;
}

.lead-stats {
  display: grid;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.lead-stats strong {
  color: var(--text);
  font-size: 0.92rem;
}

.stats-cell {
  text-align: right;
}

.reload-button {
  width: auto;
  min-width: 2rem;
  margin-top: 0.45rem;
  padding: 0.22rem 0.45rem;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--accent);
  font-weight: 700;
}

.reload-button:hover:not(:disabled) {
  background: #eef4ff;
  color: var(--accent);
}

.reload-button:disabled {
  cursor: not-allowed;
}

.lead-empty,
.lead-loading,
.lead-error {
  color: var(--muted);
  font-style: italic;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

@media (max-width: 960px) {
  .page-header {
    flex-direction: column;
  }

  .tool-panels {
    width: 100%;
    flex-direction: column;
  }

  .filter-panel,
  .control-panel {
    position: static;
    width: 100%;
    flex-basis: auto;
  }

  .filter-summary {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .table-card {
    overflow-x: auto;
  }

  td:nth-child(2),
  th:nth-child(2) {
    width: 8.5rem;
  }

  td:nth-child(5),
  th:nth-child(5) {
    width: 6.5rem;
  }
}
