/* Mainscape staff web apps: standard UI (v1.1, 2026-10-28: light/dark toggle).
   Source of truth: D:\AzureWebApps\Shared\ui.css. Each app's deploy-web.ps1 copies it to <app>-web/shared/ui.css.
   Load order on every page: Google Fonts, /shared/ui.css, then the app's own CSS (app CSS only adds, never restyles
   these components). Guidelines: project doc claude/web-app-ui-standard.md.
   CSP: no inline styles anywhere; set state with classes. */

/* ------------------------------------------------------------------ tokens (light, dark) */
:root {
  color-scheme: light;
  --bg: #F3F6F4; --surface: #FFFFFF; --surface-2: #EEF2EA; --ink: #15241A; --muted: #5A6B5F; --line: #DCE3D7;
  --brand: #007456; --brand-deep: #005A43; --brand-2: #007456; --brand-ink: #FFFFFF;
  --accent: #FCD033; --accent-ink: #1C1A0E; --accent-soft: #FEF4CF;
  --danger: #B42318; --danger-soft: #FDECEA;
  --ok-soft: rgba(0,116,86,.12);
  --hdr: #101A14; --hdr-2: #1E2C23; --hdr-line: #2E3F34; --hdr-ink: #C9D6CD;
  --f-display: "Barlow Semi Condensed", "Arial Narrow", Arial, sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 12px; --r-sm: 8px;
  --gutter: 20px;
}
/* Dark: follows the device unless the person picked a theme with the header toggle (app-menu.js sets
   <html data-theme="light|dark">). Keep the two dark blocks identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E1611; --surface: #15201A; --surface-2: #1B2820; --ink: #E6EEE8; --muted: #9BB0A2; --line: #283A2F;
    --brand: #00563F; --brand-deep: #003F2E; --brand-2: #3DB08A; --brand-ink: #F2F7F3;
    --accent-soft: #3A3216; --danger: #F97066; --danger-soft: #3A1A17; --ok-soft: rgba(61,176,138,.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1611; --surface: #15201A; --surface-2: #1B2820; --ink: #E6EEE8; --muted: #9BB0A2; --line: #283A2F;
  --brand: #00563F; --brand-deep: #003F2E; --brand-2: #3DB08A; --brand-ink: #F2F7F3;
  --accent-soft: #3A3216; --danger: #F97066; --danger-soft: #3A1A17; --ok-soft: rgba(61,176,138,.16);
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--f-body); -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--f-display); margin: 0; line-height: 1.15; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--brand-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.err { color: var(--danger); margin: 0; font-weight: 600; }
.app { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ header: [apps] logo | App name  page nav  [quick open]  user [Sign out] */
.hdr { flex: none; background: var(--hdr); color: #fff; }
.hdr-in { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 var(--gutter); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand .wm { height: 22px; width: auto; display: block; }
.brand span { font: 500 1rem var(--f-display); color: var(--hdr-ink); border-left: 1px solid var(--hdr-line); padding-left: 12px; }
.hnav { display: flex; gap: 2px; margin-left: 4px; }
.hnav a { color: var(--hdr-ink); text-decoration: none; font-weight: 600; padding: 5px 10px; border-radius: var(--r-sm); }
.hnav a:hover { color: #fff; }
.hnav a[aria-current] { color: #fff; background: var(--hdr-2); }
.jump input { width: 130px; padding: 5px 10px; background: #1B2820; border: 1px solid var(--hdr-line); border-radius: var(--r-sm); color: #fff; font-size: .9rem; }
.jump input::placeholder { color: #9BB0A2; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: .92rem; color: var(--hdr-ink); }
.hdr .btn.ghost { border-color: var(--hdr-line); color: #fff; }

/* light/dark toggle (shared/app-menu.js adds it before the user name) */
.theme-btn { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--hdr-line); background: transparent; color: var(--hdr-ink); cursor: pointer; }
.theme-btn:hover { background: var(--hdr-2); color: #fff; }
.theme-btn svg { display: block; }

/* app menu (shared/app-menu.js adds the button and panel) */
.amenu-btn { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--hdr-line); background: transparent; color: var(--hdr-ink); cursor: pointer; }
.amenu-btn:hover, .amenu-btn[aria-expanded="true"] { background: var(--hdr-2); color: #fff; }
.amenu { position: fixed; top: 50px; left: 12px; z-index: 50; width: min(340px, calc(100vw - 24px)); max-height: calc(100vh - 70px); overflow: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 12px 32px rgba(0,0,0,.25); padding: 8px; }
.amenu.amenu-right { left: auto; right: 12px; }
.amenu-h { margin: 4px 8px 6px; font: 600 .78rem var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.amenu-empty { margin: 8px; color: var(--muted); font-size: .9rem; }
.amenu-app { border-radius: var(--r-sm); }
.amenu-app.cur { background: var(--surface-2); }
.amenu-link { display: grid; gap: 1px; padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none; color: inherit; }
.amenu-link:hover { background: var(--surface-2); }
.amenu-n { font-weight: 700; }
.amenu-d { font-size: .85rem; color: var(--muted); }
.amenu-d em { font-style: normal; color: var(--danger); }
.amenu-ext { color: var(--muted); font-weight: 400; }
.amenu-tag { font-size: .72rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin-left: 4px; }
.amenu-app.soon { padding: 8px 10px; opacity: .75; }
.amenu-pages { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 8px; }
.amenu-pages a { font-size: .85rem; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.amenu-pages a[aria-current] { background: var(--brand); border-color: var(--brand); color: #fff; }

/* account panel (shared/app-menu.js: click your name) */
.acct-btn { display: inline-flex; align-items: center; gap: 4px; background: transparent; border: 1px solid transparent; border-radius: var(--r-sm); color: var(--hdr-ink); font: inherit; padding: 5px 8px; cursor: pointer; }
.acct-btn:hover, .acct-btn[aria-expanded="true"] { background: var(--hdr-2); color: #fff; border-color: var(--hdr-line); }
.acct-moved { display: none !important; }
.acct { top: 50px; }
.acct-me { display: grid; gap: 2px; padding: 6px 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.acct-me b { font: 700 1.05rem var(--f-display); }
.acct-me span { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.acct-list { list-style: none; margin: 0 0 8px; padding: 0 8px; display: grid; gap: 4px; font-size: .88rem; }
.acct-list li { display: flex; justify-content: space-between; gap: 12px; }
.acct-list span { color: var(--muted); }
.acct-list b { font-weight: 600; text-align: right; }
.acct-list b.yes { color: var(--brand-2); }
.acct-list b.no { color: var(--danger); }
.acct-diag { display: grid; gap: 8px; justify-items: start; padding: 0 8px; }
.acct-diag .acct-list { padding: 0; width: 100%; margin: 0; }
.acct-diag .ispin { margin-right: 6px; }
.acct-verdict { margin: 0; font-size: .88rem; }
.acct-verdict.ok { color: var(--brand-2); }
.acct-verdict.bad { color: var(--danger); }
.acct-note { margin: 0; font-size: .8rem; color: var(--muted); }
.acct-note.done { color: var(--brand-2); font-weight: 600; }
.acct { width: min(360px, calc(100vw - 24px)); }
.acct-rows { list-style: none; margin: 0 0 6px; padding: 0 8px; display: grid; gap: 6px; font-size: .88rem; }
.acct-rows li { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: start; }
.acct-rows .k { color: var(--muted); }
.acct-rows .v { min-width: 0; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.acct-rows .v small { display: block; width: 100%; color: var(--muted); font-size: .8rem; }
.acct-rows .v em { display: block; width: 100%; font-style: normal; color: var(--danger); font-weight: 600; font-size: .8rem; }
.acct-rows .btn.link { font-size: .82rem; white-space: nowrap; }
.acct-dot { display: inline-flex; align-items: center; gap: 5px; }
.acct-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.acct-dot.ok::before { background: var(--brand-2); }
.acct-dot.bad::before { background: var(--danger); }
.acct-dot.wait::before { background: var(--line); }
.acct-dot.na { color: var(--muted); }
.acct-sec { border-top: 1px solid var(--line); }
.acct-sec summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 8px; cursor: pointer; font-weight: 600; font-size: .92rem; border-radius: var(--r-sm); }
.acct-sec summary::-webkit-details-marker { display: none; }
.acct-sec summary:hover { background: var(--surface-2); }
.acct-sec summary .sum { margin-left: auto; font-weight: 400; font-size: .82rem; color: var(--muted); text-align: right; }
.acct-sec summary::after { content: ""; flex: none; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.acct-sec[open] summary::after { transform: rotate(45deg); }
.acct-sec > .acct-list, .acct-sec > .acct-news, .acct-sec > .acct-diag { margin: 0 0 10px; }
.acct-locs { max-height: 180px; overflow: auto; }
.acct-news { display: grid; gap: 8px; padding: 0 8px; font-size: .88rem; }
.news-i { display: grid; grid-template-columns: 52px 1fr; gap: 8px; }
.news-i b { color: var(--muted); font-weight: 600; }
.acct-btns { display: flex; flex-wrap: wrap; gap: 6px; }
dialog.news form { gap: 14px; }
dialog.news h2 { margin: 0; font: 700 1.3rem var(--f-display); }
.news-act { display: flex; justify-content: flex-end; }
.acct-foot { border-top: 1px solid var(--line); padding: 8px 8px 2px; display: flex; justify-content: flex-end; }
@media (max-width: 720px) { .acct-btn > span { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

/* ------------------------------------------------------------------ buttons */
.btn { font: 600 .95rem var(--f-body); border-radius: 10px; border: 1px solid transparent; padding: 8px 18px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: transparent; color: inherit; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(.96); }
.btn.primary:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.btn.ghost { border-color: var(--line); }
.btn.sm { padding: 4px 10px; font-size: .85rem; border-radius: var(--r-sm); }
.btn.link { padding: 0; color: var(--brand-2); background: none; border: 0; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .6; cursor: default; }
.cnt { background: var(--brand-2); color: #fff; border-radius: 999px; font-size: .75rem; padding: 0 7px; min-width: 20px; text-align: center; }

/* the one create button on a list page: "+ New <thing>", bottom right */
.fab { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); font: 700 1rem var(--f-body); text-decoration: none; border: 0; cursor: pointer;
  padding: 16px 24px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0,0,0,.28); }
.fab:hover { filter: brightness(.96); }

/* ------------------------------------------------------------------ forms */
input, select, textarea { width: 100%; font-size: .95rem; padding: 7px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: var(--brand-2); }
label, .lbl { display: grid; gap: 3px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.rq::after { content: " *"; color: var(--danger); }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink); cursor: pointer; }
.toggle input { width: auto; }

/* ------------------------------------------------------------------ surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.bar { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 8px var(--gutter); flex-wrap: wrap; }
.bar .acts { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* status badge: one color meaning in every app */
.badge { display: inline-block; font: 700 .7rem/1.6 var(--f-body); letter-spacing: .06em; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.badge.new  { background: var(--accent-soft); color: #8A6D00; }     /* draft, new, submitted by customer */
.badge.go   { background: var(--ok-soft); color: var(--brand-2); }   /* active, in progress, sent */
.badge.bad  { background: var(--danger-soft); color: var(--danger); } /* overdue, expired, rejected */
.badge.done { background: var(--surface-2); color: var(--muted); }   /* done, signed, resolved, closed, deleted */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.new { color: var(--accent); } }
:root[data-theme="dark"] .badge.new { color: var(--accent); }

/* ------------------------------------------------------------------ list page: search, status pills, Filters, scope, results */
.lhead { flex: none; padding: 12px var(--gutter) 8px; display: grid; gap: 10px; }
.lsearch { display: flex; gap: 8px; }
.lsearch input { flex: 1; font-size: 1rem; padding: 10px 14px; border-radius: 10px; }
.lsearch .btn { flex: none; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-btn { font: 600 .9rem var(--f-body); padding: 7px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.pill-btn:hover { border-color: var(--brand-2); }
.pill-btn[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.scope { font-size: .88rem; color: var(--muted); }
.fpanel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.fpanel fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; margin: 0; display: grid; gap: 8px; align-content: start; min-width: 0; }
.fpanel legend { font: 600 .82rem var(--f-display); letter-spacing: .06em; text-transform: uppercase; color: var(--brand-2); padding: 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fchip { font: 500 .85rem var(--f-body); background: var(--accent-soft); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.fchip span { color: var(--muted); font-weight: 700; }
.fchip:hover span { color: var(--danger); }

/* results as cards (phone, tablet, and the default everywhere) */
.rows { list-style: none; margin: 0; padding: 0 0 96px; }            /* bottom room so the FAB never covers the last row */
.rows > li { border-top: 1px solid var(--line); }
.rows > li:last-child { border-bottom: 1px solid var(--line); }
.rowlink { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px var(--gutter); color: inherit; text-decoration: none; }
.rowlink:hover { background: var(--surface-2); }
.rowlink .t { font: 700 1.05rem var(--f-display); min-width: 0; }
.rowlink .amt { font: 700 1.05rem var(--f-display); text-align: right; }
.rowlink .m { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .88rem; color: var(--muted); }
.rowlink .late { color: var(--danger); font-weight: 700; }
.lfoot { display: flex; justify-content: center; padding: 12px; color: var(--muted); font-size: .9rem; }
.empty { padding: 40px var(--gutter); text-align: center; color: var(--muted); }

/* optional wide table (desk-first apps, 900px and up) */
.rt { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rt th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-weight: 600; font-size: .78rem; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
/* sortable headers (app-menu.js adds .sortable and aria-sort to every <thead> th) */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable:focus-visible { outline: 2px solid var(--brand-2); outline-offset: -2px; }
th.sortable::after { content: "\2195"; margin-left: 4px; opacity: .35; font-size: .85em; }
th.sortable[aria-sort="ascending"]::after { content: "\25B2"; opacity: 1; }
th.sortable[aria-sort="descending"]::after { content: "\25BC"; opacity: 1; }
th.sortable[aria-sort="ascending"], th.sortable[aria-sort="descending"] { color: var(--ink); }
.tw { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; }
.rt .id a { font-weight: 700; text-decoration: none; }
.rt .nw { white-space: nowrap; }
.rt .num, .rt th.num { text-align: right; white-space: nowrap; }
.rt .sub b { display: block; font-weight: 600; }
.rt .sub small { display: block; color: var(--muted); }
.rt .late { color: var(--danger); font-weight: 700; }
.rt td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rt tbody tr { cursor: pointer; }
.rt tbody tr:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------ states, dialogs, toast */
.center { text-align: center; padding: 80px 16px; display: grid; gap: 12px; justify-items: center; flex: 1; }
.center h2 { font-size: 1.6rem; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--brand-2); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ispin { display: inline-block; vertical-align: -3px; width: 16px; height: 16px; margin-right: 8px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand-2); animation: spin 1s linear infinite; }
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; max-width: 560px; width: calc(100% - 32px); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10,20,14,.5); }
dialog form { padding: 20px; display: grid; gap: 12px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }
dialog .btn.danger { background: var(--danger); color: #fff; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--hdr); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 70; max-width: calc(100% - 32px); }

/* ------------------------------------------------------------------ phone (under 720px) */
@media (max-width: 720px) {
  :root { --gutter: 12px; }
  .brand span, .hnav, .jump, .who span { display: none; }
  .fpanel, .g2, .g3 { grid-template-columns: 1fr; }
  .fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  .pills { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .pills::-webkit-scrollbar { display: none; }
  .pill-btn { flex: none; }
  .lsearch .btn.primary { display: none; }   /* phone keyboards have a search key; give the box the room */
}
@media (min-width: 721px) and (max-width: 1100px) {
  .fpanel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* View as (testing) */
.acct-va { display: flex; gap: 8px; margin: 0 0 8px; }
.acct-va input { flex: 1; min-width: 0; }
.va-banner { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 6px 12px; background: var(--accent-soft); color: var(--text); font-size: .88rem; border-bottom: 1px solid var(--line); }
