/* hand-written, mobile-first. Old iPad Safari rules: no flex gap,
   literal colours before every var() so iOS < 9.3 still gets a styled page. */
:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --ink: #23201c;
  --muted: #6d665c;
  --line: #e2dcd2;
  --accent: #8a4b1f;
  --accent-ink: #ffffff;
  --ok: #2f6b3a;
  --ok-bg: #e5f2e7;
  --err: #a12c2c;
  --err-bg: #f9e5e5;
  --warn-bg: #fff3d6;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #f6f3ee; background: var(--bg); color: #23201c; color: var(--ink); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: #8a4b1f; color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
small, .hint { color: #6d665c; color: var(--muted); font-size: .85rem; }
.hint { margin: .25rem 0 .5rem; }

.top { background: #8a4b1f; background: var(--accent); color: #fff; color: var(--accent-ink); padding: .6rem 1rem; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: space-between; justify-content: space-between; }
.top .brand { color: #fff; color: var(--accent-ink); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.top .logout { margin: 0; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; }
.top .who { font-size: .85rem; opacity: .9; margin-right: .6rem; }
.top .btn { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.35); }

.nav { background: #fff; background: var(--card); border-bottom: 1px solid #e2dcd2; border-bottom: 1px solid var(--line); display: -webkit-flex; display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nav a { padding: .7rem .9rem; min-height: 44px; text-decoration: none; color: #23201c; color: var(--ink); white-space: nowrap; border-bottom: 3px solid transparent; }
.nav a.active { border-bottom-color: #8a4b1f; border-bottom-color: var(--accent); font-weight: 600; }

.main { padding: 1rem; max-width: 1100px; margin: 0 auto; }
.card { background: #fff; background: var(--card); border: 1px solid #e2dcd2; border: 1px solid var(--line); border-radius: 8px; border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
.card.narrow { max-width: 460px; margin: 2rem auto; }
.titlebar { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: space-between; justify-content: space-between; margin-bottom: .75rem; }
.titlebar h1 { margin: 0; }
.row2 > * { margin-bottom: .75rem; }
@media (min-width: 700px) {
  .row2 { display: -webkit-flex; display: flex; }
  .row2 > * { -webkit-flex: 1; flex: 1; margin-right: 1rem; }
  .row2 > *:last-child { margin-right: 0; }
}

.field { margin-bottom: .8rem; }
.field label { display: block; font-size: .85rem; color: #6d665c; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea, button { font: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; min-height: 44px; padding: .5rem .6rem; border: 1px solid #e2dcd2; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #23201c; color: var(--ink); }
input[disabled] { background: #f6f3ee; background: var(--bg); color: #6d665c; color: var(--muted); }
input[type=number] { text-align: right; }
.check { display: inline-block; margin: .25rem 1rem .25rem 0; min-height: 44px; line-height: 44px; }
.check input { width: 22px; height: 22px; vertical-align: middle; }
.checks { margin: .25rem 0; }
.inline { display: inline-block; margin: 0 .15rem .3rem 0; }
.inline input:not([type=checkbox]) { width: auto; min-height: 44px; padding: .4rem .6rem; }
.inline select { width: auto; min-height: 44px; padding: .4rem .6rem; }
.inline .w-name { width: 11rem; }

.btn { display: inline-block; min-height: 44px; padding: .55rem 1rem; border: 1px solid #e2dcd2; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: #23201c; color: var(--ink); text-decoration: none; cursor: pointer; vertical-align: middle; }
.btn-primary { background: #8a4b1f; background: var(--accent); color: #fff; color: var(--accent-ink); border-color: #8a4b1f; border-color: var(--accent); }
.btn-danger { color: #a12c2c; color: var(--err); }
.btn-sm { min-height: 44px; padding: .4rem .8rem; font-size: .9rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; }
.actions { margin-top: 1rem; }
.actions .btn { margin-right: .5rem; margin-bottom: .5rem; }

.flash { padding: .7rem .9rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-ok { background: #e5f2e7; background: var(--ok-bg); color: #2f6b3a; color: var(--ok); }
.flash-err { background: #f9e5e5; background: var(--err-bg); color: #a12c2c; color: var(--err); }

.tiles { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -.4rem 1rem; }
.tile { -webkit-flex: 1 1 120px; flex: 1 1 120px; margin: .4rem; background: #fff; background: var(--card); border: 1px solid #e2dcd2; border: 1px solid var(--line); border-radius: 8px; border-radius: var(--radius); padding: .8rem; text-decoration: none; color: #23201c; color: var(--ink); }
.tile b { display: block; font-size: 1.5rem; }
.tile span { color: #6d665c; color: var(--muted); font-size: .85rem; }
.tile.warn { background: #fff3d6; background: var(--warn-bg); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: #fff; background: var(--card); border: 1px solid #e2dcd2; border: 1px solid var(--line); border-radius: 8px; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .55rem .7rem; border-bottom: 1px solid #e2dcd2; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .8rem; color: #6d665c; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table tr.group td { background: #f6f3ee; background: var(--bg); font-weight: 600; font-size: .85rem; }
.table tr.low td { background: #fff3d6; background: var(--warn-bg); }
.table tr.muted td { color: #6d665c; color: var(--muted); }
.table.compact td { padding: .35rem .5rem; }
.tag { display: inline-block; font-size: .7rem; padding: .05rem .4rem; border-radius: 4px; background: #e2dcd2; background: var(--line); color: #6d665c; color: var(--muted); vertical-align: middle; }
.tag.warn { background: #fff3d6; background: var(--warn-bg); color: #7a4b00; }
.list { padding-left: 1.2rem; }

.filters { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin-bottom: .75rem; }
.filters > * { margin: 0 .5rem .5rem 0; width: auto; }
.filters input { min-width: 180px; }

/* recipe editor */
#lines td { padding: .35rem .4rem; }
#lines select, #lines input { min-height: 44px; }
#lines .line-item { min-width: 12rem; }
#lines .line-qty { width: 6.5rem; }
#lines .line-unit { width: 10rem; }
#lines .line-note { width: 9rem; }
#lines .line-cost { text-align: right; white-space: nowrap; color: #6d665c; color: var(--muted); }
#lines .line-remove { min-width: 44px; }
#lines tr.inactive td { background: #fff3d6; background: var(--warn-bg); }
.cost-summary { margin-top: .75rem; font-size: 1.05rem; }
.cost-summary b { font-size: 1.25rem; }
.cost-flag { color: #a12c2c; color: var(--err); font-weight: 600; }
.leaves { font-size: .9rem; }

/* Phase 3: receiving, waste, transfers */
.quick { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -.3rem 1rem; }
.quick .btn { margin: .3rem; }
.btn-big { min-height: 56px; padding: .9rem 1.2rem; font-size: 1.05rem; }
.reasons label { display: inline-block; min-height: 48px; line-height: 46px; padding: 0 1rem; margin: 0 .4rem .4rem 0; border: 1px solid #e2dcd2; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.reasons input { width: 20px; height: 20px; vertical-align: middle; margin-right: .3rem; }
.totals { font-size: 1.05rem; }
#lines .line-price, #lines .line-total { width: 7rem; }
#lines .line-expiry { width: 10rem; }
#lines .line-location { width: 9rem; }
input[type=date] { min-height: 44px; }
input[type=file] { min-height: 44px; padding: .5rem 0; border: 0; }

/* Phases 4-6: count sheet, order list, production, reports */
.count-loc { margin: 1.5rem 0 .25rem; padding: .4rem .6rem; background: #8a4b1f; background: var(--accent); color: #fff; border-radius: 6px; font-size: 1.05rem; }
.count-cat { margin: 1rem 0 .25rem; color: #6d665c; color: var(--muted); text-transform: uppercase; font-size: .8rem; letter-spacing: .04em; }
.count-row { background: #fff; background: var(--card); border: 1px solid #e2dcd2; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; margin-bottom: .45rem; }
.count-row.done { border-left: 5px solid #2f6b3a; border-left: 5px solid var(--ok); }
.count-row.failed { border-left: 5px solid #a12c2c; border-left: 5px solid var(--err); }
.count-name { font-weight: 600; margin-bottom: .35rem; }
.count-name small { font-weight: 400; }
.count-in { display: inline-block; margin: 0 .7rem .3rem 0; vertical-align: top; }
.count-in span { display: block; font-weight: 600; font-size: .95rem; margin-bottom: .15rem; }
.count-in input[type=number] { width: 6.4rem; min-height: 52px; font-size: 1.25rem; text-align: center; display: block; }
.count-state { display: block; font-size: .9rem; color: #2f6b3a; color: var(--ok); }
.count-row.failed .count-state { color: #a12c2c; color: var(--err); }
.sticky-actions { position: -webkit-sticky; position: sticky; bottom: 0; background: #f6f3ee; background: var(--bg); padding: .6rem 0; border-top: 1px solid #e2dcd2; }
.table tr.flag td { background: #f9e5e5; background: var(--err-bg); }
.table tr.ok td.mark { color: #2f6b3a; color: var(--ok); }
.table td.mark { font-size: 1.3rem; font-weight: 700; width: 2rem; text-align: center; }
.table tr.flag td.mark { color: #a12c2c; color: var(--err); }
.order-qty, .actual-qty { width: 6rem !important; display: inline-block; }
.actual-unit { width: auto !important; display: inline-block; }
.warn-card { border-color: #a12c2c; border-color: var(--err); }
#order-text { font-family: ui-monospace, Menlo, monospace; font-size: .9rem; margin: .5rem 0 1rem; }
.cards { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 0 -.4rem; }
.link-card { -webkit-flex: 1 1 260px; flex: 1 1 260px; margin: .4rem; text-decoration: none; color: #23201c; color: var(--ink); }
.filters label { display: inline-block; font-size: .85rem; color: #6d665c; color: var(--muted); }
.filters label input { display: block; }

/* platform admin */
.admin-top { background: #23201c; }
.flash .inline { margin: 0 0 0 .5rem; }

/* the demo's "Log in as…" picker */
.picks form { margin: 0 0 .6rem; }
.pick { display: block; width: 100%; text-align: left; background: #fff; border: 1px solid #e2dcd2; border: 1px solid var(--line); border-radius: 8px; border-radius: var(--radius); padding: .8rem .9rem; font: inherit; color: #23201c; color: var(--ink); cursor: pointer; -webkit-appearance: none; }
.pick b { display: block; font-size: 1.05rem; }
.pick small { display: block; margin-top: .15rem; }
.pick:hover, .pick.on { border-color: #8a4b1f; border-color: var(--accent); background: #fbf6f0; }
.pick .tag { margin-top: .35rem; }
