:root {
  --ink: #15181D; --ink2: #2A2F37; --muted: #4B5563; --line: #E5E7EB;
  --ground: #F3F4F6; --card: #FFFFFF; --accent: #C2410C; --accent-soft: #FFEDD5;
  --good: #15803D; --good-soft: #DCFCE7; --warn-soft: #FEF3C7; --warn: #92400E;
  --info-soft: #DBEAFE; --info: #1E40AF; --bad: #B91C1C; --bad-soft: #FEE2E2;
  --r: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--ink); background: var(--ground);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--ground); }
body { padding-bottom: env(safe-area-inset-bottom); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

header.bar {
  background: var(--ink); color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 16px;
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 5;
}
header.bar h1 { margin: 0; font-size: 21px; font-weight: 700; flex: 1; line-height: 1.2; }
header.bar .sub { font-size: 13px; color: #C9CDD3; font-weight: 400; display: block; margin-top: 2px; }
.round {
  width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--ink2); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer;
}
.brand { font-size: 12px; font-weight: 600; letter-spacing: .08em; color: #F59E5B; }
.testflag {
  background: #FDE047; color: #422006; text-align: center; font-size: 13px; font-weight: 700;
  padding: 6px; letter-spacing: .04em;
}

main { padding: 16px; display: flex; flex-direction: column; gap: 14px; max-width: 640px; margin: 0 auto; }
h2.sec { margin: 4px 0 0; font-size: 13px; font-weight: 600; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
  min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  font-size: 17px; font-weight: 700; cursor: pointer; text-align: left;
}
.tile.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.tile svg { width: 28px; height: 28px; }

.row {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; width: 100%; text-align: left;
}
.row .t { font-size: 16px; font-weight: 700; }
.row .s { font-size: 14px; color: var(--muted); margin-top: 3px; }
.row > div { min-width: 0; }
.row .t, .row .s { overflow: hidden; text-overflow: ellipsis; }

.chip { font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px; white-space: nowrap; background: var(--line); color: #374151; }
.chip.Approved { background: var(--info-soft); color: var(--info); }
.chip.In-Progress { background: var(--info-soft); color: var(--info); }
.chip.Waiting-Parts { background: var(--warn-soft); color: var(--warn); }
.chip.Pending { background: var(--warn-soft); color: var(--warn); }
.chip.Declined { background: var(--bad-soft); color: var(--bad); }
.chip.Done { background: var(--good-soft); color: var(--good); }

label.f { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
input.in, select.in, textarea.in {
  border: 1px solid #D1D5DB; border-radius: 12px; padding: 12px 14px; font-size: 16px; background: #fff; width: 100%;
  color: var(--ink); font-weight: 400;
}
textarea.in { min-height: 90px; resize: vertical; line-height: 1.45; }
input.in:focus, select.in:focus, textarea.in:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 15px; padding: 9px 13px; border-radius: 999px; background: var(--ground); border: 1px solid var(--line); cursor: pointer;
}
.pill.on { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.seg .pill { text-align: center; border-radius: 10px; padding: 12px 0; font-weight: 600; }

.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photos .ph { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--ink); }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph .x {
  position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 15px; border: 0;
  background: rgba(0,0,0,.65); color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
}
.addphoto {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: 12px;
  border: 2px dashed #D1D5DB; background: #fff; font-size: 16px; font-weight: 600; cursor: pointer; position: relative;
}
.addphoto input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.btn {
  height: 56px; border-radius: var(--r); border: 0; background: var(--accent); color: #fff; font-size: 18px; font-weight: 700;
  width: 100%; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.green { background: var(--good); }
.btn.dark { background: var(--ink); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); height: 48px; font-size: 16px; }
.btn[disabled] { opacity: .55; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.4; }
.err { background: var(--bad-soft); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.okbox { background: var(--good-soft); color: #065F46; border-radius: 10px; padding: 12px 14px; font-size: 15px; line-height: 1.45; }
pre.preview { white-space: pre-wrap; font-size: 13px; background: var(--ground); border-radius: 10px; padding: 10px; margin: 0; }

.jl { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--ground); }
.jl:first-child { border-top: 0; }
.jl .n { width: 34px; font-weight: 700; color: var(--muted); flex: none; }
.jl .b { flex: 1; min-width: 0; }
.jl .j { font-size: 16px; font-weight: 600; }
.jl .m { font-size: 14px; color: var(--muted); margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.empty { color: var(--muted); font-size: 15px; padding: 8px 2px; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(120px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; transition: transform .25s; z-index: 20; max-width: 90vw;
}
#toast.show { transform: translateX(-50%) translateY(0); }
.spin { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: s 1s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
