/* stanley.mfautomations.ai — prototype styles (B1)
   Subject world: site plans, survey lines, plant schedules, aerials. Not a SaaS template. */

/* ---------- Tokens ---------- */
:root {
  --ground: #F2F4EF;
  --surface: #FFFFFF;
  --ink: #17231C;
  --muted: #5C6B62;
  --line: #D5DBD3;
  --accent: #2E6B3B;
  --accent-2: #1F7A93;
  --critical: #B3261E;
  --warn: #B26A00;
  --ok: #2E6B3B;
  --accent-ink: #FFFFFF;

  --font-display: 'Bricolage Grotesque', 'Georgia', serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius: 4px;
  --gutter: 16px;
  --maxw: 720px;
  --header-h: 96px;
  --bottombar-h: 84px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --transition-fast: 140ms ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0F1613;
    --surface: #172019;
    --ink: #E9EEE8;
    --muted: #9AA79E;
    --line: #26312A;
    --accent: #7CC28C;
    --accent-2: #6FC0D8;
    --critical: #F28B82;
    --warn: #E3A34D;
    --ok: #7CC28C;
    --accent-ink: #0F1613;
  }
}

:root[data-theme="dark"] {
  --ground: #0F1613;
  --surface: #172019;
  --ink: #E9EEE8;
  --muted: #9AA79E;
  --line: #26312A;
  --accent: #7CC28C;
  --accent-2: #6FC0D8;
  --critical: #F28B82;
  --warn: #E3A34D;
  --ok: #7CC28C;
  --accent-ink: #0F1613;
}

/* ---------- Reset / base ---------- */
* , *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  overflow-x: hidden;
  max-width: 100vw;
}
img, video { max-width: 100%; height: auto; display: block; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-2); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 4px; line-height: 1.15; }
p { margin: 0 0 10px; }
ul, ol { margin: 0; padding: 0; list-style: none; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Visible focus everywhere */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Shell / header / step rail ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-t);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 10px var(--gutter) 0;
}
.brand {
  display: inline-block; font-family: var(--font-display); font-weight: 700;
  font-size: 15px; letter-spacing: 0.01em; color: var(--ink); text-decoration: none;
  margin-bottom: 8px;
}
.brand small { display: block; font-family: var(--font-mono); font-weight: 400; font-size: 10px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.steprail { overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.steprail::-webkit-scrollbar { display: none; }
.steprail ol { display: flex; gap: 2px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.steprail li {
  padding: 4px 8px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent;
}
.steprail li[data-active="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.steprail li[data-done="true"]:not([data-active="true"]) { color: var(--ink); }

main#app { display: block; max-width: var(--maxw); margin: 0 auto; padding: 20px var(--gutter) calc(24px + var(--bottombar-h)); }
main#app.no-bottombar { padding-bottom: 32px; }

/* ---------- Section rule / slot rows ---------- */
.section-block { margin: 0 0 28px; }
.section-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px;
  border-top: 1px solid var(--line); padding-top: 10px;
}
.section-head .secnum { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.section-head h2 { font-size: 17px; }
.section-sub { color: var(--muted); font-size: 13px; margin: -4px 0 10px; }

.slot-row {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: start;
}
.slot-row.required { border-left: 3px solid var(--critical); padding-left: 10px; margin-left: -13px; }
.slot-id { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.slot-title { font-weight: 600; font-size: 15px; }
.slot-why { color: var(--muted); font-size: 13px; margin-top: 2px; }
.slot-badge {
  display: inline-block; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 2px 6px; border-radius: 3px; margin-left: 6px; vertical-align: middle;
  background: rgba(179,38,30,0.12); color: var(--critical);
}
.slot-status { grid-column: 1 / -1; }
.slot-thumb-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.slot-thumb { width: 84px; height: 60px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: var(--line); }
.slot-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.slot-warn { font-size: 12.5px; color: var(--warn); margin: 6px 0 0; padding-left: 18px; position: relative; }
.slot-warn::before { content: "!"; position: absolute; left: 0; top: -1px; font-family: var(--font-mono); font-weight: 700; }
.slot-ok { font-size: 12.5px; color: var(--ok); margin-top: 6px; }
.slot-skip-note { font-size: 12.5px; color: var(--muted); font-style: italic; margin-top: 6px; }
.progressbar { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progressbar > i { display: block; height: 100%; background: var(--accent-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 14px; padding: 10px 16px; transition: background var(--transition-fast), opacity var(--transition-fast);
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: 0.92; }
.btn-primary:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--line); }
.btn-ghost { background: transparent; color: var(--accent-2); border: none; padding: 6px 4px; }
.btn-danger { background: transparent; color: var(--critical); border-color: var(--critical); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Inputs ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="tel"], input[type="search"], input[type="number"], textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
input[type="file"] { display: none; }

/* ---------- Chips ---------- */
.chip-input-row { display: flex; gap: 8px; }
.chip-input-row input { flex: 1; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--line); color: var(--ink);
  border-radius: 999px; padding: 5px 10px 5px 12px; font-size: 13px;
}
.chip button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 0; }
.chip-req { background: rgba(179,38,30,0.12); color: var(--critical); }
.chip-prop { background: rgba(31,122,147,0.14); color: var(--accent-2); }

/* ---------- Toggle ---------- */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle .track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; flex: none;
  transition: background var(--transition-fast);
}
.toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform var(--transition-fast);
}
.toggle input:checked + .track { background: var(--ok); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- Stepper ---------- */
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stepper button {
  width: 32px; height: 32px; border: none; background: var(--surface); cursor: pointer; font-size: 16px; font-weight: 700; color: var(--ink);
}
.stepper button:hover { background: var(--line); }
.stepper output { min-width: 44px; text-align: center; font-family: var(--font-mono); font-size: 14px; padding: 0 4px; }

/* ---------- Plan row ---------- */
.plan-row { border-bottom: 1px solid var(--line); padding: 14px 0; }
.plan-row-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.plan-row h3 { font-size: 15px; }
.plan-row .location { color: var(--muted); font-size: 13px; margin: 3px 0 10px; }
.plan-row-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.plan-row .unit { font-size: 12px; color: var(--muted); margin-left: 6px; }
.plan-row .fixnote { margin-top: 10px; }
.plan-row .fixnote input { font-size: 13px; }
.hardscape-list { font-size: 13.5px; color: var(--ink); }
.hardscape-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* ---------- Notices / toast ---------- */
.notice {
  border: 1px solid var(--line); background: var(--surface); border-left: 3px solid var(--accent-2);
  padding: 10px 12px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 16px;
}
.notice.warn { border-left-color: var(--warn); }
.notice.critical { border-left-color: var(--critical); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bottombar-h) + 14px + var(--safe-b));
  transform: translateX(-50%); background: var(--ink); color: var(--ground);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity var(--transition-fast);
}
.toast.show { opacity: 1; }

/* ---------- Bottom action bar ---------- */
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px var(--gutter) calc(12px + var(--safe-b));
}
.bottom-bar-inner { max-width: var(--maxw); margin: 0 auto; }
.bottom-bar .missing { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.bottom-bar .missing strong { color: var(--critical); }

/* ---------- Start page ---------- */
.promise { font-size: 15px; color: var(--muted); margin-bottom: 22px; }
.county-detect { font-family: var(--font-mono); font-size: 12.5px; color: var(--accent); margin-top: 6px; min-height: 16px; }
.recent-list li {
  border-bottom: 1px solid var(--line); padding: 12px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.recent-list a { text-decoration: none; color: var(--ink); font-weight: 600; }
.recent-list .addr { display: block; font-weight: 600; color: var(--ink); }
.recent-list .meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.pill { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 7px; border-radius: 999px; background: var(--line); color: var(--muted); flex: none; }
.pill-delivered { background: rgba(46,107,59,0.15); color: var(--ok); }

/* ---------- Plate page ---------- */
#map { width: 100%; height: 260px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--line); }
.facts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 16px 0; }
.fact dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 2px; }
.fact dd { margin: 0; font-family: var(--font-mono); font-size: 15px; }
.stub-badge {
  display: inline-block; font-size: 11px; font-family: var(--font-mono); color: var(--warn);
  border: 1px dashed var(--warn); border-radius: var(--radius); padding: 4px 8px; margin: 10px 0;
}
.oblique-row { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; }
.oblique-row img { width: 120px; height: 90px; object-fit: cover; border-radius: var(--radius); flex: none; }

/* ---------- Placeholder blocks (no fake photos) ---------- */
.placeholder-block {
  border: 1px dashed var(--line); border-radius: var(--radius); background: rgba(92,107,98,0.06);
  display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted);
  font-size: 12.5px; padding: 24px 12px; min-height: 120px;
}

/* ---------- Before/after slider ---------- */
.ba-slider {
  position: relative; width: 100%; aspect-ratio: 4 / 3; overflow: hidden; border-radius: var(--radius);
  background: var(--line); touch-action: pan-y; user-select: none;
}
.ba-slider img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.ba-slider .ba-after-wrap { position: absolute; top: 0; left: 0; height: 100%; overflow: hidden; width: 50%; }
.ba-slider .ba-after-wrap img { width: var(--ba-img-w, 100%); max-width: none; }
.ba-handle {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 3px; background: var(--surface);
  transform: translateX(-50%); cursor: ew-resize; box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
}
.ba-handle::after {
  content: "\2194"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%; background: var(--surface); color: var(--ink);
  display: flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.ba-tag { position: absolute; top: 10px; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 3px 8px; border-radius: 3px; background: rgba(23,35,28,0.72); color: #fff; }
.ba-tag.before { left: 10px; }
.ba-tag.after { right: 10px; }

/* ---------- Stills grid ---------- */
.elevation-block { margin-bottom: 22px; }
.elevation-block h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.stills-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.still-card { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--line); }
.still-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.still-card figcaption { font-size: 11.5px; padding: 6px 8px; color: var(--muted); }
.still-tag { position: absolute; top: 6px; left: 6px; }

/* ---------- Business block / footer ---------- */
.biz-block { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 20px 0; background: var(--surface); }
.biz-block h3 { font-size: 14px; }
.deliver-footer { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; margin-top: 24px; }

/* ---------- Timeline (status) ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 26px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -26px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); }
.tl-item[data-state="done"] .tl-dot { background: var(--ok); border-color: var(--ok); }
.tl-item[data-state="active"] .tl-dot { border-color: var(--accent-2); }
.tl-title { font-weight: 600; font-size: 15px; }
.tl-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tl-state { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--muted); }
.tl-item[data-state="done"] .tl-state { color: var(--ok); }

/* ---------- Ops (hidden) ---------- */
.ops-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ops-row .code { font-family: var(--font-mono); }
.ops-row .stage-btns { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------- Responsive: >=760px (tablet/desktop) ---------- */
@media (min-width: 760px) {
  main#app { padding-top: 32px; }
  .facts-grid { grid-template-columns: 1fr 1fr 1fr; }
  .stills-grid { grid-template-columns: repeat(3, 1fr); }
  #map { height: 340px; }
  .bottom-bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
  .bottom-bar .missing { margin-bottom: 0; }
}

/* Ensure nothing overflows at 390px */
.section-block, .plan-row, .slot-row { max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
