:root {
  --brand: #ee8a12;
  --brand-ink: #b8640a;
  --brand-soft: #fff4e6;
  --ink: #1b1d22;
  --ink-2: #4a4f5a;
  --ink-3: #8a909c;
  --line: #e6e8ec;
  --bg: #f4f5f7;
  --card: #ffffff;
  --pass: #17924b;
  --pass-soft: #e5f6ec;
  --fail: #d33a2c;
  --fail-soft: #fdeceb;
  --hold: #c98a00;
  --hold-soft: #fff6dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink); background: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; min-height: 54px;
}
.topbar .logo { height: 28px; width: auto; }
.topbar.editing { gap: 6px; padding-left: 4px; }
.topbar.editing .logo { height: 20px; }
.topbar .title { font-weight: 650; font-size: 15px; line-height: 1.2; flex: 1; min-width: 0; }
.topbar .title small { display: block; color: var(--ink-3); font-weight: 450; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 0; background: transparent; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  cursor: pointer; color: var(--ink-2); flex: none;
}
.icon-btn:active { background: var(--bg); }
.icon-btn svg { width: 22px; height: 22px; }

.save-state { font-size: 12px; color: var(--ink-3); white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pass); }
.save-state.saving .dot { background: var(--hold); }
.save-state.error .dot { background: var(--fail); }

/* ---------- layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 14px 14px calc(96px + var(--safe-b)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 16px; margin: 0 0 2px; }
.card h2 + .sub { color: var(--ink-3); font-size: 12px; margin: 0 0 12px; }
.sec-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.sec-head .t { flex: 1; min-width: 0; }
.sec-head h3 { font-size: 15px; margin: 0; }
.sec-head .zh { color: var(--ink-3); font-size: 12px; }
.count { font-size: 12px; color: var(--ink-3); white-space: nowrap; padding-top: 2px; }

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field label .zh { font-weight: 400; color: var(--ink-3); margin-left: 4px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: #fbfbfc; border-radius: 10px; padding: 11px 12px;
  font-size: 16px; /* prevents iOS zoom */ outline: none; transition: border-color .15s, background .15s;
}
.input:focus { border-color: var(--brand); background: #fff; }
textarea.input { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 8px 4px; font-size: 14px; font-weight: 600;
  color: var(--ink-2); cursor: pointer; min-height: 38px;
}
.seg button.on { background: #fff; box-shadow: var(--shadow); color: var(--ink); }
.seg button.on.yes, .seg button.on.pass { background: var(--pass); color: #fff; }
.seg button.on.no, .seg button.on.fail { background: var(--fail); color: #fff; }
.seg button.on.na { background: var(--ink-3); color: #fff; }
.seg button.on.hold { background: var(--hold); color: #fff; }
.seg.big button { min-height: 52px; font-size: 16px; }

.row-item { border-top: 1px solid var(--line); padding: 12px 0; }
.row-item:first-of-type { border-top: 0; padding-top: 2px; }
.row-item .name { font-weight: 600; }
.row-item .meta { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.row-item .input.remark { margin-top: 8px; padding: 8px 10px; font-size: 15px; }

.spec-row { display: grid; grid-template-columns: 38% 1fr 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.spec-row .input { padding: 9px 10px; font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 11px;
  padding: 12px 16px; font-weight: 650; cursor: pointer; min-height: 46px; text-decoration: none; font-size: 15px;
}
.btn svg { width: 19px; height: 19px; flex: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-ink); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.ghost { background: var(--bg); color: var(--ink); }
.btn.line { background: #fff; border: 1px dashed #c9cdd4; color: var(--ink-2); }
.btn.danger { background: var(--fail-soft); color: var(--fail); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

/* ---------- media capture ---------- */
.cap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.cap label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 62px;
  border-radius: 11px; background: var(--brand-soft); color: var(--brand-ink); font-weight: 650; font-size: 13px; cursor: pointer;
  text-align: center; line-height: 1.15;
}
.cap label small { font-weight: 400; font-size: 11px; opacity: .8; }
.cap label svg { width: 22px; height: 22px; }
.cap label.vid { background: #eef3ff; color: #2d55c9; }
.cap label.up { background: var(--bg); color: var(--ink-2); }
.cap input { display: none; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden; background: #e9ebef; cursor: pointer; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }
.thumb .badge {
  position: absolute; left: 5px; bottom: 5px; background: rgba(0,0,0,.62); color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: 6px; display: flex; align-items: center; gap: 3px;
}
.thumb .badge svg { width: 11px; height: 11px; }
.thumb .cap-dot { position: absolute; right: 5px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; }
.thumb.pending::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.45); }
.thumb .prog { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 5px; border-radius: 3px; background: rgba(0,0,0,.25); z-index: 2; overflow: hidden; }
.thumb .prog i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.thumb .err { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; color: #fff; background: rgba(211,58,44,.78); font-size: 12px; font-weight: 700; text-align: center; padding: 6px; }

/* ---------- bottom tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
  display: flex; padding: 4px 4px calc(4px + var(--safe-b));
}
.tabs button {
  flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; font-size: 11px; font-weight: 600; color: var(--ink-3); cursor: pointer; border-radius: 10px; position: relative;
}
.tabs button svg { width: 23px; height: 23px; }
.tabs button.on { color: var(--brand-ink); }
.tabs button .n { position: absolute; top: 2px; right: calc(50% - 22px); background: var(--brand); color: #fff; border-radius: 9px; font-size: 10px; padding: 0 5px; min-width: 17px; line-height: 16px; }

/* ---------- home ---------- */
.hero { background: linear-gradient(135deg, #1b1d22, #33363e); color: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.hero h1 { font-size: 20px; margin: 0 0 4px; }
.hero p { margin: 0 0 14px; color: #c9ccd3; font-size: 13px; }
.rep { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.rep .r-main { flex: 1; min-width: 0; }
.rep .r-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rep .r-sub { font-size: 12px; color: var(--ink-3); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; letter-spacing: .02em; white-space: nowrap; }
.pill.PASS { background: var(--pass-soft); color: var(--pass); }
.pill.FAIL { background: var(--fail-soft); color: var(--fail); }
.pill.HOLD { background: var(--hold-soft); color: var(--hold); }
.pill.draft { background: var(--bg); color: var(--ink-2); }
.pill.final { background: #e8eefc; color: #2d55c9; }
.empty { text-align: center; color: var(--ink-3); padding: 30px 10px; }

/* ---------- defects ---------- */
.tally { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tally div { background: var(--bg); border-radius: 11px; padding: 10px; text-align: center; }
.tally b { display: block; font-size: 22px; }
.tally span { font-size: 11px; color: var(--ink-3); }
.tally .over { background: var(--fail-soft); color: var(--fail); }
.defect { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.hint { font-size: 12px; color: var(--ink-3); }
.alert { border-radius: 11px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.alert.warn { background: var(--hold-soft); color: #7a5300; }
.alert.bad { background: var(--fail-soft); color: var(--fail); }
.alert.ok { background: var(--pass-soft); color: var(--pass); }

/* ---------- sheet / modal ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(15,17,21,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: #fff; width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + var(--safe-b));
  max-height: 92vh; overflow: auto;
}
.sheet .media-view { background: #0c0d10; border-radius: 12px; overflow: hidden; margin-bottom: 12px; }
.sheet .media-view img, .sheet .media-view video { width: 100%; max-height: 52vh; object-fit: contain; margin: 0 auto; }
.sheet .acts { display: flex; gap: 8px; margin-top: 10px; }
.sheet .acts .btn { flex: 1; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b)); z-index: 60; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 22px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; text-align: center;
}

.upbar { position: fixed; left: 0; right: 0; top: 54px; z-index: 19; background: var(--brand); color: #fff; font-size: 12px; font-weight: 600; padding: 5px 14px; text-align: center; }
