:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-soft: #eff4ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

.boot-splash { padding: 80px 0; text-align: center; color: var(--muted); }

/* ---- topbar ---- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: -.2px; white-space: nowrap; }
.brand .chapter { font-weight: 500; color: var(--muted); margin-left: 8px; font-size: 14px; }
.nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; }
.nav a {
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a:hover { color: var(--accent); }
.topbar .me { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.btn-newevent {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 14px; font-weight: 700; font-size: 14px; white-space: nowrap;
}
.btn-newevent:hover { background: #1e40af; }

/* ---- layout ---- */
.main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card .card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 13.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card .card-body { padding: 14px 16px; }

/* ---- generic controls ---- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid #bfd3ff; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 70px; }
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 7px 13px; font-weight: 600; font-size: 13.5px;
}
.btn:hover { border-color: #c6d0de; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }

.avatar {
  width: 26px; height: 26px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; flex: none;
  object-fit: cover; background: #cbd5e1;
}
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px;
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.overdue { color: var(--danger); font-weight: 700; }

/* ---- dashboard ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .n { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.tile .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.goal-bar { height: 8px; border-radius: 999px; background: #e6ebf3; overflow: hidden; margin-top: 8px; }
.goal-bar > div { height: 100%; background: var(--ok); border-radius: 999px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr 340px; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.list-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  border-bottom: 1px solid #f1f5f9; cursor: pointer;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #f8fafc; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-block { text-align: center; min-width: 44px; background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 4px 6px; flex: none; }
.date-block .d { font-size: 17px; font-weight: 800; line-height: 1.1; }
.date-block .m { font-size: 10.5px; font-weight: 700; text-transform: uppercase; }
.feed-row { display: flex; gap: 10px; padding: 9px 16px; border-bottom: 1px solid #f1f5f9; font-size: 13.5px; }
.feed-row:last-child { border-bottom: 0; }
.feed-row .when { color: var(--muted); font-size: 12px; }
.empty { padding: 22px 16px; color: var(--muted); text-align: center; font-size: 13.5px; }

/* ---- board ---- */
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 16px; }
.col { background: #eaeef5; border-radius: 12px; min-width: 248px; width: 248px; flex: none; }
.col-head {
  padding: 10px 12px 6px; font-weight: 800; font-size: 13px;
  display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .03em;
}
.col-head .count { color: var(--muted); font-weight: 700; }
.col-head .stage-dot { width: 9px; height: 9px; border-radius: 50%; }
.col-head .add { margin-left: auto; border: 0; background: none; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.col-head .add:hover { background: #dde4ee; color: var(--accent); }
.col-cards { padding: 6px 8px 10px; min-height: 60px; display: flex; flex-direction: column; gap: 8px; }
.col.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.ecard {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; box-shadow: var(--shadow); cursor: pointer;
}
.ecard.dragging { opacity: .4; }
.ecard .t { font-weight: 700; font-size: 14px; line-height: 1.3; margin-bottom: 6px; }
.ecard .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.ecard .badges { display: flex; gap: 8px; margin-top: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.dropped-tray { margin-top: 14px; }
.dropped-tray summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.dropped-list { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.dropped-list .ecard { width: 248px; opacity: .75; }

/* ---- calendar ---- */
.cal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cal-month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cal-month.current { border-color: var(--accent); }
.cal-month .mh { padding: 9px 14px; border-bottom: 1px solid var(--line); font-weight: 800; font-size: 13.5px; display: flex; justify-content: space-between; }
.cal-month .mh .yr { color: var(--muted); font-weight: 600; }
.cal-events { padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 44px; }
.cal-ev {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px;
  border-radius: 8px; background: #f8fafc; border-left: 3px solid var(--muted);
  cursor: pointer; font-size: 13px;
}
.cal-ev:hover { background: #f1f5f9; }
.cal-ev .day { font-weight: 800; min-width: 26px; text-align: center; }
.cal-ev .t { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-none { color: #b6c2d2; font-size: 12.5px; text-align: center; padding: 10px 0 6px; }

/* ---- tasks ---- */
.task-filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.task-filters button {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-weight: 600; font-size: 13px; color: var(--muted);
}
.task-filters button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.task-group-head { padding: 10px 16px 4px; font-weight: 800; font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid #f1f5f9; }
.task-row:last-child { border-bottom: 0; }
.task-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--ok); flex: none; }
.task-row .t { flex: 1; min-width: 0; }
.task-row.done .t { text-decoration: line-through; color: var(--muted); }
.task-row .del { border: 0; background: none; color: #c3ccd8; font-size: 15px; padding: 2px 6px; border-radius: 6px; }
.task-row .del:hover { color: var(--danger); background: #fef2f2; }
.task-add { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1fr auto; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.task-add input, .task-add select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
@media (max-width: 800px) { .task-add { grid-template-columns: 1fr 1fr; } }

/* ---- team ---- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.member { display: flex; gap: 12px; align-items: center; padding: 14px 16px; }
.member .avatar { width: 38px; height: 38px; font-size: 14px; }
.member .who { flex: 1; min-width: 0; }
.member .who .n { font-weight: 700; }
.member .who .r { color: var(--muted); font-size: 12.5px; }
.member .rm { border: 0; background: none; color: #c3ccd8; padding: 4px 6px; border-radius: 6px; }
.member .rm:hover { color: var(--danger); background: #fef2f2; }
.member-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.member .lnk {
  border: 0; background: none; color: var(--muted); font-size: 12px;
  font-weight: 600; padding: 4px 6px; border-radius: 6px; white-space: nowrap;
}
.member .lnk:hover { color: var(--accent); background: var(--accent-soft); }
.admin-chip { background: #e0e7ff; color: #4338ca; font-size: 10.5px; padding: 1px 7px; vertical-align: middle; }

/* pending access requests */
.pending-card { border-color: #c7d7fe; }
.req-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f1f5f9; }
.req-row:last-child { border-bottom: 0; }
.req-row .avatar { width: 34px; height: 34px; font-size: 13px; }
.req-row .who { flex: 1; min-width: 0; }
.req-row .who .n { font-weight: 700; }
.req-row .who .r { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.req-actions { display: flex; gap: 6px; flex: none; }
.pill {
  display: inline-block; background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 800; padding: 1px 7px; margin-left: 6px; vertical-align: middle;
}
.nav a.active .pill { background: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
a.list-row { color: inherit; text-decoration: none; }

.share-note { background: var(--accent-soft); border: 1px solid #d6e2ff; border-radius: var(--radius); padding: 14px 16px; font-size: 13.5px; margin-top: 14px; }
.share-note code { background: #fff; border: 1px solid var(--line); padding: 1px 7px; border-radius: 6px; font-size: 12.5px; }

/* ---- program view ---- */
.prog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .prog-grid { grid-template-columns: 1fr; } }
.warn-note {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  border-radius: var(--radius); padding: 11px 15px; font-size: 13.5px; font-weight: 600; margin-bottom: 14px;
}
.mix-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.mix-label { width: 132px; font-size: 12.5px; color: var(--muted); font-weight: 600; flex: none; }
.mix-bar { flex: 1; height: 16px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.mix-bar > div { height: 100%; border-radius: 5px; min-width: 0; }
.mix-n { width: 18px; text-align: right; font-weight: 800; font-size: 12.5px; flex: none; }
.spacing { display: flex; gap: 4px; align-items: flex-end; }
.sp-col { flex: 1; text-align: center; }
.sp-bars { display: flex; flex-direction: column-reverse; gap: 2px; justify-content: flex-start; min-height: 46px; }
.sp-bars span { display: block; height: 13px; background: var(--accent); border-radius: 3px; }
.sp-m { font-size: 10.5px; font-weight: 700; color: var(--muted); margin-top: 5px; }
.sp-m.empty { color: #cbd5e1; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 16px; border-bottom: 1px solid var(--line); font-weight: 700;
}
.tbl td { padding: 9px 16px; border-bottom: 1px solid #f1f5f9; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r, .tbl th.r { text-align: right; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover { background: #f8fafc; }
.tbl td.over { color: var(--danger); font-weight: 700; }
.stars { color: #f59e0b; letter-spacing: 1px; white-space: nowrap; }
.stars .dim { color: #e2e8f0; }

/* ---- directory ---- */
.dir-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.dir-card { display: flex; flex-direction: column; }
.dir-head { display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px 8px; }
.dir-head > div:first-child { flex: 1; min-width: 0; }
.dir-name { font-weight: 800; font-size: 15px; }
.dir-sub { color: var(--muted); font-size: 12.5px; }
.dir-rating { white-space: nowrap; flex: none; }
.dir-rating .star { color: #e2e8f0; cursor: pointer; font-size: 15px; }
.dir-rating .star.on { color: #f59e0b; }
.dir-rating .star:hover { color: #fbbf24; }
.dir-body { padding: 0 16px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.dir-body .k { color: var(--muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; margin-right: 5px; }
.dir-notes { background: #f8fafc; border-radius: 8px; padding: 7px 10px; margin: 3px 0; }
.dir-foot { border-top: 1px solid #f1f5f9; padding: 8px 12px; display: flex; gap: 4px; }
.lnk { border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.lnk:hover { color: var(--accent); background: var(--accent-soft); }
.lnk.danger:hover { color: var(--danger); background: #fef2f2; }

/* ---- rsvp ---- */
.rsvp-summary { display: flex; gap: 6px; flex-wrap: wrap; }
.rs-chip { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.rs-chip.yes { background: #dcfce7; color: #15803d; }
.rs-chip.maybe { background: #fef3c7; color: #b45309; }
.rs-chip.no { background: #fee2e2; color: #b91c1c; }
.rs-chip.none { background: #f1f5f9; color: var(--muted); }
.rs-chip.came { background: #dbeafe; color: #1d4ed8; }
.rsvp-list { margin-top: 10px; max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.rsvp-row { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-bottom: 1px solid #f1f5f9; }
.rsvp-row:last-child { border-bottom: 0; }
.rsvp-name { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rsvp-btns { display: flex; gap: 3px; flex: none; }
.rsvp-b {
  width: 26px; height: 24px; border: 1px solid var(--line); background: #fff;
  border-radius: 6px; font-size: 11px; font-weight: 800; color: var(--muted); padding: 0;
}
.rsvp-b:hover { border-color: #c6d0de; }
.rsvp-b.yes.on { background: #16a34a; border-color: #16a34a; color: #fff; }
.rsvp-b.maybe.on { background: #d97706; border-color: #d97706; color: #fff; }
.rsvp-b.no.on { background: #dc2626; border-color: #dc2626; color: #fff; }
.rsvp-b.attended.on { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }

/* ---- checklist template editor ---- */
.tpl-tbl { width: 100%; border-collapse: collapse; }
.tpl-tbl th { text-align: left; font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 4px 6px; font-weight: 700; }
.tpl-tbl td { padding: 2px 6px 2px 0; }
.tpl-tbl input { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; }
.tpl-tbl input:focus { outline: 2px solid #bfd3ff; border-color: var(--accent); }
.tpl-tbl .del { border: 0; background: none; color: #c3ccd8; padding: 4px 6px; border-radius: 6px; }
.tpl-tbl .del:hover { color: var(--danger); background: #fef2f2; }

/* ---- drawer ---- */
.backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 96vw);
  background: var(--surface); z-index: 61; box-shadow: -8px 0 30px rgba(15, 23, 42, .18);
  display: flex; flex-direction: column;
}
.drawer-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.drawer-head input.title {
  border: 0; font-size: 17px; font-weight: 800; flex: 1; min-width: 0; padding: 2px 4px; border-radius: 6px;
}
.drawer-head input.title:focus { outline: 2px solid #bfd3ff; }
.drawer-head .close { border: 0; background: none; font-size: 20px; color: var(--muted); padding: 2px 8px; border-radius: 6px; }
.drawer-head .close:hover { background: #f1f5f9; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.drawer h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 0 8px; }
.drawer .task-row { padding: 6px 0; }
.inline-add { display: flex; gap: 6px; margin-top: 8px; }
.inline-add input[type="text"] { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
.inline-add input[type="date"], .inline-add select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 6px; }
.comment { display: flex; gap: 10px; margin-bottom: 12px; }
.comment .body { background: #f6f8fb; border-radius: 10px; padding: 8px 12px; flex: 1; font-size: 13.5px; }
.comment .body .who { font-weight: 700; font-size: 12.5px; margin-bottom: 2px; }
.comment .body .when { color: var(--muted); font-weight: 400; font-size: 11.5px; margin-left: 6px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 12px 18px; display: flex; gap: 8px; justify-content: space-between; }

/* ---- modal ---- */
.modal-wrap { position: fixed; inset: 0; z-index: 70; display: flex; align-items: flex-start; justify-content: center; padding: 7vh 16px; background: rgba(15, 23, 42, .35); overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 560px; max-width: 100%; box-shadow: 0 20px 60px rgba(15, 23, 42, .3); }
.modal .modal-head { padding: 16px 20px 0; font-size: 17px; font-weight: 800; }
.modal .modal-body { padding: 14px 20px 4px; }
.modal .modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 400px; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.login-card h1 { margin: 0 0 2px; font-size: 22px; letter-spacing: -.3px; }
.login-card .sub { color: var(--muted); margin-bottom: 20px; font-size: 14px; }
.login-users { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.login-user {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; text-align: left; width: 100%;
}
.login-user:hover { border-color: var(--accent); }
.login-user.sel { border-color: var(--accent); background: var(--accent-soft); }
.login-user .n { font-weight: 700; }
.login-user .r { color: var(--muted); font-size: 12.5px; }

/* ---- toasts ---- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff; border-radius: 10px; padding: 10px 18px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 10px 30px rgba(15, 23, 42, .35);
  animation: toast-in .18s ease-out;
}
.toast.err { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
