:root {
  --brand: #21438D;
  --brand-ink: #fff;
  --red: #E92526;
  --gold: #FCB319;
  --green: #1f9d55;
  --bg: #f3f4f8;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e3e6ee;
  --chip: #eef1f7;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151f;
    --card: #1a2030;
    --ink: #e8ebf3;
    --muted: #9aa3b8;
    --line: #2a3246;
    --chip: #252d42;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink);
  overscroll-behavior-y: contain;
}
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.splash { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.splash img { border-radius: 16px; }

/* ── Top bar and tabs ───────────────────────────────────── */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--brand); color: var(--brand-ink);
  padding: calc(10px + var(--safe-t)) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.top h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sub { font-size: 12px; opacity: .8; font-weight: 400; display: block; }
.top button { background: none; border: 0; color: inherit; padding: 6px; font-size: 20px; line-height: 1; cursor: pointer; }
.banner { padding: 8px 16px; font-size: 13px; background: #fff3cd; color: #6b4e00; }
.banner.bad { background: #fde2e2; color: #8a1c1c; }

main { padding: 12px 12px calc(84px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs button {
  flex: 1; border: 0; background: none; padding: 8px 4px 10px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; cursor: pointer;
}
.tabs button .ic { font-size: 21px; line-height: 1; }
.tabs button.on { color: var(--brand); font-weight: 600; }
@media (prefers-color-scheme: dark) { .tabs button.on { color: #8fb0ff; } }
.tabs .badge { position: absolute; top: 4px; left: 54%; background: var(--red); color: #fff; border-radius: 9px; font-size: 10px; min-width: 17px; padding: 1px 5px; font-weight: 700; }

/* ── Lists ──────────────────────────────────────────────── */
.seg { display: flex; gap: 6px; margin: 2px 0 12px; overflow-x: auto; }
.seg button { border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 5px 12px; font-size: 13px; white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.card { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 10px; }
.job { padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; cursor: pointer; width: 100%; text-align: left; border: 0; }
.job:active { opacity: .7; }
.job .body { flex: 1; min-width: 0; }
.job .title { font-weight: 600; margin: 2px 0; }
.job .meta { font-size: 12.5px; color: var(--muted); }
.job .right { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 4px 8px; }

.prio { display: inline-block; min-width: 30px; text-align: center; border-radius: 6px; font-weight: 700; font-size: 12px; padding: 3px 6px; color: #fff; }
.prio.p1 { background: var(--red); }
.prio.p2 { background: var(--gold); color: #3b2a00; }
.prio.p3 { background: var(--brand); }
.prio.req { opacity: .55; }
.st { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 10px; background: var(--chip); color: var(--ink); font-weight: 600; }
.st.Submitted { background: #fff1d6; color: #7a5200; }
.st.Assigned { background: #dcecff; color: #154a8c; }
.st.InProgress { background: #dfe6ff; color: #21438D; }
.st.OnHold { background: #ececec; color: #555; }
.st.Completed { background: #dcf5e6; color: #146c3c; }
.st.Closed { background: var(--green); color: #fff; }
.st.Rejected, .st.Cancelled { background: #fde2e2; color: #8a1c1c; }
.down { color: var(--red); font-weight: 700; }
.pending { font-size: 11.5px; color: #8a6500; }

/* ── Job detail ─────────────────────────────────────────── */
.detail { padding: 14px; }
.detail h2 { font-size: 18px; margin: 6px 0 4px; }
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 6px 12px; font-size: 14px; margin: 12px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.note { background: #fff8e1; color: #5b4300; border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-size: 14px; }
@media (prefers-color-scheme: dark) { .note { background: #3a3220; color: #f3dfa6; } }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; font-size: 13.5px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.timeline .when { color: var(--muted); font-size: 12px; }

.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + var(--safe-b)); display: flex; gap: 8px; flex-wrap: wrap;
}
.btn {
  border: 0; border-radius: 10px; padding: 12px 14px; font-weight: 600; cursor: pointer; flex: 1 1 auto;
  background: var(--chip); color: var(--ink); min-height: 46px;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.go { background: var(--green); color: #fff; }
.btn.warn { background: #fff1d6; color: #7a5200; }
.btn.danger { background: #fde2e2; color: #8a1c1c; }
.btn.small { min-height: 0; padding: 8px 12px; font-size: 13px; flex: 0 0 auto; }
.btn:disabled { opacity: .5; }

/* ── Sheets (forms) ─────────────────────────────────────── */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto;
  padding-bottom: calc(90px + var(--safe-b));
}
.sheet .top { background: var(--card); color: var(--ink); border-bottom: 1px solid var(--line); }
.form { padding: 14px; max-width: 720px; margin: 0 auto; }
.field { margin-bottom: 14px; }
.field label, .field .lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.input, textarea.input, select.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--card);
  font-size: 16px; /* stops iOS zooming on focus */
}
textarea.input { min-height: 84px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { margin: 0; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: inline-block; padding: 8px 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--card);
  font-size: 14px; color: var(--ink); cursor: pointer;
}
.chips input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.techrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.techrow:last-child { border-bottom: 0; }
.techrow .nm { flex: 1; }
.techrow .nm small { color: var(--muted); display: block; }
.techrow input[type=checkbox] { width: 22px; height: 22px; }
.star { background: none; border: 0; font-size: 22px; color: var(--gold); cursor: pointer; }
.err { color: var(--red); font-size: 14px; min-height: 1em; margin: 6px 0; }

/* ── Sign-in ────────────────────────────────────────────── */
.signin { max-width: 380px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 20px 40px; }
.signin .logo { text-align: center; margin-bottom: 18px; }
.signin .logo img { border-radius: 18px; }
.signin h1 { text-align: center; font-size: 22px; margin: 8px 0 2px; }
.signin p.lead { text-align: center; color: var(--muted); margin: 0 0 22px; }
.pin { letter-spacing: .5em; text-align: center; font-size: 22px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); z-index: 30;
  background: #222b3d; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 92vw;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.bad { background: var(--red); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.list-pad { padding: 4px 0; }
.setrow { padding: 14px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.setrow:last-child { border-bottom: 0; }
.setrow .grow { flex: 1; }
