/* Shop Tracker v2 — mobile-first styles */
:root {
  --nav-h: 64px;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --green: #15803d; --green-bg: #dcfce7;
  --red: #b91c1c;   --red-bg: #fee2e2;
  --amber: #b45309; --amber-bg: #fef3c7;
  --blue: #1d4ed8;  --blue-bg: #dbeafe;
  --neutral-bg: #e2e8f0;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; background: var(--bg); min-height: 100vh; }

/* top bar */
#topbar {
  position: sticky; top: 0; z-index: 40;
  background: #0f172a; color: #fff;
  padding: 10px 12px calc(10px + env(safe-area-inset-top, 0px));
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-mark { background: var(--accent); border-radius: 8px; padding: 4px 7px; font-size: 13px; }
.shop-switch { display: flex; background: #1e293b; border-radius: 999px; padding: 3px; }
.shop-btn {
  border: 0; background: transparent; color: #cbd5e1; border-radius: 999px;
  padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.shop-btn.on { background: #fff; color: #0f172a; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-bw { background: #ef4444; } .dot-ru { background: #3b82f6; }

/* main: bottom padding >= nav height (fixes v1's overlap bug) */
#view { padding: 12px 12px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px); }
.page-title { font-size: 20px; margin: 4px 0 10px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.back { display: inline-block; margin-bottom: 6px; color: var(--accent); text-decoration: none; font-weight: 600; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.neg { color: var(--red); } .pos { color: var(--green); }
.empty { padding: 24px; text-align: center; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); padding: 12px; margin: 10px 0;
  box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.card h2 { font-size: 15px; margin: 0 0 8px; }
.card h3 { font-size: 13.5px; margin: 12px 0 6px; }
.subhead { font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .04em; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.stat { background: var(--card); border-radius: 10px; padding: 10px 6px; text-align: center;
  box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.stat span { display: block; font-size: 11px; color: var(--muted); }
.stat b { font-size: 15px; }
.hero { background: #0f172a; color: #fff; border-radius: var(--radius); padding: 16px; margin: 10px 0;
  display: flex; justify-content: space-between; align-items: center; }
.hero b { font-size: 26px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv.total { font-weight: 700; border-top: 2px solid var(--line); margin-top: 4px; padding-top: 8px; }

/* badges & chips */
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px; margin: 2px 3px 2px 0; }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-neutral { background: var(--neutral-bg); color: #475569; }
.badges { margin-top: 6px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: #0f172a; color: #fff; border-color: #0f172a; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; }
.filters input[type=search] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }

/* buttons */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-block { width: 100%; margin-top: 10px; padding: 13px; font-size: 16px; }
.row { display: flex; align-items: center; } .gap { gap: 8px; margin: 10px 0; flex-wrap: wrap; }
a.btn { text-decoration: none; display: inline-block; }

/* job cards */
.job-card { display: block; background: var(--card); border-radius: var(--radius); padding: 12px; margin: 8px 0;
  text-decoration: none; color: inherit; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.jc-top { display: flex; justify-content: space-between; gap: 8px; font-size: 15px; }
.rowlink { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; font-size: 14px; }
.follow-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.follow-actions { display: flex; gap: 6px; flex-shrink: 0; }
.flag { border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.flag.warn { background: var(--amber-bg); color: var(--amber); }
.flag.info { background: var(--blue-bg); color: var(--blue); }

/* quick links */
.quick-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.quick { background: var(--card); border-radius: 10px; padding: 12px 4px; text-align: center; text-decoration: none;
  color: inherit; font-size: 12px; font-weight: 600; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.qicon { display: block; font-size: 22px; margin-bottom: 4px; }

/* forms */
.form .fld { display: block; margin: 8px 0; }
.fld-lbl { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.fld input, .fld select, .fld textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; background: #fff; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.frow4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.fld-row { display: flex; gap: 6px; align-items: stretch; }
.fld-row input, .fld-row textarea, .fld-row select { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }
.mic-btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 0 12px; font-size: 18px; cursor: pointer; }
.mic-btn.listening { background: var(--red-bg); border-color: var(--red); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; }
.check input[type=checkbox] { width: 18px; height: 18px; }
.check .qty { width: 56px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; margin-left: auto; }
.calc { display: flex; flex-wrap: wrap; gap: 12px; background: #f8fafc; border: 1px dashed var(--line);
  border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 14px; }
.form-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.form-row input, .form-row select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.partsbox { margin: 10px 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.partsbox summary { cursor: pointer; font-weight: 700; font-size: 14px; }

/* pipeline stepper */
.stepper { display: flex; margin: 8px 0; }
.step { flex: 1; border: 0; background: transparent; cursor: pointer; padding: 4px 2px; }
.step-dot { display: block; width: 14px; height: 14px; border-radius: 50%; background: var(--line); margin: 0 auto 4px; }
.step.done .step-dot { background: var(--green); }
.step.current .step-dot { background: var(--accent); box-shadow: 0 0 0 4px var(--blue-bg); }
.step-lbl { font-size: 9.5px; color: var(--muted); display: block; line-height: 1.2; }
.step.current .step-lbl { color: var(--ink); font-weight: 700; }

/* photo slots */
.pslot { margin: 10px 0; }
.pslot-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.ptiles { display: flex; gap: 8px; flex-wrap: wrap; }
.ptile { position: relative; width: 84px; height: 84px; border-radius: 10px; background: var(--neutral-bg);
  border: 2px dashed #94a3b8; display: flex; align-items: center; justify-content: center; }
.ptile.starred { border: 2px solid #f59e0b; background: #fef3c7; }
.pimg { font-size: 26px; }
.star { position: absolute; top: -8px; right: -8px; border: 1px solid var(--line); background: #fff;
  border-radius: 50%; width: 26px; height: 26px; cursor: pointer; color: #cbd5e1; font-size: 14px; }
.star.on { color: #f59e0b; border-color: #f59e0b; }
.pdel { position: absolute; bottom: -8px; right: -8px; border: 1px solid var(--line); background: #fff;
  border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 11px; color: var(--red); }

/* week picker */
.weekpick { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.weekpick input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; }

/* tables */
.tblwrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tr.total td { font-weight: 700; border-top: 2px solid var(--line); }

/* bottom tab bar */
#tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 40;
}
.tab { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; }
.tab .ticon { font-size: 20px; }
.tab.on { color: var(--accent); font-weight: 700; }
.tab-add .ticon { background: var(--accent); color: #fff; border-radius: 50%; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center; font-size: 22px; }

/* more sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop[hidden] { display: none; }
.sheet { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 8px 16px 24px; }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 12px; }
.sheet-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
.sheet .btn-block, .sheet .btn-ghost { width: 100%; }

/* modal + toast */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 70;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 440px; max-height: 85vh; overflow-y: auto; }
.modal h3 { margin: 0 0 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
#toast-root { position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%); z-index: 80;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: #0f172a; color: #fff; border-radius: 999px; padding: 10px 18px; font-size: 14px;
  opacity: 0; transition: opacity .25s; max-width: 92vw; }
.toast.show { opacity: 1; }

/* app-update banner */
#update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: #0f172a; color: #fff; padding: 10px 14px; font-size: 14px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25); }
#update-banner .btn-sm { padding: 6px 14px; font-size: 13px; }

/* helper */
#helper-fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 52px; height: 52px; border-radius: 50%; border: 0; background: #7c3aed; color: #fff;
  font-size: 24px; cursor: pointer; z-index: 50; box-shadow: 0 4px 14px rgba(124,58,237,.4); }
#helper-panel[hidden] { display: none; }
#helper-panel { position: fixed; right: 12px; left: 12px; max-width: 528px; margin: 0 auto;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 78px); z-index: 55;
  background: #fff; border-radius: 16px; box-shadow: 0 12px 40px rgba(15,23,42,.25);
  display: flex; flex-direction: column; max-height: 55vh; }
.helper-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.helper-sub { font-size: 12px; color: var(--muted); flex: 1; }
.helper-head button { border: 0; background: transparent; font-size: 16px; cursor: pointer; }
.helper-log { padding: 12px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.hmsg { max-width: 85%; padding: 9px 12px; border-radius: 14px; font-size: 14px; }
.hmsg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.hmsg.assistant { align-self: flex-start; background: var(--bg); }
.helper-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.helper-form input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; }
.helper-form button { border: 0; background: var(--accent); color: #fff; border-radius: 50%; width: 42px; height: 42px; font-size: 17px; cursor: pointer; }

/* inventory */
.irow.low { border-left: 4px solid var(--red); }

/* print */
@media print {
  #tabbar, #topbar, #helper-fab, .filters, .btn { display: none !important; }
  #view { padding: 0; } #app { max-width: none; }
}
