/* Tradescom web.
 *
 * Sized for one hand, in a truck, in sun. Big tap targets (44px floor), high
 * contrast, dark by default because that is what a phone on a dash is set to
 * and a white screen at 6am is a flashbang.
 */

:root {
  --bg: #101418;
  --card: #191f26;
  --card-2: #212a33;
  --line: #2c3742;
  --ink: #f2f5f7;
  --ink-dim: #9aa7b4;
  --accent: #3d8bfd;
  --ok: #2fb673;
  --warn: #e0a33a;
  --bad: #e5644f;
  --radius: 12px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --card-2: #eef1f4;
    --line: #d9dfe5;
    --ink: #121820;
    --ink-dim: #5d6b78;
    color-scheme: light;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 12px calc(32px + env(safe-area-inset-bottom));
}

main.centered {
  min-height: 100dvh;
  display: flex;
  align-items: center;
}

h1 {
  font-size: 22px;
  margin: 0 0 4px;
}
h3 {
  font-size: 15px;
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}
h4 {
  font-size: 13px;
  margin: 14px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}
p {
  margin: 0 0 8px;
}

.muted {
  color: var(--ink-dim);
}
.small {
  font-size: 13px;
}
.error {
  color: var(--bad);
}
.pad {
  padding: 24px 4px;
}

/* --- header ------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 2px 10px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.top-left {
  flex: 1;
  min-width: 0;
}
.company {
  font-weight: 650;
  font-size: 17px;
}

.icon {
  min-width: 44px;
  min-height: 44px;
  font-size: 20px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

/* --- day bar ------------------------------------------------------------ */

.daybar {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 10px;
}
.daybar .day {
  flex: 1;
  min-height: 44px;
  font-size: 17px;
  font-weight: 600;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.scope {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.chip {
  flex: 1;
  min-height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  font-size: 15px;
  cursor: pointer;
}
.chip.on {
  background: var(--card-2);
  color: var(--ink);
  border-color: var(--accent);
}

/* --- banners ------------------------------------------------------------ */

.banner {
  padding: 10px 12px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 14px;
  border: 1px solid var(--line);
  background: var(--card);
}
.banner.ok {
  border-color: var(--ok);
}
.banner.warn {
  border-color: var(--warn);
}
.banner.error {
  border-color: var(--bad);
  color: var(--bad);
}

/* --- cards -------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  width: 100%;
}
.signin {
  display: flex;
  flex-direction: column;
}
.signin label {
  font-size: 13px;
  color: var(--ink-dim);
  margin: 10px 0 4px;
}
input {
  min-height: 48px;
  font-size: 16px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
}

button,
.button {
  font: inherit;
}
.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  min-height: 48px;
  border-radius: var(--radius);
  margin-top: 16px;
  font-weight: 600;
  cursor: pointer;
}
.primary:disabled {
  opacity: 0.6;
}

.link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 15px;
  padding: 12px 4px;
  cursor: pointer;
}
.refresh {
  display: block;
  margin: 4px auto 0;
}

ul.plain {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
ul.plain li {
  margin-bottom: 8px;
}
.row-button {
  width: 100%;
  text-align: left;
  min-height: 48px;
  padding: 0 14px;
  background: var(--card-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}
.row-button.on {
  border-color: var(--accent);
}

/* --- stops -------------------------------------------------------------- */

.stops {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stop {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.stop.is-live {
  border-left-color: var(--ok);
}
.stop.is-dead {
  opacity: 0.55;
}

.when {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 6px;
}
.time {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 15px;
  color: var(--ink-dim);
}

.badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  white-space: nowrap;
}
.badge.live {
  border-color: var(--ok);
  color: var(--ok);
}
.badge.done {
  border-color: var(--line);
}
.badge.dead {
  border-color: var(--bad);
  color: var(--bad);
}

.who {
  font-size: 19px;
  font-weight: 650;
  line-height: 1.2;
}
.where {
  margin-top: 2px;
  font-size: 15px;
  color: var(--ink);
}
.what {
  margin-top: 6px;
  font-size: 15px;
  color: var(--ink-dim);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.tag {
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--card-2);
  color: var(--ink-dim);
}
.tag.warn {
  color: var(--warn);
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.actions .button {
  flex: 1;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.actions .button.primary {
  margin-top: 0;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.expand {
  padding: 10px 0 0;
}
.detail {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.note {
  white-space: pre-wrap;
  font-size: 15px;
}

.empty {
  text-align: center;
  padding: 40px 12px;
  color: var(--ink-dim);
}

.loading {
  padding: 40px;
  text-align: center;
  color: #9aa7b4;
}

/* ==========================================================================
 * SHARED FILE — three agents write here.
 *
 * app.css is owned by W3 above this line. W1 (a tech's day) and W2 (the money
 * book) append INSIDE their own block below and nowhere else, so that two
 * people editing the same file never touch the same bytes.
 *
 * House rules for both blocks:
 *   - Use the variables from :root at the top. Do not hardcode a hex.
 *   - 44px minimum on anything tappable; this is used at arm's length.
 *   - Both light and dark must be legible. There is one media query above and
 *     it flips the variables — if you need a new colour, add the variable in
 *     BOTH :root and the light block rather than a colour here.
 *   - No @import, no url() to another host. The page must load with no network.
 * ========================================================================== */

/* --- W1: a tech's day (notes, photos, close-out) ------------------------- */
/* W1: append below this line. */

/* --- end W1 -------------------------------------------------------------- */

/* --- W2: the money book (invoices, estimates) ---------------------------- */
/* W2: append below this line. */

/* --- end W2 -------------------------------------------------------------- */

/* W2: the money book (Lane G2). Appended block — nothing above this line was
 * changed. Every selector is prefixed `.mb-` so it cannot reach the day list.
 * ------------------------------------------------------------------------- */

/* --- the money, first ---------------------------------------------------- */

.mb-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.mb-hero-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
}
.mb-hero-amount {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 2px 0 4px;
}
.mb-hero-sub {
  font-size: 14px;
  color: var(--ink-dim);
}
.mb-hero-collected {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-dim);
}

.mb-bar {
  display: flex;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 10px;
  background: var(--card-2);
  gap: 2px;
}
.mb-seg {
  min-width: 3px;
}
.mb-seg-bad {
  background: var(--bad);
}
.mb-seg-warn {
  background: var(--warn);
}
.mb-seg-ok {
  background: var(--ok);
}
.mb-seg-flat {
  background: var(--ink-dim);
}

.mb-legend {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mb-legend li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  padding: 3px 0;
}
.mb-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: 0 0 auto;
}
.mb-legend-label {
  flex: 1;
  color: var(--ink-dim);
}
.mb-legend-amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.mb-legend-n {
  color: var(--ink-dim);
  font-size: 12px;
  min-width: 84px;
  text-align: right;
}

.mb-notes {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.mb-note {
  font-size: 13px;
  color: var(--warn);
  margin: 0 0 6px;
}

/* --- controls ------------------------------------------------------------ */

.mb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.mb-tabs .chip {
  flex: 1;
}

.mb-searchrow {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.mb-search {
  flex: 1;
  min-width: 0;
}
.mb-searchgo {
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  cursor: pointer;
}

.mb-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}
.mb-chips .chip {
  flex: 0 0 auto;
  padding: 0 14px;
  white-space: nowrap;
}

.mb-range {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.mb-date-input {
  min-height: 44px;
  flex: 1 1 120px;
  min-width: 0;
}

.mb-scope {
  font-size: 13px;
  color: var(--ink-dim);
  margin: 0 2px 10px;
}

/* --- rows ---------------------------------------------------------------- */

.mb-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mb-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.mb-row.is-live {
  border-left-color: var(--accent);
}
.mb-row.is-open {
  border-color: var(--accent);
}

.mb-rowmain {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--ink);
  padding: 12px 14px 10px;
  cursor: pointer;
  font: inherit;
}
.mb-rowtop {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  color: var(--ink-dim);
  margin-bottom: 4px;
}
.mb-date {
  font-variant-numeric: tabular-nums;
}
.mb-id {
  font-variant-numeric: tabular-nums;
  background: var(--card-2);
  border-radius: 5px;
  padding: 1px 6px;
}
.mb-rowbody {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.mb-rowtext {
  flex: 1;
  min-width: 0;
}
.mb-cust {
  font-size: 17px;
  font-weight: 650;
  line-height: 1.2;
}
.mb-title {
  font-size: 14px;
  color: var(--ink-dim);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mb-status {
  font-size: 13px;
  margin-top: 5px;
}
.mb-ok {
  color: var(--ok);
}
.mb-warn {
  color: var(--warn);
}
.mb-bad {
  color: var(--bad);
}
.mb-flat {
  color: var(--ink-dim);
}

.mb-amt {
  text-align: right;
  flex: 0 0 auto;
}
.mb-amt-main {
  font-size: 18px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.mb-amt-sub {
  font-size: 12px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
.mb-amt-owed {
  font-size: 13px;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

.mb-rowactions {
  display: flex;
  gap: 8px;
  padding: 0 14px 12px;
}
.mb-rowaction {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
.mb-rowactions:empty {
  display: none;
}

.mb-detail {
  border-top: 1px solid var(--line);
  padding: 10px 14px 14px;
  background: var(--card-2);
}
.mb-lines {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}
.mb-lines li {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.mb-totals li:last-child {
  font-weight: 700;
  border-bottom: none;
}
.mb-line-name {
  flex: 1;
  min-width: 0;
}
.mb-line-amt {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mb-dim {
  color: var(--ink-dim);
}
.mb-link {
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.mb-foot {
  margin: 18px 2px 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

/* W1: a tech's day — notes, photos, close-out.
 *
 * Appended in one marked block because three agents are writing in this
 * directory tonight. Nothing above this line has been changed. Two rules below
 * deliberately re-state an existing selector rather than editing it, and both
 * say why.
 *
 * Colour: tokens only. Amber and red are used for BORDERS and dots, never for
 * body text — `--warn` on `--card` measures about 2:1 in light mode, which is
 * the "invisible in one mode" defect the native app has already paid for. The
 * words stay `--ink` in both modes; the colour carries the signal.
 */

/* W1: four action chips on a stop card wrapped instead of truncating.
 * The native visit row shows `Step…` `Left` `Mark…` `…` at four chips; this is
 * the same bug arriving on the web, and `flex-wrap` is the whole fix. */
.actions {
  flex-wrap: wrap;
}
.actions .button {
  flex: 1 1 40%;
  min-width: 40%;
}

/* W1: the record meter — 2 photos and a note, counted live. */
.meter {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--card);
}
.meter.is-ok {
  border-left-color: var(--ok);
}
.meter.is-thin {
  border-left-color: var(--warn);
}
.meter-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.meter-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
  background: var(--ink-dim);
}
.meter-dot.ok {
  background: var(--ok);
}
.meter-dot.thin {
  background: var(--warn);
}
.meter-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.meter .composer,
.meter .photo-actions,
.meter .pending-photo {
  margin-top: 12px;
}

/* W1: typing — the note box and the caption box. */
textarea,
.note-box {
  width: 100%;
  font: inherit;
  font-size: 16px; /* below 16px iOS zooms the whole page on focus */
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  resize: vertical;
}
.caption-box,
.amount-box {
  width: 100%;
  margin-top: 8px;
}
.composer {
  display: flex;
  flex-direction: column;
}
.composer .primary {
  margin-top: 10px;
}

/* W1: the note feed. */
ul.notes li.note-row {
  border-top: 1px solid var(--line);
  padding: 10px 0 2px;
  margin-bottom: 0;
}
ul.notes li.note-row.is-queued {
  border-left: 3px solid var(--warn);
  padding-left: 10px;
}
.note-body {
  white-space: pre-wrap;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 2px;
}

/* W1: photos. */
.photo-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.photo-actions .button {
  flex: 1 1 40%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  cursor: pointer;
}
.photo-actions .button.primary {
  margin-top: 0;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.pending-photo {
  border: 1px dashed var(--warn);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 10px;
}
.tagrow {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.tagrow .chip {
  flex: 1 1 22%;
  min-height: 40px;
}
.strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.thumb {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card-2);
}
.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--card-2);
}
.thumb figcaption {
  display: block;
  padding: 8px 10px 0;
  font-size: 12px;
}
.thumb .cap {
  display: block;
  color: var(--ink);
  margin-bottom: 2px;
}
.thumb .link {
  padding: 6px 10px 8px;
}
.thumb-failed {
  padding: 24px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-dim);
}

/* W1: close-out choices — one screen, no dialog ladder. */
.choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-top: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  cursor: pointer;
}
.choice.on {
  border-color: var(--accent);
  border-left-width: 4px;
}
.choice-title {
  display: block;
  font-size: 16px;
  font-weight: 650;
}
.choice-sub {
  display: block;
  font-size: 13px;
  color: var(--ink-dim);
  margin-top: 2px;
}
.money-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.money-sign {
  font-size: 20px;
  font-weight: 650;
}
.select {
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  font: inherit;
  font-size: 16px;
  padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
}
.warnbox {
  border-color: var(--warn);
}
.errorbox {
  border-color: var(--bad);
}
.wide {
  width: 100%;
}

/* W1: Menu → What didn't save. */
.trouble-row {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.trouble-what {
  font-weight: 600;
  color: var(--ink);
}

/* W2 (cont.): drafts nobody has priced yet — out of the way of the money,
 * never out of sight. */
.mb-unpriced {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 10px 12px;
}
.mb-unpriced > summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-dim);
  min-height: 28px;
  display: flex;
  align-items: center;
}
.mb-unpriced[open] > summary {
  margin-bottom: 8px;
  color: var(--ink);
}
.mb-unpriced .mb-list {
  margin-top: 8px;
}

/* W2 (cont.): the back control on the money book is an <a>, and `.icon` was
 * written for a <button>. Centre its glyph and drop the underline without
 * touching the shared rule. */
.top a.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  line-height: 1;
}

/* W1: the menu's link out to the money book. `.row-button` was written for a
 * <button>; an <a> needs the box drawn explicitly or it collapses to a line of
 * text with no tap target. */
a.row-button {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
}

/* W1: label on the meter's inline fix-it block. */
.meter-label {
  margin-top: 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}

/* W1: a photo record whose file is not there says so. An empty square reads as
 * "no photo"; the truth is "a record pointing at a file that is missing". */
.thumb-failed {
  padding: 18px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

/* W1: the heading of a thumbnail that could not be shown. */
.thumb-failed-title {
  font-weight: 650;
}
