/* The hub's look: quiet, precise, one accent (NFR-12, NFR-13).
   Prussian blue, first made in Berlin, marks what can be clicked; muted oxblood, ochre and
   pine mark state. Everything else is ink on white with hairline rules. */

/* Source Sans 3 (Adobe, SIL Open Font License; licence in fonts/), served by the hub itself
   rather than a font service, so no visitor's address goes to a third party. */
@font-face { font-family: "Source Sans 3"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/SourceSans3-Regular.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/SourceSans3-Medium.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/SourceSans3-Semibold.woff2") format("woff2"); }
@font-face { font-family: "Source Sans 3"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/SourceSans3-Bold.woff2") format("woff2"); }

:root {
  --ink: #15191e;
  --slate: #5b6470;
  --rule: #e4e7eb;
  --rule-strong: #d6dbe1;
  --wash: #f6f7f8;
  --paper: #ffffff;
  --blue: #1b4a72;
  --blue-deep: #11324f;
  --blue-wash: #e8eef5;
  --control: #c9d3de;
  --late: #8f2d2d;
  --late-wash: #f7eaea;
  --due: #8a6200;
  --due-wash: #f7f0dc;
  --ok: #2e6a4f;
  --ok-wash: #e7f0eb;
  --radius: 6px;
  --font: "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-deep); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1 { margin: 0; font-size: 2rem; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
h2 { margin: 0 0 14px; font-size: 1.125rem; font-weight: 600; }
h3 { margin: 18px 0 8px; font-size: 1rem; font-weight: 600; }
p { margin: 0 0 12px; }
.quiet { color: var(--slate); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Header and menus */
.top { border-bottom: 1px solid var(--rule); background: var(--paper); }
.bar { max-width: 1200px; margin: 0 auto; padding: 0 32px; min-height: 60px; display: flex; align-items: center; gap: 40px; }
.brand { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; }
.brand:hover { color: var(--ink); text-decoration: none; }
.nav { display: flex; align-items: stretch; gap: 28px; flex: 1; align-self: stretch; }
.nav-link {
  display: flex; align-items: center; gap: 5px; height: 100%; min-height: 60px;
  color: var(--slate); font-weight: 500; font-size: 15px; cursor: pointer;
  border-bottom: 2px solid transparent; list-style: none; white-space: nowrap;
}
.nav-link::-webkit-details-marker { display: none; }
.nav-link:hover { color: var(--ink); text-decoration: none; }
.nav-link.on { color: var(--ink); border-bottom-color: var(--blue); }
.menu { position: relative; }
.menu[open] > .nav-link { color: var(--ink); }
.menu-panel {
  position: absolute; top: calc(100% + 6px); left: -12px; z-index: 20; min-width: 200px;
  padding: 6px; background: var(--paper); border: 1px solid var(--rule-strong);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(21, 25, 30, 0.12);
}
.menu-panel a { display: block; padding: 8px 12px; border-radius: 4px; color: var(--ink); font-size: 15px; }
.menu-panel a:hover { background: var(--wash); text-decoration: none; }
.menu-panel a.on { color: var(--blue); font-weight: 600; }
.who { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--slate); }
.who form { display: flex; }
.menu-toggle { display: none; }

/* Page */
main { max-width: 1200px; margin: 0 auto; padding: 40px 32px 72px; }
main.wide { max-width: 1440px; }
body:has(main.wide) .bar { max-width: 1440px; }
.heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 20px; margin-bottom: 24px; }
.crumb { margin: 0 0 16px; font-size: 15px; }
main > h1 { margin-bottom: 24px; }
main > h1 + p { margin-top: -12px; }
section { margin-top: 40px; }
.banner { padding: 12px 16px; border-radius: var(--radius); background: var(--due-wash); color: #5c4200; margin-bottom: 20px; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 24px; }
.messages li { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px; background: var(--wash); }
.messages .success { background: var(--ok-wash); color: #1f4a37; }
.messages .error { background: var(--late-wash); color: var(--late); }
.messages .info, .messages .warning { background: var(--due-wash); color: #5c4200; }
.errorlist { list-style: none; margin: 4px 0; padding: 0; color: var(--late); font-size: 15px; }
.errorlist.nonfield { padding: 10px 14px; border-radius: var(--radius); background: var(--late-wash); margin-bottom: 16px; }

/* Controls */
input, select, textarea, button { font: inherit; }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select, textarea {
  min-height: 40px; padding: 6px 10px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--control); border-radius: var(--radius); max-width: 100%;
}
textarea { width: 100%; max-width: 640px; min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-wash); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--blue); vertical-align: middle; }
button, .button, .heading > a {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius); cursor: pointer;
  font-size: 15px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  color: var(--blue); background: var(--paper); border: 1px solid var(--control);
}
button:hover, .button:hover, .heading > a:hover { background: #f3f6f9; border-color: var(--blue); text-decoration: none; color: var(--blue); }
.primary,
main form:not(.inline):not(.row):not(.filters) > button[type="submit"],
main form:not(.inline):not(.row):not(.filters) > p > button[type="submit"] {
  color: #ffffff; background: var(--blue); border-color: var(--blue);
}
.primary:hover,
main form:not(.inline):not(.row):not(.filters) > button[type="submit"]:hover,
main form:not(.inline):not(.row):not(.filters) > p > button[type="submit"]:hover {
  color: #ffffff; background: #163d5e; border-color: #163d5e;
}
.ghost, .who button { color: var(--slate); background: transparent; border-color: transparent; font-weight: 500; }
.ghost:hover, .who button:hover { color: var(--ink); background: var(--wash); border-color: transparent; }
.inline { display: inline; }
.inline-links { display: inline-flex; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin: 12px 0 20px; }
.filters label, .row label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--slate); }
.filters > a, .row > a { align-self: center; }
.filters > a { align-self: flex-end; padding-bottom: 9px; }

/* Forms rendered field by field (as_p): label above, help below */
main form > p { display: flex; flex-direction: column; gap: 6px; max-width: 520px; margin: 0 0 18px; }
main form > p > label { font-weight: 600; font-size: 15px; }
main form > p > button { align-self: flex-start; }
main form > p:has(> input[type="checkbox"]) { flex-direction: row; align-items: center; gap: 10px; }
main form > p:has(> input[type="checkbox"]) > label { order: 2; font-weight: 500; }
main form > p > button + a, main form > button + a { margin-left: 12px; align-self: center; }
.helptext { color: var(--slate); font-size: 14px; }
main form > a { margin-left: 12px; }

/* Tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: 13px; font-weight: 600; color: var(--slate); padding-top: 0; padding-bottom: 10px; border-bottom-color: var(--rule-strong); }
th.num, td.num { text-align: right; }
tfoot th, tfoot td { color: var(--ink); font-weight: 600; border-bottom: 0; padding-top: 12px; }
table.customers th a { color: inherit; }

/* State */
.pill, .status, .flag, .tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; margin: 2px 4px 2px 0;
  border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
  color: #3d4550; background: #f1f3f5;
}
.flag { color: var(--late); background: var(--late-wash); }
.flag.soft { color: var(--due); background: var(--due-wash); }
.tag { font-weight: 500; }
.tag form { display: inline-flex; }
.tag button { min-height: 0; padding: 0 0 0 2px; border: 0; background: none; color: var(--slate); font-weight: 600; }
.tag button:hover { background: none; color: var(--late); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.status.active { color: var(--ok); background: var(--ok-wash); }
.status.due_soon, .status.pending_payment, .status.pending_papers { color: var(--due); background: var(--due-wash); }
.status.new_lead { color: var(--blue); background: var(--blue-wash); }
.status.expired, .status.cancelled { color: #f1f3f5; background: var(--ink); }
.pill.late { color: var(--late); background: var(--late-wash); }
.pill.owner { color: var(--blue); background: var(--blue-wash); }

/* Customers who are not current keep the spreadsheet's black rows (FR-204). */
.black { background: var(--ink); color: #eef0f2; }
.black td { border-bottom-color: #2c323a; }
.black a { color: #a9c4e0; }
.black .flag { color: #ffc9c2; background: rgba(255, 201, 194, 0.12); }
.black .status { color: #eef0f2; background: rgba(255, 255, 255, 0.12); }

/* Key facts as a strip, and term/definition pairs */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; margin: 0; }
.facts dt { color: var(--slate); }
.facts dd { margin: 0; }
.strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 20px 32px; margin: 0 0 8px; padding: 22px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.strip dt { font-size: 13px; color: var(--slate); margin: 0 0 2px; }
.strip dd { margin: 0; }
.strip .big { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Customer profile */
.profile-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px 24px; margin-bottom: 24px; }
.profile-head.black { padding: 20px 24px; border-radius: 8px; }
.profile-head .states { margin-top: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.columns { display: flex; flex-wrap: wrap; gap: 8px 56px; }
.columns > .main { flex: 999 1 560px; min-width: 0; }
.columns > aside { flex: 1 1 300px; min-width: 0; }
aside section { margin-top: 32px; }
aside h2 { font-size: 1rem; }
.subscription { padding: 4px 0 20px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.subscription h3 { margin: 4px 0 12px; font-size: 1.0625rem; }
.subscription.cancelled { color: var(--slate); }
.links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; }
.note { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.note p { margin: 0; }

/* Today */
.today-head { margin-bottom: 32px; }
.today-head h1 { font-size: 2.5rem; line-height: 1.1; }
.today-head p { margin: 12px 0 0; font-size: 17px; color: var(--slate); max-width: 62ch; }
.queue td { padding-top: 16px; padding-bottom: 16px; }
.queue th:first-child, .queue td:first-child { padding-left: 0; }
.queue th:last-child, .queue td:last-child { padding-right: 0; }
.queue .what strong { display: block; font-weight: 600; }
.acts { display: flex; justify-content: flex-end; flex-wrap: nowrap; gap: 4px; }
.queue td.actions { width: 1%; white-space: nowrap; }
.acts form { display: flex; gap: 4px; align-items: center; }
.pop { position: relative; }
.pop > summary { list-style: none; }
.pop > summary::-webkit-details-marker { display: none; }
.pop-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 15; display: flex; align-items: flex-end; gap: 8px;
  padding: 12px; background: var(--paper); border: 1px solid var(--rule-strong); border-radius: 8px;
  box-shadow: 0 12px 32px rgba(21, 25, 30, 0.12);
}
.pop-panel label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--slate); }
.coming { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); max-width: 760px; }
.coming li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }

/* Sign-in pages */
body.entrance { background: var(--wash); }
.entrance-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 16px; }
.entrance-brand { font-weight: 600; font-size: 18px; letter-spacing: -0.01em; margin-bottom: 28px; color: var(--ink); }
.entrance-card { width: 100%; max-width: 420px; padding: 40px; background: var(--paper); border: 1px solid var(--rule); border-radius: 12px; }
.entrance-card h1 { font-size: 1.625rem; margin-bottom: 8px; }
.entrance-card .lead { color: var(--slate); margin-bottom: 28px; }
.entrance-card form p, .entrance-card .field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 18px; }
.entrance-card label { font-weight: 600; font-size: 15px; }
.entrance-card input:not([type="checkbox"]) { width: 100%; min-height: 44px; }
.entrance-card button[type="submit"]:not(.ghost) { width: 100%; min-height: 46px; margin-top: 8px; color: #fff; background: var(--blue); border-color: var(--blue); }
.entrance-card button[type="submit"]:not(.ghost):hover { background: #163d5e; border-color: #163d5e; color: #fff; }
.entrance-card .remember { flex-direction: row; align-items: center; gap: 10px; }
.entrance-card .remember label { font-weight: 500; }
.entrance-foot { margin-top: 24px; font-size: 14px; color: var(--slate); }

/* Phones (NFR-13): the menu folds, tables become stacked rows */
@media (max-width: 760px) {
  .bar { padding: 0 16px; gap: 12px; flex-wrap: wrap; }
  .menu-toggle { display: inline-flex; margin-left: auto; color: var(--ink); border-color: transparent; padding: 0 10px; }
  .nav, .who { display: none; }
  .top.open .nav { display: flex; flex-direction: column; gap: 0; width: 100%; padding: 4px 0 12px; }
  .top.open .who { display: flex; width: 100%; padding-bottom: 12px; }
  .top.open .nav-link { min-height: 44px; border-bottom: 0; }
  .menu-panel { position: static; box-shadow: none; border: 0; padding: 0 0 0 12px; }
  main { padding: 24px 16px 48px; }
  h1, .today-head h1 { font-size: 1.75rem; }
  button, .button, .heading > a { min-height: 44px; }
  .queue thead { display: none; }
  .queue tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
  .queue td { display: block; padding: 0; border: 0; }
  .queue td.when, .queue td.about, .queue td.actions { grid-column: 1 / -1; }
  .queue td.amount { grid-column: 2; grid-row: 2; }
  .queue td.actions { padding-top: 8px; }
  .acts { justify-content: flex-start; flex-wrap: wrap; }
  .queue td.actions { width: auto; }
  .coming li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
  .entrance-card { padding: 28px 20px; }
}
