:root {
  color-scheme: light;
  --bg: #f3eee4; --card: #fffdf8; --text: #1c1a16; --muted: #736c5f; --line: #e7dfd0;
  --brand: #0f4a3b; --brand-text: #fdf8ec; --ok: #1c7a55; --warn: #a2620a; --bad: #b6412f;
  --soft: #f6f0e4; --gold: #b68b3e; --gold-soft: #ecd193;
  --lift: 0 1px 0 rgba(255,255,255,.9) inset, 0 1px 2px rgba(60,45,15,.05), 0 10px 24px rgba(60,45,15,.07);
  --hero: radial-gradient(110% 90% at 100% 0%, rgba(214,176,98,.38) 0%, rgba(214,176,98,0) 55%), linear-gradient(160deg, #145a48 0%, #0a3329 100%);
  --hero-text: #fbf6ea; --hero-muted: rgba(251,246,234,.7); --hero-line: rgba(251,246,234,.18);
  --ui: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --display: Fraunces, Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
       padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
       background: var(--brand); color: var(--brand-text); }
.top .logo { display: block; flex: none; }
.top button.ghost { display: grid; place-items: center; }
.top strong { letter-spacing: .06em; }
.top .sub { opacity: .8; }
.top button { white-space: nowrap; flex: none; }
@media (max-width: 430px) { .top .sub { display: none; } }
.spacer { flex: 1; }
main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }
h2 { font-size: 1.15rem; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin: 10px 0; }
.card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta { font-size: .9rem; color: var(--muted); }
.pill { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.pill.pending { color: var(--warn); border-color: currentColor; }
.pill.redo, .pill.overdue { color: var(--bad); border-color: currentColor; }
.pill.received { color: var(--brand); border-color: currentColor; }
.pill.done { color: var(--ok); border-color: currentColor; }
.note { background: color-mix(in srgb, var(--bad) 10%, transparent); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer; min-height: 44px;
               background: var(--brand); color: var(--brand-text); text-decoration: none; display: inline-block; }
button.secondary, .btn.secondary { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
button.danger { background: var(--bad); color: #fff; }
button.ghost { background: transparent; color: inherit; padding: 6px 8px; min-width: 44px; min-height: 44px; }
button.big { width: 100%; padding: 14px; font-size: 1.05rem; margin-top: 8px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; width: 100%; padding: 10px; border-radius: 10px;
                          border: 1px solid var(--line); background: var(--card); color: var(--text); }
label { display: block; margin: 10px 0 4px; font-size: .9rem; color: var(--muted); }
/* Tick boxes keep their own size and sit beside their words, not above them. */
input[type=checkbox], input[type=radio] { width: 1.15em; height: 1.15em; padding: 0; margin: 0 6px 0 0; vertical-align: -0.15em; flex: none; accent-color: var(--brand); }
a.btn.big { display: block; width: 100%; padding: 14px; font-size: 1.05rem; text-align: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.tabs button { background: transparent; color: var(--text); border: 1px solid var(--line); white-space: nowrap; }
.tabs button.on { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }

/* Phone: a bar at the bottom, the rest behind More, and a switch on top of the request lists */
body.hasbar { --bar: calc(62px + env(safe-area-inset-bottom)); }
body.hasbar main { padding-bottom: calc(96px + var(--bar)); }
.navbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; display: grid; gap: 0; margin: 0; flex-wrap: nowrap;
          padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
.navbar button, .navsheet button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
          border: 0; color: var(--muted); min-width: 0; -webkit-tap-highlight-color: transparent; }
.navbar button { height: 54px; justify-content: center; padding: 0 2px; font-size: .72rem; border-radius: 12px; }
.navbar button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.navbar button.on { background: transparent; color: var(--brand); font-weight: 700; }
.navdot { position: absolute; top: 3px; left: calc(50% + 5px); min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px;
          border-radius: 999px; background: var(--bad); color: #fff; font-size: .68rem; font-weight: 700; }
.navshade { position: fixed; inset: 0; z-index: 7; background: rgba(0,0,0,.45); }
.navsheet { position: fixed; left: 0; right: 0; bottom: var(--bar); z-index: 8; display: grid; grid-template-columns: repeat(3, 1fr);
          gap: 10px; margin: 0; padding: 16px 14px; background: var(--card); border-radius: 18px 18px 0 0;
          max-height: calc(100dvh - var(--bar) - 80px); overflow-y: auto; }
.navsheet button { gap: 6px; padding: 14px 4px; font-size: .85rem; border-radius: 14px; background: var(--bg); color: var(--text); white-space: normal; }
.navsheet button svg { color: var(--brand); }
.navsheet button.on { background: var(--bg); color: var(--text); box-shadow: inset 0 0 0 2px var(--brand); }
.navsheet .navdot { top: 8px; left: auto; right: 10px; }
.navseg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; flex-wrap: nowrap; margin: 0 0 10px; padding: 3px;
          background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.navseg button { border: 0; padding: 9px 2px; font-size: .9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
body.hasbar .fab { bottom: calc(14px + var(--bar)); }
body.hasbar .flag { bottom: calc(14px + var(--bar)); }
body.hasbar #toast { bottom: calc(16px + var(--bar)); }
.files { list-style: none; padding: 0; margin: 8px 0; }
.files li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); }
.files a { color: var(--brand); word-break: break-all; display: inline-block; padding: 10px 0; min-height: 44px; }
.files li { flex-wrap: wrap; }
.files .seen { flex-basis: 100%; }
.fab { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); border-radius: 999px;
       padding: 14px 20px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
#toast { position: fixed; left: 16px; right: 16px; bottom: 20px; margin: auto; max-width: 520px; z-index: 20;
         background: #222; color: #fff; padding: 12px 14px; border-radius: 10px; }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px));
         background: var(--card); color: var(--text); }
dialog form { padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
.banner { background: color-mix(in srgb, var(--brand) 12%, transparent); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.card.isnew { border-color: var(--brand); box-shadow: inset 4px 0 0 var(--brand); }
#newVersion { position: sticky; top: 0; z-index: 30; display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
              padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: #fff3c4; color: #3a2c00; font-weight: 600; }
#newVersion button { background: #3a2c00; color: #fff; padding: 8px 14px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; word-break: break-all; }

/* Tappable choice chips (firms) */
.pill.pick { cursor: pointer; padding: 8px 12px; display: inline-flex; align-items: center; min-height: 44px; margin: 0; color: var(--text); font-size: .9rem; }
.pill.pick input { margin: 0 6px 0 0; }
label.pick:not(.pill) { color: var(--text); padding: 8px 0; }
.pill.pick:has(input:checked) { background: var(--brand); color: var(--brand-text); }

/* The "Problem / request" button, on every page, bottom left */
.flag { position: fixed; left: 12px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 6; border-radius: 999px;
        padding: 10px 14px; font-size: .9rem; background: var(--card); color: var(--text); border: 1px solid var(--line);
        box-shadow: 0 3px 10px rgba(0,0,0,.22); }
.flag-n { background: var(--bad); color: #fff; border-radius: 999px; padding: 1px 8px; margin-left: 4px; font-size: .8rem; }
dialog#fbDialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
#fbKinds { gap: 6px; }

/* To fix: the Tally cleanup list */
.fix .fixdetail { white-space: pre-wrap; margin: 6px 0 10px; }
.fix .fixrow { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.fix .fixrow button { flex: none; }
.fix .fixbtns { display: flex; gap: 8px; flex: none; }
.fix .fixentry { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0 0 10px; }
.fix .fixline { display: flex; justify-content: space-between; gap: 10px; }
.fix .fixline span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.fix .bad { color: var(--bad); }
.fix.isdone { border-color: var(--ok); }
.fix.isdone > p { opacity: .6; }
.fix.isdone > p:first-child b { text-decoration: line-through; }
@media (max-width: 380px) { .top { gap: 2px; padding-left: 10px; padding-right: 8px; } }

/* Local names tab */
#names input[type=search] { width: 100%; min-height: 44px; }
#names .nm-chips { display: flex; gap: 8px; margin: 10px 0; }
.nm-chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: inherit; font-size: .95rem; }
.nm-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-text); }
.nm-list { padding: 2px 12px; }
.nm-group .nm-list { padding: 0; }
.nm-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-top: 1px dashed var(--line); }
.nm-row:first-child { border-top: 0; }
.nm-legal b { display: block; overflow-wrap: anywhere; }
.nm-legal .meta, .nm-opt .meta { display: block; margin: 0; }
.nm-box { width: 100%; min-height: 44px; margin: 0; }
.nm-box.nm-done { border-color: var(--ok); }
.nm-quick { display: flex; gap: 8px; flex-wrap: wrap; }
.nm-quick button { min-height: 44px; padding: 0 14px; font-size: .9rem; }
.nm-group h3 { margin: 0 0 4px; overflow-wrap: anywhere; }
.nm-add, .nm-more { min-height: 44px; margin-top: 8px; }
.nm-more { display: block; width: 100%; }
dialog.nm-pick input { width: 100%; min-height: 44px; }
dialog.nm-pick .nm-found { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.nm-opt { display: block; width: 100%; min-height: 44px; text-align: left; background: transparent; color: inherit; border: 0; border-top: 1px dashed var(--line); border-radius: 0; padding: 8px 0; }
.nm-opt b { display: block; overflow-wrap: anywhere; }
@media (min-width: 700px) { .nm-row { grid-template-columns: 1fr 280px auto; align-items: center; } }
/* Flags: the screenshot the app took, small in the box and on each note, large on a tap. */
.fb-shot { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; min-height: 44px; }
.fb-shot img { height: 72px; border-radius: 6px; border: 1px solid var(--line); }
.fb-pics { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.fb-pic { padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); width: 84px; height: 112px; overflow: hidden; min-height: 0; }
.fb-pic img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.fb-chips { margin: 0 0 10px; gap: 8px; flex-wrap: wrap; }
dialog.fb-big { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow-y: auto; }
dialog.fb-big form { padding: 10px; display: grid; gap: 10px; }
dialog.fb-big img { width: 100%; border-radius: 8px; display: block; }
.flag[data-busy] { opacity: .55; }
select { min-height: 44px; }   /* a picker is as easy to tap as a button, whatever the font */
.fix .fixage { margin: 2px 0 0; font-size: .85rem; color: var(--muted); }
.fix .fixage:empty { display: none; }
.fix .fixage.isred { color: var(--bad); font-weight: 700; }
.fix.isred:not(.isdone) { border-left: 4px solid var(--bad); }
.push-on { color: var(--ok); font-weight: 700; margin: 0; }
