:root {
  --blue: #1f4e78;
  --blue-2: #2c6aa0;
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #111827;
  --muted: #5b6472;
  --line: #d4d9e1;
  --ok: #157f3b;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
.mockbar {
  background: #fde68a; color: #713f12; font-size: 13px; text-align: center; padding: 4px 8px;
}
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  background: var(--blue); color: #fff; padding: 8px 12px; min-height: 56px;
}
.top[hidden] { display: none; }
.back {
  background: transparent; border: 0; color: #fff; font-size: 26px; width: 44px; height: 44px;
  border-radius: 8px; cursor: pointer;
}
.back:active { background: rgba(255,255,255,.15); }
.top-title { flex: 1; min-width: 0; }
.brand { font-weight: 700; font-size: 17px; }
.sub { font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signal {
  border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  background: #dcfce7; color: var(--ok); cursor: pointer; min-height: 36px;
}
.signal.off { background: #fee2e2; color: var(--bad); }

main { max-width: 560px; margin: 0 auto; padding: 16px 16px 96px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
p.help, .help { color: var(--muted); font-size: 14px; margin: 4px 0 10px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.notice {
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; font-size: 15px;
  background: #e0ecf8; color: #12324f;
}
.notice.warn { background: #fef3c7; color: #713f12; }
.notice.bad { background: #fee2e2; color: #7f1d1d; }
.notice.ok { background: #dcfce7; color: #14532d; }

/* Home tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 12px; min-height: 112px; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.tile:active { background: #eaf1f8; }
.tile .ic { font-size: 30px; line-height: 1; }
.tile .t { font-weight: 700; }
.tile .d { color: var(--muted); font-size: 13px; }
.tile.wide { grid-column: 1 / -1; min-height: 72px; flex-direction: row; align-items: center; gap: 12px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list button, .row-btn {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  text-align: left; font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
  min-height: 60px; cursor: pointer;
}
.list small { display: block; color: var(--muted); }

/* Forms */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
label .opt { font-weight: 400; color: var(--muted); font-size: 14px; }
input[type=text], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1.5px solid #aab3c0; border-radius: 10px; padding: 12px; min-height: 50px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #93c5fd; border-color: var(--blue-2); }
.req { color: var(--bad); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid #aab3c0; background: #fff; border-radius: 999px; padding: 10px 16px;
  font: inherit; font-size: 15px; min-height: 46px; cursor: pointer; color: inherit;
}
.chip[aria-pressed=true] { background: var(--blue); border-color: var(--blue); color: #fff; }

.rows .r { display: grid; grid-template-columns: 1fr 84px 44px; gap: 8px; margin-bottom: 8px; }
.rows .r.three { grid-template-columns: 1fr 1fr 44px; }
.icon-btn {
  border: 1.5px solid #aab3c0; background: #fff; border-radius: 10px; font-size: 20px;
  min-height: 50px; cursor: pointer; color: var(--muted);
}
.link-btn {
  background: none; border: 0; color: var(--blue-2); font: inherit; font-weight: 600;
  padding: 10px 0; cursor: pointer; min-height: 44px;
}

.btn {
  display: block; width: 100%; border: 0; border-radius: var(--radius); padding: 15px;
  font: inherit; font-weight: 700; font-size: 18px; min-height: 56px; cursor: pointer;
  background: var(--blue); color: #fff; margin-top: 12px;
}
.btn:active { background: var(--blue-2); }
.btn.secondary { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 600; font-size: 16px; }

.sticky-actions {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(242,244,247,.96);
  border-top: 1px solid var(--line); padding: 8px 16px 12px;
}
.sticky-actions .inner { max-width: 560px; margin: 0 auto; }
.sticky-actions .btn { margin-top: 0; }
.saved { font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 6px; min-height: 18px; }

/* Photos */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.thumbs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.file-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed #8fa3bb; border-radius: var(--radius); padding: 18px; min-height: 64px;
  background: #fff; font-weight: 700; color: var(--blue); cursor: pointer;
}
.file-btn input { display: none; }

/* Progress */
.boq { padding: 12px 14px; }
.boq .name { font-weight: 700; }
.boq .prev { color: var(--muted); font-size: 14px; }
.boq .pct { display: grid; grid-template-columns: 1fr 96px; gap: 10px; align-items: center; margin-top: 8px; }
.boq input[type=range] { width: 100%; height: 36px; accent-color: var(--blue); }
.boq .err { color: var(--bad); font-size: 14px; margin-top: 4px; }

/* Punch items */
.punch { position: relative; }
.punch .num { font-weight: 700; color: var(--muted); font-size: 14px; }
.punch .rm { position: absolute; top: 10px; right: 10px; width: 44px; }

/* Outbox */
.status { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status.wait { background: #fef3c7; color: var(--warn); }
.status.sent { background: #dcfce7; color: var(--ok); }

details.agent { margin-top: 12px; }
details.agent summary { cursor: pointer; font-weight: 600; color: var(--blue-2); min-height: 44px; padding: 10px 0; }
pre {
  background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 10px; font-size: 12.5px;
  overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}

/* QR scanner overlay */
.scan-ov { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.scan-box { background: var(--bg); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 14px 16px 20px; max-height: 92vh; overflow: auto; }
.scan-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.scan-head .icon-btn { width: 44px; }
.scan-video { position: relative; background: #000; border-radius: 12px; aspect-ratio: 4/3; overflow: hidden; }
.scan-video video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18% 22%; border: 3px solid #fff; border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-msg { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: #fff; font-size: 14px; padding: 0 12px; }
.scan-btn { white-space: nowrap; }
.idlist { list-style: none; padding: 0; margin: 8px 0; }
.idlist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 12px; margin-bottom: 6px; }
.idlist li .icon-btn { width: 44px; min-height: 44px; }
.alert-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.alert-row:first-of-type { border-top: 0; }
.pill { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; flex: none; }
.pill.HIGH { background: #fee2e2; color: var(--bad); }
.pill.MEDIUM { background: #fef3c7; color: var(--warn); }

.login-logo {
  width: 72px; height: 72px; border-radius: 18px; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 24px; margin: 24px auto 12px;
}
.center { text-align: center; }
.foot { color: var(--muted); font-size: 13px; text-align: center; margin-top: 24px; }
