/* public/styles.css
   Styles for every Metivo screen (public/index.html + public/app.js).
   Follows the UI standard in AGENTS.md: compact white cards with a subtle
   border, 12px radius, 14px 16px padding, 10px gaps; controls at least 40px
   tall; visible keyboard focus; no horizontal scrolling at 320px. Crew use
   this one-handed on phones, so everything stacks in a single column first
   and only widens on larger screens. */

:root {
  /* Brand: deep navy with a clear blue for the one main action on a screen,
     the two colors of the logo. The action color always carries white text. */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #dde3ec;
  --text: #0b1b36;
  --muted: #566379;
  --accent: #0a1f44;
  --accent-text: #ffffff;
  --action: #1668e3;
  --action-text: #ffffff;
  /* A light wash of the action color, for "next" and "selected" backgrounds. */
  --wash: #e5effd;
  --wash-text: #0b4aa8;
  --danger: #a4262c;
  --focus: #0b57d0;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.loading { padding: 48px 16px; text-align: center; color: var(--muted); }

/* Shared header: brand, the active page name, then company and account. */
.header {
  display: flex;
  /* One row even at 320px: the company name gives way (it shortens with an
     ellipsis) so Sign out never drops onto a line of its own. */
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  /* The page is drawn edge to edge (viewport-fit=cover) so the phone reports its safe areas: the header
     keeps clear of the notch, and the bottom menu of the home bar. */
  padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 10px calc(16px + env(safe-area-inset-left));
  background: var(--accent);
  color: var(--accent-text);
}
/* The blue focus ring disappears on charcoal, so the header uses amber. */
.header :focus-visible { outline-color: #9cc5ff; }
.brand { font-weight: 700; }
.page-name { font-weight: 600; margin: 0; font-size: 16px; }
.header .spacer { flex: 1 1 0; min-width: 0; }
.header > * { flex: 0 0 auto; }
.header .who {
  color: #c9cfd3;
  font-size: 14px;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header select { flex: 0 1 auto; min-width: 0; width: auto; }

.main { max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 10px; }
.narrow { max-width: 440px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: grid;
  gap: 10px;
}
.card h2 { margin: 0; font-size: 16px; }
.card p { margin: 0; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.row .name { font-weight: 600; }
.meta { color: var(--muted); font-size: 14px; }
.list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.list > li { border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 2px; }
.list > li:first-child { border-top: 0; padding-top: 0; }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
}
.chip.you { color: var(--accent); border-color: var(--accent); background: var(--surface); }
.chip.off { color: var(--danger); border-color: var(--danger); background: var(--surface); }

label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input, select, textarea, button, .button {
  font: inherit;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}
input, select, textarea { width: 100%; }
textarea { resize: vertical; line-height: 1.4; }
button, .button {
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
button.primary, .button.primary { background: var(--action); border-color: var(--action); color: var(--action-text); font-weight: 700; }
button.quiet { font-weight: 500; }
button:disabled { opacity: 0.6; cursor: default; }

.form { display: grid; gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions > * { flex: 1 1 140px; }

.notice { border-left: 4px solid var(--action); padding: 8px 12px; background: var(--bg); border-radius: 4px; font-size: 14px; }
.notice.error { border-left-color: var(--danger); color: var(--danger); }
.link-box { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

@media (min-width: 560px) {
  .form.inline { grid-template-columns: 1fr 160px auto auto; align-items: end; }
}

/* The hidden attribute must win over the display rules above (buttons are
   inline-flex), or "hidden" buttons would still show. */
[hidden] { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand img { display: block; border-radius: 7px; }

/* Welcome page: one centred card, no header bar. */
.welcome { padding-top: 40px; }
.hero { justify-items: center; text-align: center; padding: 28px 20px; gap: 14px; }
.hero-mark { border-radius: 14px; }
.hero-title { margin: 0; font-size: 26px; line-height: 1.2; }
.hero-lead { font-size: 17px; }
.hero .actions { width: 100%; }
.points { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; text-align: left; font-size: 15px; }
.points li { padding-left: 26px; position: relative; }
.points li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  width: 12px;
  height: 7px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

/* Set-up steps: "1 Company  2 Team". */
.steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; font-size: 14px; color: var(--muted); }
.steps li { display: flex; align-items: center; gap: 6px; flex: 1 1 0; padding-bottom: 8px; border-bottom: 3px solid var(--border); }
.steps .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
}
.steps .current, .steps .done { border-bottom-color: var(--accent); }
.steps .current { color: var(--text); font-weight: 600; }
.steps .current .num, .steps .done .num { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

.optional { font-size: 13px; color: var(--muted); opacity: 0.85; }
.center { text-align: center; }
.row h2 { flex: 0 1 auto; }
.row .spacer { flex: 1 1 0; }

/* Small but still a 40px touch target, per the UI standard. */
button.small { padding: 4px 12px; font-size: 14px; }

/* City / State / ZIP share a row once there is room; stacked on narrow phones. */
.grid-3 { display: grid; gap: 10px; }
@media (min-width: 360px) {
  .grid-3 { grid-template-columns: 2fr 1fr 1fr; }
}

/* Tick box with its label beside it. The whole row is the 40px touch target. */
label.check { display: flex; align-items: center; gap: 10px; min-height: 40px; text-align: left; color: var(--text); font-size: 15px; cursor: pointer; }
label.check input { width: 22px; height: 22px; min-height: 0; padding: 0; flex: 0 0 auto; accent-color: var(--accent); }

/* A small tab strip under the header. Only the Metivo admin screen uses it
   now (Companies, Plans); the app's own sections are in .menu further down. */
.tabs { display: flex; gap: 4px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.tab {
  white-space: nowrap;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--action); }

/* A long job name in the header shortens instead of pushing Sign out away. */
/* min-width keeps short names (Jobs, Team) whole; only long job names shorten. */
.page-name { flex: 0 1 auto; min-width: 3em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* On a narrow phone the company name gives way before the page name does. */
.header .who { flex-shrink: 1000; }

/* Job board. */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar input { flex: 1 1 180px; width: auto; }
.groups, .group { display: grid; gap: 10px; }
.group-title { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; font-size: 15px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); flex: 0 0 auto; }
.card.job { cursor: pointer; }
a.card.job { color: inherit; text-decoration: none; gap: 2px; }
.card.job:hover { border-color: var(--muted); }
.center-self { justify-self: center; }
a.back { color: var(--muted); font-size: 14px; text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; justify-self: start; }

/* One job. */
.grid-2 { display: grid; gap: 10px; }
@media (min-width: 360px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}
.notes { white-space: pre-wrap; }
.tasks .task { display: flex; align-items: center; gap: 10px; }
.tasks .task .check { flex: 1 1 auto; min-width: 0; }
.task-title.done { text-decoration: line-through; color: var(--muted); }
.due { display: block; }

/* Settings: one phase per row; colour and name on top, actions underneath. */
/* A label in Settings is one compact line: a small color dot, its name, then
   move and remove. Each control keeps a 40px tap height. */
.list > li.phase { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding-top: 6px; }
.list:has(> li.phase) { gap: 6px; }
.phase input[type="color"] { flex: 0 0 32px; width: 32px; height: 40px; padding: 6px 2px; border: 0; background: transparent; }
.phase .phase-name { flex: 1 1 70px; min-width: 0; min-height: 40px; padding: 6px 10px; font-size: 15px; }
.phase .check { font-size: 14px; }
.phase-actions { display: inline-flex; flex: 0 0 auto; }
.phase-actions .icon-btn { border-color: transparent; background: transparent; width: 36px; }
.form.inline-2 { grid-template-columns: 1fr auto; align-items: end; }

/* On phones the logo alone stands for the brand, leaving the header's one row
   to the page name and the company. */
@media (max-width: 479px) {
  .brand-name { display: none; }
}

/* A label chip with its colour dot (phase on a job card). */
.chip.with-dot { display: inline-flex; align-items: center; gap: 6px; }
.chip.with-dot .dot { width: 9px; height: 9px; }

/* Pill filters (files, checks, templates, invoices): one tap each, always
   visible. They wrap rather than scroll sideways on a narrow phone. */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter { border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 600; gap: 6px; }
.filter .count { color: var(--muted); font-weight: 500; }
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.filter[aria-pressed="true"] .count { color: #c9cfd3; }
.filter.flagged:not([aria-pressed="true"]) { border-color: var(--danger); color: var(--danger); }

/* Board status filter: an icon in the toolbar with the picker laid invisibly
   over it, and one line that says which status is showing. A red dot on the
   icon means something needs attention. */
.pick-over { position: relative; }
.pick-over select { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; }
.pick-over:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.pick-over.flagged::after { content: ""; position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.showing { margin: 0; font-size: 14px; font-weight: 600; display: flex; gap: 6px; }
.showing .count { color: var(--muted); font-weight: 500; }
/* One column that may be narrower than its content asks for: without this a
   row that does not wrap (the toolbar) would push the page wider than a phone. */
.main { grid-template-columns: minmax(0, 1fr); }
.toolbar { flex-wrap: nowrap; }
.toolbar input { flex: 1 1 0; min-width: 0; }

/* Icon actions (UI standard): a small drawing in a 40px touch area. Quiet by
   default so a card reads as content, not as a row of buttons. */
.icon-btn {
  width: 40px; height: 40px; min-height: 40px; padding: 0; flex: 0 0 40px;
  border-color: transparent; background: transparent; color: var(--muted); border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover, .icon-btn[aria-pressed="true"] { background: var(--bg); color: var(--text); }
.icon-btn.primary { background: var(--action); border-color: var(--action); color: var(--action-text); }
.icon-btn:disabled { opacity: 0.35; }
/* A card's heading: title and chips wrap on the left, icons hold the corner
   without adding height. */
.head { display: flex; align-items: flex-start; gap: 2px; }
.head > .row { flex: 1 1 0; min-width: 0; min-height: 24px; }
.head .icon-btn { margin: -8px 0; }
.head .icon-btn:last-child { margin-right: -8px; }
.card .head h2 { font-size: 16px; }

/* Something late or waited on too long. Always said in words as well. */
.flag { color: var(--danger); font-weight: 600; }
h2.flag { font-weight: 700; }

/* A chip tinted with a label's own colour (set from script); dark text on a
   light wash stays readable whatever colour the company picked. */
.chip.tint { color: var(--text); font-weight: 600; }

/* Job card: step strip, what is next or late, and for owners the money bar. */
.card.job { gap: 6px; }
/* Phase and status pickers on the card: chip-shaped, as tall as any control.
   They may shrink (cutting the text with …) but never push the card wider. */
/* A narrow pill with one small arrow, so two pickers fit beside the job name. The picker itself reaches a little past the pill above and below to keep a 40px touch target. */
.pill.pick-over { display: inline-flex; align-items: center; flex: 0 1 auto; min-width: 0; max-width: 100%; min-height: 32px; padding: 0 22px 0 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: #fff url(/chevron.svg) no-repeat right 8px center / 10px 10px; }
.pill.pick-over > span { overflow: hidden; text-overflow: ellipsis; }
.pill.pick-over select { inset: -6px 0; height: calc(100% + 12px); }
.card.job .row, .card.job .picks { min-width: 0; max-width: 100%; }
/* Short job names share the line with both pickers; a long name keeps its full text and the pickers drop below it. */
.card.job .picks { flex-wrap: wrap; gap: 6px; }
.card.job .picks .name { flex: 1 1 auto; }
.card.job .chip { overflow-wrap: anywhere; }
.strip { display: flex; gap: 4px; }
.seg { flex: 1 1 0; height: 6px; border-radius: 3px; background: var(--border); }
.seg.done { background: #17a05a; }
.seg.now { background: var(--action); }
.banner { background: var(--wash); color: var(--wash-text); border-radius: 8px; padding: 6px 10px; font-size: 14px; font-weight: 600; }
.banner.late { background: #fde7e9; color: var(--danger); }
.pay { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.bar { appearance: none; -webkit-appearance: none; flex: 1 1 60px; min-width: 40px; height: 8px; border: 0; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar::-webkit-progress-bar { background: var(--border); border-radius: 999px; }
.bar::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.bar::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.amount { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.amount.total { font-size: 15px; }

/* Job facts: small label over its value, two across. */
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 14px; }
.facts span { display: block; color: var(--muted); font-size: 12px; }
.facts:empty { display: none; }

/* Lines inside a card (schedule steps, payments, costs): tick, what, when. */
.lines { list-style: none; margin: 0; padding: 0; }
.lines > li { border-top: 1px solid #eceff0; }
.lines > li:first-child { border-top: 0; }
.line { display: flex; align-items: center; gap: 8px; padding: 4px 0; min-height: 48px; color: inherit; text-decoration: none; }
.line .what { flex: 1 1 0; min-width: 0; display: grid; }
.line .what b { font-weight: 600; }
.line .what span { color: var(--muted); font-size: 13px; }
.line .what span.flag { color: var(--danger); }
.line .when { font-size: 13px; color: var(--muted); text-align: right; white-space: nowrap; }
.line .when.amount { font-size: 14px; color: var(--text); }
.line .when.flag { color: var(--danger); }

/* The round tick. The button is a 40px touch area; the ring is drawn inside it. */
.tick {
  width: 40px; height: 40px; min-height: 40px; padding: 0; flex: 0 0 40px; margin-left: -9px;
  border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: #fff;
}
.tick::before { content: ""; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #b9c0c4; box-sizing: border-box; position: absolute; }
.tick { position: relative; }
.tick.now::before { border-color: var(--action); background: var(--wash); }
.tick.done::before { border-color: #17a05a; background: #17a05a; }
.tick svg { position: relative; width: 14px; height: 14px; stroke-width: 3; }

/* A date shown as words; tapping it opens the phone's date picker, which
   belongs to the invisible date box behind it. */
.date-wrap { position: relative; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: flex-end; min-width: 56px; min-height: 44px; border-radius: 8px; }
.date-wrap:hover { background: var(--bg); }
.date-wrap:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.date-btn { padding: 4px 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
/* The real date box covers the words and is see-through, so the tap lands on
   it and the phone opens its own picker. */
input.picker { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; min-width: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }

/* An add form opened inside a card. */
.form.add { border-top: 1px solid #eceff0; padding-top: 10px; }
.grid-2 input, .grid-3 input { min-width: 0; }
button.link, a.link { border: 0; background: transparent; color: var(--focus); font-weight: 600; padding: 0 2px; justify-self: start; text-decoration: underline; }

/* Settings: a milestone is a name, its percent, and remove, on one row. */
.milestone-main { display: flex; align-items: center; gap: 8px; }
.milestone-main input:first-child { flex: 1 1 auto; min-width: 0; }
.milestone-main input:nth-child(2) { flex: 0 0 76px; width: 76px; }

/* Documents and signing. */
.banner.ok { background: #e6f4ea; color: #17592f; }
.row.nowrap { flex-wrap: nowrap; }
.row.nowrap input { flex: 1 1 0; min-width: 0; }
.fingerprint { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.signature { width: 100%; max-width: 420px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.signature polyline { fill: none; stroke: var(--text); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
/* The signature pad: a finger draws here, so the page must not scroll under it. */
.pad { width: 100%; aspect-ratio: 10 / 3; border: 1px dashed var(--muted); border-radius: 8px; background: var(--surface); touch-action: none; cursor: crosshair; }
a.button svg { margin-right: 6px; }
input[type="file"] { padding: 6px; }

/* My work: the address box that opens Maps and the site contact row. */
.over { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 4px 2px 0; }
.place { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; color: inherit; text-decoration: none; }
.place span { flex: 1 1 0; min-width: 0; overflow-wrap: anywhere; }
.place svg { flex: 0 0 auto; color: var(--muted); }
.contact { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 a { color: inherit; text-decoration: none; }
label.sees { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin-top: 4px; }
label.sees select { flex: 0 1 220px; min-width: 0; }
[hidden] { display: none !important; }

/* iPhone date boxes size themselves by their contents and center the text,
   which pushed "End date" off the screen. Make them behave like other boxes. */
input[type="date"], input[type="datetime-local"], input[type="time"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; text-align: left; }
input::-webkit-date-and-time-value { text-align: left; }
.grid-2 > *, .grid-3 > *, .form > * { min-width: 0; }

/* Job page: the back link sits close under the tabs. */
a.back { margin: -10px 0 -8px; }

/* Paper clip beside a line's name: grey with no file, Metivo amber with one
   (drawn a little heavier so the amber reads clearly on white). */
.line { flex-wrap: wrap; }
.line .title { display: flex; align-items: center; gap: 2px; min-width: 0; }
.line .title b, .line .title input { min-width: 0; }
.clip { color: #9aa0a6; border-color: transparent; background: transparent; margin: -8px 0; }
.clip.has { color: var(--action); }
.clip.has svg { stroke-width: 2.6; }
span.clip { display: inline-flex; align-items: center; justify-content: center; width: 28px; }
.clip svg { width: 18px; height: 18px; }
.files { flex: 0 0 100%; list-style: none; margin: 0 0 6px; padding: 0 0 0 40px; display: grid; gap: 2px; }
.files li { display: flex; align-items: center; gap: 4px; min-width: 0; }
.files .link { flex: 1 1 0; min-width: 0; text-align: left; overflow-wrap: anywhere; min-height: 40px; }
a.link { display: inline-flex; align-items: center; min-height: 40px; }
.files .link { justify-content: flex-start; }
.facts > div { min-width: 0; }
.facts a.wrap { overflow-wrap: anywhere; }

/* Pull down to refresh. The page itself must not bounce or trigger the
   browser's own reload, or two refreshes would fight each other. */
html { overscroll-behavior-y: contain; }
.puller { position: fixed; top: 0; left: 50%; z-index: 20; width: 40px; height: 40px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); display: flex; align-items: center; justify-content: center; color: var(--muted); transform: translate(-50%, -48px); pointer-events: none; }
.puller.ready { color: var(--text); border-color: var(--action); }
.puller.spin svg { animation: puller-spin 0.7s linear infinite; }
@keyframes puller-spin { to { transform: rotate(-360deg); } }
@media (prefers-reduced-motion: reduce) { .puller.spin svg { animation: none; } }

/* Sign out in the dark header: a light icon, no box. */
.header .icon-btn { color: #fff; border-color: transparent; background: transparent; flex: 0 0 auto; }
.header .icon-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* Check register and the job's Profit card. */
.stack { display: grid; gap: 10px; }
.sum { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 14px; }
.sum span { color: var(--muted); min-width: 0; }
.sum b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sum.total { border-top: 1px solid #eceff0; padding-top: 8px; font-size: 16px; }
.sum.total span { color: var(--text); font-weight: 700; }
.sum.total b { color: #17592f; }
.sum.total.over b { color: var(--danger); }
.card.sum.total { border-top: 1px solid var(--border); padding-top: 14px; flex-direction: row; }
.card.sum.total b { color: var(--text); }
.chip.tint { background: var(--wash); border-color: var(--wash); color: var(--wash-text); }
a.chip { text-decoration: none; color: var(--text); }
.card > .files { padding-left: 0; }
/* Settings: where the check register is kept. */
.opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.opt > div { display: grid; gap: 2px; min-width: 0; }
.opt.on { border-color: var(--action); background: #f3f8ff; }
.opt:not(.on) { opacity: 0.6; }
.radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #b9c0c4; flex: 0 0 auto; margin-top: 2px; }
.opt.on .radio { border-color: var(--action); background: radial-gradient(var(--action) 45%, #fff 50%); }

/* Modules card (Settings) and the Metivo admin. */
.switch { width: 52px; min-width: 52px; height: 40px; padding: 0; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
.switch span { width: 44px; height: 26px; border-radius: 999px; background: #c9cfd3; position: relative; transition: background 0.15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch[aria-checked="true"] span { background: var(--action); }
.switch[aria-checked="true"] span::after { left: 21px; }
.switch:disabled { opacity: 0.5; cursor: default; }
.chip.plan { background: var(--accent); border-color: transparent; color: #fff; }
.lines .line.locked .what { opacity: 0.5; }
fieldset.boxes { border: 0; padding: 0; margin: 0; display: grid; }
fieldset.boxes legend { font-size: 14px; font-weight: 600; color: var(--muted); padding: 0; margin-bottom: 2px; }
fieldset.boxes label.check + label.check { border-top: 1px solid #eceff0; }
.row select.plan-pick { width: auto; flex: 0 0 auto; max-width: 50%; }
.row .name { min-width: 0; overflow-wrap: anywhere; }

/* A confirmation that floats for a few seconds (see toast() in app.js). */
.toast { position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); margin: 0; z-index: 30; background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 14px; font-size: 15px; font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); width: max-content; max-width: calc(100vw - 32px); text-align: center; }
/* Phase and group pickers on the job card. */
.status label { font-size: 12px; color: var(--muted); }

/* Record payment on the job's Payments card. */
button.wide { width: 100%; }
.line .when small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); text-align: right; }
.files li > span { flex: 1 1 auto; min-width: 0; font-size: 14px; }

/* Invoicing: a real choice between two options (Settings), the "Invoice when"
   picker under each milestone, and the client's invoice page. */
.opts { display: grid; gap: 8px; }
.opt.pick { opacity: 1; width: 100%; justify-content: flex-start; min-height: 44px; align-items: center; text-align: left; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.opt.pick.on { background: #f3f8ff; }
.opt.pick:disabled { cursor: default; }
.opt.pick .radio { margin-top: 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting-row > div { display: grid; gap: 2px; min-width: 0; }
.setting-row b { color: var(--text); font-size: 15px; }
.setting-row select { width: auto; flex: 0 0 auto; min-height: 40px; }
.milestone-when { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.milestone-when select { width: auto; max-width: 62%; min-height: 40px; }
.card.invoice { display: grid; gap: 6px; }
.card.invoice > b { margin-top: 8px; }
.inv-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 15px; }
.inv-row:first-of-type { margin-top: 8px; }
.inv-row.total { font-weight: 700; }
.inv-row span:last-child { white-space: nowrap; }
.setting-row input.short { width: 110px; flex: 0 0 auto; text-align: right; }
/* Clients list: the search box and its plus stay on one line. */
.row.search-row { flex-wrap: nowrap; }
.row.search-row input { flex: 1 1 0; min-width: 0; }

/* Files cards: a tinted file mark, and the whole row opens the file. */
.file-icon { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: #eef1f2; color: var(--muted); }
.file-icon.pdf { background: #fdecea; color: #b3261e; }
.file-icon.img { background: #e7f3ec; color: #1f6b43; }
.file-icon.dir { background: #fdf3dc; color: #8a5a00; }
.file-open { flex: 1 1 0; min-width: 0; min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; text-align: left; color: inherit; font: inherit; }
.card .filters { margin-bottom: 6px; }

/* The menu. On a phone it is fixed along the bottom, like an app: four places
   plus More. From 900px it runs down the left side and lists every section,
   so More and the phone-only pieces are hidden there. */
.menu { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
.menu-item { flex: 1 1 0; min-width: 0; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none; border-radius: 10px; }
.menu-item span { white-space: nowrap; }
.menu-item[aria-current="page"] { color: var(--text); }
.menu-item[aria-current="page"] svg { color: var(--action); }
/* Room for the fixed menu under the last card. */
body:has(.menu) .main { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
@media (max-width: 899px) { .wide-only { display: none !important; } }
@media (min-width: 900px) {
  .phone-only { display: none !important; }
  .menu { top: 0; right: auto; width: 200px; flex-direction: column; gap: 2px; padding: 68px 10px 10px; border-top: 0; border-right: 1px solid var(--border); }
  .menu-item { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 0 12px; font-size: 15px; min-height: 44px; }
  .menu-item[aria-current="page"] { background: #eef1f2; }
  body:has(.menu) { padding-left: 200px; }
  body:has(.menu) .main { padding-bottom: 16px; }
  /* The header spans the full width, over the top of the side menu. */
  body:has(.menu) .header { margin-left: -200px; position: relative; z-index: 21; }
}

/* Tabs of a job or client page; they stay in view while the page scrolls. */
.subtabs { position: sticky; top: 0; z-index: 10; display: flex; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 8px; }
.subtabs button { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 4px; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; color: var(--muted); font-weight: 600; font-size: 15px; white-space: nowrap; }
.subtabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--action); }
@media (min-width: 900px) { .subtabs { justify-content: center; } .subtabs button { flex: 0 0 150px; } }
/* A row that is a button (Sign out under More) looks like the link rows beside it. */
button.as-row { width: 100%; border: 0; background: none; text-align: left; font: inherit; border-radius: 0; }
.panel { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.panel[hidden] { display: none; }
.menu-item { overflow: hidden; }

/* Connections: a colored letter stands for each outside service. */
.service-mark { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px; display: inline-grid; place-items: center; font-weight: 800; color: #fff; background: #5a6368; }
.service-mark.dropbox { background: #0061fe; }
.service-mark.box { background: #0f6fc6; }
.service-mark.gdrive { background: #1e8e3e; }
.service-mark.gmail { background: #d93025; }
.service-mark.quickbooks { background: #2ca01c; }
.service-mark.plaid { background: #111; }
.chip.ok { color: #17592f; border-color: #bfe3cb; background: #e6f4ea; }
button.danger { color: var(--danger); }
/* A card on the board never grows past its column. */
.groups > .card.job { min-width: 0; max-width: 100%; }

/* Estimate tab: the client's form as categories that open to their lines. */
.est-total { font-size: 24px; font-weight: 800; }
.est-head { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; }
.est-head label { min-width: 0; font-size: 13px; color: var(--muted); }
.est-head input, .est-head select { width: 100%; min-width: 0; }
.est-cat { border-top: 1px solid #eceff0; }
.est-cat summary { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; list-style: none; font-weight: 600; }
.est-cat summary::-webkit-details-marker { display: none; }
.est-cat .est-name { flex: 1 1 auto; min-width: 0; }
.est-cat.empty summary { color: var(--muted); font-weight: 500; }
.est-flags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.est-lines { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.est-line { display: grid; grid-template-columns: 1fr 112px; gap: 6px 8px; align-items: center; }
.est-line .est-item { font-size: 14px; min-width: 0; }
.est-line .est-amount { text-align: right; min-width: 0; }
.est-line .est-comment { grid-column: 1 / -1; font-size: 14px; min-width: 0; }
.est-line .icon-btn { grid-column: 2; justify-self: end; }
.est-cat summary .amount, .card > .row > .amount { white-space: nowrap; flex: 0 0 auto; }
.est-cat .est-name { overflow-wrap: break-word; }

/* QuickBooks: the small mark on a job's cards, and the job-to-project pickers on its connection screen. */
.service-mark.small { width: 24px; height: 24px; border-radius: 6px; font-size: 13px; }
.qb-link { flex-wrap: nowrap; }
.qb-link .what { flex: 0 1 40%; overflow-wrap: anywhere; }
select.qb-pick { flex: 1 1 0; min-width: 0; width: auto; min-height: 40px; text-overflow: ellipsis; }
select.qb-pick.unset { color: var(--danger); border-color: var(--danger); }

/* Reconcile: the four totals, the month picker, and a statement line with the trail of where it was found. */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.tile b { display: block; font-size: 19px; overflow-wrap: anywhere; }
.tile span { color: var(--muted); font-size: 13px; }
.tile.bad b { color: var(--danger); }
select.month-pick { width: auto; min-height: 40px; font-weight: 600; }
.tx { padding: 10px 0; display: grid; gap: 6px; }
.tx .row { align-items: flex-start; flex-wrap: nowrap; }
.tx .what { flex: 1 1 0; min-width: 0; display: grid; overflow-wrap: anywhere; }
.tx .amount { white-space: nowrap; font-weight: 700; }
.tx .amount.in { color: #17592f; }
.trail { display: flex; flex-wrap: wrap; gap: 5px; }
.src { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 2px 7px; background: #eef1f6; color: var(--muted); overflow-wrap: anywhere; }
.src.ok { background: #e6f4ea; color: #17592f; }
.src.ok::after { content: " \2713"; }
.src.no { background: #fdecea; color: var(--danger); }
.src.job { background: var(--wash); color: var(--wash-text); }
.recon-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.recon-edit select[name="qb"], .recon-edit input[name="note"] { grid-column: 1 / -1; }
.recon-edit > * { min-width: 0; }
.recon-edit button { grid-column: 1 / -1; justify-self: start; }
