/* KSL Purchase. Light and clean. 60 percent white and pale grey, 30 percent ink, 10 percent KSL red.
   Stage is never shown by colour alone: each stage has a ring that fills a step more, and a word. */
:root {
  --red: #CD1B36;
  --red-d: #A8142B;
  --ink: #211D1D;
  --ink2: #5C5757;
  --line: #E6E3E3;
  --bg: #F6F5F5;
  --card: #FFFFFF;
  --ok: #1C6B3C;
  --warn: #8A5A00;
  --r: 14px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --bar: 48px;
  --tabh: 58px;
  font-family: Calibri, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { overflow-x: clip; }
body { margin: 0; background: var(--bg); font-size: 16px; line-height: 1.35; overflow-x: clip; padding-top: env(safe-area-inset-top); }
h1 { font-size: 30px; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 8px; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--ink2); }
.small { font-size: 13px; }
.red { color: var(--red); }

/* frame */
#cbar { position: fixed; z-index: 20; top: env(safe-area-inset-top); left: 0; right: 0; height: var(--bar); display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: rgba(255,255,255,.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
  transform: translateY(-110%); transition: transform .25s var(--ease-out); }
body.stuck #cbar { transform: none; }
.cbar-logo { height: 20px; width: auto; }
#cb-t { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view { padding: 0 16px calc(var(--tabh) + 28px + env(safe-area-inset-bottom)); max-width: 980px; margin: 0 auto; min-height: 100vh; }
.hdr { padding: 18px 0 12px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.hdr .sub { font-size: 13px; color: var(--ink2); margin-bottom: 2px; }
.brand { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.brand img { height: 22px; }
#tabs { position: fixed; z-index: 15; left: 0; right: 0; bottom: 0; height: calc(var(--tabh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(255,255,255,.9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
#tabs button { flex: 1; border: 0; background: none; font-size: 12px; color: var(--ink2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; position: relative; }
#tabs button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#tabs button.on { color: var(--red); font-weight: 700; }
#tabs .badge { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
#tabs[hidden] { display: none; }
body.sheet-open { overflow: hidden; } /* the page behind does not scroll */
body.sheet-open #tabs { visibility: hidden; } /* round 3: no tab bar under or over a sheet */
@media (min-width: 900px) { #tabs { max-width: 520px; left: 50%; transform: translateX(-50%); border-radius: 18px 18px 0 0; border: 1px solid var(--line); border-bottom: 0; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 700; cursor: pointer; transition: transform .1s, background .15s; }
.btn:active { transform: scale(.97); }
a.btn { text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
a.btn.primary { color: #fff; }
.btn.primary:hover { background: var(--red-d); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: none; }
.pill { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 14px; font-weight: 700; cursor: pointer; }
:focus-visible { outline: 3px solid #1B5FCD; outline-offset: 2px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.card.alert { border-left: 5px solid var(--red); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 700; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.chip.co { background: #fff; }
.chip.red { background: #FCEBEE; border-color: #F3C3CB; color: var(--red-d); }
.ring { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: conic-gradient(var(--ink) calc(var(--p) * 1%), transparent 0); flex: none; }
.ring.x { background: none; position: relative; border-color: var(--ink2); }
.ring.x::after { content: "\00d7"; position: absolute; inset: -6px 0 0 1px; font-size: 14px; line-height: 14px; }
.item { padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.item:first-of-type { border-top: 0; }
.item .t { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--ink2); }
.stagetxt { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 14px; }
.note { background: #FCEBEE; border: 1px solid #F3C3CB; border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 14px; }
.empty { text-align: center; color: var(--ink2); padding: 36px 12px; }
.err { color: var(--red-d); font-size: 14px; }
.skeleton { height: 76px; border-radius: var(--r); background: linear-gradient(90deg, #ECEAEA, #F6F5F5, #ECEAEA); background-size: 200% 100%; animation: sk 1.2s infinite; margin-bottom: 12px; }
@keyframes sk { to { background-position: -200% 0; } }

/* forms */
label { display: block; font-weight: 700; font-size: 14px; margin: 12px 0 4px; }
label .opt { font-weight: 400; color: var(--ink2); }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid #CFCACA; background: #fff; }
textarea { min-height: 70px; resize: vertical; }
input.bad, select.bad, textarea.bad { border-color: var(--red); background: #FFF7F8; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fgrid > div label { margin-top: 12px; }
.lines .card { position: relative; }
.lines .rm { position: absolute; top: 8px; right: 8px; border: 0; background: none; font-size: 22px; color: var(--ink2); cursor: pointer; min-width: 44px; min-height: 44px; }
.missing { background: #FFF7F8; border: 1px solid #F3C3CB; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 12px 0; }
.missing ul { margin: 4px 0 0 18px; padding: 0; }
.stickybar { position: sticky; bottom: calc(var(--tabh) + env(safe-area-inset-bottom) + 8px); padding-top: 14px; background: linear-gradient(to bottom, transparent, var(--bg) 40%); }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; position: sticky; top: calc(var(--bar) + env(safe-area-inset-top)); background: var(--bg); z-index: 5; scrollbar-width: none; }
.chips button { flex: none; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 4px 0; }
.check input { width: 20px; min-height: 20px; }

/* sign-in */
.signin { text-align: center; padding: 60px 0 20px; max-width: 360px; margin: 0 auto; }
.signin img.logo { width: 200px; margin-bottom: 18px; }
.signin form { text-align: left; margin-top: 20px; }
.or { color: var(--ink2); margin: 18px 0 0; font-size: 13px; text-align: center; }

/* sheet and toast */
#sheetwrap { position: fixed; inset: 0; z-index: 40; background: rgba(33,29,29,.5); overscroll-behavior: contain; display: flex; align-items: flex-end; justify-content: center; }
#sheetwrap[hidden] { display: none; }
#sheet { background: #FFFFFF; opacity: 1; width: 100%; max-width: 560px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }

.ev { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.ev .when { color: var(--ink2); width: 92px; flex: none; }
#toast { position: fixed; z-index: 50; left: 50%; bottom: calc(var(--tabh) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s var(--ease-out); max-width: 90vw; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#ptr { position: fixed; z-index: 30; top: 0; left: 50%; width: 36px; height: 36px; margin-left: -18px; border-radius: 50%; background: #fff; border: 1px solid var(--line); opacity: 0; transform: translateY(-48px); display: flex; align-items: center; justify-content: center; }
#ptr.spin::after { content: ""; width: 16px; height: 16px; border: 2px solid var(--red); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
table.lines-t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.lines-t td, table.lines-t th { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.lines-t th { font-size: 12px; color: var(--ink2); border-top: 0; }

/* purchaser screens */
.statusline { font-size: 13px; color: var(--ink2); margin: 0 0 8px; }
.statusline.bad { color: var(--red-d); font-weight: 700; }
.card.need { cursor: pointer; }
.card.need:hover { border-color: #CFCACA; }
details.oldbox { margin: 14px 0; }
details.oldbox summary { cursor: pointer; font-weight: 700; color: var(--ink2); padding: 10px 0; }
.chips .n, .stagebar .n, .board h3 .n { margin-left: 6px; font-size: 12px; font-weight: 700; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 0 7px; }
.chips button.on .n, .stagebar button.on .n { background: #fff; color: var(--ink); }
.chips .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--red); margin-left: 6px; }
.pill .ring { margin-right: 6px; display: inline-block; vertical-align: -2px; }
.stagebar { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 10px; scrollbar-width: none; }
.stagebar button { flex: none; }
.stagebar button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.stagebar button.on .ring { border-color: #fff; background: conic-gradient(#fff calc(var(--p) * 1%), transparent 0); }
.board { display: block; }
.board .col { display: none; }
.board .col.on { display: block; }
.board h3 { display: none; }
.bcard.late { border-left: 5px solid var(--red); }
.bcard { cursor: pointer; margin-bottom: 8px; }
.pathline { word-break: break-all; font-size: 11px; }
.proof { font-size: 11px; word-break: break-all; }
.note.store { background: #EEF6F0; border-color: #C6E0CE; }
.struck td { text-decoration: line-through; color: var(--ink2); }
.maprow { border-top: 1px solid var(--line); padding: 10px 0; transition: opacity .2s; }
.maprow.gone { opacity: 0; }
.maprow .t { font-weight: 600; }
.sug { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.btn.sugbtn { justify-content: flex-start; text-align: left; font-weight: 400; min-height: 44px; padding: 6px 12px; height: auto; }
@media (min-width: 900px) {
  .stagebar { display: none; }
  .board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: start; }
  .board .col, .board .col.on { display: block; }
  .board h3 { display: flex; align-items: center; gap: 6px; font-size: 14px; margin: 0 0 8px; position: sticky; top: calc(var(--bar) + 44px); background: var(--bg); padding: 6px 0; z-index: 3; }
  #view { max-width: 1280px; }
}
.btn.small-btn { min-height: 38px; padding: 0 14px; margin-top: 8px; font-size: 14px; }
.pill.on-alerts { background: #EEF6F0; border-color: #C6E0CE; }
.btn.sugbtn { display: block; white-space: normal; }
.btn.sugbtn b { display: block; }
.banner { background: #fff; border: 1px solid var(--line); border-left: 5px solid var(--ink); border-radius: var(--r); padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.banner .b-main { font-weight: 700; }
