/* Shared page styles. Colours and font come from the client's branding via public/lib/theme.mjs;
   the defaults below are used until it loads, or when a copy isn't set up. */
:root {
  --side: clamp(16px, 3vw, 40px);
  /* The client's header and button colours: the same in both themes. */
  --primary: #2f3a45; --on-primary: #ffffff;
  --accent: #6b7c8c; --on-accent: #ffffff;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Paper: documents that print (Proposals & quotes). White in both themes, as printed. */
  --paper: #ffffff; --paper-fg: #1d2329; --paper-muted: #444c55; --paper-line: #d5d9dd; --paper-edge: #c9ced3;

  /* Light theme. --brand-* come from the client's branding (applyBranding). Pages use only
     the role names below (--bg, --surface, --danger…), never colours of their own, so both
     themes cover every page. */
  --bg: var(--brand-bg, #ffffff); --fg: var(--brand-fg, #1d2329); --heading: var(--brand-heading, #1d2329);
  --accent-line: var(--accent);     /* card edges and focus rings */
  --muted: #5b6570;                 /* secondary text */
  --line: #dcdfe2;                  /* dividers and card borders */
  --field-line: #b8bec4;            /* borders of inputs and plain buttons */
  --surface: #ffffff;               /* cards, panels, inputs, menus */
  --surface-2: #f7f7f5;             /* table headings */
  --hover: #f3f5f7;                 /* hovered rows and buttons */
  --pressed: #eef0f2;               /* pressed buttons, badges */
  --danger: #a12a2a; --on-danger: #ffffff; --danger-bg: #fdf3f3;
  --focus: #3b6ea5; --focus-soft: rgba(59, 110, 165, .35);
  --shadow: rgba(0, 0, 0, .12);     /* menus */
  --edge: rgba(0, 0, 0, .18);       /* the shadow on a table that scrolls sideways */
  color-scheme: light;
}

/* Dark theme: set on <html data-theme="dark"> by /lib/theme-early.js before the page draws.
   The client's colours are lightened where needed to pass WCAG AA (core/branding.mjs). */
:root[data-theme="dark"] {
  --bg: var(--brand-bg-dark, #16191d); --fg: var(--brand-fg-dark, #e6e8eb); --heading: var(--brand-heading-dark, #e6e8eb);
  --accent-line: var(--brand-accent-line-dark, #9aa8b5);
  --muted: var(--brand-muted-dark, #a7b0ba);
  --surface: var(--brand-surface-dark, #1f2329);
  --line: #363d46;
  --field-line: #6b7580;
  --surface-2: #262b32;
  --hover: #2b3139;
  --pressed: #353c46;
  --danger: #ff8f87; --on-danger: #16191d; --danger-bg: #3a1e1e;
  --focus: #8ab4f8; --focus-soft: rgba(138, 180, 248, .4);
  --shadow: rgba(0, 0, 0, .55);
  --edge: rgba(255, 255, 255, .16);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; font: 300 16px/1.5 var(--font); background: var(--bg); color: var(--fg); }
strong, b, th { font-weight: 600; }
/* Pages use the whole width of the screen. Side padding grows from 16px on a phone to 40px. */
header.site { background: var(--primary); color: var(--on-primary); padding: 14px var(--side); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; border-bottom: 4px solid var(--accent); }
header.site h1 { margin: 0; font-size: 20px; font-weight: 600; display: flex; align-items: center; gap: 12px; min-width: 0; }
header.site nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 10px; margin-left: auto; }
header.site a:focus-visible, header.site button:focus-visible { outline-color: var(--on-primary); }
/* The logo (or product name) in the header goes back to the hub's home page. */
a.brand-home { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; border-radius: 4px; }
a.brand-home:hover .brand-label { text-decoration: underline; text-underline-offset: 3px; }
header.site a, header.site button { color: var(--on-primary); }
header.site button { background: none; border: 1px solid currentColor; border-radius: 4px; padding: 2px 8px; font: inherit; cursor: pointer; }
.brand-logo { height: 44px; width: auto; display: block; margin: -6px 0; } /* logo files often carry their own clear space */
.brand-label { font-weight: 300; font-size: 20px; padding-left: 12px; border-left: 1px solid currentColor; }
main { padding: 24px var(--side); }
h2 { color: var(--heading); font-weight: 300; font-size: 26px; margin: 28px 0 10px; }
h3 { color: var(--fg); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; margin: 20px 0 8px; }
a { color: var(--fg); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
.muted { color: var(--muted); }
.notice { border-left: 4px solid var(--accent-line); background: var(--surface); padding: 8px 12px; }
/* Anything marked hidden stays hidden, even if a class gives it a display (such as .button). */
[hidden] { display: none !important; }
/* The theme switch in the header (added by theme.mjs). */
header.site .app-version { font-size: 13px; font-variant-numeric: tabular-nums; text-decoration: none; border: 1px solid currentColor; border-radius: 10px; padding: 0 7px; white-space: nowrap; }
header.site .app-version:hover { text-decoration: underline; }
header.site .theme-toggle { display: inline-flex; align-items: center; justify-content: center; padding: 4px 7px; }
header.site .theme-toggle svg { width: 16px; height: 16px; }
/* The person's name and Sign out go last in the header, whatever is added to the nav after them. */
header.site nav #who { order: 1; }
header.site .theme-toggle[aria-pressed="true"] { background: var(--on-primary); color: var(--primary); }
.button, .signin { display: inline-block; background: var(--accent); color: var(--on-accent); padding: 8px 16px; border-radius: 4px; text-decoration: none; font-weight: 600; }

/* Phones: a smaller header, and nothing pushes the page wider than the screen. */
@media (max-width: 600px) {
  header.site { padding-top: 10px; padding-bottom: 10px; }
  header.site h1, .brand-label { font-size: 17px; }
  .brand-logo { height: 36px; }
  .brand-label { padding-left: 10px; }
  h2 { font-size: 22px; }
  main { padding-top: 16px; }
}

/* The notifications bell in the header, and its panel (public/lib/feedback.mjs). */
header.site .notif-bell { position: relative; display: inline-flex; align-items: center; padding: 3px 7px; }
header.site .notif-bell svg { width: 16px; height: 16px; }
header.site .notif-bell[aria-expanded="true"] { background: var(--on-primary); color: var(--primary); }
.notif-count { position: absolute; top: -8px; right: -9px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--on-primary); color: var(--primary); border: 1px solid var(--primary); font-size: 11px; font-weight: 600; line-height: 16px; text-align: center; }
.notif-panel { position: fixed; top: 64px; right: var(--side); z-index: 50; width: min(380px, calc(100vw - 2 * var(--side))); max-height: min(70vh, 560px); overflow: auto; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 24px var(--shadow); }
.notif-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.notif-head button, .fb-secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--field-line); border-radius: 4px; padding: 4px 10px; font: inherit; font-size: 14px; cursor: pointer; }
.notif-head button:disabled { opacity: .55; cursor: default; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { border-bottom: 1px solid var(--line); }
.notif-list li > a, .notif-list li > span { display: block; padding: 10px 14px 10px 22px; color: inherit; text-decoration: none; position: relative; }
.notif-list li > a:hover, .notif-list li > a:focus-visible { background: var(--hover); }
.notif-list li.unread > a::before, .notif-list li.unread > span::before { content: ""; position: absolute; left: 9px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-line); }
.notif-list li.unread .notif-title { font-weight: 600; }
.notif-title { display: block; font-size: 14px; }
.notif-when { display: block; font-size: 12px; color: var(--muted); }
.notif-empty { padding: 14px; }
.notif-foot { margin: 0; padding: 8px 14px; font-size: 14px; }

/* The ? button at the bottom left, and its form. */
.feedback-fab { position: fixed; left: 16px; bottom: 16px; z-index: 40; width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--on-primary); background: var(--primary); color: var(--on-primary); font: 600 22px/1 var(--font); cursor: pointer; box-shadow: 0 2px 10px var(--shadow); }
.feedback-fab:hover { filter: brightness(1.1); }
.feedback-fab:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
body.has-feedback main { padding-bottom: 84px; }
.feedback-dialog { width: min(520px, calc(100vw - 24px)); background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px; box-shadow: 0 10px 40px var(--shadow); }
.feedback-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.feedback-dialog h2 { margin-top: 0; }
.feedback-dialog label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
.feedback-dialog input[type=text], .feedback-dialog textarea { width: 100%; font: inherit; padding: 6px 8px; border: 1px solid var(--field-line); border-radius: 4px; background: var(--surface); color: var(--fg); }
.feedback-dialog textarea { resize: vertical; }
.fb-kinds { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.fb-kinds legend { font-weight: 600; font-size: 14px; margin-bottom: 4px; padding: 0; }
.fb-kinds label { display: inline-flex; gap: 6px; align-items: center; font-weight: 300; font-size: 16px; margin: 0; }
.fb-page { font-size: 13px; }
.fb-msg.error { color: var(--danger); }
.fb-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.fb-actions .button { border: 0; cursor: pointer; font: inherit; font-weight: 600; }
.fb-secondary { font-size: 16px; padding: 7px 14px; }
@media (max-width: 600px) { .notif-panel { top: 56px; } }

/* ---- Each person's appearance settings (the Settings wheel). /lib/theme-early.js sets these
   attributes on <html> before the page draws; public/lib/prefs.mjs lists the choices. ---- */

/* Text size: scales the whole page, so spacing and tables keep their proportions. */
html[data-text="small"] body { zoom: 0.875; }
html[data-text="large"] body { zoom: 1.125; }
html[data-text="larger"] body { zoom: 1.25; }

/* Compact: less space around things, so more fits on the screen. */
html[data-density="compact"] main { padding-top: 12px; padding-bottom: 12px; }
html[data-density="compact"] h2 { margin: 0.3em 0 0.4em; }
html[data-density="compact"] h3 { margin: 0.8em 0 0.3em; }
html[data-density="compact"] p { margin: 0.4em 0; }
html[data-density="compact"] header.site { padding-top: 6px; padding-bottom: 6px; }

/* More contrast: secondary text as strong as the main text, and firmer lines. */
/* :root[…] so these win over the dark theme's own colours (:root[data-theme="dark"]). */
:root[data-contrast="more"] { --muted: var(--fg); --line: #8a939c; --field-line: #5b6570; }
:root[data-contrast="more"][data-theme="dark"] { --muted: var(--fg); --line: #7d8792; --field-line: #a3adb7; }
html[data-contrast="more"] a { text-decoration-thickness: 2px; }

/* The device's own font instead of the client's. */
html[data-font="system"] { --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important; }

/* Centred: a narrower page, easier to read on a very wide screen. */
html[data-width="centred"] main { max-width: 1280px; margin-left: auto; margin-right: auto; }

/* Reduce motion: no transitions or animations, chosen here or set on the device. */
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }


/* ---- The Settings wheel and its panel (public/lib/settings-panel.mjs) ---- */
header.site .settings-button { display: inline-flex; align-items: center; justify-content: center; padding: 4px 7px; }
header.site .settings-button svg { width: 18px; height: 18px; }
dialog.settings-panel { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100%; max-height: 100%; width: min(420px, 100vw); box-sizing: border-box; padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--surface); color: var(--fg); display: none; flex-direction: column; box-shadow: -8px 0 30px var(--shadow); }
dialog.settings-panel[open] { display: flex; }
dialog.settings-panel::backdrop { background: rgba(0, 0, 0, .35); }
.settings-panel .sp-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.settings-panel .sp-head h2 { margin: 0; font-size: 20px; }
.settings-panel .sp-close { font: inherit; font-size: 24px; line-height: 1; background: none; border: 0; color: inherit; cursor: pointer; padding: 2px 8px; border-radius: 4px; }
.settings-panel .sp-body { overflow-y: auto; padding: 4px 20px 16px; flex: 1; }
.settings-panel h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; font-weight: 600; }
.settings-panel fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.settings-panel legend { font-weight: 600; padding: 0; margin-bottom: 4px; color: var(--heading); }
.settings-panel .sp-options { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.settings-panel .sp-options label { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--field-line); border-radius: 999px; padding: 3px 10px 3px 6px; cursor: pointer; }
.settings-panel .sp-options label:has(input:checked) { background: var(--pressed); border-color: var(--accent-line); font-weight: 600; }
.settings-panel .sp-switches { display: grid; gap: 6px; margin-bottom: 8px; }
.settings-panel .sp-switch, .settings-panel .sp-pipelines > label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.settings-panel ol, .settings-panel ul { list-style: none; margin: 0; padding: 0; }
.settings-panel .sp-order li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.settings-panel .sp-order label, .settings-panel .sp-pipelines li label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.settings-panel .sp-pipelines ul { margin: 4px 0 0 22px; }
.settings-panel .sp-move { display: inline-flex; gap: 4px; }
.settings-panel .sp-reset { white-space: nowrap; }
.settings-panel .sp-move button, .settings-panel .sp-reset { font: inherit; background: var(--surface); color: inherit; border: 1px solid var(--field-line); border-radius: 4px; padding: 1px 8px; cursor: pointer; }
.settings-panel .sp-move button[disabled] { visibility: hidden; }
.settings-panel .sp-hint { color: var(--muted); font-size: 14px; margin: 0 0 6px; }
.settings-panel .sp-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }
.settings-panel .sp-status { margin: 0; color: var(--muted); font-size: 14px; }
.settings-panel button:focus-visible, .settings-panel input:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }
