:root {
  --ink: #141414;
  --ink-soft: #4a5057;
  --paper: #ffffff;
  --bg: #f3f6f8;
  --line: #d2dbe1;
  --mustard: #ffc233;
  --mustard-soft: #fff4d6;
  --red: #c8261c;
  --biro: #1f3a93;
  --ok: #1d7a45;
  --radius: 14px;
  --display: "Big Shoulders Display", "Arial Narrow", sans-serif;
  --text: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef1f4;
    --ink-soft: #a9b1b9;
    --paper: #1c1f23;
    --bg: #121417;
    --line: #2f343a;
    --mustard-soft: #3a3016;
    --red: #ff6b5e;
    --biro: #8fa8ff;
    --ok: #4fc483;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--biro); }
h1, h2 { font-family: var(--display); font-weight: 800; letter-spacing: .01em; line-height: 1.05; margin: 0 0 .4em; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.5rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.inline { display: inline; margin: 0; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--mustard); color: #141414;
}
.brand { display: flex; align-items: center; gap: 8px; font: 800 1.6rem var(--display); color: inherit; text-decoration: none; }
.brand img { border-radius: 7px; box-shadow: 0 0 0 2px #141414; }
.top nav { display: flex; gap: 6px; align-items: center; }
.top .btn-ghost { color: #141414; }
.top .btn-primary { background: #141414; color: var(--mustard); border-color: #141414; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--paper); color: var(--ink);
  font: 700 1rem var(--text); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-soft); }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-big { min-height: 52px; font-size: 1.1rem; padding: 10px 24px; width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger { color: var(--red); border-color: currentColor; background: transparent; }
.btn:disabled { opacity: .6; }

/* cards & forms */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
fieldset.card { margin: 0; display: flex; flex-direction: column; gap: 12px; }
legend { font: 800 1.35rem var(--display); padding: 0 6px; margin-left: -6px; }
label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .92rem; color: var(--ink-soft); }
input, select, textarea {
  font: 400 1.05rem var(--text); color: var(--ink); background: var(--paper);
  border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 46px; width: 100%;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--mustard); box-shadow: 0 0 0 3px rgba(255,194,51,.35); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }
.actions { position: sticky; bottom: 0; padding: 12px 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.filepick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.filepick { align-self: flex-start; }
.filepick:focus-within .btn { border-color: var(--mustard); }
.preview { display: flex; flex-wrap: wrap; gap: 8px; }
.preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.uploader { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.danger { margin: 28px 0 8px; text-align: center; }

.flash { padding: 12px 14px; border-radius: 10px; margin: 0 0 14px; font-weight: 700; }
.flash-ok { background: #e3f5ea; color: #155c34; }
.flash-error { background: #fde7e5; color: #8f1a12; }

/* login */
.login { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.login img { border-radius: 14px; }
.login h1 { font-size: 3rem; margin: 10px 0 0; }
.login form { text-align: left; margin-top: 20px; }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font: 800 1.9rem/1 var(--display); }
.stat span { font-size: .8rem; color: var(--ink-soft); }
@media (max-width: 520px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.due { background: var(--mustard-soft); border-color: var(--mustard); }
.due h2 { font-size: 1.3rem; }
.due ul { list-style: none; margin: 0; padding: 0; }
.due li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid rgba(0,0,0,.08); }
.due li:first-child { border-top: 0; }
.due a { font-weight: 700; color: var(--ink); }
.when { font-size: .9rem; white-space: nowrap; }
.overdue { color: var(--red); font-weight: 700; }

.stages { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.stages::-webkit-scrollbar { display: none; }
.pill { flex: none; padding: 6px 12px; border-radius: 999px; border: 2px solid var(--line); background: var(--paper); color: var(--ink); text-decoration: none; font-weight: 700; font-size: .92rem; }
.pill i { font-style: normal; color: var(--ink-soft); font-weight: 400; margin-left: 2px; }
.pill.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pill.on i { color: inherit; opacity: .7; }

.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input { flex: 1; }
.search select { width: auto; flex: none; max-width: 46%; }

.shoplist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.shoprow { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.shoprow:hover { border-color: var(--ink-soft); }
.shoprow img, .noimg { width: 64px; height: 64px; flex: none; border-radius: 10px; object-fit: cover; }
.noimg { display: grid; place-items: center; background: var(--mustard); color: #141414; font: 800 1.8rem var(--display); }
.info { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.info strong { font-size: 1.08rem; }
.info small { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }

.badge, .chip { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.int-hot { background: #fde3e0; color: #9b1c12; border-color: #f4b5ad; }
.int-warm { background: #fff1d1; color: #7a5300; border-color: #f3d48a; }
.int-cold { background: #e2ecfb; color: #234a8c; border-color: #b8cdee; }

/* stage colours */
.st-lead        { --st: #6b7480; }
.st-contacted   { --st: #2f6fd6; }
.st-visited     { --st: #7a4fd0; }
.st-demo        { --st: #c35fb3; }
.st-trial       { --st: #d98a00; }
.st-negotiating { --st: #e0602b; }
.st-won         { --st: #1d8a4c; }
.st-lost        { --st: #9aa1a8; }
.badge[class*="st-"] { background: var(--st); border-color: var(--st); color: #fff; }
.pill[class*="st-"] { border-left: 8px solid var(--st); }
.pill.on[class*="st-"] { background: var(--st); border-color: var(--st); color: #fff; }
.badge-select[class*="st-"] { border-color: var(--st); border-width: 3px; font-weight: 700; }

.empty { text-align: center; color: var(--ink-soft); padding: 24px 16px; }
.empty .btn { max-width: 320px; margin-top: 8px; }
.foot { text-align: center; font-size: .9rem; margin-top: 24px; }

/* shop page */
.back { margin: 0 0 8px; }
.back a { text-decoration: none; font-weight: 700; }
.shophead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.shophead h1 { margin: 0; }
.shophead p { margin: 4px 0 0; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick form { margin: 0; }
@media (max-width: 420px) { .quick { grid-template-columns: 1fr; } }
.facts dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; margin: 0; }
@media (max-width: 520px) { .facts dl { grid-template-columns: 1fr 1fr; } }
.facts dt { font-size: .8rem; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 2px 0 0; font-size: 1.05rem; }
.contact-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.addr { white-space: pre-line; margin: 12px 0 0; color: var(--ink-soft); }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery figure { position: relative; margin: 0; }
.gallery img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.gallery form { position: absolute; top: 4px; right: 4px; margin: 0; }
.x { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 1.2rem; line-height: 1; cursor: pointer; }
.docs, .timeline { list-style: none; margin: 12px 0 0; padding: 0; }
.docs li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.docs li a { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.docs .x, .timeline .x { background: transparent; color: var(--ink-soft); }
.timeline { margin-top: 16px; }
.timeline li { position: relative; padding: 10px 36px 10px 14px; border-left: 3px solid var(--mustard); margin-bottom: 6px; background: var(--bg); border-radius: 0 10px 10px 0; }
.timeline time { display: block; font-size: .8rem; font-weight: 700; color: var(--ink-soft); }
.timeline form { position: absolute; top: 6px; right: 4px; }

[hidden] { display: none !important; }

/* "I'm here" GPS button */
.here { display: flex; flex-direction: column; gap: 6px; }
.btn-here { width: 100%; background: var(--mustard); color: #141414; border-color: var(--mustard); min-height: 50px; }
.ok { color: var(--ok); font-weight: 700; }
.err { color: var(--red); font-weight: 700; }
