:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687386;
  --border: #dbe2ee;
  --primary: #2457d6;
  --primary-dark: #1d46ad;
  --green: #167a3f;
  --green-bg: #e8f6ee;
  --blue: #1f5fbf;
  --blue-bg: #eaf1ff;
  --yellow: #8a5a00;
  --yellow-bg: #fff5d6;
  --gray: #58606f;
  --gray-bg: #eef1f5;
  --red: #b42318;
  --red-bg: #feeceb;
  --shadow: 0 16px 40px rgba(31, 44, 71, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.12;
}

h2 {
  font-size: 18px;
}

.rate-card,
.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.rate-card {
  min-width: 220px;
  padding: 16px 18px;
  border-radius: 8px;
}

.rate-card span,
.metric span,
label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 7px;
}

.rate-card strong {
  font-size: 28px;
}

.panel {
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

input,
select {
  height: 40px;
  padding: 0 12px;
}

textarea {
  min-height: 285px;
  margin-top: 14px;
  padding: 14px;
  line-height: 1.55;
  resize: vertical;
  white-space: pre;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36, 87, 214, 0.12);
}

.section-title,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

button {
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
  color: #fff;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 92px;
  padding: 16px;
  border-radius: 8px;
}

.metric strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 22px;
}

.metric.wide {
  grid-column: span 2;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.toolbar input {
  max-width: 280px;
}

.toolbar select {
  max-width: 160px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1380px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 800;
}

td.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr.profit-positive td.profit {
  color: var(--green);
  font-weight: 800;
}

tr.profit-negative td.profit {
  color: var(--red);
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge-strong {
  background: var(--green-bg);
  color: var(--green);
}

.badge-good {
  background: var(--blue-bg);
  color: var(--blue);
}

.badge-careful {
  background: var(--yellow-bg);
  color: var(--yellow);
}

.badge-thin {
  background: var(--gray-bg);
  color: var(--gray);
}

.badge-no {
  background: var(--red-bg);
  color: var(--red);
}

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

.unmatched-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.unmatched-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfe;
}

.unmatched-item code {
  display: block;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.unmatched-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .page-header,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .rate-card {
    min-width: 0;
  }

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

  .metric.wide {
    grid-column: span 2;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 16px;
  }

  .input-grid,
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .metric.wide {
    grid-column: auto;
  }

  .toolbar input,
  .toolbar select,
  .toolbar button {
    max-width: none;
    width: 100%;
  }
}
