/* Client portal — deliberately plain and legible. The people reading this are
   centre managers on a laptop between meetings, not engineers. */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e2e5ea;
  --text: #1a1d23;
  --muted: #6b7280;
  --accent: #1e5aa8;
  --red: #b42318;
  --orange: #b54708;
  --green: #027a48;
  --amber-bg: #fef6e7;
  --red-bg: #fef3f2;
  --green-bg: #ecfdf3;
  --blue-bg: #eff6ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --panel: #1c2027; --line: #2b313a; --text: #e8eaed; --muted: #98a2b3;
    --accent: #6ba4e8; --red: #f97066; --orange: #fdb022; --green: #47cd89;
    --amber-bg: #2e2410; --red-bg: #2e1614; --green-bg: #10261c; --blue-bg: #16232e;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
.boot { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 32px; width: 100%; max-width: 420px;
}
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

input[type=email], input[type=search], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font-size: 15px;
}
button {
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); font-weight: 500; }
button.tab { background: transparent; color: var(--muted); border-color: transparent; }
button.tab.on { background: var(--panel); color: var(--text); border-color: var(--line); }
button:disabled { opacity: .55; cursor: default; }

/* ---------- shell ---------- */
header {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 14px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
header .brand { font-weight: 700; font-size: 17px; margin-right: auto; }
header .who { color: var(--muted); font-size: 13px; }
main { max-width: 1180px; margin: 0 auto; padding: 24px; }
h2 { font-size: 19px; margin: 0 0 4px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.card .n { font-size: 27px; font-weight: 700; line-height: 1.1; }
.card .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar select, .toolbar input { width: auto; min-width: 180px; }

/* Wide tables scroll inside their panel rather than the page. */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.small { font-size: 12.5px; color: var(--muted); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--orange); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.blue { background: var(--blue-bg); color: var(--accent); }
.pill.grey { background: var(--bg); color: var(--muted); }

.defect { border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 12px; background: var(--panel); }
.defect h3 { margin: 0 0 8px; font-size: 15.5px; }
.defect .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.defect dl { margin: 0; display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; font-size: 14px; }
.defect dt { color: var(--muted); font-size: 13px; }
.defect dd { margin: 0; }
.quote-line {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; font-size: 14px;
}
.quote-line b { font-size: 16px; }

.empty { padding: 34px; text-align: center; color: var(--muted); }
#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .18s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- tabs ----------
   A row of its own under the header rather than tucked into a toolbar: on a portal
   that is read once every few months, the way around has to be the most obvious
   thing on the page after the verdict. */
.tabs {
  display: flex; gap: 4px; padding: 0 24px; background: var(--panel);
  border-bottom: 1px solid var(--line); overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.tabs .tab {
  border-radius: 0; border: 0; border-bottom: 2px solid transparent;
  padding: 12px 14px; white-space: nowrap; font-weight: 600;
}
.tabs .tab.on { background: transparent; color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- the verdict ----------
   The first thing read and often the only thing read. Colour carries the answer;
   the words carry the evidence. */
.verdict {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--muted);
  border-radius: 10px; padding: 20px 22px; margin-bottom: 20px;
}
.verdict.green { border-left-color: var(--green); background: var(--green-bg); }
.verdict.amber { border-left-color: var(--orange); background: var(--amber-bg); }
.verdict.red { border-left-color: var(--red); background: var(--red-bg); }
.verdict h2 { margin: 0 0 6px; }
.verdict-h { font-size: 21px; font-weight: 700; line-height: 1.25; }
.verdict.green .verdict-h { color: var(--green); }
.verdict.amber .verdict-h { color: var(--orange); }
.verdict.red .verdict-h { color: var(--red); }
.verdict-l { color: var(--muted); font-size: 14px; margin-top: 6px; }

/* ---------- the empty state ----------
   Load-bearing on a new portal, where most sections have nothing in them yet. It is
   a promise about what will be here, never a count of zero — see the note at the top
   of app.js. Styled to look deliberate rather than like a failed query. */
.promise { text-align: center; padding: 32px 24px; }
.promise-h { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.promise-l { color: var(--muted); font-size: 14px; max-width: 52ch; margin: 0 auto; }

/* ---------- change password ----------
   A signed-in person changes their own password with their own token — no email, which
   is the whole reason a handed-over password is an acceptable way in. */
.pw-nudge {
  background: var(--blue-bg); border-bottom: 1px solid var(--line);
  padding: 10px 24px; font-size: 13.5px;
}
.pw-nudge a { margin-left: 6px; }
.pw-nudge .pw-dismiss { color: var(--muted); }
.modal-wrap {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 200;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  overflow-y: auto;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; width: 100%; max-width: 420px;
}
.modal-box h2 { margin: 0 0 4px; }
.modal-box label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.pw-msg { color: var(--red); font-size: 13.5px; margin-top: 10px; min-height: 1em; }

h3.sec { font-size: 15px; margin: 0 0 12px; }
.panel h3.sec { margin-bottom: 10px; }
.next-row {
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.next-row:last-child { border-bottom: 0; padding-bottom: 0; }

tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--bg); }
.back { display: inline-block; margin-bottom: 12px; font-size: 14px; }
dl.facts { margin: 14px 0 0; display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; font-size: 14px; }
dl.facts dt { color: var(--muted); font-size: 13px; }
dl.facts dd { margin: 0; }

.foot {
  max-width: 1180px; margin: 0 auto; padding: 22px 24px 40px;
  color: var(--muted); font-size: 13px; line-height: 1.6;
}

@media (max-width: 640px) {
  main { padding: 16px; }
  header { padding: 12px 16px; }
  .pw-nudge { padding: 10px 16px; }
  .modal-wrap { padding: 0; align-items: stretch; }
  .modal-box { max-width: none; border-radius: 0; min-height: 100dvh; }
  .tabs { padding: 0 8px; }
  .tabs .tab { padding: 12px 11px; font-size: 14px; }
  .defect dl { grid-template-columns: 1fr; gap: 2px; }
  .defect dt { margin-top: 8px; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dt { margin-top: 8px; }
  .verdict { padding: 16px; }
  .verdict-h { font-size: 18px; }
  .foot { padding: 20px 16px 36px; }
}
