:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-strong: #f1f7f4;
  --ink: #18211f;
  --muted: #66716d;
  --line: #dfe5df;
  --green: #1f7a5b;
  --blue: #3366cc;
  --yellow: #d89518;
  --red: #c84c3c;
  --shadow: 0 20px 50px rgba(29, 42, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

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

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

button {
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  background: #142320;
  color: #eff7f3;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #8fd2b3;
  color: #10221d;
  font-weight: 800;
  font-size: 1.35rem;
}

.brand h1,
.topbar h2,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 1.1rem;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #a5bbb3;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  color: #d9e8e2;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
}

.nav-list a.active,
.nav-list a:hover {
  background: rgba(143, 210, 179, 0.15);
  color: #fff;
}

.privacy-note {
  margin-top: auto;
  padding: 14px;
  display: grid;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #d9e8e2;
  font-size: 0.9rem;
}

main {
  padding: 28px;
  min-width: 0;
}

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

.topbar h2 {
  font-size: clamp(1.7rem, 3vw, 2.6rem);
}

.actions,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  display: grid;
  gap: 6px;
}

.metric span,
.metric small {
  color: var(--muted);
}

.metric strong {
  font-size: 2rem;
  line-height: 1;
}

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

.panel {
  padding: 18px;
  min-width: 0;
}

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

.panel-heading {
  margin-bottom: 14px;
}

canvas {
  width: 100%;
  max-width: 100%;
}

.legend {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.empty-state,
.empty-cell {
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-state {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafcfb;
}

.empty-cell {
  padding: 22px 10px;
  text-align: center;
}

.legend-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend-row span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.form-stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px 11px;
  font-weight: 500;
}

textarea {
  resize: vertical;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.record-list,
.insight-list,
.grade-snapshot,
.support-list {
  display: grid;
  gap: 10px;
}

.record,
.insight,
.grade-card,
.support-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.record strong,
.insight strong,
.grade-card strong,
.support-item strong {
  display: block;
  margin-bottom: 4px;
}

.record small,
.insight p,
.grade-card small,
.support-item p {
  color: var(--muted);
}

.grade-card {
  display: grid;
  gap: 8px;
}

.grade-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.grade-row b {
  color: var(--ink);
}

.chess-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.6fr);
  gap: 16px;
  align-items: start;
}

.chess-summary {
  display: grid;
  gap: 10px;
}

.chess-stat {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fbff;
}

.chess-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.chess-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

.event-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.event-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.event-card strong {
  display: block;
  font-size: 0.92rem;
}

.event-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.delta {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  font-weight: 900;
}

.delta.up {
  color: var(--green);
}

.delta.down {
  color: var(--red);
}

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

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

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.pill.good {
  background: #e4f4ed;
  color: var(--green);
}

.pill.warn {
  background: #fff2d4;
  color: #96600b;
}

.pill.risk {
  background: #ffe5e0;
  color: var(--red);
}

.roadmap {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.roadmap li + li {
  margin-top: 10px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .chess-layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  main {
    padding: 18px;
  }

  .topbar,
  .actions,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics-grid,
  .dashboard-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .panel.wide {
    grid-column: span 1;
  }

  .event-strip {
    grid-template-columns: 1fr;
  }
}
