:root {
  --navy: #17365d;
  --navy-2: #0f2948;
  --blue: #2f75b5;
  --teal: #2f8f9d;
  --green: #70ad47;
  --amber: #e89547;
  --red: #c84747;
  --ink: #172033;
  --muted: #667085;
  --line: #dbe3ee;
  --surface: #ffffff;
  --canvas: #f3f6fa;
  --soft-blue: #edf4fb;
  --soft-green: #eef7e9;
  --soft-amber: #fff6e7;
  --soft-red: #fff0ed;
  --shadow: 0 18px 45px rgba(23, 54, 93, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 15% -10%, rgba(47, 117, 181, 0.12), transparent 32rem),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }

.app-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 20px auto 40px;
}

.hero {
  overflow: hidden;
  position: relative;
  padding: 30px 34px 32px;
  border-radius: 22px 22px 10px 10px;
  color: #fff;
  background:
    linear-gradient(125deg, rgba(255,255,255,0.07), transparent 38%),
    linear-gradient(135deg, var(--navy-2), var(--navy) 58%, #265a91);
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  right: -70px;
  top: -130px;
  border: 42px solid rgba(255,255,255,0.055);
  border-radius: 50%;
}

.hero__eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 20px;
  color: #cfe3f8;
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: #83c95a;
  box-shadow: 0 0 0 5px rgba(131, 201, 90, 0.14);
}

.hero__content {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.hero h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(2rem, 3.6vw, 4.1rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero p {
  margin: 16px 0 0;
  color: #d9e8f6;
  font-size: clamp(0.95rem, 1.4vw, 1.12rem);
}

.rate-card {
  min-width: 120px;
  padding: 14px 18px;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 16px;
  background: rgba(255,255,255,0.1);
  text-align: right;
  backdrop-filter: blur(8px);
}

.rate-card span { display: block; color: #d7e7f6; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; }
.rate-card strong { display: block; margin-top: 2px; font-size: 2rem; line-height: 1; }

.filter-panel {
  position: relative;
  z-index: 2;
  margin: -4px 16px 22px;
  padding: 22px;
  border: 1px solid rgba(219, 227, 238, 0.9);
  border-radius: 0 0 18px 18px;
  background: rgba(255,255,255,0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.filter-panel__heading,
.panel__header,
.pagination,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.filter-panel__heading { margin-bottom: 16px; }
.section-kicker { color: var(--blue); font-size: 0.69rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.filter-panel h2, .panel h2 { margin: 3px 0 0; font-size: 1.1rem; letter-spacing: -0.015em; }

.filters-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(120px, 1fr));
  gap: 10px;
}

.field { min-width: 0; }
.field--wide { grid-column: span 2; }
.field > span,
.sort-field > span {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.field input,
.field select,
.sort-field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--ink);
  padding: 0 11px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field input:focus,
.field select:focus,
.sort-field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 117, 181, 0.12);
  background: #fbfdff;
}

.filter-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(112, 173, 71, 0.13);
}

.button {
  min-height: 38px;
  border-radius: 10px;
  padding: 0 15px;
  border: 1px solid transparent;
  font-size: 0.8rem;
  font-weight: 750;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.45; transform: none; }
.button--ghost { border-color: var(--line); background: #fff; color: var(--navy); }
.button--ghost:hover { border-color: #aec1d6; background: var(--soft-blue); }
.button--primary { background: var(--navy); color: #fff; }
.button--primary:hover { background: #244b78; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  position: relative;
  overflow: hidden;
  min-height: 154px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 9px 26px rgba(23, 54, 93, 0.055);
}

.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: currentColor;
}

.kpi > span { display: block; min-height: 36px; color: var(--muted); font-size: 0.78rem; font-weight: 750; }
.kpi strong { display: block; margin: 10px 0 8px; color: currentColor; font-size: clamp(1.45rem, 2.15vw, 2.25rem); letter-spacing: -0.045em; white-space: nowrap; }
.kpi small { color: var(--muted); font-size: 0.72rem; line-height: 1.35; }
.kpi--navy { color: var(--navy); background: linear-gradient(145deg, #fff, #f0f5fa); }
.kpi--blue { color: var(--blue); background: linear-gradient(145deg, #fff, var(--soft-blue)); }
.kpi--green { color: #5a9937; background: linear-gradient(145deg, #fff, var(--soft-green)); }
.kpi--amber { color: #c7731f; background: linear-gradient(145deg, #fff, var(--soft-amber)); }
.kpi--slate { color: #56677c; }
.kpi--red { color: var(--red); background: linear-gradient(145deg, #fff, var(--soft-red)); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(23, 54, 93, 0.055);
}

.panel--wide { grid-column: span 2; }
.panel__header { margin-bottom: 18px; }
.metric-tag { padding: 5px 9px; border-radius: 999px; background: var(--soft-blue); color: var(--blue); font-size: 0.68rem; font-weight: 800; }
.chart-wrap { position: relative; height: 290px; }
canvas { display: block; width: 100%; height: 100%; }
canvas.chart--interactive { cursor: crosshair; }

.chart-tooltip {
  position: fixed;
  z-index: 100;
  width: min(260px, calc(100vw - 20px));
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 11px;
  background: rgba(15, 41, 72, 0.96);
  box-shadow: 0 14px 36px rgba(15, 41, 72, 0.24);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  visibility: hidden;
  transition: opacity 100ms ease, transform 100ms ease, visibility 100ms ease;
  backdrop-filter: blur(8px);
}

.chart-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.chart-tooltip__title {
  display: block;
  margin-bottom: 8px;
  color: #fff;
  font-size: 0.78rem;
}

.chart-tooltip__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding-top: 5px;
  color: #cfe3f8;
  font-size: 0.7rem;
}

.chart-tooltip__row strong {
  color: #fff;
  font-size: 0.72rem;
  white-space: nowrap;
}

.rank-list { display: grid; gap: 13px; min-height: 290px; align-content: center; }
.rank-item__line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.rank-item__line span { overflow: hidden; color: #344054; font-size: 0.77rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.rank-item__line strong { color: var(--navy); font-size: 0.76rem; white-space: nowrap; }
.rank-track { overflow: hidden; height: 7px; border-radius: 99px; background: #eef2f6; }
.rank-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #5aafba); transform-origin: left; animation: grow 420ms ease-out both; }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.notes-panel { margin-bottom: 16px; }
.notes-panel__header { align-items: flex-end; }
.table-actions { display: flex; align-items: flex-end; gap: 10px; }
.sort-field { min-width: 230px; }
.sort-field select { min-height: 38px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 950px; border-collapse: collapse; }
th { position: sticky; top: 0; z-index: 1; background: #f1f5f9; color: #475467; font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; }
th, td { padding: 12px 13px; border-bottom: 1px solid #e9eef4; text-align: left; }
td { color: #344054; font-size: 0.78rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8fbfe; }
.numeric { text-align: right; }
.client-cell { max-width: 360px; font-weight: 650; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 84px; padding: 4px 8px; border-radius: 99px; font-size: 0.68rem; font-weight: 750; }
.status-pill--ok { color: #397726; background: var(--soft-green); }
.status-pill--missing { color: #a44734; background: var(--soft-red); }
.pagination { margin-top: 14px; color: var(--muted); font-size: 0.78rem; }
.pagination > div { display: flex; gap: 8px; }
.empty-row { padding: 34px !important; color: var(--muted); text-align: center; }

footer { padding: 12px 4px; color: #7a8797; font-size: 0.72rem; }

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 15px;
  background: #f4f7fa;
  color: var(--navy);
  transition: opacity 260ms ease, visibility 260ms ease;
}
.loading-screen.is-hidden { opacity: 0; visibility: hidden; }
.loading-mark { width: 38px; height: 38px; border: 4px solid #cdd9e6; border-top-color: var(--blue); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .filters-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 18px, 1540px); margin-top: 9px; }
  .hero { padding: 24px 20px; }
  .hero__content { align-items: flex-start; flex-direction: column; }
  .rate-card { text-align: left; }
  .filter-panel { margin-inline: 7px; padding: 18px; }
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field--wide { grid-column: span 2; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
  .panel--wide { grid-column: auto; }
  .notes-panel__header { align-items: stretch; flex-direction: column; }
  .table-actions { align-items: stretch; flex-direction: column; }
  .sort-field { min-width: 0; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 460px) {
  .filters-grid, .kpi-grid { grid-template-columns: 1fr; }
  .field--wide { grid-column: auto; }
  .filter-panel__heading { align-items: flex-start; flex-direction: column; }
  .kpi { min-height: 134px; }
  .chart-wrap { height: 250px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
