/* YardMate Residential — design system
   Layout: office dashboard = left rail + working canvas (bottom tabs on phones); crew app and homeowner portal = single phone column.
   The before/after photo pair is the signature element; everything else stays quiet. */
:root {
  --bg: #f2f5ef;          /* pale leaf */
  --surface: #ffffff;
  --surface-2: #e9efe6;
  --ink: #15241b;
  --muted: #526257;
  --line: #d9e2d6;
  --line-strong: #b9c9b6;
  --green: #1f6342;       /* YardMate green */
  --green-deep: #174b33;
  --green-soft: #dcebe0;
  --gold: #f2b63a;        /* YardMate gold, a touch deeper for white backgrounds */
  --gold-soft: #fff1cf;
  --sprout: #6fb57a;
  --ok: #1b7044; --ok-soft: #dff3e7;
  --warn: #c98a12; --warn-soft: #fbefd2;
  --bad: #c0392f; --bad-soft: #fbe3e0;
  --info: #2562b8; --info-soft: #e1ecfb;
  --map-land: #eef3ea; --map-grid: #dde6d8; --map-water: #cfe3f0; --map-label: #7f948a; --map-route: #1f6342; --map-done: #9db79f;
  --shadow: 0 1px 2px rgba(21, 36, 27, .06), 0 10px 30px -18px rgba(21, 36, 27, .25);
  --display: "Bricolage Grotesque", "Plus Jakarta Sans", "Helvetica Neue", Arial, sans-serif;
  --body: "Figtree", "Segoe UI", Roboto, Arial, sans-serif;
  --r: 12px; --r-sm: 8px; --r-lg: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1813; --surface: #16221b; --surface-2: #1d2c23; --ink: #e8efe9; --muted: #9fb0a3; --line: #263729; --line-strong: #3b5141;
    --green: #4fae7c; --green-deep: #3b8f63; --green-soft: #1b3326; --gold: #f6c75a; --gold-soft: #3a3012; --sprout: #5f9f6a;
    --ok: #4cc585; --ok-soft: #173427; --warn: #e6b04a; --warn-soft: #3a2d10; --bad: #ef7a6f; --bad-soft: #3d1d1a; --info: #6ea2ee; --info-soft: #182a44;
    --map-land: #152019; --map-grid: #1f2e24; --map-water: #16303f; --map-label: #6f877a; --map-route: #4fae7c; --map-done: #3f5a47;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1813; --surface: #16221b; --surface-2: #1d2c23; --ink: #e8efe9; --muted: #9fb0a3; --line: #263729; --line-strong: #3b5141;
  --green: #4fae7c; --green-deep: #3b8f63; --green-soft: #1b3326; --gold: #f6c75a; --gold-soft: #3a3012; --sprout: #5f9f6a;
  --ok: #4cc585; --ok-soft: #173427; --warn: #e6b04a; --warn-soft: #3a2d10; --bad: #ef7a6f; --bad-soft: #3d1d1a; --info: #6ea2ee; --info-soft: #182a44;
  --map-land: #152019; --map-grid: #1f2e24; --map-water: #16303f; --map-label: #6f877a; --map-route: #4fae7c; --map-done: #3f5a47;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -18px rgba(0,0,0,.7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
main > * { min-width: 0; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; line-height: 1.12; text-wrap: balance; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 28px; } h2 { font-size: 21px; } h3 { font-size: 16px; } h4 { font-size: 14px; }
p { margin: 0; }
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; display: block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hide { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; line-height: 1.2; white-space: nowrap; transition: background .15s, transform .08s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-deep); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1d1a0b; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: var(--surface); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.lg { padding: 14px 18px; font-size: 16px; border-radius: var(--r); }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }

/* Pills & status */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.gold { background: var(--gold-soft); color: #7a5a06; }
:root[data-theme="dark"] .pill.gold { color: var(--gold); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.gold { color: var(--gold); } }

/* Cards & panels */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.card.pad { padding: 16px; }
.card.raised { box-shadow: var(--shadow); border-color: transparent; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; }
.card-body { padding: 16px; }
.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; gap: 12px; align-items: center; padding: 12px 16px; }
.item.link { cursor: pointer; }
.item.link:hover { background: var(--surface-2); }

/* Forms */
.field { display: grid; gap: 6px; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.input, input.input, select.input, textarea.input { width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-width: 0; }
textarea.input { resize: vertical; min-height: 80px; }
.input:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: var(--green); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) { .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .15s; margin: 0; flex: none; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle input:checked { background: var(--green); }
.toggle input:checked::after { left: 19px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Avatar */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--green); flex: none; font-family: var(--display); }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }

/* Before / after pair — the signature */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; position: relative; }
.pair img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; background: var(--surface-2); }
.pair .tag { position: absolute; bottom: 8px; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: 4px; background: rgba(21,36,27,.75); color: #fff; }
.pair .tag.b { left: 8px; } .pair .tag.a { right: 8px; background: var(--green); }
.pair::after { content: "→"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 28px; height: 28px; border-radius: 50%; background: var(--gold); color: #1d1a0b; display: grid; place-items: center; font-weight: 800; font-size: 15px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.pair.lone::after, .pair.lone .tag.a { display: none; }
.pair.lone { grid-template-columns: 1fr; }

/* Stat tiles */
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 2px; }
.stat .v { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .d { font-size: 12px; color: var(--muted); }

/* Progress */
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .4s; }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.link { cursor: pointer; } .table tr.link:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
.table td.r, .table th.r { text-align: right; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 20, 14, .45); display: grid; place-items: end center; z-index: 50; padding: 0; }
.modal { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 20px max(16px, env(safe-area-inset-left, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; }
@media (min-width: 700px) { .modal-bg { place-items: center; padding: 20px; } .modal { border-radius: var(--r-lg); padding: 24px; } }

/* Empty state */
.empty { padding: 28px 16px; text-align: center; color: var(--muted); display: grid; gap: 6px; justify-items: center; }
.empty b { color: var(--ink); font-family: var(--display); font-size: 16px; }

/* Map */
.map { width: 100%; height: auto; border-radius: var(--r); border: 1px solid var(--line); font-family: var(--body); }
.map .pin { cursor: pointer; }

/* Phone frame for crew app & portal on wide screens */
.phone-wrap { min-height: 100%; display: grid; place-items: start center; padding-block: 24px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.phone { width: 100%; max-width: 430px; background: var(--surface); border-radius: 28px; border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; min-height: 760px; display: flex; flex-direction: column; position: relative; }
@media (max-width: 480px) { .phone-wrap { padding: 0; display: block; } .phone { max-width: none; border-radius: 0; border: 0; box-shadow: none; min-height: 100vh; } }
.phone-body { flex: 1; overflow: auto; padding: 16px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 14px; align-content: start; }
.phone-top { padding: 14px max(16px, env(safe-area-inset-left, 0px)) 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 2; }
.phone-nav { display: grid; grid-auto-flow: column; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom, 0px); }
.phone-nav button { border: 0; background: transparent; padding: 10px 4px 8px; display: grid; justify-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; }
.phone-nav button.on { color: var(--green); }
.phone-nav svg { width: 22px; height: 22px; }

/* Charts */
.chart { width: 100%; height: auto; font-family: var(--body); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid line { stroke: var(--line); }
.chart .axis line { stroke: var(--line-strong); }
.chart .cbar { fill: var(--green); }
.chart .cbar.soft { fill: var(--sprout); opacity: .55; }
.chart .line { fill: none; stroke: var(--green); stroke-width: 2; }
.chart .area { fill: var(--green); opacity: .12; }
.chart .dot { fill: var(--green); stroke: var(--surface); stroke-width: 2; }
.chart .val { fill: var(--ink); font-weight: 600; }

/* Kbd-ish code */
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

/* Company logo (uploaded) wherever the brand appears */
.brand-logo { height: 36px; width: auto; max-width: 140px; object-fit: contain; flex: none; border-radius: 4px; }
.brand-logo.sm { height: 28px; max-width: 72px; }
.brand-logo.lg { height: 56px; max-width: 200px; }
