:root {
  --bg: #0f1115;
  --card: #171a21;
  --text: #e6e6e6;
  --muted: #9aa0a6;
  --accent: #4f8cff;
  --danger: #e05252;
  --warn: #e0a852;
  --ok: #52e082;
  /* Overdose pills. Deliberately off the green/red quota axis so a bad
     overdose week can't be mistaken for a missed-quota week. */
  --pill: #b06fe8;
  /* Per-attribute breakdown bars - informational, not pass/fail, so they
     stay off the green/red axis too. */
  --attr: #5bb8f0;
  --border: #2a2e37;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
main { max-width: 900px; margin: 0 auto; padding: 24px; }
.banner { display: block; width: 100%; max-width: 400px; height: auto; border-radius: 6px; margin: 0 auto 16px; }
nav { display: flex; gap: 16px; align-items: center; margin-bottom: 24px; font-size: 14px; }
nav a { color: var(--accent); text-decoration: none; }
nav span { color: var(--muted); margin-right: auto; }
.card {
  max-width: 420px;
  margin: 80px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
}
h1 { font-size: 20px; font-weight: 500; margin: 0 0 8px; }
p { line-height: 1.5; color: var(--muted); font-size: 14px; }
code { background: var(--border); padding: 1px 5px; border-radius: 3px; }
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--muted); font-weight: 500; }
input, button {
  width: 100%;
  padding: 10px 12px;
  margin-top: 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0f1115;
  color: var(--text);
  font-size: 14px;
}
button {
  background: var(--accent);
  border: none;
  color: white;
  cursor: pointer;
  width: auto;
  padding: 10px 20px;
}
button:hover { opacity: 0.9; }
.error { color: var(--danger); }
.notice { color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }
.badge {
  background: rgba(224, 82, 82, 0.15);
  color: var(--danger);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.badge.warn { background: rgba(224, 168, 82, 0.15); color: var(--warn); }
.badge.ok { background: rgba(82, 224, 130, 0.15); color: var(--ok); }
h2 { font-size: 16px; font-weight: 500; margin: 32px 0 4px; }
.calendar { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; }
.month {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  width: 220px;
}
.month h3 { margin: 0 0 8px; font-size: 14px; font-weight: 500; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-header { font-size: 10px; text-align: center; color: var(--muted); opacity: 0.7; padding-bottom: 2px; }
.day { font-size: 11px; text-align: center; color: var(--muted); }
.day.empty { visibility: hidden; }
.day input { width: auto; display: block; margin: 0 auto 2px; }
.danger-zone {
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 16px;
  margin-top: 32px;
}
.danger-zone h2 { color: var(--danger); margin-top: 0; }
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 16px 0;
}
.week-nav .disabled { color: var(--muted); pointer-events: none; }
.week-label { color: var(--muted); font-size: 14px; text-align: center; flex: 1; }
/* Sized to its own content rather than the page width: the grid below is
   only as wide as its week columns, and a full-width nav stretched over a
   narrower table reads as misaligned. */
.week-nav.compact { width: max-content; max-width: 100%; justify-content: flex-start; gap: 18px; }
.week-nav.compact .week-label { flex: 0 0 auto; text-align: left; }
.bar-list { margin-top: 16px; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.bar-name { width: 140px; flex-shrink: 0; font-size: 14px; }
.bar-name.me { font-weight: 700; color: var(--accent); }
.bar-track {
  flex: 1 1 160px;
  min-width: 120px;
  background: var(--border);
  border-radius: 4px;
  height: 18px;
  overflow: hidden;
  position: relative;
}
.bar-fill { height: 100%; border-radius: 4px; }
.bar-fill.red { background: var(--danger); }
.bar-fill.ok { background: var(--ok); }
.bar-fill.attr { background: var(--attr); }
.bar-value { width: 100px; flex-shrink: 0; text-align: right; font-size: 13px; color: var(--muted); }
.bar-overdose { width: 100%; font-size: 12px; color: var(--muted); }

/* Viewer's own week, lifted out of the roster list into its own panel. */
.me-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 20px 18px;
  margin-top: 16px;
}
.me-card h2 { margin-top: 16px; }
.me-card .bar-row { border-bottom: 1px solid var(--border); }
.attr-heading { font-size: 13px; font-weight: 500; color: var(--muted); margin: 18px 0 4px; }
.attr-bars { display: flex; flex-direction: column; gap: 6px; }
.attr-row { display: flex; align-items: center; gap: 12px; }
.attr-name { width: 80px; flex-shrink: 0; font-size: 13px; color: var(--muted); }
.attr-row .bar-track { height: 14px; }

/* --- Faction report grid --- */
.grid-controls { display: flex; align-items: center; gap: 8px; margin: 8px 0 0; }
.grid-controls label { font-size: 13px; color: var(--muted); }
.grid-controls input { width: 70px; margin-top: 0; }
.grid-controls button { margin-top: 0; padding: 8px 14px; }
/* A link that downloads rather than navigates, dressed as a button so it reads
   as an action. Pushed to the far end of the controls row, away from the
   week-window inputs it has nothing to do with. */
.button-link {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  white-space: nowrap;
}
.button-link:hover { opacity: 0.9; }
.export-link { margin-left: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 16px 0 4px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend-stars { color: var(--muted); opacity: 0.8; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.ok { background: var(--ok); }
.swatch.missed { background: var(--danger); }
.swatch.not_member { background: var(--border); }
/* Cells stay a fixed legible size at any window width - the grid scrolls
   sideways instead of squeezing 52 weeks into the viewport. */
.grid-scroll { overflow-x: auto; margin-top: 8px; }
table.grid { width: auto; border-collapse: separate; border-spacing: 3px; }
table.grid th, table.grid td { border-bottom: none; padding: 0; }
.grid-week { font-size: 10px; color: var(--muted); font-weight: 400; text-align: center; width: 48px; }
/* Sortable headers. Kept deliberately quiet - the grid's own colours are the
   signal, so headers hint at being clickable on hover rather than shouting. */
th[data-sort-type] {
  cursor: pointer;
  user-select: none;
  border-radius: 3px;
  transition: color 0.12s, background 0.12s;
}
th[data-sort-type]:hover { color: var(--text); background: var(--border); }
th[data-sort-type]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
th[data-sort-type].is-sorted { color: var(--accent); }
.sort-arrow { font-style: normal; font-size: 8px; margin-left: 2px; line-height: 1; }
/* The name header is sticky, so it needs its own opaque background on hover -
   otherwise rows scroll visibly underneath it. */
.grid-name[data-sort-type]:hover { background: var(--border); }
.grid-name {
  position: sticky;
  left: 0;
  background: var(--bg);
  text-align: left;
  font-size: 13px;
  padding-right: 10px !important;
  white-space: nowrap;
  min-width: 130px;
}
.grid-name .badge { font-size: 10px; padding: 1px 5px; margin-left: 4px; }
.grid-summary { font-size: 12px; color: var(--muted); text-align: center; padding-left: 10px !important; }
.grid-summary.avg { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; min-width: 52px; }
.grid-summary.avg.na { color: var(--muted); opacity: 0.6; }
/* Wider than tall on purpose - the extra width is what lets five stars sit
   at a readable size without crowding the cell colour. */
.grid-cell {
  width: 48px;
  height: 28px;
  border-radius: 3px;
  position: relative;
}
.grid-cell.ok { background: var(--ok); }
.grid-cell.missed { background: var(--danger); }
.grid-cell.not_member { background: var(--border); opacity: 0.45; }

/* Stars and pills are overlays positioned by their container, so the same
   markup works on the grid's cells and the dashboard's bars. Shadows keep
   both legible against green and red alike. */
.stars {
  position: absolute;
  font-size: 9px;
  line-height: 1;
  letter-spacing: -1px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.pills {
  position: absolute;
  display: flex;
  gap: 1.5px;
  pointer-events: none;
}
.pill {
  display: block; /* so width/height apply in the legend too, not just in flex */
  width: 4px;
  height: 7px;
  border-radius: 2px;
  background: var(--pill);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.65);
  flex: none;
}
/* Grid cell: pills top-right, stars bottom-right. */
.grid-cell .pills { top: 2px; right: 3px; }
.grid-cell .stars { bottom: 2px; right: 3px; }
/* Dashboard bar: pills left-middle, stars right-middle. */
.bar-track .pills { left: 5px; top: 50%; transform: translateY(-50%); }
.bar-track .stars { right: 5px; top: 50%; transform: translateY(-50%); }
