:root {
  --bg: #0b0d12;
  --bg-2: #11141b;
  --bg-3: #171b24;
  --border: #232936;
  --border-2: #2e3646;
  --text: #e7eaf0;
  --text-2: #9aa3b2;
  --text-3: #667085;
  --accent: #6c7cff;
  --accent-2: #8b98ff;
  --red: #ef4444;
  --orange: #f97316;
  --yellow: #eab308;
  --green: #22c55e;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; padding: 20px 14px;
  background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
.logo .mark { width: 26px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), #b16cff); display: grid; place-items: center; font-size: 13px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; color: var(--text-2); font-weight: 500;
  border: none; background: none; width: 100%; text-align: left; font-size: 13.5px;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--bg-3); color: var(--text); }
.nav-item .ic { display: grid; place-items: center; color: var(--text-3); }
.nav-item:hover .ic, .nav-item.active .ic { color: var(--accent-2); }
.nav-item .badge { margin-left: auto; }
.sidebar .spacer { flex: 1; }
.userbox {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 6px 2px; border-top: 1px solid var(--border);
}
.userbox .avatar {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b16cff);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
}
.userbox .uinfo { flex: 1; min-width: 0; }
.userbox .uinfo b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbox .uinfo span { display: block; color: var(--text-3); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn {
  display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0;
  background: none; border: none; border-radius: 8px; color: var(--text-3); transition: .15s;
}
.iconbtn:hover { background: var(--bg-3); color: var(--text); }
.iconbtn.active { background: var(--bg-3); color: var(--accent-2); }

.main { flex: 1; padding: 28px 36px 60px; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; letter-spacing: -.02em; font-weight: 700; }
.page-head p { color: var(--text-2); margin-top: 4px; font-size: 13px; }

/* ---------- components ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; border: none;
  padding: 8px 15px; border-radius: 8px; font-weight: 600; font-size: 13.5px;
  transition: .15s;
}
.btn:hover { background: var(--accent-2); }
.btn.secondary { background: var(--bg-3); color: var(--text); border: 1px solid var(--border-2); }
.btn.secondary:hover { border-color: var(--text-3); }
.btn.ghost { background: none; color: var(--text-2); border: none; padding: 6px 10px; }
.btn.ghost:hover { color: var(--text); }
.btn.danger { background: rgba(239,68,68,.12); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.btn:disabled { opacity: .5; cursor: default; }

.card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1000px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }

.stat .label { color: var(--text-2); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; }
.stat .sub { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.stat.warn .value { color: var(--yellow); }
.stat.bad .value { color: var(--red); }
.stat.good .value { color: var(--green); }

.statrow { display: flex; gap: 40px; flex-wrap: wrap; }
.statrow .stat { min-width: 130px; }
.statrow .codebar { margin-top: 10px; }

.attention { margin-top: 14px; }
.attention .label { color: var(--text-2); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.attention ul { list-style: none; }
.attention li { padding: 4px 0; font-size: 13.5px; }

.badge {
  display: inline-flex; align-items: center; padding: 2px 9px; gap: 5px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.badge.red { background: rgba(239,68,68,.14); color: #f87171; }
.badge.orange { background: rgba(249,115,22,.14); color: #fb923c; }
.badge.yellow { background: rgba(234,179,8,.14); color: #facc15; }
.badge.green { background: rgba(34,197,94,.14); color: #4ade80; }
.badge.grey { background: var(--bg-3); color: var(--text-2); }
.badge.violet { background: rgba(108,124,255,.14); color: var(--accent-2); }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border-2); border-radius: 14px;
  padding: 46px 30px; text-align: center; transition: .2s; cursor: pointer;
  background: var(--bg-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: rgba(108,124,255,.05); }
.dropzone .icon { font-size: 34px; margin-bottom: 12px; }
.dropzone h3 { font-size: 16px; margin-bottom: 6px; }
.dropzone p { color: var(--text-2); font-size: 13px; }

.joblist { margin-top: 18px; display: flex; flex-direction: column; gap: 8px; }
.jobrow {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.jobrow .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobrow .detail { color: var(--text-3); font-size: 12px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spinner {
  width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid var(--border-2); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- table ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.search {
  flex: 1; min-width: 220px; max-width: 380px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 13px; border-radius: 8px; font: inherit; font-size: 13.5px;
}
.search:focus { outline: none; border-color: var(--accent); }

table.reg { width: 100%; border-collapse: collapse; }
.reg th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-3); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.reg td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.reg tr.row { cursor: pointer; transition: background .1s; }
.reg tr.row:hover { background: var(--bg-2); }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--bg-3); display: grid; place-items: center; color: var(--text-3); font-size: 15px; flex-shrink: 0; }
.namecell { display: flex; align-items: center; gap: 12px; }
.namecell .nm { font-weight: 600; }
.namecell .sub { color: var(--text-3); font-size: 12px; margin-top: 1px; }

/* ---------- drawer (desktop: centered modal / mobile: full-screen sheet) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(1320px, calc(100vw - 48px)); max-height: min(900px, calc(100dvh - 48px)); z-index: 50;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden; padding: 22px 28px 24px;
  animation: popin .18s cubic-bezier(.2,.8,.2,1);
}
@keyframes popin { from { transform: translate(-50%, -48%) scale(.97); opacity: 0; } }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.confirm-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(480px, 92vw); z-index: 81;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  padding: 22px 24px; animation: popin .18s cubic-bezier(.2,.8,.2,1);
}
.confirm-box h3 { font-size: 16px; letter-spacing: -.01em; margin-bottom: 8px; }
.confirm-box p { color: var(--text-2); font-size: 13px; line-height: 1.55; }
.confirm-box .actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; flex-wrap: wrap; }

/* subtle photo swap tools + gallery picker */
.photo-tools { display: flex; gap: 14px; justify-content: center; margin-top: 8px; }
.linkbtn { background: none; border: none; color: var(--text-3); font-size: 12px; padding: 0; }
.linkbtn:hover { color: var(--accent-2); text-decoration: underline; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; margin-top: 14px; max-height: 320px; overflow-y: auto; }
.photo-grid button { background: var(--bg-3); border: 1px solid var(--border); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.photo-grid button:hover { border-color: var(--accent); }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.photo-grid .lbl { font-size: 10.5px; color: var(--text-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer h2 { font-size: 19px; letter-spacing: -.02em; margin-bottom: 2px; }
.drawer .close { position: absolute; top: 18px; right: 20px; }
.media-panel { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px; min-height: 360px; display: grid; place-items: center; }
.media-col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.media-col .media-panel { flex: 1; min-height: 240px; position: relative; overflow: hidden; }
.media-col .hero-img { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); max-height: none; object-fit: contain; }
.fieldgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px; margin-top: 12px; align-items: start; }
.fieldgrid .wide { grid-column: 1 / -1; }
.fieldgrid .textblock { grid-column: auto; }
.field label { display: block; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 5px; }
.field.missing label { color: var(--text-3); }
.field.missing label::after { content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 7px; border-radius: 50%; background: rgba(250,204,21,.85); vertical-align: 2px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 11px; border-radius: 8px; font: inherit; font-size: 13.5px;
}
.field select option { background: var(--bg); color: var(--text); }
.field.missing input, .field.missing textarea, .field.missing select { border-color: rgba(250,204,21,.38); background: var(--bg); }
.field.missing select option { background: var(--bg); color: var(--text); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field.missing input::placeholder, .field.missing textarea::placeholder { color: var(--text-3); opacity: 1; }
.field textarea { min-height: 42px; max-height: 118px; resize: vertical; overflow: hidden; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.reviewbox { margin-top: 16px; background: rgba(234,179,8,.07); border: 1px solid rgba(234,179,8,.25); border-radius: 8px; padding: 12px 14px; font-size: 13px; }
.reviewbox li { margin-left: 18px; margin-top: 3px; color: #facc15; }
.hero-img { display: block; width: 100%; max-width: 100%; max-height: 420px; object-fit: contain; border-radius: 8px; }

/* ---------- review wizard ---------- */
.drawer.wizard { display: flex; flex-direction: column; height: min(900px, calc(100dvh - 48px)); }
.drawer.register-edit { width: min(1440px, calc(100vw - 48px)); }
.wiz-badges { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.wsteps { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.wstep-tab {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--bg-3); border: 1px solid var(--border); color: var(--text-2);
  padding: 6px 12px 6px 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.wstep-tab i {
  font-style: normal; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
  background: var(--bg-2); color: var(--text-3);
}
.wstep-tab.active { border-color: var(--accent); color: var(--text); }
.wstep-tab.active i { background: rgba(108,124,255,.16); color: var(--accent-2); }
.wstep-tab.done i { background: rgba(34,197,94,.14); color: var(--green); }
.wiz-body { flex: 1; min-height: 200px; overflow-y: auto; margin-top: 14px; }
.wstep { display: none; }
.wstep.active { display: block; }
.wiz-cols { display: grid; grid-template-columns: minmax(220px, 32%) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.wiz-footer { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ai-item { position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px 10px; }
.ai-item dt { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding-right: 64px; }
.ai-item dd { font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.conf { position: absolute; top: 8px; right: 10px; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.conf.hi { background: rgba(34,197,94,.14); color: var(--green); }
.conf.mid { background: rgba(234,179,8,.14); color: #facc15; }
.conf.lo { background: rgba(239,68,68,.14); color: #f87171; }
.conf.none { background: var(--bg-3); color: var(--text-3); }
.fold { margin-top: 16px; }
.fold summary { cursor: pointer; color: var(--text-3); font-size: 12.5px; font-weight: 600; margin-bottom: 12px; }
.fold summary:hover { color: var(--accent-2); }
.pdf-frame { width: 100%; height: min(58vh, 620px); border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.attest-row {
  display: flex; gap: 10px; align-items: flex-start; margin-top: 14px;
  padding: 12px 14px; background: rgba(234,179,8,.07); border: 1px solid rgba(234,179,8,.25);
  border-radius: 10px; font-size: 13px; line-height: 1.5; cursor: pointer;
}
.attest-row input { margin-top: 3px; flex-shrink: 0; }
.register-edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 42%); gap: 18px; align-items: start; }
.register-edit-main { min-width: 0; }
.register-edit-photo { margin-bottom: 14px; }
.register-edit-photo .media-panel { min-height: 220px; max-height: 300px; }
.register-edit-photo .hero-img { max-height: 260px; }
.register-edit-photo.empty-photo { display: flex; justify-content: flex-start; margin-bottom: 2px; }
.register-edit-photo.empty-photo .photo-tools { justify-content: flex-start; margin-top: 0; }
.register-edit-sds { min-width: 0; }
.register-edit-sds h3 { font-size: 14px; letter-spacing: -.01em; margin-bottom: 10px; }
.register-edit-sds .pdf-frame { height: min(650px, calc(100dvh - 260px)); min-height: 360px; }

/* ---------- auth ---------- */
/* body.auth: size to the visual viewport exactly — no page scroll, no jump when
   the on-screen keyboard opens (100dvh + interactive-widget=resizes-content). */
body.auth { height: 100dvh; overflow: hidden; overscroll-behavior: none; }
body.auth #app { height: 100%; }
.auth-wrap { height: 100%; min-height: 0; display: grid; grid-template-columns: 100%; place-items: center; padding: 20px; overflow-y: auto; }
.auth-card { width: 400px; max-width: 100%; }
.auth-card .card { padding: 34px; }
.auth-card h1 { font-size: 22px; margin: 18px 0 4px; letter-spacing: -.02em; }
.auth-card .sub { color: var(--text-2); margin-bottom: 22px; font-size: 13.5px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }
.auth-submit { position: relative; min-height: 42px; overflow: hidden; transition: transform .14s ease, filter .18s ease, opacity .18s ease; }
.auth-submit:active { transform: translateY(1px) scale(.995); }
.auth-submit:disabled { cursor: wait; opacity: .92; }
.auth-submit.is-loading { cursor: wait; opacity: .92; pointer-events: none; }
.auth-submit-label { transition: transform .18s ease, opacity .18s ease; }
.auth-submit-spinner {
  position: absolute; left: 50%; top: 50%; margin-left: -8.5px; margin-top: -8.5px;
  width: 17px; height: 17px; border-radius: 50%; opacity: 0; transform: translateY(8px) scale(.8);
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .7s linear infinite; transition: transform .18s ease, opacity .18s ease;
  pointer-events: none;
}
.auth-submit.is-loading .auth-submit-label { opacity: 0; transform: translateY(-8px) scale(.96); }
.auth-submit.is-loading .auth-submit-spinner { opacity: 1; transform: translateY(0) scale(1); }
.auth-submit.is-loading .auth-submit-label { pointer-events: none; }
.auth-submit.is-loading .auth-submit-spinner { z-index: 1; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--text-2); font-size: 13px; }
.auth-card input:-webkit-autofill,
.auth-card input:-webkit-autofill:hover,
.auth-card input:-webkit-autofill:focus,
.auth-card input:autofill {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--bg) inset;
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset;
  transition: background-color 9999s ease-in-out 0s, color 9999s ease-in-out 0s;
}

/* ---------- misc ---------- */
#toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--bg-3); border: 1px solid var(--border-2); color: var(--text);
  padding: 11px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow);
  animation: slidein .2s;
}
.toast.err { border-color: rgba(239,68,68,.4); }
.empty { text-align: center; color: var(--text-3); padding: 60px 20px; }
.empty .big { font-size: 36px; margin-bottom: 12px; }
.imgcard { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; }
.imgcard img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.imgcard select { flex: 1; background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: 8px; }
.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 12px; letter-spacing: -.01em; }
.section-hint { color: var(--text-3); font-size: 12.5px; margin: -6px 0 14px; }
.reviewcard { margin-bottom: 12px; cursor: pointer; transition: border-color .15s, transform .15s; }
.reviewcard:hover { border-color: var(--accent); transform: translateY(-1px); }
.queue-hint { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }

/* ---------- add & review flow ---------- */
.allclear {
  display: flex; align-items: center; gap: 14px; margin-top: 22px;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-2); font-size: 13.5px;
}
.allclear .tick {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
  background: rgba(34,197,94,.14); color: var(--green);
}
.allclear b { display: block; margin-bottom: 2px; }
.allclear .sub { color: var(--text-3); font-size: 12.5px; }
.codebar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.progressbar { height: 6px; border-radius: 4px; background: var(--bg-3); overflow: hidden; margin-top: 10px; }
.progressbar > div { height: 100%; background: linear-gradient(90deg, var(--accent), #b16cff); transition: width .4s; }

.dz-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* ---------- mobile ---------- */
.mobilebar { display: none; }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .mobilebar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; background: var(--bg-2); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 30;
  }
  .mobilebar .logo { padding: 0; }
  /* sidebar becomes a fixed bottom tab bar */
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    width: 100%; height: auto; flex-direction: row; gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--border); z-index: 30;
  }
  .sidebar .logo, .sidebar .userbox, .sidebar .spacer { display: none; }
  .nav-item { justify-content: center; text-align: center; font-size: 12.5px; padding: 10px 4px; }
  .nav-item .badge { margin-left: 4px; }

  .main { padding: 18px 14px calc(88px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 19px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .statrow { gap: 20px; }

  .dropzone { padding: 28px 16px; }
  .jobrow .detail { max-width: 30%; }
  .reviewcard > div, .imgcard { flex-wrap: wrap; }

  .drawer {
    top: 0; left: 0; transform: none; width: 100vw; height: 100%;
    max-height: none; border-radius: 0; border: none;
    overflow-y: auto;
    padding: 20px 16px calc(60px + env(safe-area-inset-bottom));
    animation: slidein .22s cubic-bezier(.2,.8,.2,1);
  }
  .drawer.wizard { height: 100%; }
  .wiz-cols { display: block; }
  .register-edit-layout { display: block; }
  .register-edit-sds { margin-top: 18px; }
  .register-edit-sds .pdf-frame { height: 62vh; min-height: 0; }
  .wiz-cols .media-col { margin-bottom: 14px; }
  .drawer.wizard .wiz-body { overflow-y: visible; }
  .pdf-frame { height: 62vh; }
  .media-panel { min-height: 0; margin-bottom: 14px; }
  .media-col { margin-bottom: 14px; gap: 8px; }
  .media-col .media-panel { margin-bottom: 0; flex: none; min-height: 0; position: static; }
  .media-col .hero-img { position: static; width: 100%; height: auto; max-height: 180px; }
  .hero-img { max-height: 180px; }
  .field textarea { min-height: 48px; max-height: 220px; }
  .fieldgrid { grid-template-columns: 1fr; }
  .fieldgrid .textblock { grid-column: 1 / -1; }

  /* register table: keep thumb, name, storage, status; rest scrolls off less usefully on a phone */
  .reg th:nth-child(3), .reg td:nth-child(3),
  .reg th:nth-child(4), .reg td:nth-child(4),
  .reg th:nth-child(6), .reg td:nth-child(6),
  .reg th:nth-child(7), .reg td:nth-child(7) { display: none; }

  /* 16px inputs prevent iOS auto-zoom on focus */
  .field input, .field textarea, .field select, .search, .imgcard select { font-size: 16px; }
  .btn { padding: 10px 16px; }

  #toasts { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); align-items: stretch; }

  /* top-anchor the auth card so the keyboard resize doesn't re-centre (jump) it */
  .auth-wrap { place-items: start center; padding-top: max(40px, 8svh); }
  .auth-card .card { padding: 26px 22px; }
}

/* ---------- mobile register ---------- */
.mregcard {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 9px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px;
}
.mregcard .minfo { flex: 1; min-width: 0; }
.mregcard b {
  display: -webkit-box; font-size: 13.5px; line-height: 1.25; overflow: hidden;
  line-clamp: 2;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.mregcard .sub { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mregmeta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.mobile-register-toolbar { display: flex; align-items: center; gap: 10px; }
.mobile-register-toolbar .search { flex: 1; }
.mgallery-btn {
  position: relative; width: 42px; height: 42px; flex-shrink: 0; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 50%; background: var(--bg-2); color: var(--text-2);
}
.mgallery-badge {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--yellow); color: #111; font-size: 10px; font-weight: 800;
  display: grid; place-items: center; box-shadow: 0 3px 10px rgba(0, 0, 0, .28);
}
.mphoto-sheet { padding-top: 8px; overflow-x: hidden; }
.mphoto-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.mphoto-head h2 { font-size: 18px; letter-spacing: -.02em; }
.mphoto-head p { color: var(--text-3); font-size: 12px; margin-top: 4px; line-height: 1.45; }
.mphoto-section { margin-top: 14px; }
.mphoto-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 8px; }
.mphoto-card {
  width: 100%; max-width: 100%; min-width: 0;
  display: grid; grid-template-columns: 48px minmax(0, 1fr) 74px; align-items: center; gap: 8px; margin-bottom: 8px; text-align: left;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 14px; padding: 9px 10px;
}
.mphoto-card img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; background: var(--bg-2); flex-shrink: 0; }
.mphoto-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.mphoto-meta b { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mphoto-meta span { color: var(--text-3); font-size: 11.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mphoto-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.mphoto-retake, .mphoto-delete {
  width: 34px; height: 34px; flex-shrink: 0; display: grid; place-items: center;
  border-radius: 50%;
}
.mphoto-retake {
  border: 1px solid var(--border); background: rgba(255, 255, 255, .03); color: var(--text-2);
}
.mphoto-delete {
  border: 1px solid rgba(239, 68, 68, .22); border-radius: 50%; background: rgba(239, 68, 68, .08); color: #f87171;
}
.mphoto-retake svg, .mphoto-delete svg { width: 15px; height: 15px; }
.mphoto-open { padding-right: 12px; }
.mphoto-empty { padding: 14px 0; }

/* archived register entries — kept visible but clearly inactive */
.reg tr.archived td { opacity: .45; }
.reg tr.archived .thumb { filter: grayscale(1); }
.mregcard.archived { opacity: .55; }
.mregcard.archived .thumb { filter: grayscale(1); }
.msheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--bg-2); border-top: 1px solid var(--border); border-radius: 16px 16px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 82dvh; overflow-y: auto;
  animation: sheetup .22s cubic-bezier(.2, .8, .2, 1);
}
@keyframes sheetup { from { transform: translateY(48px); opacity: 0; } }
.msheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--border-2); margin: 2px auto 14px; }
.msheet-photo { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 10px; }
.msheet-photo .linkbtn { padding-bottom: 4px; }
.msheet-img { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; }
.msheet-noimg { display: grid; place-items: center; font-size: 30px; background: var(--bg-3); border: 1px solid var(--border); }
.msheet h2 { font-size: 18px; letter-spacing: -.02em; }
.msheet-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.msheet-facts { margin-top: 6px; }
.msheet-facts dt { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; margin-top: 12px; }
.msheet-facts dd { font-size: 13.5px; margin-top: 2px; }
.msheet .btn { width: 100%; justify-content: center; margin-top: 10px; }
.msheet .cap-desktop-hint { margin-top: 16px; }
