/* Richmond Stake — New Convert Dashboard (dark theme) */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2129;
  --border: #2b313b;
  --text: #e6edf3;
  --text-dim: #9aa4b2;
  --text-faint: #6e7681;
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --gray: #8b949e;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #131922, var(--bg));
  padding: 22px 24px 16px;
}
.header-inner { max-width: 1240px; margin: 0 auto; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
h1 .accent { color: var(--blue); font-weight: 500; }
.meta { color: var(--text-faint); font-size: 13px; margin-top: 2px; }

.viewer {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  color: var(--text-faint); font-size: 12.5px;
}
.viewer a { color: var(--text-dim); text-decoration: none; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.viewer a:hover { color: var(--text); border-color: var(--text-faint); }

.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* Mobile replacements: ward dropdown (header) & sort dropdown (roster) — hidden on desktop */
.ward-select, .sort-select {
  display: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa4b2' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.ward-select { margin-top: 14px; }
.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.pill:hover { border-color: var(--blue); color: var(--text); }
.pill.active {
  background: rgba(88, 166, 255, .15);
  border-color: var(--blue);
  color: var(--blue);
  font-weight: 600;
}
.pill .pill-count { opacity: .65; font-size: 11.5px; margin-left: 5px; }

main { max-width: 1240px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* ---- tiles ---- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--tile-color, var(--blue));
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: transform .12s, border-color .12s, background .12s;
}
.tile:hover { transform: translateY(-2px); background: var(--surface-2); border-color: var(--tile-color, var(--blue)); }
.tile.selected { background: var(--surface-2); border-color: var(--tile-color); box-shadow: 0 0 0 1px var(--tile-color); }
.tile h3 { font-size: 13px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.tile .big { font-size: 34px; font-weight: 700; margin: 4px 0 2px; color: var(--tile-color, var(--text)); font-variant-numeric: tabular-nums; }
.tile .big .pct { font-size: 16px; font-weight: 500; color: var(--text-faint); margin-left: 8px; }
.tile .sub { font-size: 12.5px; color: var(--text-faint); }

.tile.milestones { cursor: default; }
.tile.milestones:hover { transform: none; }
.mile-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--text-dim); padding: 3px 0; }
.mile-row .mile-val { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.mile-bar { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin: 1px 0 6px; }
.mile-bar > div { height: 100%; background: var(--purple); border-radius: 2px; }

/* ---- drill-down ---- */
.drill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.drill.hidden { display: none; }
.drill-head { display: flex; justify-content: space-between; align-items: center; }
.drill-head h2 { font-size: 17px; }
.drill-sub { color: var(--text-faint); font-size: 13px; margin: 2px 0 12px; }
.close-btn {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 14px;
}
.close-btn:hover { color: var(--text); border-color: var(--text-faint); }

.ward-group { margin-bottom: 14px; }
.ward-group-head {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 14px; font-weight: 650; padding: 6px 0; border-bottom: 1px solid var(--border);
}
.ward-group-head .count { color: var(--text-faint); font-weight: 500; font-size: 13px; }
.person-row {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  padding: 7px 2px; border-bottom: 1px solid #1c212933; font-size: 13.5px;
}
.person-row:hover { background: var(--surface-2); }
.person-row .pname { min-width: 220px; font-weight: 550; }
.person-row .pdetail { color: var(--text-dim); font-size: 12.5px; }

/* ---- badges & dots ---- */
.badge {
  display: inline-block; padding: 1.5px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge.active     { background: rgba(63,185,80,.15);  color: var(--green); }
.badge.atrisk     { background: rgba(210,153,34,.15); color: var(--amber); }
.badge.disengaged { background: rgba(139,148,158,.15); color: var(--gray); }
.badge.urgent     { background: rgba(248,81,73,.18);  color: var(--red); }
.badge.info       { background: rgba(88,166,255,.13); color: var(--blue); }
.badge.flag       { background: rgba(188,140,255,.15); color: var(--purple); }
.badge.muted      { background: var(--surface-2); color: var(--text-faint); }

.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #2b313b; }
.dot.on { background: var(--green); }
.dot.off { background: #3d2426; }

/* ---- panels ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel h2 { font-size: 17px; }
.panel-sub { color: var(--text-faint); font-size: 13px; margin: 2px 0 10px; }
.scope-label { color: var(--blue); font-size: 14px; font-weight: 500; }

/* ---- chart ---- */
#chart svg { width: 100%; height: auto; display: block; }
.chart-line { fill: none; stroke: var(--blue); stroke-width: 2.5; }
.chart-area { fill: url(#chartFill); }
.chart-grid { stroke: #21262d; stroke-width: 1; }
.chart-pt { fill: var(--bg); stroke: var(--blue); stroke-width: 2.5; }
.chart-label { fill: var(--text-dim); font-size: 12px; }
.chart-val { fill: var(--text); font-size: 12.5px; font-weight: 600; }

/* ---- roster table ---- */
.roster-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
#search {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 7px 12px; font-size: 13.5px; width: 280px; max-width: 100%;
}
#search:focus { outline: none; border-color: var(--blue); }

.table-wrap { overflow-x: auto; margin-top: 6px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid #21262d; }
th {
  color: var(--text-dim); font-weight: 600; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .04em; cursor: pointer; user-select: none; position: sticky; top: 0;
  background: var(--surface);
}
th:hover { color: var(--text); }
th .arrow { font-size: 9px; margin-left: 3px; }
tbody tr:hover { background: var(--surface-2); }
td.dim { color: var(--text-dim); }
td.num { font-variant-numeric: tabular-nums; }

/* ---- tappable person cards (mobile roster) ---- */
#roster-cards { display: none; margin-top: 6px; }
.pcard {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pcard-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pcard-name { font-weight: 650; font-size: 15px; }
.pcard-badges { display: flex; gap: 5px; flex-shrink: 0; }
.pcard-sub { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; }
.pcard-stats {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 9px; font-size: 12.5px; color: var(--text-dim);
}
.pcard-chevron { margin-left: auto; color: var(--text-faint); font-size: 11px; transition: transform .15s; }
.pcard.open .pcard-chevron { transform: rotate(180deg); }
.pcard-details {
  display: none;
  margin-top: 11px; padding-top: 11px;
  border-top: 1px solid var(--border);
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  font-size: 12.5px;
}
.pcard.open .pcard-details { display: grid; }
.pcard-details .lbl { color: var(--text-faint); }

footer { max-width: 1240px; margin: 0 auto; padding: 8px 24px 32px; color: var(--text-faint); font-size: 12px; }

@media (max-width: 720px) {
  header { padding: 16px 14px 12px; }
  h1 { font-size: 18px; }
  .meta { font-size: 12px; }
  main { padding: 14px; gap: 14px; }
  .drill, .panel { padding: 14px; }

  /* Ward pills become a dropdown on mobile */
  .pills { display: none; }
  .ward-select { display: block; }

  .tile { padding: 14px; }
  .tile .big { font-size: 28px; }

  /* Drill-down rows: name on its own line, details wrap beneath */
  .person-row { padding: 10px 2px; }
  .person-row .pname { min-width: 100%; }

  /* Roster table becomes tappable person cards on mobile */
  .table-wrap { display: none; }
  #roster-cards { display: block; }
  .sort-select { display: block; }

  .roster-head { flex-direction: column; align-items: stretch; }
  #search { width: 100%; }
}
