:root {
  color-scheme: light;
  --page-bg: #eef0f6;
  --surface: #ffffff;
  --surface-alt: #f5f6fb;
  --surface-sunken: #e8eaf2;
  --text-primary: #14151f;
  --text-secondary: #4d5066;
  --text-muted: #82859e;
  --border: rgba(20, 21, 31, 0.13);
  --border-soft: rgba(20, 21, 31, 0.07);
  --accent: #a86a0c;
  --accent-ink: #6e4708;
  --accent-wash: rgba(184, 121, 15, 0.12);
  --good: #0ca30c;
  --good-bg: rgba(12, 163, 12, 0.11);
  --bad: #c23a2b;
  --bad-bg: rgba(194, 58, 43, 0.11);
  --shadow: 0 1px 2px rgba(20, 21, 31, 0.04), 0 8px 24px -12px rgba(20, 21, 31, 0.18);
  --ramp-lo-h: 42; --ramp-lo-s: 70%; --ramp-lo-l: 93%;
  --ramp-hi-h: 32; --ramp-hi-s: 68%; --ramp-hi-l: 30%;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page-bg: #0c0d13;
    --surface: #15161f;
    --surface-alt: #1b1c28;
    --surface-sunken: #101117;
    --text-primary: #f3f3f7;
    --text-secondary: #b7b9cc;
    --text-muted: #7d7f97;
    --border: rgba(255, 255, 255, 0.11);
    --border-soft: rgba(255, 255, 255, 0.06);
    --accent: #d9a44a;
    --accent-ink: #f2c980;
    --accent-wash: rgba(217, 164, 74, 0.16);
    --good: #35c25a;
    --good-bg: rgba(53, 194, 90, 0.14);
    --bad: #e2564a;
    --bad-bg: rgba(226, 86, 74, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
    --ramp-lo-h: 42; --ramp-lo-s: 30%; --ramp-lo-l: 20%;
    --ramp-hi-h: 40; --ramp-hi-s: 82%; --ramp-hi-l: 62%;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page-bg);
  color: var(--text-primary);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  -webkit-font-smoothing: antialiased;
}
.sans { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
nav.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
nav.topnav .topnav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 46px;
}
nav.topnav .brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-ink);
  margin-right: 18px;
  white-space: nowrap;
}
nav.topnav a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  line-height: 1;
}
nav.topnav a:hover {
  color: var(--text-primary);
  background: var(--surface-alt);
}
nav.topnav a.active {
  color: var(--accent-ink);
  background: var(--accent-wash);
  font-weight: 600;
}
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 44px 28px 72px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

header.masthead {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 28px;
}
.eyebrow {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
h1 { margin: 0; font-size: 34px; line-height: 1.15; font-weight: 600; letter-spacing: -0.01em; }
.lede {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  max-width: 66ch;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
  margin: 4px 0 0;
}
.lede code, footer code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 0.05em 0.4em;
  font-size: 0.92em;
  color: var(--text-primary);
}

section { display: flex; flex-direction: column; gap: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
h2 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -0.005em; }
.section-note {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 46ch;
  text-align: right;
  line-height: 1.5;
}

/* roster cards */
.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}
.roster-card {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.roster-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.roster-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}
.eligible-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--good);
  background: var(--good-bg);
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
  white-space: nowrap;
}
.eligible-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); display: inline-block; }

.roster-stats { display: flex; gap: 22px; }
.roster-stat .num { font-size: 20px; font-weight: 700; }
.roster-stat .lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.hist { display: flex; flex-direction: column; gap: 3px; }
.hist-row { display: grid; grid-template-columns: 32px 1fr 26px; align-items: center; gap: 8px; font-size: 11px; color: var(--text-muted); }
.hist-track { background: var(--surface-sunken); border-radius: 3px; height: 7px; overflow: hidden; }
.hist-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.hist-row .count { text-align: right; }

/* member list within card */
.member-list { display: flex; flex-direction: column; gap: 2px; max-height: 160px; overflow-y: auto; border-top: 1px solid var(--border-soft); padding-top: 8px; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; padding: 2px 0; }
.member-row .name { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row .level { font-weight: 600; margin-left: auto; margin-right: 8px; }
.member-row button {
  border: none; background: transparent; color: var(--bad); cursor: pointer; font-size: 11px; padding: 2px 4px;
}
.member-row button:hover { text-decoration: underline; }

/* edit form */
.edit-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.edit-form select, .edit-form input {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-primary);
}
.edit-form input[type="number"] { width: 110px; }
.edit-form button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.edit-form button:hover { opacity: 0.9; }
.form-status { font-size: 12px; color: var(--text-muted); }
.form-status.error { color: var(--bad); }
.form-status.ok { color: var(--good); }

/* heatmap */
.heatmap-scroll { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border-soft); box-shadow: var(--shadow); }
table#heatmapTable { border-collapse: collapse; width: 100%; background: var(--surface); font-size: 12px; }
table#heatmapTable th, table#heatmapTable td { padding: 6px 10px; text-align: center; white-space: nowrap; }
table#heatmapTable thead th { background: var(--surface-alt); color: var(--text-muted); font-weight: 600; position: sticky; top: 0; }
table#heatmapTable th.corner { text-align: left; }
table#heatmapTable tbody th { text-align: left; font-weight: 700; background: var(--surface-alt); position: sticky; left: 0; }
table#heatmapTable td.cell.empty { color: var(--text-muted); background: var(--surface-sunken); }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--page-bg);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.1s ease;
  z-index: 10;
}
.tooltip.show { opacity: 1; }

/* weekly skilling trial */
#trialSection { margin-top: 36px; }
.trial-banner {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin: 12px 0;
}
.trial-banner.warn {
  background: var(--accent-wash);
  color: var(--accent-ink);
  border: 1px solid var(--border-soft);
}
.trial-controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.trial-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.trial-controls select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
}
.trial-btn {
  font-size: 13px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.trial-btn:hover { opacity: 0.9; }
.trial-btn:disabled { opacity: 0.55; cursor: wait; }
#trialSection .form-status { margin-top: 10px; display: inline-block; }
.trial-results { margin-top: 18px; }
.trial-total { margin-bottom: 12px; }
.trial-total-num {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent-ink);
}
.trial-total-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.trial-sub { font-size: 12px; color: var(--text-secondary); margin-bottom: 14px; }
.trial-table {
  border-collapse: collapse;
  width: 100%;
  background: var(--surface);
  font-size: 13px;
  box-shadow: var(--shadow);
  border-radius: 10px;
  overflow: hidden;
}
.trial-table th, .trial-table td { padding: 8px 12px; text-align: center; white-space: nowrap; }
.trial-table thead th { background: var(--surface-alt); color: var(--text-muted); font-weight: 600; }
.trial-table tbody td:first-child { text-align: left; font-weight: 600; }
.trial-table .trial-detail-row td { padding: 0; background: var(--surface-sunken); }
.trial-member-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
.trial-member {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
}
.muted { color: var(--text-muted); font-size: 12px; }
.trial-plans { margin-top: 28px; }
.trial-plans h3 { margin: 0 0 10px; font-size: 16px; }
.trial-plans-list { display: flex; flex-direction: column; gap: 8px; }
.trial-plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.trial-plan-info { font-size: 13px; color: var(--text-secondary); }
.trial-plan-row button {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-primary);
  cursor: pointer;
}
.trial-plan-row button:hover { background: var(--surface-sunken); }

footer {
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
