/* BatchTicket — small, token-based stylesheet. Mobile first: tickets get
   photographed and typed in on a phone at the pour. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --ink: #1b1f24; --muted: #5c6672; --line: #d9dee5;
  --brand: #1f5f8b; --brand-ink: #ffffff; --accent: #e8a33d;
  --pass-bg: #e3f5e8; --pass-ink: #1d6b36; --fail-bg: #fbe3e4; --fail-ink: #9b1c24;
  --warn-bg: #fff4d6; --warn-ink: #7a5200; --info-bg: #e6f0f8; --info-ink: #1f5f8b;
  --radius: 14px; --gap: 1rem; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #11151a; --surface: #1a2027; --ink: #e8ecf1; --muted: #9aa5b1; --line: #2d3640;
    --brand: #5aa0d6; --brand-ink: #0b1620; --pass-bg: #163a24; --pass-ink: #8fe0a8;
    --fail-bg: #45191c; --fail-ink: #ff9ea4; --warn-bg: #3f3113; --warn-ink: #ffd27a;
    --info-bg: #15283a; --info-ink: #9ccbee; }
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .9em; background: var(--info-bg); padding: .1em .3em; border-radius: 4px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6rem; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; } h2 { font-size: 1.2rem; margin-top: 1.5rem; } h3 { font-size: 1rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--muted); }
.disclaimer { font-size: .8rem; line-height: 1.35; max-width: 70ch; }
.legal { max-width: 72ch; margin: 0 auto; line-height: 1.5; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 0; border-top: 1px solid var(--border, #e3e6ea); }
.row-between:first-of-type { border-top: 0; }
.legal h2 { margin-top: 1.8rem; } .legal h3 { margin-top: 1rem; }
.legal ul { padding-left: 1.2rem; } .legal li { margin: .3rem 0; }
.legal table { font-size: .9rem; } .legal p.disclaimer { max-width: none; font-size: .95rem; }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .inner { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; max-width: 1200px; margin: 0 auto; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); display: flex; align-items: center; gap: .4rem; }
.brand .dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; margin-left: auto; }
.nav a { padding: .35rem .6rem; border-radius: 6px; color: var(--ink); font-size: .95rem; }
.nav a.active, .nav a:hover { background: var(--bg); text-decoration: none; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.narrow { max-width: 640px; margin: 0 auto; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: 0 1px 2px rgb(0 0 0 / .04); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 1rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: .35rem; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line); font-weight: 500; transition: background .15s, filter .15s;
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.busy { opacity: .85; cursor: progress; }
.btn.busy::before { content: ""; width: .9em; height: .9em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.busy::before { animation: none; border-right-color: currentColor; opacity: .5; } }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--fail-ink); border-color: var(--fail-ink); background: transparent; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.block { width: 100%; justify-content: center; }
.btn.big { padding: .9rem 1.2rem; font-size: 1.05rem; }

/* badges */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; letter-spacing: .02em; }
.badge.pass, .badge.ACCEPT { background: var(--pass-bg); color: var(--pass-ink); }
.badge.fail, .badge.REVIEW { background: var(--fail-bg); color: var(--fail-ink); }
.badge.warn, .badge.INCOMPLETE { background: var(--warn-bg); color: var(--warn-ink); }
.badge.info { background: var(--info-bg); color: var(--info-ink); }
.badge.none { background: var(--bg); color: var(--muted); }

/* messages */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .9rem; border-radius: 8px; margin-bottom: .5rem; border: 1px solid transparent; }
.messages .success { background: var(--pass-bg); color: var(--pass-ink); }
.messages .error { background: var(--fail-bg); color: var(--fail-ink); }
.messages .warning { background: var(--warn-bg); color: var(--warn-ink); }
.messages .info { background: var(--info-bg); color: var(--info-ink); }
.callout { padding: .8rem 1rem; border-radius: 8px; background: var(--info-bg); color: var(--info-ink); margin: .5rem 0 1rem; }
.callout.warn { background: var(--warn-bg); color: var(--warn-ink); }
.callout.pass { background: var(--pass-bg); color: var(--pass-ink); }
.callout.fail { background: var(--fail-bg); color: var(--fail-ink); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .5rem 0 1rem; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; background: var(--surface); }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr.FAIL td { background: color-mix(in srgb, var(--fail-bg) 55%, transparent); }
tr.section td { background: var(--bg); font-weight: 600; color: var(--muted); }
td.note { color: var(--muted); font-size: .8rem; max-width: 28rem; }
tfoot td { font-weight: 600; }
.stat { display: flex; flex-direction: column; gap: .1rem; }
.stat .v { font-size: 1.4rem; font-weight: 700; } .stat .l { color: var(--muted); font-size: .8rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; margin-bottom: 1rem; }

/* forms */
form .field { display: flex; flex-direction: column; gap: .2rem; margin-bottom: .75rem; }
form label { font-size: .85rem; color: var(--muted); font-weight: 600; }
input[type=text], input[type=number], input[type=email], input[type=password], input[type=date], input[type=time], input[type=file], select, textarea {
  font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.help { font-size: .78rem; color: var(--muted); }
.errorlist { color: var(--fail-ink); font-size: .85rem; margin: 0; padding-left: 1rem; }
.form-grid { display: grid; gap: .25rem 1rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.form-grid .field.wide { grid-column: 1 / -1; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 0; margin: 0 0 1rem; background: var(--surface); }
legend { font-weight: 600; padding: 0 .4rem; }
details > summary { cursor: pointer; font-weight: 600; margin: .5rem 0; }
table.entry input { min-width: 6rem; padding: .35rem .5rem; }
table.entry td { vertical-align: middle; }
.sticky-save { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: .6rem 0; margin-top: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }

/* landing */
.hero { padding: 2.5rem 0 1.5rem; }
.hero h1 { font-size: 2rem; max-width: 36rem; }
.hero p { font-size: 1.1rem; max-width: 40rem; color: var(--muted); }
.features { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin: 1.5rem 0; }
.price { font-size: 1.6rem; font-weight: 700; }
.oauth-buttons { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0; }
.oauth-buttons .btn { justify-content: center; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.5rem; text-align: center; background: var(--surface); }
.dropzone input[type=file] { border: 0; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
@media (max-width: 640px) { h1 { font-size: 1.3rem; } main { padding: .75rem; } th, td { padding: .4rem .45rem; } }

.org-switch select { width: auto; padding: .3rem 1.6rem .3rem .5rem; font-size: .9rem; }
.store-build .billing-link, .store-build #install-app, .store-build .purchase-ui { display: none !important; }

/* ticket-shaped load form (templates/mixes/ticket_form.html) */
.walker { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .6rem .9rem; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn-ink); margin-bottom: 1rem; position: sticky; top: calc(var(--topbar-h, 3.2rem) + .3rem); z-index: 5; }
.walker .notes { flex-basis: 100%; font-size: .85rem; } .walker .notes summary { margin: 0; }
.walker .notes ul { margin: .2rem 0 0; padding-left: 1.2rem; }
.ticket-layout { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
.ticket-layout.with-photo { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.ticket-photo { position: sticky; top: calc(var(--topbar-h, 3.2rem) + .5rem); align-self: start; max-height: calc(100vh - 4rem); overflow: auto;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ticket-photo img { width: 100%; height: auto; display: block; }
.ticket-photo iframe { width: 100%; height: 80vh; border: 0; }
@media (max-width: 1100px) { .ticket-layout.with-photo { grid-template-columns: minmax(0, 1fr); }
  .ticket-photo { position: static; max-height: 60vh; order: -1; } }
.ticket .strip { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .75rem; background: var(--surface); margin-bottom: 1rem; }
.ticket .cell { display: flex; flex-direction: column; gap: .15rem; padding: .2rem; border-radius: 6px; }
.ticket .cell label, .ticket .cell .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.ticket .cell .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.ticket .cell input, .ticket .cell select { padding: .4rem .5rem; }
.ticket td .cell { padding: 0; } .ticket td .cell input { min-width: 5.5rem; text-align: right; }
.ticket .flag { background: var(--warn-bg); outline: 2px solid var(--accent); outline-offset: -2px; }
.ticket .flag.fail { background: var(--fail-bg); outline-color: var(--fail-ink); }
.ticket .flag.done { background: var(--pass-bg); outline-color: var(--pass-ink); }
.ticket .why { display: block; font-size: .75rem; color: var(--warn-ink); }
.ticket .flag.fail .why { color: var(--fail-ink); } .ticket .muted.why { color: var(--muted); }
.ticket table.batch .why { max-width: 16rem; white-space: normal; }
.ticket .chk { font-size: .75rem; color: var(--muted); }
.ticket .confirm { display: flex; align-items: center; gap: .3rem; font-size: .75rem; text-transform: none; letter-spacing: 0; }
.ticket .confirm input { width: auto; }
.ticket table.batch th, .ticket table.batch td { padding: .35rem .45rem; vertical-align: middle; }
.ticket .footer-line { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; padding: .5rem .75rem; border: 1px dashed var(--line);
  border-radius: var(--radius); font-size: .9rem; margin: .25rem 0 1rem; background: var(--surface); }
.ticket .footer-line b { font-variant-numeric: tabular-nums; }
.walker .notes ul { max-height: 30vh; overflow: auto; }
/* Phones: drop Design /cy and Tol ± from the batch table; the unmatched table's column 3 is Quantity. */
@media (max-width: 640px) {
  .ticket table.batch:not(.unmatched) th:nth-child(3), .ticket table.batch:not(.unmatched) td:nth-child(3),
  .ticket table.batch:not(.unmatched) th:nth-child(8), .ticket table.batch:not(.unmatched) td:nth-child(8) { display: none; }
}

/* ticket capture (templates/documents/_capture.html) */
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); border: 0; white-space: nowrap; }
.capture-btn { position: relative; cursor: pointer; }
.capture-btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.capture[data-mode=camera] .icon-upload, .capture[data-mode=upload] .icon-camera { display: none; }
.capture-stage { display: flex; justify-content: center; padding: 2.5rem 0; }
.capture-stage .capture-btn { flex-direction: column; gap: .6rem; width: 11rem; height: 11rem; justify-content: center; border-radius: 50%; white-space: normal; text-align: center; }
.capture-stage .icon { width: 3.5rem; height: 3.5rem; stroke-width: 1.5; }
.capture-sheet { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #000; }
.capture-sheet[hidden], .capture-choices[hidden] { display: none; }
.capture-sheet img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.capture-panel { margin-top: auto; background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; padding: 1.1rem 1rem calc(1.1rem + env(safe-area-inset-bottom)); }
.capture-status { margin: 0 0 .9rem; font-weight: 600; text-align: center; }
.capture-status.busy { display: flex; gap: .6rem; align-items: center; justify-content: center; margin: 0; }
.capture-status.busy::before { content: ""; flex: none; width: 1.1em; height: 1.1em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
.capture-choices { display: flex; flex-wrap: wrap; gap: .5rem; max-width: 32rem; margin: 0 auto; }
.capture-choices .btn { flex: 1 1 100%; justify-content: center; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
body.capture-open { overflow: hidden; }
.more { position: relative; }
.more > summary { list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more-menu { position: absolute; right: 0; top: calc(100% + .35rem); z-index: 6; display: flex; flex-direction: column; gap: .35rem; min-width: 10rem; padding: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / .14); }
.more-menu .btn { width: 100%; justify-content: flex-start; }

/* phones and tablets */
.nav-toggle { display: none; }
@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .nav.collapsible { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; margin: 0; }
  .nav.collapsible.open { display: flex; }
  .nav.collapsible .org-switch select { width: 100%; }
  .nav.collapsible form .btn { width: 100%; justify-content: center; }
}
@media (any-pointer: coarse) {
  .btn, .nav a { min-height: 44px; align-items: center; }
  .nav a { display: flex; }
  .btn.small { min-height: 40px; }
  /* iOS zooms the page into any field under 16px */
  input, select, textarea, .org-switch select { font-size: 16px; }
}
@media (max-width: 640px) {
  .page-head > .actions { width: 100%; }
  .page-head > .actions .capture:not([data-role=upload]) { flex-basis: 100%; }
  .page-head > .actions .capture:not([data-role=upload]) .capture-btn { width: 100%; justify-content: center; padding: 1.1rem; border-radius: var(--radius); }
  .page-head > .actions .capture:not([data-role=upload]) .capture-btn .icon { width: 2.25rem; height: 2.25rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-save { padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); }
  table.cards thead, table.cards tfoot { display: none; }
  table.cards, table.cards tbody { display: block; background: none; }
  table.cards tr { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .8rem; margin-bottom: .6rem; }
  table.cards tr.FAIL { border-color: var(--fail-ink); }
  table.cards td { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 0; padding: .2rem 0; text-align: right; background: none !important; white-space: normal; }
  table.cards td:empty { display: none; }
  table.cards td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; flex: none; max-width: 45%; }
  table.cards td.note { max-width: none; }
}
/* The pour's load list: on a tablet the columns that fit, on a phone a compact card
   that opens the load when tapped. Totals are in the stat cards above. */
@media (max-width: 900px) {
  table.loads tfoot { display: none; }
  table.loads td:first-child { white-space: nowrap; }
  table.loads th:nth-child(5), table.loads td:nth-child(5), table.loads th:nth-child(8), table.loads td:nth-child(8),
  table.loads th:nth-child(10), table.loads td:nth-child(10) { display: none; }
}
@media (max-width: 640px) {
  table.loads tr { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .15rem .75rem; padding: .7rem .85rem; }
  table.loads td { display: block; padding: 0; text-align: left; }
  table.loads td[data-label]::before { display: block; max-width: none; font-size: .72rem; }
  table.loads td:nth-child(1) { grid-column: 1 / 2; order: -2; font-weight: 600; font-size: 1.05rem; }
  table.loads td:nth-child(1)::before, table.loads td:nth-child(6)::before { display: none; }
  table.loads td:nth-child(1) a::after { content: ""; position: absolute; inset: 0; }
  table.loads td:nth-child(6) { grid-column: 2 / 4; order: -1; text-align: right; }
  table.loads td:nth-child(7), table.loads td:nth-child(9) { display: none; }
  table.loads td.note { grid-column: 1 / -1; margin-top: .25rem; }
  table.loads td.note::before { display: none; }
  table.loads td:only-child { grid-column: 1 / -1; font-weight: 400; font-size: 1rem; }
}
@media (any-pointer: coarse) { .capture-btn .icon { width: 1.75rem; height: 1.75rem; } }

/* jobs */
.job-card { display: flex; flex-direction: column; gap: .15rem; color: var(--ink); }
.job-card:hover { text-decoration: none; border-color: var(--brand); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0 .6rem; }
.section-head h2 { margin: 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .35rem .85rem; min-height: 3rem; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.inline-add { display: flex; gap: .5rem; margin-top: .6rem; }
.inline-add select { flex: 1; min-width: 0; }
.archived { margin-top: 1.5rem; color: var(--muted); }
.job-card[hidden] { display: none; }
input.job-search { font: inherit; padding: .55rem .75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); width: 100%; margin-bottom: .75rem; }

/* walkthrough (static/js/tour.js) */
.tour-spot { position: fixed; z-index: 60; border-radius: var(--radius); box-shadow: 0 0 0 9999px rgb(0 0 0 / .5); pointer-events: none; }
.tour-spot[hidden] { display: none; }
.tour-box { position: fixed; z-index: 61; width: min(22rem, calc(100vw - 16px)); padding: 1rem; background: var(--surface); color: var(--ink); border-radius: var(--radius); box-shadow: 0 8px 28px rgb(0 0 0 / .3); }
.tour-box p { margin: .4rem 0 .8rem; }
.tour-row { display: flex; justify-content: space-between; gap: .5rem; }

/* Automatic renewal terms beside a tier's sign-up button (billing/renewal.py) */
.renewal-terms { border: 1px solid var(--line); border-left: 4px solid var(--info-ink); background: var(--info-bg); color: var(--info-ink); padding: .6rem .8rem; border-radius: 6px; margin: .6rem 0; }
.renewal-agree { display: flex; gap: .5rem; align-items: flex-start; margin: .4rem 0 .8rem; font-weight: 600; }
.renewal-agree input { margin-top: .25rem; }
