:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #667085;
  --line: #d8dee6;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --accent: #8f2f3f;
  --accent-2: #2c6e59;
  --gold: #b0832e;
  --danger: #a33a2b;
  --radius: 8px;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 24px 28px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 28px; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 22px; }
h3 { font-size: 16px; }
.topbar p, .hint { color: var(--muted); margin-bottom: 0; }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
button, .button-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
button:hover, .button-link:hover { border-color: var(--accent); }
.tab.active, form button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

main { padding: 24px 28px 48px; }
.view { display: none; }
.view.active { display: block; }
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.filters, .upload-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.recommendation-summary { display: flex; gap: 16px; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.target-status { min-width: 96px; }
.target-score { min-width: 64px; }
.target-notes { min-width: 220px; font-size: 12px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.two-col {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }
fieldset {
  border: 0;
  padding: 6px 0 12px;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
fieldset label { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
fieldset input { width: auto; }
form { display: grid; gap: 12px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.metric strong { display: block; font-size: 24px; margin-top: 6px; }
.bars {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.bar-row { margin: 10px 0; }
.bar-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.bar-track { height: 10px; background: #edf0f3; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent-2); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 9px 8px; vertical-align: top; }
th { color: var(--muted); font-size: 12px; white-space: nowrap; }
tr:hover td { background: #fafafa; }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  color: #fff;
  font-weight: 800;
}
.grade-S { background: var(--accent-2); }
.grade-A { background: #3572a5; }
.grade-B { background: var(--gold); }
.grade-C { background: #7b6f63; }
.grade-Avoid { background: var(--danger); }
.tag {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  margin: 1px;
  white-space: nowrap;
  color: var(--muted);
}
.star-rating {
  display: inline-flex;
  gap: 2px;
  min-width: 92px;
}
.star {
  border: 0;
  background: transparent;
  min-width: 18px;
  min-height: 24px;
  padding: 0;
  color: #c6ccd4;
  font-size: 18px;
  line-height: 1;
}
.star.filled { color: var(--gold); }
.star:hover { color: var(--gold); border: 0; }
.hidden { display: none; }
#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #202124;
  color: #fff;
  padding: 10px 12px;
  border-radius: 6px;
  opacity: 0;
  transform: translateY(8px);
  transition: 160ms ease;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
code { background: #eceff3; padding: 2px 4px; border-radius: 4px; }

@media (max-width: 980px) {
  .topbar { align-items: start; flex-direction: column; }
  .two-col, .bars, .metric-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  main, .topbar { padding-left: 14px; padding-right: 14px; }
  .grid-form, fieldset { grid-template-columns: 1fr; }
  .tabs { width: 100%; }
  .tab { flex: 1 1 44%; justify-content: center; }
}
