/* Favo ERP. The look follows our other ERPs: busy-mcp (dark side menu with icons and a marker on the open page, quiet
   cards, tinted stat tiles, chips) and spt-erp (Inter, Tally status in the top bar, toasts bottom right). Colour carries
   meaning only: red = act now, amber = look at it, green = fine. Plain CSS, no build step. */
:root {
    --bg: #f5f6f8; --card: #fff; --text: #0f172a; --muted: #64748b; --soft: #f1f5f9; --line: #e5e7eb; --line-2: #cbd5e1;
    --favo-red: #ed3237; --brand: #1f3a5f; --brand-2: #2d5a8e; --brand-soft: #e8eef6;
    --side: #172b45; --side-text: #cbd5e1;
    --red: #c62828; --red-bg: #fdecea; --amber: #a15c00; --amber-bg: #fff4e0; --green: #15803d; --green-bg: #e7f6ec; --blue: #1d4ed8; --blue-bg: #e8f0fe;
    --radius: 10px; --shadow: 0 1px 2px rgba(15, 23, 42, .05); --shadow-lg: 0 12px 32px rgba(15, 23, 42, .18);
    --side-w: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 6px; }
table, .n, .num, td.r { font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.sub { color: var(--muted); font-size: 13px; }
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.center-text { text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; gap: 8px 12px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head .grow { flex: 1; min-width: 200px; }
.card-head .hint { margin-bottom: 0; }
.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.big-i { width: 34px; height: 34px; color: var(--line-2); margin-bottom: 6px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 14px; }
label input, label select { display: block; width: 100%; margin-top: 5px; }
label .hint { display: block; font-weight: 400; margin: 4px 0 0; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; margin: 0; }
input, select, textarea { font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--text); min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(45, 90, 142, .18); }
input[type=checkbox] { min-height: 0; width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
input.num { width: 92px; text-align: right; }
input.saved { border-color: var(--green); box-shadow: 0 0 0 3px rgba(21, 128, 61, .15); transition: none; }
.search { position: relative; display: inline-flex; align-items: center; }
.search .i { position: absolute; left: 10px; color: var(--muted); width: 16px; height: 16px; pointer-events: none; }
.search input { padding-left: 32px; width: 100%; }

/* Buttons */
.btn { font: inherit; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px;
    padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--soft); }
.btn:focus-visible, .tab:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible, .big:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .i { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--red); border-color: #f0c2c2; }
.btn.danger:hover { background: var(--red-bg); }
.btn.danger-solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn.link { border: none; background: none; color: var(--brand-2); padding: 4px 6px; min-height: 0; }
.btn.link:hover { text-decoration: underline; }
.btn.wide { width: 100%; }
.btn.big-btn { min-height: 44px; font-size: 15px; margin-top: 4px; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: var(--muted) transparent var(--muted) transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.primary.loading::after { border-color: #fff transparent #fff transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--soft); color: var(--text); }
.error { background: var(--red-bg); color: var(--red); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }

/* Segmented choice (filters) */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: none; border: 0; border-radius: 7px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.seg button b { font-weight: 600; color: var(--muted); margin-left: 4px; }
.seg button.on b { color: var(--brand-2); }

/* Sign-in */
.auth-card { width: 100%; max-width: 400px; padding: 30px 28px 22px; box-shadow: 0 8px 24px rgba(15, 23, 42, .08); }
.auth-logo { text-align: center; margin: 4px 0 24px; }
.auth-logo img { display: block; height: 44px; width: auto; margin: 0 auto 10px; }
.auth-logo small { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.auth-title { font-size: 19px; margin: 0 0 4px; text-align: center; }
.auth-links { display: flex; justify-content: space-between; margin-top: 10px; }

/* App shell: side menu + top bar */
.app { min-height: 100vh; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); color: var(--side-text); display: flex; flex-direction: column; z-index: 30; }
.side-brand { display: flex; align-items: flex-end; gap: 10px; padding: 22px 20px 16px; }
.side-brand img { height: 28px; width: auto; display: block; }
.side-brand > small { color: rgba(255, 255, 255, .55); font-size: 11px; font-weight: 600; letter-spacing: .2em; padding-left: 10px; border-left: 1px solid rgba(255, 255, 255, .18); line-height: 18px; }
.top-logo { display: none; height: 26px; width: 26px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .42); padding: 16px 10px 6px; }
.tab { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; font: inherit; font-size: 14px; font-weight: 500; color: var(--side-text); background: none; border: 0;
    padding: 9px 10px; border-radius: 8px; cursor: pointer; text-align: left; margin-bottom: 2px; }
.tab .i { opacity: .7; }
.tab:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.tab.active { background: rgba(255, 255, 255, .13); color: #fff; font-weight: 600; }
.tab.active .i { opacity: 1; }
.tab.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--favo-red); }
.tab span { flex: 1; }
.count { min-width: 22px; padding: 1px 7px; border-radius: 99px; font-size: 12px; font-weight: 600; text-align: center; background: rgba(255, 255, 255, .14); color: #fff; }
.count.red { background: #dc2626; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding: 12px 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; font-size: 13px; font-weight: 600; text-transform: uppercase; flex-shrink: 0; }
.me-text { min-width: 0; }
.me-text b { display: block; color: #fff; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: rgba(255, 255, 255, .5); font-size: 12px; }
.me-actions { display: flex; gap: 4px; }
.me-actions .btn { flex: 1; color: var(--side-text); padding: 4px 6px; }
.me-actions .btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.main { margin-left: var(--side-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 24px; background: rgba(245, 246, 248, .86);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.menu-btn { display: none; margin-left: -8px; }
.crumb { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); min-width: 0; flex: 1; }
.crumb b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { width: 14px; height: 14px; }
.tally { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.tally .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-bg); }
.tally.old { color: var(--red); font-weight: 600; }
.tally.old .dot { background: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.tally.syncing .i { animation: spin 1s linear infinite; }
.net { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 50; overflow: hidden; }
.net::after { content: ""; position: absolute; top: 0; bottom: 0; width: 30%; background: var(--brand-2); animation: net 1s ease-in-out infinite; }
@keyframes net { from { left: -30%; } to { left: 100%; } }
.shade { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 25; }
.page { max-width: 1240px; margin: 0 auto; padding: 24px; }

/* Page heading */
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; min-width: 220px; }
.page-head .hint { margin: 4px 0 0; font-size: 14px; }
.page-head .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Stat tiles */
.big-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.big { --tone: var(--brand-2); --tone-bg: var(--brand-soft); display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px; cursor: pointer; text-align: left; font: inherit; color: inherit; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.big:hover { border-color: var(--tone); transform: translateY(-1px); }
.big .ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--tone-bg); color: var(--tone); flex-shrink: 0; }
.big .ic .i { width: 20px; height: 20px; }
.big .n { font-size: 28px; font-weight: 700; line-height: 1.1; color: var(--text); }
.big .l { font-weight: 600; font-size: 14px; margin-top: 2px; }
.big .hint { margin: 2px 0 0; }
.big.warn { --tone: var(--red); --tone-bg: var(--red-bg); }
.big.warn .n { color: var(--red); }
.big.amber { --tone: var(--amber); --tone-bg: var(--amber-bg); }
.big.good { --tone: var(--green); --tone-bg: var(--green-bg); }

/* Lists, pills, banners */
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row.click { cursor: pointer; margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 8px; }
.list-row.click:hover { background: var(--soft); }
.list-row.click + .list-row.click { border-top-color: transparent; box-shadow: 0 -1px 0 var(--line); }
.list-row .go { color: var(--line-2); }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; vertical-align: 1px; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.banner { background: var(--amber-bg); color: #7a4500; border: 1px solid #f6d7a7; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; }
.banner > .i { color: var(--amber); }
.banner.red { background: var(--red-bg); color: #8e1c1c; border-color: #f3c3c3; }
.banner.blue { background: var(--blue-bg); color: #1e3a8a; border-color: #c7d7fb; }
.banner.blue > .i { color: var(--blue); }
.banner .grow { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; background: var(--soft); border: 1px solid var(--line); font-size: 13px; font-weight: 500; }

/* Tables */
.table-wrap { overflow-x: auto; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 16px 18px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child > td { border-bottom: none; }
tbody tr:hover > td, table tr:not(:first-child):hover > td { background: #fafbfc; }
td.r, th.r { text-align: right; white-space: nowrap; }
.th-sort { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; border-radius: 4px; }
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.th-sort .arrow { font-size: 10px; opacity: .6; min-width: 10px; }
th.sorted { color: var(--brand); }
th.sorted .arrow { opacity: 1; }
.sort-pick { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.sort-pick select { margin: 0; width: auto; min-height: 34px; padding: 5px 8px; font-size: 13px; }
th.c, td.c { width: 1%; }
tr.removed td { opacity: .45; text-decoration: line-through; }
tr.urgent > td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.why { color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.45; }
details > summary { cursor: pointer; }
details > summary.why { list-style: none; }
details > summary.why::-webkit-details-marker { display: none; }
details > summary.why::before { content: "▸ "; }
details[open] > summary.why::before { content: "▾ "; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.toolbar .search { min-width: 320px; }
.foot-note { color: var(--muted); font-size: 13px; padding: 10px 14px; border-top: 1px solid var(--line); margin: 0; background: #fcfcfd; }

/* Items: the bar for ticked items */
.bulk { position: sticky; bottom: 16px; z-index: 10; background: var(--side); color: #fff; padding: 12px 14px; border-radius: 12px; display: flex; gap: 10px; align-items: center;
    flex-wrap: wrap; margin-top: 12px; box-shadow: var(--shadow-lg); }
.bulk label { margin: 0; color: rgba(255, 255, 255, .8); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.bulk input, .bulk select { margin: 0; min-height: 34px; padding: 5px 8px; }
.bulk input.num { width: 76px; }
.bulk select { max-width: 210px; }
.bulk .btn { min-height: 34px; padding: 5px 12px; }
.bulk .btn.link { color: #fff; }
.bulk .sep { width: 1px; align-self: stretch; background: rgba(255, 255, 255, .15); }

/* Orders to place: vendor list + the open order */
.two { display: grid; grid-template-columns: 264px 1fr; gap: 16px; align-items: start; }
.two > * { min-width: 0; }
.side-list { padding: 8px; position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow-y: auto; }
.side-list .search { width: 100%; margin: 2px 0 8px; }
.side-sort { padding: 0 2px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.side-sort .sort-pick { width: 100%; }
.side-sort select { flex: 1; }
.side-list .list-row { cursor: pointer; padding: 10px; border-radius: 8px; border-top: none; }
.side-list .list-row:hover { background: var(--soft); }
.side-list .list-row.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.empty { color: var(--muted); padding: 28px 16px; text-align: center; }
.empty h2 { color: var(--text); }
.empty .btn { margin-top: 12px; }

/* Open POs: how much has come */
.bar { height: 6px; border-radius: 99px; background: var(--soft); overflow: hidden; width: 120px; display: inline-block; vertical-align: middle; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.po-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.po-head .grow { flex: 1; min-width: 220px; }
.po-num { font-weight: 700; }

/* On the way */
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--soft); border: 1px solid var(--line); border-radius: 99px; padding: 3px 6px 3px 10px; font-size: 13px; margin: 0 6px 6px 0; }
.chip button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; }
.chip button:hover { color: var(--red); }
.bill { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.check-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.check-line .grow { flex: 1; min-width: 200px; }
.check-line select { max-width: 360px; flex: 1; min-width: 200px; }
.pick-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.pick-list .list-row { padding: 8px 12px; }
.ai-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Settings */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 20px; margin-top: 12px; }

/* Modal, question box and toasts */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 40; animation: fade .12s ease-out; }
.modal-box { position: relative; background: #fff; border-radius: 14px; padding: 22px 22px 20px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .15s ease-out; }
.modal-box h2 { font-size: 19px; padding-right: 36px; margin-bottom: 6px; }
.modal-x { position: absolute; top: 12px; right: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.ask-box { max-width: 440px; }
#ask { z-index: 45; }
.ask-text { color: #334155; margin: 6px 0 0; white-space: pre-line; }
.big-code { font-size: 26px; font-weight: 700; letter-spacing: 1px; background: var(--soft); border-radius: 10px; padding: 12px 16px; text-align: center; margin: 12px 0 0; user-select: all; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 8px; background: #0f172a; color: #fff; padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); max-width: 380px; animation: pop .15s ease-out; }
.toast .i { color: #4ade80; width: 17px; height: 17px; }
.toast.error { background: var(--red); }
.toast.error .i { color: #fff; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Tablets and phones: the side menu slides in from the menu button */
@media (max-width: 960px) {
    .side { transform: translateX(-100%); transition: transform .2s ease-out; box-shadow: var(--shadow-lg); }
    .side.open { transform: none; }
    .main { margin-left: 0; }
    .menu-btn { display: inline-grid; }
    .top-logo { display: block; }
    .two { grid-template-columns: 1fr; }
    .side-list { position: static; max-height: 320px; }
}
@media (max-width: 640px) {
    .topbar { padding: 0 12px; }
    .crumb-app, .crumb-sep, .tally .btn span, #books-age, .tally .dot { display: none; }
    .tally .btn { width: 38px; padding: 0; }
    .tally.old .btn { color: var(--red); border-color: #f0c2c2; background: var(--red-bg); }
    .banner { flex-wrap: wrap; }
    .banner .grow { min-width: calc(100% - 40px); }
    .banner > .btn { margin-left: 30px; }
    .seg { max-width: 100%; }
    .page-head .tools { width: 100%; }
    .page { padding: 16px 12px; }
    h1 { font-size: 21px; }
    .toolbar .search { min-width: 0; flex: 1; }
    .big-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .big { flex-direction: column; gap: 8px; padding: 12px; }
    .big .hint { display: none; }
    .toasts { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
}
