:root {
  --forest: #17291F; --cream: #FAF6F0; --ink: #1E1812;
  --teal: #2F7F7E; --plum: #6D58A8; --rose: #A84A6A; --amber: #9A5E22;
  --line: #E4DCCF; --muted: #6B6259; --card: #FFFFFF;
  --ok-bg: #E3F1EC; --ok: #1F5F55; --wait-bg: #F7EBD9; --wait: #7A4A16; --err: #A13A3A;
  --sub-bg: #F7F5FB;
  /* Theme colors (light). Dark versions are below; see "Dark mode". */
  --primary: #17291F; --on-primary: #FAF6F0; --primary-hover: #24402F;
  --field: #FFFFFF; --hover: #F1ECE3; --row-line: #F0EAE0; --inactive-bg: #EEECE8;
  --wait-line: #E8D3B3; --crisis-bg: #FBECEC; --crisis-line: #E9C4C4;
  --overlay: rgba(23, 41, 31, .55); --shadow: rgba(23, 41, 31, .12); --paper-bg: #E9E5DE;
  --rule: linear-gradient(90deg, #9A5E22, #A84A6A, #6D58A8, #2F7F7E, #9A5E22);
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: 'Outfit', system-ui, sans-serif; color: var(--ink); background: var(--cream); font-size: 15px; line-height: 1.5; }
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; }
header { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.who { display: flex; align-items: center; justify-content: flex-end; gap: 4px; flex-wrap: wrap; }
.today { flex-basis: 100%; text-align: right; font-size: 15px; font-weight: 500; color: var(--ink); margin-bottom: 2px; }
@media (max-width: 600px) { .who { justify-content: flex-start; } .today { text-align: left; } }
h1 { font-size: 22px; font-weight: 500; margin: 0; }
.logo { display: block; height: 44px; width: auto; max-width: 100%; margin: 0 0 14px; }
@media (max-width: 420px) { .logo { height: auto; width: 100%; } }
h2 { font-size: 17px; font-weight: 500; margin: 0 0 12px; }
.rule { height: 3px; border-radius: 2px; margin: 10px 0 18px; background: var(--rule); }
.sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.hours { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px; align-items: end; }
label { display: block; font-size: 13px; color: var(--muted); }
label .hint { display: block; }
label .code { font-weight: 500; color: var(--ink); }
label.sub-cat .code { color: var(--plum); }
input, select { width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 8px; }
label.sub-cat input { background: var(--sub-bg); }
input.fixed { background: var(--cream); color: var(--muted); }
input:focus, select:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--teal); }
button { font: inherit; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--teal); }
button.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
button.primary:hover { background: var(--primary-hover); }
.link, button.link { border: none; background: none; padding: 2px 6px; color: var(--teal); font-size: 13px; text-decoration: none; cursor: pointer; }
button.link.danger { color: var(--err); }
button:disabled { opacity: .6; cursor: wait; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 4px; }
.seg button { border: none; border-radius: 0; padding: 8px 14px; }
.seg button.on { background: var(--primary); color: var(--on-primary); }
.seg button:disabled { cursor: not-allowed; opacity: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.total { font-size: 14px; }
.total b { font-weight: 500; font-size: 18px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.msg { font-size: 13px; margin-top: 10px; min-height: 18px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.summary div { background: var(--cream); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.summary span { display: block; color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; font-weight: 500; font-size: 12px; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); vertical-align: bottom; }
th span { font-weight: 400; }
th.l, td.l { text-align: left; }
th.sub-cat { color: var(--plum); }
td { text-align: right; padding: 8px; border-bottom: 1px solid var(--row-line); white-space: nowrap; }
td.sub-cat { color: var(--plum); background: var(--sub-bg); }
td b { font-weight: 500; }
tr.tot td { font-weight: 500; border-top: 2px solid var(--ink); border-bottom: none; }
.pill { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 99px; }
.pill.Signed { background: var(--ok-bg); color: var(--ok); }
.pill.Pending { background: var(--wait-bg); color: var(--wait); }
.empty { color: var(--muted); padding: 18px 0 6px; }
.note { font-size: 12px; color: var(--muted); margin-top: 12px; }
.hidden { display: none !important; }
#loading { padding: 60px 0; text-align: center; color: var(--muted); }


/* ---------- Supervisor view ---------- */
.sig-row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-top: 12px; }
/* Stays white in dark mode: signatures are dark ink on a transparent background. */
.sig-box { width: 260px; height: 110px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; background: #fff; }
.sig-box img { max-width: 240px; max-height: 96px; }
.sig-form { flex: 1; min-width: 240px; display: grid; gap: 10px; }
.assoc { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.assoc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.assoc-head .name { font-weight: 500; }
.assoc table { margin-top: 8px; }
button.approve { background: var(--primary); color: var(--on-primary); border-color: var(--primary); padding: 4px 12px; font-size: 13px; }
button.approve:hover { background: var(--primary-hover); }
.signed-on { display: block; font-size: 11px; color: var(--muted); }

/* Harry's supervisors and practice settings */
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; align-items: end; margin-top: 12px; }
.inline-form > button { justify-self: start; }
#addressForm { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 520px) { #addressForm { grid-template-columns: minmax(0, 1fr); } }
#teamTable { margin-top: 6px; }
.sign-as { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.sign-as b { font-weight: 500; color: var(--ink); }

/* Harry's associates list */
#assocTable { margin-top: 10px; }
#assocTable tr.inactive td { color: var(--muted); }
.sub-form { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 12px; }
.sub-form h3 { font-size: 15px; font-weight: 500; margin: 0 0 10px; }
.pill.Inactive { background: var(--inactive-bg); color: var(--muted); }
.pill.Invited { background: var(--wait-bg); color: var(--wait); }
.pill.Active { background: var(--ok-bg); color: var(--ok); }

/* Progress toward licensure */
.progress { display: grid; gap: 12px; margin-top: 12px; }
.prog-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.prog-head b { font-weight: 500; }
.prog-head span:last-child { white-space: nowrap; }
.prog-bar { height: 8px; background: var(--cream); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.prog-bar span { display: block; height: 100%; background: var(--teal); border-radius: 4px; }
.prog-bar.max span { background: var(--plum); }
.prog-bar.over span { background: var(--err); }
.prog-row.met .prog-head b::after { content: ' ✓'; color: var(--ok); }
.prog-sup { font-size: 13px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.prog-sup b { font-weight: 500; color: var(--ink); }
.assoc details { margin-top: 8px; }
.assoc summary { cursor: pointer; font-size: 13px; color: var(--teal); }

/* BBS form preview */
.modal { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal-box { background: var(--card); border-radius: 12px; width: min(960px, 100%); height: min(92vh, 1100px); display: flex; flex-direction: column; padding: 14px 16px; }
.modal-head { margin-bottom: 10px; }
.preview-pages { flex: 1; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-bg); padding: 8px; }
/* BBS form pages stay white (paper) in both themes. */
.preview-pages canvas { display: block; margin: 0 auto 10px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); max-width: 100%; height: auto; }
.preview-pages .hint { text-align: center; padding: 24px 8px; }
.modal.hidden { display: none; }
.modal-head a { white-space: nowrap; }
@media (max-width: 520px) {
  .modal { padding: 8px; }
  .modal-box { height: 96vh; padding: 10px; }
  .modal-head h2 { font-size: 15px; width: 100%; }
  #previewOpen { display: none; }
}

/* Supervisor working in an associate's log */
.viewing { position: sticky; top: 8px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--wait-bg); color: var(--wait); border: 1px solid var(--wait-line); border-radius: 10px; padding: 8px 8px 8px 14px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.4; box-shadow: 0 4px 14px var(--shadow); }
.viewing b { font-weight: 500; }
.viewing button { flex-shrink: 0; padding: 6px 12px; font-size: 13px; white-space: nowrap; }
@media (max-width: 600px) { .viewing #viewingText span { display: none; } }
.assoc-head button.primary { white-space: nowrap; }

/* Week form: line up every hours box, whatever the label length or note below it.
   Each field spans three shared rows (label, box, note) via subgrid; the label text sits at the bottom of its row. */
.hours { align-items: start; grid-auto-rows: auto; row-gap: 0; column-gap: 12px; }
.hours > label { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 4px; margin-bottom: 12px; }
.hours .lbl { display: flex; align-items: flex-end; line-height: 1.35; }
.hours > label input { margin-top: 0; }
.hours > label .hint { margin: 0; min-height: 0; line-height: 1.35; }
@supports not (grid-template-rows: subgrid) {
  .hours .lbl { min-height: 2.7em; }
}

/* ---------- Dark mode ----------
   Follows the device setting unless someone picks a theme with the header button (stored as
   <html data-theme="dark|light"> by /hub/theme.js). The same values appear twice: once for the
   device setting and once for the button. Dark rule colors come from public/brand/README.md. */
.only-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream: #111A15; --card: #19241E; --ink: #EFE9E0; --muted: #A9A196; --line: #33413A;
    --teal: #8ED3D2; --plum: #BFA9EC; --rose: #EBA6B8; --amber: #E8BE7E;
    --ok-bg: #173A31; --ok: #93D8C2; --wait-bg: #3B2D1A; --wait: #F0C88E; --err: #F09B9B;
    --sub-bg: #222235;
    --primary: #8ED3D2; --on-primary: #10201B; --primary-hover: #A8E0DF;
    --field: #141E19; --hover: #24322B; --row-line: #26332C; --inactive-bg: #2A332E;
    --wait-line: #5A4526; --crisis-bg: #3A1F1F; --crisis-line: #6B3434;
    --overlay: rgba(0, 0, 0, .65); --shadow: rgba(0, 0, 0, .45); --paper-bg: #0E1512;
    --rule: linear-gradient(90deg, #E8BE7E, #EBA6B8, #BFA9EC, #8ED3D2, #E8C98C);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .only-light { display: none; }
  :root:not([data-theme="light"]) .only-dark { display: block; }
}
:root[data-theme="dark"] {
  --cream: #111A15; --card: #19241E; --ink: #EFE9E0; --muted: #A9A196; --line: #33413A;
  --teal: #8ED3D2; --plum: #BFA9EC; --rose: #EBA6B8; --amber: #E8BE7E;
  --ok-bg: #173A31; --ok: #93D8C2; --wait-bg: #3B2D1A; --wait: #F0C88E; --err: #F09B9B;
  --sub-bg: #222235;
  --primary: #8ED3D2; --on-primary: #10201B; --primary-hover: #A8E0DF;
  --field: #141E19; --hover: #24322B; --row-line: #26332C; --inactive-bg: #2A332E;
  --wait-line: #5A4526; --crisis-bg: #3A1F1F; --crisis-line: #6B3434;
  --overlay: rgba(0, 0, 0, .65); --shadow: rgba(0, 0, 0, .45); --paper-bg: #0E1512;
  --rule: linear-gradient(90deg, #E8BE7E, #EBA6B8, #BFA9EC, #8ED3D2, #E8C98C);
  color-scheme: dark;
}
:root[data-theme="dark"] .only-light { display: none; }
:root[data-theme="dark"] .only-dark { display: block; }
.theme-btn { white-space: nowrap; }
