:root {
  --navy: #1f2a44;
  --navy-2: #33426a;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #141822;
  --muted: #5e677a;
  --line: #dde2ec;
  --accent: #e0a11b;
  --accent-bg: #fff3d1;
  --good: #1e7b4a;
  --good-bg: #e3f4ea;
  --bad: #b03a2e;
  --bad-bg: #fbe7e4;
  --radius: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[x-cloak] { display: none !important; }

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; }
.topbar .sub { color: #b4bed3; font-size: 13px; margin-left: auto; text-align: right; white-space: nowrap; }
.topbar .brand { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.wrap.wide { max-width: 1100px; }

.progress { height: 4px; background: #c9d1e3; }
.progress > div { height: 100%; background: var(--accent); transition: width .25s; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
}
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span.lbl { display: block; font-weight: 600; font-size: 15px; margin-bottom: 5px; }
label.field > span.lbl .req { color: var(--bad); }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.err { color: var(--bad); font-size: 13px; margin-top: 4px; }

.input-row { display: flex; gap: 8px; align-items: stretch; }
input, select {
  width: 100%;
  font: inherit;
  font-size: 17px; /* 16px+ stops iPhone from zooming into the field */
  padding: 11px 12px;
  border: 1px solid #c3cad8;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  min-height: 48px;
}
input:focus, select:focus { outline: 3px solid rgba(224, 161, 27, .35); border-color: var(--accent); }
input.filled { background: var(--accent-bg); border-color: var(--accent); }
input.invalid, select.invalid { border-color: var(--bad); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  min-height: 48px;
  cursor: pointer;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--navy-2); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid #c3cad8; }
.btn.ghost:hover { background: #eef1f7; }
.btn.accent { background: var(--accent); color: #1b1300; }
.btn.good { background: var(--good); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #e3b5ae; }
.btn.icon { padding: 0 12px; min-width: 48px; background: #eef1f7; color: var(--navy); }
.btn.icon.listening { background: var(--bad); color: #fff; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 14px; }

.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.scan-btn { text-align: left; justify-content: flex-start; padding: 16px; }
.scan-btn .ico { font-size: 26px; line-height: 1; }
.scan-btn .t { display: block; }
.scan-btn .d { display: block; font-weight: 400; font-size: 13px; opacity: .85; }

.notice { border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.notice.good { background: var(--good-bg); color: #14532f; }
.notice.bad { background: var(--bad-bg); color: #7a2219; }
.notice.info { background: #e8eefb; color: #23345c; }

.nav { display: flex; gap: 10px; margin-top: 6px; }
.nav .btn { flex: 1; }

.review dt { color: var(--muted); font-size: 13px; }
.review dd { margin: 0 0 8px; font-weight: 600; word-break: break-word; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- desk ---- */
.desk-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .desk-grid { grid-template-columns: 1fr; } }
.qr { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.qr svg { width: 100%; height: auto; display: block; }
.link-box { font-size: 12px; word-break: break-all; color: var(--muted); }
.pill { display: inline-block; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 4px 10px; }
.pill.waiting { background: #eef1f7; color: var(--muted); }
.pill.opened, .pill.filling { background: var(--accent-bg); color: #6b4a00; }
.pill.sent { background: var(--good-bg); color: #14532f; }
table.vals { width: 100%; border-collapse: collapse; }
table.vals td { padding: 7px 6px; border-top: 1px solid var(--line); vertical-align: middle; }
table.vals td.k { color: var(--muted); font-size: 14px; width: 34%; }
table.vals td.v { font-weight: 600; word-break: break-word; }
table.vals td.act { width: 1%; white-space: nowrap; text-align: right; }
.src { font-size: 11px; font-weight: 600; color: #23345c; background: #e8eefb; border-radius: 6px; padding: 2px 6px; margin-left: 6px; white-space: nowrap; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.photos figcaption { font-size: 12px; color: var(--muted); }
.lightbox { position: fixed; inset: 0; background: rgba(10,14,24,.85); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.code { font: 700 30px/1.2 Consolas, "Cascadia Mono", monospace; letter-spacing: .18em; text-align: center; background: var(--accent-bg); border: 1px dashed var(--accent); border-radius: 10px; padding: 10px; margin: 8px 0; }
.small-qr { max-width: 180px; margin: 0 auto; }
.builder .sec { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.builder .frow { display: grid; grid-template-columns: 24px 1fr 90px 28px; gap: 8px; align-items: center; padding: 4px 0; }
.builder .frow input[type=text] { min-height: 38px; padding: 6px 10px; font-size: 15px; }
.builder .frow.off { opacity: .55; }
.builder .frow .req { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.builder .frow .x { background: none; border: 0; color: var(--bad); cursor: pointer; font-size: 18px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; margin: 0; }
