/* Garage Mission Control — calm, high-contrast, glove-friendly. */
:root {
  --bg: #f5f3ee;
  --card: #ffffff;
  --ink: #16181b;
  --muted: #545b63;
  --line: #d9d5cc;
  --brand: #0e5a55;
  --brand-ink: #ffffff;
  --brand-soft: #e1efed;
  --active: #1d4ed8;
  --active-soft: #e3ebff;
  --done: #157a3a;
  --done-soft: #ddf3e4;
  --overdue: #b42318;
  --overdue-soft: #fde4e1;
  --blocked: #a15c00;
  --blocked-soft: #fff0d6;
  --decision: #6b2bd1;
  --decision-soft: #eee5ff;
  --radius: 14px;
  --tap: 56px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}
a { color: var(--brand); }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; margin-top: 1.5rem; }
h3 { font-size: 1.05rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.hidden { display: none !important; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--brand); color: var(--brand-ink);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar a { color: inherit; text-decoration: none; }
.topbar .brand { font-weight: 800; letter-spacing: .2px; font-size: 1.05rem; }
.topbar .who { font-size: .9rem; opacity: .9; }
.bell { position: relative; font-size: 1.2rem; }
.bell .dot { position: absolute; top: -4px; right: -8px; background: #ffcc33; color: #222; border-radius: 99px; font-size: .7rem; padding: 0 5px; font-weight: 700; }

/* bottom nav — big targets, always visible */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 600; gap: 2px;
}
.bottomnav a .ic { font-size: 1.45rem; line-height: 1; }
.bottomnav a.on { color: var(--brand); }
.bottomnav a.scan .ic { background: var(--brand); color: #fff; border-radius: 99px; width: 46px; height: 46px; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 2px 8px #0003; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 12px; }
.card.hero { border: 3px solid var(--active); }
.card.hero.blocked { border-color: var(--blocked); }
.kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 800; color: var(--muted); }

/* buttons */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: 12px;
  border: 2px solid var(--brand); background: #fff; color: var(--brand);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  touch-action: manipulation;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.go { background: var(--done); border-color: var(--done); color: #fff; }
.btn.warn { border-color: var(--blocked); color: var(--blocked); }
.btn.danger { border-color: var(--overdue); color: var(--overdue); }
.btn.decide { border-color: var(--decision); color: var(--decision); }
.btn.block { display: flex; width: 100%; }
.btn.huge { min-height: 72px; font-size: 1.2rem; }
.btn.small { min-height: 44px; padding: 0 14px; font-size: .95rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btngrid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.btngrid .wide { grid-column: 1 / -1; }

/* forms */
label.f { display: block; font-weight: 700; margin: 12px 0 4px; }
input[type=text], input[type=email], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 52px; font: inherit; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 96px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid #f59e0b; outline-offset: 1px; }
.choice { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.choice label { display: block; border: 2px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; background: #fff; }
.choice input { margin-right: 8px; transform: scale(1.4); }
.choice label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

/* pills / status — color AND text */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; padding: 3px 12px; font-size: .85rem; font-weight: 700; border: 1.5px solid currentColor; white-space: nowrap; }
.pill.active { color: var(--active); background: var(--active-soft); }
.pill.done { color: var(--done); background: var(--done-soft); }
.pill.overdue { color: var(--overdue); background: var(--overdue-soft); }
.pill.blocked { color: var(--blocked); background: var(--blocked-soft); }
.pill.decision { color: var(--decision); background: var(--decision-soft); }
.pill.neutral { color: var(--muted); background: #f1efe9; }
.pill.high { color: var(--overdue); background: #fff; }

/* mission */
.mission-photo { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; background: #eee; }
.mission-title { font-size: 1.45rem; font-weight: 800; margin: 8px 0; }
.facts { display: flex; gap: 8px 16px; flex-wrap: wrap; font-weight: 600; color: var(--muted); margin: 6px 0 10px; }
.why { background: var(--brand-soft); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
details.more { margin-top: 10px; }
details.more summary { min-height: 48px; display: flex; align-items: center; font-weight: 700; cursor: pointer; color: var(--brand); }

/* big code (record page) */
.bigcode { font-size: 3.2rem; font-weight: 900; letter-spacing: .02em; line-height: 1; }
.countdown { font-size: 2rem; font-weight: 900; }

/* gallery */
.gallery { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.tile { display: block; text-decoration: none; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.tile .ph { aspect-ratio: 1; background: #ece9e2 center/cover no-repeat; display: grid; place-items: center; font-size: 2.4rem; color: #9a958a; }
.tile .ph img { width: 100%; height: 100%; object-fit: cover; }
.tile .meta { padding: 8px 10px; }
.tile .code { font-weight: 900; font-size: 1.05rem; }
.tile .nm { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .top { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.overdue { border: 2px solid var(--overdue); }

/* stats */
.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-decoration: none; color: inherit; display: block; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.bar { height: 14px; border-radius: 99px; background: #e6e2d8; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--done); }

/* lists */
.list { list-style: none; padding: 0; margin: 0; }
.list > li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.list > li + li { margin-top: 8px; }
.list a.rowlink { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #ece9e2; flex: none; display: grid; place-items: center; color: #9a958a; font-size: 1.5rem; }
table.t { width: 100%; border-collapse: collapse; background: #fff; font-size: .92rem; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.scrollx { overflow-x: auto; }

/* contents list (permanent storage) */
.contents li { display: flex; align-items: center; gap: 10px; }
.contents .nm { flex: 1; font-weight: 600; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 48px; height: 48px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-size: 1.4rem; font-weight: 800; }
.qty b { min-width: 2ch; text-align: center; }

/* flash */
.flash { background: #fff7d6; border: 2px solid #e8c547; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-weight: 600; }
.flash.err { background: var(--overdue-soft); border-color: var(--overdue); }

/* upload */
.progress { height: 10px; background: #e6e2d8; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .1s linear; }
.photos { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.photos a img { aspect-ratio: 1; object-fit: cover; border-radius: 8px; width: 100%; }

/* scanner */
.scanner { position: relative; background: #000; border-radius: 14px; overflow: hidden; aspect-ratio: 3/4; max-height: 60vh; margin: 0 auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 18%; border: 4px solid #fff; border-radius: 16px; box-shadow: 0 0 0 999px #0006; }
.codeinput { font-size: 2rem !important; text-transform: uppercase; text-align: center; letter-spacing: .1em; font-weight: 800; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottomnav { position: sticky; top: 0; bottom: auto; grid-template-columns: repeat(5, 140px); justify-content: center; border-bottom: 1px solid var(--line); }
  .bottomnav a.scan .ic { margin-top: 0; width: 34px; height: 34px; font-size: 1.1rem; }
}
.tile .pill { white-space: normal; font-size: .78rem; padding: 2px 8px; }
.btngrid form { display: flex; }
.btngrid form > .btn { flex: 1; }

/* quick add */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #e8e4da; padding: 4px; border-radius: 14px; }
.segbtn { min-height: 52px; border: 0; border-radius: 10px; background: transparent; font: inherit; font-weight: 700; color: var(--muted); }
.segbtn.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px #0002; }
.btngrid .wide { grid-column: 1 / -1; }
.quick-list { margin-top: 12px; }
.qcard { display: flex; gap: 12px; align-items: flex-start; }
.qcard .thumb { width: 84px; height: 84px; }
.qcard .qbody { flex: 1; min-width: 0; }
.qcard .qbody > * + * { margin-top: 6px; }
.qcode { font-size: 1.4rem; font-weight: 900; }
.qcard[data-state="done"] { border-left: 6px solid var(--done); }
.qcard[data-state="error"] { border-left: 6px solid var(--overdue); }
.qcard[data-state="uploading"], .qcard[data-state="queued"], .qcard[data-state="creating"], .qcard[data-state="shrinking"] { border-left: 6px solid var(--active); }
