/* LPC Accomplishment Reports
   Colours come from the college seal and letterhead: field green, leaf green, seal gold, seal red. */

:root {
  --green-900: #12401b;
  --green-700: #1f6b2a;
  --green-600: #24802f;
  --green-100: #e3f1de;
  --gold: #f2c230;
  --gold-100: #fcefc2;
  --gold-ink: #6b4e00;
  --red: #b3261e;
  --red-100: #fbe3e1;
  --ink: #18231c;
  --muted: #5a675e;
  --line: #d6ded3;
  --bg: #f3f6f1;
  --card: #ffffff;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}
img { max-width: 100%; }
a { color: var(--green-700); text-underline-offset: 2px; }
a:hover { color: var(--green-900); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.65rem; font-weight: 750; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
code { font-size: .9em; background: #eef2ec; padding: 1px 5px; border-radius: 4px; }
pre.code { background: #eef2ec; padding: 12px; border-radius: var(--radius); overflow-x: auto; font-size: 13px; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.text-alert { color: var(--red); }
.text-ok { color: var(--green-700); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 50; background: #fff; padding: 8px 12px; }
.skip:focus { left: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--green-900);
  color: #fff;
  border-bottom: 4px solid var(--gold);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand:hover { color: #fff; }
.brand img { width: 40px; height: 40px; border-radius: 50%; background: #fff; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 1rem; }
.brand-app { font-size: .82rem; color: #cfe3c9; }

.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav a {
  color: #e9f1e6; text-decoration: none; padding: 8px 10px; border-radius: 6px;
  border-bottom: 3px solid transparent;
}
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a[aria-current="page"] { color: #fff; border-bottom-color: var(--gold); border-radius: 6px 6px 0 0; }
.nav-spacer { flex: 1; }
.nav-user { display: flex; flex-direction: column; line-height: 1.15; text-align: right; }
.nav-user small { color: #b9d3b2; font-size: .75rem; }
.nav-logout button {
  font: inherit; font-size: .9rem; color: #fff; cursor: pointer;
  background: transparent; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 6px 10px;
}
.nav-logout button:hover { background: rgba(255,255,255,.1); }
.menu-toggle { display: none; }

@media (max-width: 820px) {
  .js .menu-toggle {
    display: inline-block; margin-left: auto;
    font: inherit; font-weight: 600; color: var(--green-900); background: var(--gold);
    border: 0; border-radius: 6px; padding: 7px 14px; cursor: pointer;
  }
  .nav { flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 2px; padding-top: 6px; }
  .js .nav:not(.is-open) { display: none; }
  .nav a { padding: 10px; }
  .nav a[aria-current="page"] { border-bottom: 0; border-left: 4px solid var(--gold); border-radius: 0 6px 6px 0; }
  .nav-spacer { display: none; }
  .nav-user { text-align: left; border-top: 1px solid rgba(255,255,255,.15); margin-top: 6px; padding-top: 12px !important; }
  .nav-logout { padding: 4px 10px 8px; }
}

/* ---------- Page ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px; }
.sitefoot { padding-top: 0; color: var(--muted); font-size: .8rem; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
  margin-bottom: 20px;
}
.page-head > div:first-child { min-width: 0; max-width: 760px; }
.page-head p { margin: 0; }
.crumbs { font-size: .875rem; color: var(--muted); margin-bottom: 4px !important; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.panel.narrow { max-width: 560px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.layout-2 > .panel { margin-bottom: 0; }
.layout-2 + .layout-2, .layout-2 + .panel, .panel + .layout-2 { margin-top: 16px; }
.layout-2 > div > .panel:last-child { margin-bottom: 0; }
@media (max-width: 860px) { .layout-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
  padding: 10px 16px; min-height: 42px;
  color: var(--green-900); background: #fff;
  border: 1px solid #b9c6b5; border-radius: 6px;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: #f1f6ef; color: var(--green-900); }
.btn-primary { background: var(--green-700); border-color: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-900); border-color: var(--green-900); color: #fff; }
.btn-alert { color: var(--red); border-color: #e2b4b0; }
.btn-alert:hover { background: var(--red-100); color: var(--red); }
.btn-small { padding: 6px 12px; min-height: 34px; font-size: .875rem; }
.btn-block { width: 100%; }
.link-btn {
  font: inherit; font-size: .875rem; background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--green-700); text-decoration: underline; text-underline-offset: 2px;
}
.link-btn.text-alert { color: var(--red); }

/* ---------- Forms ---------- */
.form fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.form legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
.field small { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.field .static { margin: 0; padding: 9px 0; }
input[type=text], input:not([type]), input[type=email], input[type=password], input[type=number],
input[type=date], input[type=month], select, textarea {
  width: 100%;
  font: inherit; color: var(--ink);
  background: #fff;
  border: 1px solid #b9c6b5; border-radius: 6px;
  padding: 9px 10px; min-height: 42px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--gold); outline-offset: 0; border-color: var(--green-700); }
input[type=file] { font: inherit; font-size: .9rem; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; font-size: .95rem; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--green-700); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.span-2 { grid-column: 1 / -1; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 600px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.form .check input[type=radio] { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--green-700); }
.auth-card ol { padding-left: 20px; }
.auth-card ol li { margin-bottom: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.inline { display: inline; }
.inline select { min-height: 34px; padding: 4px 8px; width: auto; }

.period-picker { display: flex; align-items: center; gap: 8px; }
.period-picker label { font-size: .875rem; color: var(--muted); font-weight: 600; }
.period-picker input { width: auto; min-height: 42px; }

/* ---------- Messages ---------- */
.flash { padding: 12px 14px; border-radius: 6px; margin-bottom: 12px; border-left: 4px solid; background: #fff; }
.flash-success { border-color: var(--green-700); background: var(--green-100); }
.flash-info { border-color: var(--gold); background: var(--gold-100); }
.flash-error { border-color: var(--red); background: var(--red-100); }
.callout { padding: 14px 16px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout ul { margin: 8px 0 0; padding-left: 20px; }
.callout-alert { background: var(--red-100); border-color: #efc2be; }
.callout-alert strong { color: #7d1a15; }
.empty { text-align: center; padding: 48px 16px; max-width: 520px; margin: 0 auto; }
.empty h1, .empty h2 { margin-bottom: 8px; }

/* ---------- Status badges ---------- */
.badge {
  display: inline-block; white-space: nowrap;
  font-size: .78rem; font-weight: 650; line-height: 1;
  padding: 5px 9px; border-radius: 999px;
  background: #eceeea; color: #3e4741;
}
.badge-submitted { background: var(--gold-100); color: var(--gold-ink); }
.badge-returned { background: var(--red-100); color: #8e1c16; }
.badge-received_head { background: var(--green-100); color: var(--green-700); }
.badge-received_president { background: var(--green-700); color: #fff; }

/* ---------- Lists of reports ---------- */
.month-group { margin-bottom: 28px; }
.month-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; border-bottom: 2px solid var(--green-700); padding-bottom: 6px; margin-bottom: 4px; }
.month-head h2 { margin: 0; font-size: 1.2rem; }
.month-print { margin-left: auto; }
.report-list { list-style: none; margin: 0; padding: 0; }
.report-list li {
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line);
}
.report-list li:last-child { border-bottom: 0; }
.report-link { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 12px 0; text-decoration: none; color: var(--ink); }
.report-link:hover .report-subject { text-decoration: underline; }
.report-subject { font-weight: 650; color: var(--green-900); }
.go { font-size: .875rem; font-weight: 600; color: var(--green-700); }
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mini-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }

/* ---------- Tally strip ---------- */
.tally {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.tally > div { padding: 14px 18px; border-left: 1px solid var(--line); }
.tally > div:first-child { border-left: 0; }
.tally dt { font-size: .85rem; color: var(--muted); font-weight: 600; }
.tally dd { margin: 2px 0 0; font-size: 2rem; font-weight: 750; line-height: 1.1; color: var(--green-900); }
.tally dd small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.tally dd.is-hot { color: var(--gold-ink); box-shadow: inset 0 -4px 0 var(--gold); display: inline-block; }
.tally dd.is-alert { color: var(--red); }
@media (max-width: 760px) {
  .tally { grid-template-columns: 1fr 1fr; }
  .tally > div:nth-child(3) { border-left: 0; }
  .tally > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { font-size: .8rem; color: var(--muted); font-weight: 650; border-bottom: 2px solid var(--line); vertical-align: bottom; }
.table .num, .num { text-align: right; }
.table tr.is-inactive td { opacity: .6; }
.row-actions { white-space: nowrap; display: flex; gap: 14px; align-items: center; }

.watch .bar-col { width: 34%; min-width: 150px; }
.bar {
  position: relative; display: inline-block; vertical-align: middle;
  width: calc(100% - 3.2em); height: 10px; border-radius: 5px; background: #e9ede7;
}
.bar > span { position: absolute; inset: 0 auto 0 0; width: var(--v); border-radius: 5px; background: var(--red); }
.bar::after { content: ""; position: absolute; top: -3px; bottom: -3px; left: var(--t); width: 2px; background: var(--ink); opacity: .45; }
.bar-num { display: inline-block; width: 3em; text-align: right; font-weight: 650; }

/* On-screen tracking matrix */
.matrix { border-collapse: collapse; width: 100%; font-size: .9rem; }
.matrix th, .matrix td { border: 1px solid var(--line); padding: 7px 8px; }
.matrix thead th { background: #f1f5ef; font-size: .78rem; font-weight: 700; text-align: center; vertical-align: bottom; }
.matrix thead th.wk span { display: block; font-weight: 500; color: var(--muted); }
.matrix thead th:nth-child(-n+4) { text-align: left; }
.matrix tbody th { text-align: left; white-space: nowrap; }
.matrix td small { display: block; font-size: .72rem; color: var(--muted); }
.matrix td.is-low { background: var(--red-100); }
.matrix td.is-low small { color: var(--red); font-weight: 650; }
.matrix td.off { text-align: center; color: var(--muted); font-size: .78rem; font-weight: 650; background: #f7f8f6; }
.matrix .blank { color: var(--red); font-weight: 700; }

/* ---------- Routing slip (stamps) ---------- */
.slip {
  list-style: none; margin: 0 0 18px; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.stamp {
  position: relative;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 14px;
  border: 2px dashed #bfc9bc; border-radius: 6px;
  color: var(--muted); background: rgba(255,255,255,.6);
}
.stamp-role { font-size: .78rem; font-weight: 650; }
.stamp-name { font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.stamp-verb { font-size: .85rem; }
.stamp-done {
  border: 3px double var(--green-700); color: var(--green-700); background: #fff;
  transform: rotate(-0.8deg);
}
.stamp-done:nth-child(2) { transform: rotate(0.6deg); }
.stamp-done:nth-child(3) { transform: rotate(-0.4deg); }
.stamp-done .stamp-verb { font-weight: 750; letter-spacing: .02em; }
.stamp-alert { border: 3px double var(--red); color: var(--red); background: #fff; transform: rotate(-0.8deg); }
.stamp-alert .stamp-verb { font-weight: 750; }
@media (max-width: 640px) { .slip { grid-template-columns: 1fr; } .stamp, .stamp-done, .stamp-alert { transform: none !important; } }
@media (prefers-reduced-motion: reduce) { .stamp { transform: none !important; } }

/* ---------- Report view ---------- */
.prose p { overflow-wrap: anywhere; }
.prose h3 { margin-top: 14px; }
.prose h3:first-of-type { margin-top: 0; }
.review-panel { border: 2px solid var(--gold); }
.inline-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 16px; }
.files { list-style: none; padding: 0; margin: 0 0 12px; }
.files li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; display: flex; flex-direction: column; }
.timeline li::before { content: ""; position: absolute; left: -26px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid #9fb09a; }
.timeline li.tl-received_head::before, .timeline li.tl-received_president::before { background: var(--green-700); border-color: var(--green-700); }
.timeline li.tl-returned::before { background: var(--red); border-color: var(--red); }
.timeline li.tl-submitted::before, .timeline li.tl-resubmitted::before { background: var(--gold); border-color: var(--gold-ink); }
.tl-what { font-weight: 650; }
.timeline blockquote { margin: 6px 0 0; padding: 8px 10px; background: #f4f6f2; border-radius: 6px; font-size: .9rem; }

/* ---------- Report form ---------- */
.week { border-top: 1px solid var(--line) !important; padding-top: 14px !important; }
.week:first-of-type { border-top: 0 !important; padding-top: 0 !important; }
.week legend { float: left; width: 100%; margin-bottom: 6px; color: var(--green-900); }
.week-dates { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 12px; clear: both; }
.week-dates .field { width: 170px; }
.week-dates .link-btn { margin: 0 0 22px auto; }

.class-card {
  border: 1px solid var(--line) !important; border-radius: var(--radius);
  padding: 14px !important; margin-bottom: 14px !important; background: #fbfcfa;
}
.class-card legend { padding: 0 6px !important; color: var(--green-900); font-size: 1.05rem; }
.class-fields { display: grid; grid-template-columns: 1.1fr .8fr 1fr 1.3fr; gap: 0 12px; }
@media (max-width: 700px) { .class-fields { grid-template-columns: 1fr 1fr; } }
.week-grid { border-collapse: collapse; width: 100%; margin-bottom: 6px; font-size: .92rem; }
.lbl-short { display: none; }
.week-grid th, .week-grid td { padding: 6px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.week-grid thead th { font-size: .78rem; color: var(--muted); font-weight: 650; }
.week-grid tbody th { font-weight: 650; white-space: nowrap; }
.week-grid tbody th span { display: block; font-weight: 400; font-size: .78rem; }
.week-grid td.num, .week-grid th.num { text-align: right; }
.week-grid input[type=number] { width: 6em; text-align: right; }
.week-grid select { min-width: 9.5em; }
.week-grid tr.is-off input { background: #f1f3ef; }
.week-grid input.is-over { border-color: var(--red); background: var(--red-100); }
.rate { display: inline-block; min-width: 3em; font-weight: 650; color: var(--muted); font-size: .85rem; }
.rate.is-low { color: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  font: inherit; font-size: .82rem; text-align: left; cursor: pointer;
  background: var(--green-100); color: var(--green-900);
  border: 1px solid #c4dcbc; border-radius: 999px; padding: 6px 12px;
}
.chip:hover { background: #d4e9cc; }
.chip.is-used { background: #fff; color: var(--muted); border-style: dashed; }

.implicit-submit { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.action-bar {
  position: sticky; bottom: 0; z-index: 4;
  margin: 0 -16px; padding: 10px 16px;
  background: rgba(243, 246, 241, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(4px);
}
.action-bar-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.action-bar-inner [data-save-state] { margin-right: auto; }
.action-bar-inner [data-save-state].is-dirty { color: var(--gold-ink); font-weight: 600; }
@media (max-width: 520px) {
  .action-bar-inner [data-save-state] { flex-basis: 100%; }
  .action-bar-inner .btn { flex: 1; }
}
.danger-zone { margin-top: 18px; text-align: right; }

@media (max-width: 600px) {
  .wrap { padding: 18px 12px; }
  .panel { padding: 14px; }
  .class-card { padding: 10px !important; }
  .week-grid { font-size: .85rem; }
  .week-grid th, .week-grid td { padding: 5px 3px; }
  .week-grid thead th { font-size: .72rem; }
  .week-grid select { min-width: 0; width: 100%; padding: 6px 2px; font-size: .85rem; }
  .week-grid input[type=number] { width: 3.4em; padding: 6px 4px; }
  .rate { min-width: 0; font-size: .75rem; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }
  .action-bar { margin: 0 -12px; padding: 8px 12px; }

  /* low-attendance list becomes stacked rows */
  .watch thead { display: none; }
  .watch, .watch tbody { display: block; }
  .watch tr {
    display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
    grid-template-areas: "cls wk" "subj subj" "bar num";
    padding: 12px 0; border-bottom: 1px solid var(--line);
  }
  .watch td { display: block; border: 0; padding: 0; text-align: left; }
  .watch td:nth-child(1) { grid-area: cls; }
  .watch td:nth-child(2) { grid-area: subj; }
  .watch td:nth-child(3) { grid-area: wk; }
  .watch td:nth-child(4) { grid-area: num; align-self: center; }
  .watch td:nth-child(5) { grid-area: bar; width: auto; min-width: 0; align-self: center; }
}

/* ---------- Sign in and installer ---------- */
.page-auth { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; background: var(--green-900); }
.auth-card {
  width: 100%; max-width: 440px; background: #fff; border-radius: 10px; padding: 26px 26px 20px;
  border-top: 6px solid var(--gold);
}
.auth-wide { max-width: 680px; }
.auth-letterhead { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 0 20px; }
.auth-card h1 { font-size: 1.45rem; }
.auth-card fieldset { border-top: 1px solid var(--line); padding-top: 12px; }
