/* TVC Production - one look for every screen. 8 px spacing grid, system font (SF on iPhone). */
:root {
  --bg: #F6F3EE; --card: #FFFFFF; --ink: #1E2622; --ink2: #5E6762; --ink3: #8E9690; --line: #E7E2DA; --soft: #F1EDE6;
  --accent: #1F5A45; --accent-soft: #E4EFE9;
  --red: #B3261E; --red-soft: #FBEAE8; --amber: #B26A00; --amber-soft: #FBF1DF; --green: #2F7A4F; --green-soft: #E5F2EA;
  --r: 16px; --r-s: 10px; --shadow: 0 1px 2px rgba(30,38,34,.05), 0 4px 16px rgba(30,38,34,.05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif; }
.num, td.n, .qty { font-variant-numeric: tabular-nums; }

/* top bar (scrolls away: no frozen rows) */
.bar { display: flex; align-items: center; justify-content: space-between; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; max-width: 720px; margin: 0 auto; }
.brand { display: flex; align-items: baseline; gap: 8px; }
.mark { font-weight: 800; letter-spacing: .06em; font-size: 20px; color: var(--accent); }
.sub { font-size: 15px; color: var(--ink2); }
.who { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink2); }
.who select { width: auto; padding: 6px 28px 6px 12px; border-radius: 999px; font-size: 15px; font-weight: 600; background-color: var(--card); }

main { max-width: 720px; margin: 0 auto; padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); }
h1 { font-size: 28px; line-height: 1.15; font-weight: 750; letter-spacing: -.01em; margin: 8px 0 16px; }
h2 { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink3); margin: 24px 0 8px; }
.mut { color: var(--ink2); font-size: 15px; }
.small { font-size: 13px; color: var(--ink3); }

/* bottom tabs for thumbs (fixed nav, not a frozen data row) */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; color: var(--ink3); text-decoration: none; font-size: 11px; font-weight: 600; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent); }

/* cards and lists */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; margin: 0 0 12px; }
.card.link { display: block; color: inherit; text-decoration: none; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title { font-size: 18px; font-weight: 700; }
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row .name { min-width: 0; }
.row .name b { font-weight: 600; display: block; }
.row .val { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.row .val small { display: block; font-weight: 500; color: var(--ink3); font-size: 12px; }

/* status */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.red { background: var(--red-soft); color: var(--red); } .pill.amber { background: var(--amber-soft); color: var(--amber); } .pill.green { background: var(--green-soft); color: var(--green); } .pill.grey { background: var(--soft); color: var(--ink2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.neg { color: var(--red); }

/* map */
.flow { display: flex; justify-content: center; margin: -4px 0 8px; color: var(--ink3); }
.flow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.lots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.lot { font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: var(--r-s); background: var(--soft); color: var(--ink); }
.lot small { font-weight: 500; color: var(--ink2); }
.lot.give { background: var(--amber-soft); } .lot.over { background: var(--red-soft); }
.subunit { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 14px; padding: 6px 12px; border-radius: 999px; background: var(--soft); color: var(--ink); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; }

/* forms */
label.f { display: block; font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink3); margin: 20px 0 8px; }
select, input, textarea, button { font: inherit; color: inherit; }
select, input[type=text], input[type=date], input[type=number] { width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); -webkit-appearance: none; appearance: none; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E9690' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg button { min-height: 64px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-align: left; font-weight: 600; font-size: 15px; }
.seg button small { display: block; font-weight: 500; font-size: 12px; color: var(--ink3); margin-top: 2px; }
.seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.seg button.on small { color: var(--accent); }
.route { display: grid; grid-template-columns: 1fr 32px 1fr; align-items: end; gap: 8px; }
.route .arrow { display: flex; align-items: center; justify-content: center; height: 48px; color: var(--accent); }
.route .arrow svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.route label.f { margin-top: 0; }
.toggle { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle label { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 15px; font-weight: 600; }
.toggle input { display: none; }
.toggle label.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.toggle label small { font-weight: 500; opacity: .75; }

/* quantity rows */
.qrow { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.qrow:first-child { border-top: 0; }
.qrow .need { font-size: 13px; color: var(--ink2); margin-top: 2px; }
.qrow .need b { color: var(--ink); font-variant-numeric: tabular-nums; }
.qrow input { width: 108px; min-height: 44px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* buttons and messages */
.save { width: 100%; min-height: 56px; margin-top: 24px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 18px; font-weight: 700; }
.save:active { transform: scale(.99); } .save:disabled { background: var(--ink3); }
.ghost { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 600; margin-top: 10px; }
.msg { margin-top: 16px; padding: 14px 16px; border-radius: 14px; font-size: 16px; }
.msg.ok { background: var(--green-soft); color: #1d5233; }
.msg.err { background: var(--red-soft); color: var(--red); }
.msg ul { margin: 6px 0 0 18px; padding: 0; }

/* register lines */
.mv { padding: 14px 16px; border-top: 1px solid var(--line); }
.mv:first-child { border-top: 0; }
.mv .route-t { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.mv .route-t svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mv .what { margin-top: 2px; }
.mv .what b { font-variant-numeric: tabular-nums; }
.mv .meta { font-size: 13px; color: var(--ink3); margin-top: 4px; }
.mv.cx { opacity: .5; } .mv.cx .what { text-decoration: line-through; }
.empty { padding: 32px 16px; text-align: center; color: var(--ink3); }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.toolbar > * { flex: 1; }

/* ---- Map: the whole picture (v6) ---- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.tile { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; }
.t-n { font-size: 28px; font-weight: 750; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.t-l { font-size: 14px; color: var(--ink2); margin-top: 4px; line-height: 1.25; }
.attn { display: flex; align-items: center; justify-content: space-between; background: var(--amber-soft); color: var(--amber); font-weight: 650; border-radius: var(--r); padding: 14px 16px; text-decoration: none; margin-bottom: 4px; }
.attn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }
.flowcard { padding: 8px 16px; }
.fl { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; padding: 10px 0; color: inherit; text-decoration: none; }
.fl-k { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink3); padding-top: 3px; }
.fl-arrow .flow { margin: -6px 0 -6px 56px; height: 20px; }
.fl-units { display: grid; gap: 8px; }
.fl-unit { background: var(--soft); border-radius: var(--r-s); padding: 8px 12px; }
.fn { display: grid; grid-template-columns: 76px 1fr 64px; gap: 10px; align-items: center; padding: 5px 0; }
.fn-l { font-size: 14px; color: var(--ink2); }
.fn-b { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.fn-b i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.fn-n { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 15px; }
.unitstock { margin-bottom: 8px; }
.lotrow { display: block; padding: 14px 16px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.lotrow:first-child { border-top: 0; }
.lr-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.lr-top b { font-size: 17px; }
.stage { font-size: 13px; font-weight: 650; color: var(--accent); background: var(--accent-soft); padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.dot-green, .dot-amber, .dot-red, .dot-grey { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }
.dot-green { background: var(--green); } .dot-amber { background: var(--amber); } .dot-red { background: var(--red); } .dot-grey { background: var(--ink3); }
.steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 8px; }
.trk { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.trk i { display: block; height: 100%; background: var(--accent); }
.st-n { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 4px; }
.st-l { font-size: 11px; color: var(--ink3); line-height: 1.2; }
.flag { font-size: 14px; margin-top: 6px; padding-left: 12px; border-left: 3px solid; }
.flag.amber { color: var(--amber); border-color: var(--amber); } .flag.red { color: var(--red); border-color: var(--red); }
.toolbar .btn { flex: 0 0 auto; margin-top: 0; }
.qhead { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink3); background: var(--soft); padding: 8px 16px; }
.picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.picker select:disabled { opacity: .5; }
textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); resize: vertical; }
.photobtn { display: inline-block; margin-top: 6px; padding: 10px 16px; border: 1px dashed var(--line); border-radius: 12px; font-weight: 600; cursor: pointer; }
.photobtn input { display: none; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; display: block; }
.th { position: relative; }
.th button { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--red); color: #fff; font-weight: 700; line-height: 1; }
.mv.prob { border-left: 4px solid var(--red); }
.grid2 + .grid2 { margin-top: 8px; }
a.save { display: flex; align-items: center; justify-content: center; }

.tbl { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 6px; border-top: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-weight: 600; color: var(--ink3); border-top: 0; }
/* v10: lot timeline strip, date cards */
.strip { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; margin-top: 8px; }
.sp { background: var(--soft); border-radius: 6px; padding: 4px 2px; text-align: center; font-size: 10px; line-height: 1.25; color: var(--ink2); min-width: 0; }
.sp-k { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-d.f { color: var(--ink3); }
.sp.done { background: var(--green-soft); color: var(--green); }
.sp.open { background: var(--amber-soft); color: var(--amber); }
.sp.late { background: var(--red-soft); color: var(--red); }
.mv.dc { border-left: 4px solid var(--red); }
.mv .tbl { margin-top: 8px; }
a.row.lotplan { display: block; }
.mv .tbl td:first-child, .card .tbl td:first-child { white-space: normal; }
.mv .tbl { table-layout: auto; }

/* frozen header row and first column for every table (Arjun 6 Dec) */
.tw { max-height: calc(100vh - 170px); overflow: auto; }
.tbl tr:first-child th { position: sticky; top: 0; z-index: 2; background: var(--card); box-shadow: 0 1px 0 var(--line); }
.tbl td:first-child, .tbl th:first-child { position: sticky; left: 0; z-index: 1; background: var(--card); box-shadow: 1px 0 0 var(--line); }
.tbl tr:first-child th:first-child { z-index: 3; }
