:root {
  --brand: #1f4e8c;
  --brand-600: #1a4277;
  --brand-50: #eef3fa;
  --ink: #142033;
  --ink-2: #4a5568;
  --ink-3: #7b8597;
  --line: #e3e7ee;
  --bg: #f4f6fa;
  --card: #ffffff;
  --blue: #2563eb;   --blue-bg: #e8effe;
  --amber: #b45309;  --amber-bg: #fef3e2;
  --green: #15803d;  --green-bg: #e6f6ec;
  --red: #c0262d;    --red-bg: #fde9ea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #c9d0dc; background: #fafbfc; }
.btn-link { background: none; border: none; color: var(--brand); padding: 0 4px; height: auto; }
.btn-danger-link { background: none; border: none; color: var(--red); padding: 4px; height: auto; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--red); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 9px;
  border: 1px solid #d5dbe5; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31, 78, 140, .15); }
.input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(192, 38, 45, .1); }
.hint { font-size: 12.5px; color: var(--ink-3); }
.error-text { font-size: 12.5px; color: var(--red); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-hero {
  background: linear-gradient(155deg, #1f4e8c 0%, #163a6a 55%, #0f2a4f 100%);
  color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::after {
  content: ''; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px;
  border-radius: 50%; border: 60px solid rgba(255, 255, 255, .05);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: #fff; color: var(--brand);
  display: grid; place-items: center;
}
.brand-mark svg { width: 20px; height: 20px; }
.login-hero h1 { font-size: 38px; letter-spacing: -.02em; max-width: 440px; }
.login-hero p { color: rgba(255, 255, 255, .78); max-width: 420px; font-size: 15.5px; }
.hero-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.hero-points li { display: flex; gap: 10px; align-items: center; color: rgba(255, 255, 255, .9); }
.hero-points svg { width: 18px; height: 18px; flex: none; color: #8fd3a8; }
.hero-foot { font-size: 12.5px; color: rgba(255, 255, 255, .55); }

.login-panel { display: grid; place-items: center; padding: 40px 24px; background: #fff; }
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 26px; letter-spacing: -.015em; }
.login-card .sub { color: var(--ink-3); margin: 6px 0 28px; }
.login-form { display: grid; gap: 16px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: none; background: none; cursor: pointer; color: var(--ink-3);
  display: grid; place-items: center; border-radius: 6px;
}
.pw-toggle:hover { background: var(--bg); }
.pw-toggle svg { width: 18px; height: 18px; }
.form-alert {
  display: none; padding: 10px 12px; border-radius: 9px; font-size: 13.5px;
  background: var(--red-bg); color: var(--red); border: 1px solid #f6c9cc;
}
.form-alert.show { display: block; }
.demo-box {
  margin-top: 22px; padding: 12px 14px; border-radius: 10px; background: var(--brand-50);
  font-size: 13px; color: var(--ink-2); display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 64px;
  display: flex; align-items: center; gap: 28px;
}
.topbar .brand { color: var(--ink); font-size: 18px; }
.topbar .brand-mark { background: var(--brand); color: #fff; width: 30px; height: 30px; }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-weight: 500;
}
.nav a { display: flex; align-items: center; gap: 8px; }
.nav a svg { width: 17px; height: 17px; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--brand-50); color: var(--brand); font-weight: 600; }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-meta { text-align: right; line-height: 1.25; }
.user-meta strong { display: block; font-size: 13.5px; }
.user-meta span { font-size: 12px; color: var(--ink-3); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-50); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 18px; height: 18px; }

.page { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; letter-spacing: -.015em; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); }
.crumb { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.crumb a { color: var(--ink-3); text-decoration: none; }
.crumb a:hover { color: var(--brand); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  padding: 18px 20px; cursor: pointer; text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
  position: relative;
}
.stat:hover { border-color: #c9d0dc; }
.stat.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.stat-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); }
.stat-icon svg { width: 18px; height: 18px; }
.stat-value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12.5px; color: var(--ink-3); }
.stat.s-total { --accent: var(--blue); --accent-bg: var(--blue-bg); }
.stat.s-pending { --accent: var(--amber); --accent-bg: var(--amber-bg); }
.stat.s-approved { --accent: var(--green); --accent-bg: var(--green-bg); }
.stat.s-rejected { --accent: var(--red); --accent-bg: var(--red-bg); }

.table-card .table-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.table-head h2 { font-size: 16px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); }
.search .input { padding-left: 34px; height: 38px; width: 260px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; background: #fafbfc; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: #f8fafd; }
tbody tr:last-child td { border-bottom: none; }
.permit-id { font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; white-space: nowrap; }
.modal { user-select: none; }
#cid { text-transform: uppercase; }
#cid:placeholder-shown { text-transform: none; }
.cell-sub { font-size: 12.5px; color: var(--ink-3); }
.empty { padding: 48px 20px; text-align: center; color: var(--ink-3); }
.empty svg { width: 40px; height: 40px; color: #c3cad6; margin-bottom: 8px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pending { background: var(--amber-bg); color: var(--amber); }
.badge.approved { background: var(--green-bg); color: var(--green); }
.badge.rejected { background: var(--red-bg); color: var(--red); }

/* ---------- New application (stepper) ---------- */
.form-layout { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.steps { position: sticky; top: 88px; padding: 10px; }
.step {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px;
  color: var(--ink-3); font-weight: 500; cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.step:hover { background: var(--bg); }
.step .num {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid #cfd6e1; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; flex: none; background: #fff;
}
.step.active { color: var(--brand); background: var(--brand-50); font-weight: 600; }
.step.active .num { border-color: var(--brand); background: var(--brand); color: #fff; }
.step.done { color: var(--ink); }
.step.done .num { border-color: var(--green); background: var(--green); color: #fff; }
.step.done .num svg { width: 14px; height: 14px; }

.form-card { padding: 28px; }
.section-title { font-size: 18px; letter-spacing: -.01em; }
.section-desc { color: var(--ink-3); margin: 4px 0 22px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.span-2 { grid-column: span 2; }
.notice {
  padding: 12px 14px; border-radius: 10px; background: var(--brand-50); color: #24426e;
  font-size: 13px; margin-bottom: 22px; border-left: 3px solid var(--brand);
}
.form-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }

/* workers */
.worker-list { display: grid; gap: 12px; }
.worker-row {
  display: grid; grid-template-columns: 32px 1.6fr 1fr 150px 32px; gap: 12px; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fcfdfe;
}
.worker-row .idx { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-50); color: var(--brand); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.sig-btn {
  height: 42px; border-radius: 9px; border: 1px dashed #b9c3d3; background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--ink-2); font-weight: 500; font-size: 13px; overflow: hidden;
}
.sig-btn img { max-height: 36px; max-width: 100%; }
.sig-btn.signed { border-style: solid; border-color: var(--green); background: #f6fcf8; }
.sig-btn svg { width: 16px; height: 16px; }

/* hazards */
.hazard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.hazard-row { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; }
.hazard-row .n { color: var(--ink-3); font-weight: 600; font-size: 13px; text-align: right; }
.seg { display: inline-flex; border: 1px solid #d5dbe5; border-radius: 9px; overflow: hidden; background: #fff; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 0 12px; height: 40px; line-height: 40px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--ink-3); border-right: 1px solid #e3e7ee; user-select: none; min-width: 48px; text-align: center;
}
.seg label:last-child span { border-right: none; }
.seg input:checked + span.y { background: var(--green-bg); color: var(--green); }
.seg input:checked + span.n { background: var(--red-bg); color: var(--red); }
.seg input:checked + span.na { background: #eef0f4; color: var(--ink-2); }
.seg input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: -2px; }

/* ppe */
.ppe-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ppe-item {
  display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fcfdfe;
}
.ppe-item .ppe-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ppe-item .ppe-name svg { width: 18px; height: 18px; color: var(--brand); }
.ppe-item.missing { border-color: #f1b6ba; background: #fff8f8; }
.ppe-item .seg { align-self: flex-start; }

/* declaration */
.decl-box { padding: 16px 18px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfc; margin-bottom: 14px; }
.decl-box h3 { font-size: 14px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); }
.decl-box p { margin: 0 0 8px; color: var(--ink-2); }
.decl-box ul { margin: 6px 0 0; padding-left: 20px; color: var(--ink-2); }
.decl-box li { margin: 3px 0; }
.check {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  cursor: pointer; margin-bottom: 18px; background: #fff;
}
.check input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--brand); flex: none; }
.check.invalid { border-color: var(--red); background: #fff8f8; }
.sig-pad-inline { height: 120px; }

/* review */
.review-section { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.review-section h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); padding: 10px 14px; background: #fafbfc;
  border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center;
}
.review-body { padding: 14px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 16px; }
.kv dt { color: var(--ink-3); font-size: 13px; }
.kv dd { margin: 0; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: #eef0f4; color: var(--ink-2); }
.chip.y { background: var(--green-bg); color: var(--green); }
.chip.n { background: var(--red-bg); color: var(--red); }
.mini-table { width: 100%; }
.mini-table th, .mini-table td { padding: 8px 10px; font-size: 13.5px; }
.mini-table tbody tr { cursor: default; }
.mini-table tbody tr:hover td { background: none; }

/* ---------- Permit detail ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.detail-main { padding: 0; }
.detail-main .review-section { border: none; border-radius: 0; margin: 0; border-bottom: 1px solid var(--line); }
.detail-main .review-section:last-child { border-bottom: none; }
.side-card { padding: 20px; }
.side-card + .side-card { margin-top: 16px; }
.side-card h3 { font-size: 14px; margin-bottom: 12px; }
.status-banner { padding: 14px 16px; border-radius: 10px; margin-bottom: 18px; display: flex; gap: 12px; align-items: flex-start; }
.status-banner svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.status-banner.pending { background: var(--amber-bg); color: var(--amber); }
.status-banner.approved { background: var(--green-bg); color: var(--green); }
.status-banner.rejected { background: var(--red-bg); color: var(--red); }
.status-banner strong { display: block; }
.status-banner span { color: var(--ink-2); font-size: 13.5px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; font-size: 13.5px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline li::after { content: ''; position: absolute; left: 7.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--ink-3); font-size: 12.5px; }
.sig-img { max-height: 48px; border-bottom: 1px solid var(--line); }

/* ---------- Work activity & permit forms ---------- */
.step > span:last-child { display: flex; flex-direction: column; line-height: 1.25; }
.step small { font-size: 11px; font-weight: 500; color: var(--ink-3); }
.step-form .num { border-style: dashed; }

.activity-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 10px; border-radius: 12px; }
.activity-grid.missing { outline: 2px solid var(--red); outline-offset: 4px; }
.activity {
  position: relative; display: flex; gap: 12px; padding: 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.activity:hover { border-color: #c3ccda; }
.activity input { position: absolute; opacity: 0; pointer-events: none; }
.activity input:focus-visible + .act-box { outline: 2px solid var(--brand); outline-offset: 2px; }
.act-box {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid #c3ccda; flex: none; margin-top: 1px;
  display: grid; place-items: center; color: transparent; background: #fff;
}
.act-box svg { width: 14px; height: 14px; }
.activity.on { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 3px rgba(31, 78, 140, .1); }
.activity.on .act-box { background: var(--brand); border-color: var(--brand); color: #fff; }
.act-body { display: flex; flex-direction: column; gap: 3px; }
.act-body strong { font-size: 14.5px; }
.act-body > span { font-size: 12.5px; color: var(--ink-3); }
.act-body em {
  font-style: normal; font-size: 11.5px; font-weight: 600; color: var(--brand); margin-top: 4px;
  display: inline-flex; align-items: center; gap: 4px;
}
.act-body em svg { width: 13px; height: 13px; }

.act-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.act-tag { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: #eef0f4; color: var(--ink-2); white-space: nowrap; }
.act-tag.t-hotwork { background: #fdecdf; color: #b4470f; }
.act-tag.t-wah { background: #e6effc; color: #1d4f9b; }

.form-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--brand);
  background: var(--brand-50); padding: 4px 10px; border-radius: 999px; margin-bottom: 10px;
}
.form-badge svg { width: 14px; height: 14px; }
.sub-title {
  font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2);
  margin: 26px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.from-job { border: 1px dashed #c3ccda; border-radius: 10px; padding: 12px 14px; background: #fafbfc; }
.from-job-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.from-job-head span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.from-job .kv { grid-template-columns: 150px 1fr; gap: 4px 16px; }

.q-list { display: grid; gap: 8px; margin-top: 14px; }
.q-row {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fcfdfe;
}
.q-row .n { color: var(--ink-3); font-weight: 600; font-size: 13px; text-align: right; }
.q-row .q-text { font-size: 14px; }
.q-row.missing { border-color: #f1b6ba; background: #fff8f8; }

.dark-note { margin: 22px 0 6px; padding: 12px 14px; border-radius: 10px; background: #142033; color: #fff; font-size: 13px; font-weight: 600; }
.check-group { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-top: 12px; }
.check-group.missing { border-color: var(--red); background: #fff8f8; }
.check-group-title { font-weight: 600; font-size: 13.5px; margin-bottom: 10px; }
.check-group-title small { font-weight: 400; color: var(--ink-3); }
.check-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cbox {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line);
  cursor: pointer; font-size: 13.5px; background: #fff;
}
.cbox:hover { border-color: #c3ccda; }
.cbox input { width: 17px; height: 17px; accent-color: var(--brand); margin: 1px 0 0; flex: none; }
.cbox:has(input:checked) { border-color: var(--brand); background: var(--brand-50); }
.display-note { text-align: center; color: var(--red); font-weight: 700; margin: 22px 0 0; }
.ehs-note {
  display: flex; gap: 8px; align-items: flex-start; margin: 20px 0 0; font-size: 13px; color: var(--ink-3);
  padding: 10px 12px; background: #fafbfc; border-radius: 10px;
}
.ehs-note svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--brand); }
.review-section h3 small { font-weight: 500; color: var(--ink-3); letter-spacing: 0; margin-left: 6px; }
.form-section { border-left: 3px solid var(--brand); }
.q-table { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; }
.q-table td:last-child, .q-table th:last-child { text-align: right; white-space: nowrap; }

/* ---------- HIRARC & MOS uploads ---------- */
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: #f1b6ba; background: #fff8f8; }
.doc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.doc-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fff; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.doc-card.missing { border-color: var(--red); background: #fff8f8; }
.doc-card.has-file { border-color: #bfe3cb; background: #f8fdf9; }
.doc-head { display: flex; flex-direction: column; gap: 2px; }
.doc-head strong { font-size: 15px; }
.doc-head > span { font-size: 12.5px; color: var(--ink-3); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  min-height: 150px; padding: 18px; border: 1.5px dashed #b9c3d3; border-radius: 10px; background: #fafbfd; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-50); }
.dropzone strong { font-size: 14px; color: var(--ink); }
.dropzone > span:not(.dz-icon) { font-size: 12.5px; color: var(--ink-3); }
.dz-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; margin-bottom: 4px; }
.dz-icon svg { width: 20px; height: 20px; }
.doc-file, .doc-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pdf-icon { width: 40px; height: 40px; border-radius: 9px; background: #fde9ea; color: #c0262d; display: grid; place-items: center; flex: none; }
.pdf-icon svg { width: 22px; height: 22px; }
.doc-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.doc-meta strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta > span { font-size: 12.5px; color: var(--ink-3); }
.doc-meta .doc-kind { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.doc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-actions label.btn { cursor: pointer; }
.doc-list { display: grid; gap: 12px; }
.doc-err:empty { display: none; }
.pdf-modal { max-width: 960px; height: min(88vh, 900px); display: flex; flex-direction: column; overflow: hidden; }
.pdf-modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pdf-modal-head .doc-meta { min-width: 120px; }
.pdf-frame { flex: 1; width: 100%; border: 0; background: #525659; }

/* ---------- Roles & status ---------- */
.role-switch { display: inline-flex; padding: 4px; background: var(--bg); border-radius: 10px; margin-bottom: 22px; border: 1px solid var(--line); }
.role-switch button {
  border: none; background: none; padding: 7px 16px; border-radius: 7px; font-weight: 600; font-size: 13.5px;
  color: var(--ink-3); cursor: pointer;
}
.role-switch button.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.role-pill { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; background: #e6f6ec; color: var(--green); padding: 2px 7px; border-radius: 999px; vertical-align: 2px; margin-left: 4px; }
.badge.inspecting { background: var(--blue-bg); color: var(--blue); }
.status-banner.inspecting { background: var(--blue-bg); color: var(--blue); }
.stat.s-inspecting { --accent: var(--blue); --accent-bg: var(--blue-bg); }
.date-tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.date-tag.today { background: var(--blue-bg); color: var(--blue); }
.date-tag.late { background: var(--red-bg); color: var(--red); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a51f25; }
.pbar { height: 8px; border-radius: 999px; background: #e8ecf2; overflow: hidden; }
.pbar span { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .25s; }
.pbar span.has-fail { background: var(--red); }
.mini-progress { display: grid; gap: 6px; margin-bottom: 16px; }
.doc-row.compact .pdf-icon { width: 34px; height: 34px; }
.doc-row.compact .doc-meta strong { font-size: 13px; }

/* ---------- Inspection checklist ---------- */
.insp-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; padding-bottom: 90px; }
.insp-main { display: grid; gap: 16px; min-width: 0; }
.insp-side { position: sticky; top: 84px; }
.insp-sec { padding: 0; overflow: hidden; }
.insp-sec-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px;
  border-bottom: 1px solid var(--line); background: #fafbfc; flex-wrap: wrap;
}
.insp-sec-head h2 { font-size: 16px; display: flex; align-items: center; gap: 10px; }
.insp-sec-head h2 small { font-size: 11.5px; font-weight: 600; color: var(--brand); background: var(--brand-50); padding: 2px 8px; border-radius: 999px; }
.insp-sec-head p { margin: 4px 0 0 38px; font-size: 13px; color: var(--ink-3); }
.sec-letter {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; flex: none;
}
.sec-letter svg { width: 15px; height: 15px; }
.insp-sec-tools { display: flex; align-items: center; gap: 10px; }
.sec-count { font-size: 12.5px; font-weight: 700; color: var(--ink-3); background: #eef0f4; padding: 3px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.sec-count.ok { background: var(--green-bg); color: var(--green); }
.sec-count.bad { background: var(--red-bg); color: var(--red); }
.insp-items { display: grid; }
.insp-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; padding: 12px 18px;
  border-bottom: 1px solid var(--line); border-left: 3px solid transparent; transition: background .15s;
}
.insp-item:last-child { border-bottom: none; }
.insp-item.pass { border-left-color: var(--green); }
.insp-item.fail { border-left-color: var(--red); background: #fffafa; }
.insp-item.na { border-left-color: #c3ccda; }
.insp-item.missing { background: #fff8f0; border-left-color: var(--amber); }
.insp-q { display: flex; gap: 10px; font-size: 14px; }
.insp-q .n { color: var(--ink-3); font-weight: 600; font-size: 12.5px; min-width: 20px; text-align: right; padding-top: 1px; }
.insp-remark { grid-column: 1 / -1; padding-left: 30px; }
.insp-remark[hidden] { display: none; }
.insp-signoff { padding: 18px; }
.worker-check { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.worker-check li { display: flex; flex-direction: column; font-size: 13.5px; padding: 8px 10px; background: #fafbfc; border-radius: 8px; }
.worker-check span { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.insp-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(16, 24, 40, .06); }
.insp-bar-inner { max-width: 1200px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 10px; }
.insp-progress { flex: 1; display: grid; gap: 5px; min-width: 0; }
.ptext { font-size: 13px; color: var(--ink-2); }
.fail-text { color: var(--red); font-weight: 600; }
.ok-text { color: var(--green); font-weight: 600; }
.saved { color: var(--ink-3); }
.btn.not-ready { opacity: .55; }

/* Inspection result on the permit */
.insp-result h3 .badge { text-transform: none; letter-spacing: 0; }
.insp-result.ok { border-left: 3px solid var(--green); }
.insp-result.bad { border-left: 3px solid var(--red); }
.insp-res-sec { margin-top: 16px; }
.insp-res-title { font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.insp-res-title small { font-weight: 500; color: var(--ink-3); }
.insp-res-row { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: start; padding: 6px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.insp-res-row:last-child { border-bottom: none; }
.insp-res-row .chip { text-align: center; }
.insp-res-row.fail { color: var(--red); }
.insp-res-remark { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.insp-res-remark::before { content: 'Remark: '; font-weight: 600; }

@media (max-width: 1000px) {
  .insp-layout { grid-template-columns: 1fr; }
  .insp-side { position: static; order: -1; }
}
@media (max-width: 820px) {
  .insp-item { grid-template-columns: 1fr; }
  .insp-item .seg { margin-left: 30px; justify-self: start; }
  .insp-bar-inner { padding: 10px 16px; flex-wrap: wrap; }
  .insp-progress { flex-basis: 100%; }
  .insp-bar-inner .btn { flex: 1; }
  .insp-sec-head p { margin-left: 0; }
}

/* ---------- Registration & admin ---------- */
.login-card.wide { max-width: 480px; }
.auth-note { font-size: 13px; color: var(--ink-2); margin: 18px 0 0; line-height: 1.5; }
.auth-note a { font-weight: 600; }
.field-err { margin-top: -2px; }
.form-group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-top: 4px; }
.done-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--green-bg); color: var(--green); display: grid; place-items: center; margin-bottom: 14px; }
.done-icon svg { width: 30px; height: 30px; }
.done-card { max-width: 640px; margin: 0 auto; text-align: center; }
.done-card .done-icon { margin: 0 auto 14px; }
.done-card h1 { font-size: 22px; }
.done-card .cred-box { text-align: left; }
.role-pill.admin { background: #fdecdf; color: #b4470f; }
.nav-count { font-size: 11px; font-weight: 700; background: var(--red); color: #fff; border-radius: 999px; padding: 0 6px; line-height: 18px; min-width: 18px; text-align: center; }
.gen-row { display: flex; gap: 8px; }
.gen-row .input { flex: 1; min-width: 0; }
.input.mono, code { font-family: ui-monospace, 'SFMono-Regular', Consolas, monospace; letter-spacing: .02em; }
.input[readonly] { background: #f7f9fc; }
code { background: #eef0f4; padding: 2px 7px; border-radius: 6px; font-size: 13px; }
.cred-box { border: 1px solid #bfe3cb; background: #f6fcf8; border-radius: 12px; padding: 16px 18px; margin: 18px 0; }
.cred-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.cred-head svg { width: 20px; height: 20px; color: var(--green); flex: none; margin-top: 2px; }
.cred-head strong { display: block; }
.cred-head span { font-size: 13px; color: var(--ink-2); }
.cred-kv { grid-template-columns: 150px 1fr; margin-bottom: 14px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.mini-stats div { background: #fafbfc; border-radius: 10px; padding: 10px 6px; display: flex; flex-direction: column; }
.mini-stats strong { font-size: 22px; }
.mini-stats span { font-size: 12px; color: var(--ink-3); }
.pending-card .table-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.pending-card .table-head h2 { font-size: 16px; }
#r-sid:placeholder-shown { text-transform: none; }
.pending-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pending-row:last-child { border-bottom: none; }
.pending-info { flex: 1; min-width: 220px; display: flex; flex-direction: column; font-size: 13.5px; }
.pending-info strong { font-size: 14.5px; }
.pending-actions { display: flex; gap: 8px; }
@media (max-width: 820px) {
  .cred-kv { grid-template-columns: 1fr; }
  .gen-row { flex-wrap: wrap; }
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 16px;
  animation: fade .15s ease;
}
.modal { width: 100%; max-width: 520px; background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-head { padding: 18px 20px 0; }
.modal-head h3 { font-size: 17px; }
.modal-head p { margin: 4px 0 0; color: var(--ink-3); font-size: 13.5px; }
.modal-body { padding: 16px 20px; }
.modal-foot { padding: 0 20px 18px; display: flex; justify-content: space-between; gap: 10px; }
.sig-canvas {
  width: 100%; height: 200px; border: 1px dashed #b9c3d3; border-radius: 10px; background: #fff;
  touch-action: none; cursor: crosshair; display: block;
  background-image: linear-gradient(to right, transparent 0, transparent 100%);
}
.sig-line { position: relative; }
.sig-line::after { content: 'Sign above the line'; position: absolute; left: 16px; right: 16px; bottom: 34px; border-top: 1px solid #d5dbe5; font-size: 11px; color: #a0a9b8; padding-top: 4px; pointer-events: none; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #0f1b2d; color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 500; z-index: 60;
  transition: opacity .2s, transform .2s; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-layout { grid-template-columns: 1fr; }
  .steps { position: static; display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .step { width: auto; flex: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .ppe-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 28px 24px; }
  .login-hero h1 { font-size: 26px; }
  .hero-points, .hero-foot { display: none; }
  .hazard-grid { grid-template-columns: 1fr; }
  .activity-grid, .check-grid, .doc-grid { grid-template-columns: 1fr; }
  .q-row { grid-template-columns: 22px 1fr; }
  .q-row .seg { grid-column: 2; justify-self: start; }
  .from-job .kv { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .worker-row { grid-template-columns: 28px 1fr 32px; }
  .worker-row .w-ic, .worker-row .sig-btn { grid-column: 2; }
  .worker-row .btn-danger-link { grid-row: 1; grid-column: 3; }
  .user-meta { display: none; }
  .topbar-inner { gap: 12px; padding: 0 16px; }
  .page { padding: 20px 16px 48px; }
  .form-card { padding: 20px 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .hide-sm { display: none; }
  th, td { padding: 12px; }
  .search .input { width: 100%; }
  .search { width: 100%; }
}
@media (max-width: 560px) {
  .ppe-grid { grid-template-columns: 1fr; }
  .nav a span { display: none; }
  .brand-text { display: none; }
}

@media print {
  .topbar, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .card { box-shadow: none; }
}

/* Upload in progress */
.doc-card.uploading { opacity: .6; pointer-events: none; }
.doc-card.uploading .dropzone strong::after { content: ' — uploading…'; }

/* Email log */
.mail-status { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; margin-bottom: 18px; font-size: 13.5px; }
.mail-status svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.mail-status strong { display: block; font-size: 14px; }
.mail-status span { color: var(--ink-2); }
.mail-status.ok { background: var(--green-bg); color: var(--green); }
.mail-status.off { background: var(--amber-bg); color: var(--amber); }
.email-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.chip-btn b { font-weight: 700; color: var(--ink-3); margin-left: 2px; }
.chip-btn.on { background: var(--brand-50); border-color: var(--brand); color: var(--brand); }
.email-modal { max-width: 720px; height: min(86vh, 860px); display: flex; flex-direction: column; overflow: hidden; }
.email-modal-head { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.email-meta { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-3); min-width: 0; }
.email-meta strong { font-size: 15px; color: var(--ink); }
.email-frame { flex: 1; width: 100%; border: 0; background: #f4f6fa; }

/* Keep nav labels on one line; make room on medium screens */
.nav a { white-space: nowrap; }
@media (max-width: 1080px) { .user-meta { display: none; } }
@media (max-width: 900px) { .nav a span { display: none; } .nav a .nav-count { display: inline-block; } }

/* Get the app */
.get-app-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 13.5px; font-weight: 600; text-decoration: none; }
.get-app-link svg { width: 16px; height: 16px; }
a.icon-btn { text-decoration: none; }
.getapp { max-width: 980px; margin: 0 auto; padding: 24px 24px 56px; }
.getapp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.getapp-head .brand-mark { background: var(--brand); color: #fff; width: 30px; height: 30px; }
.getapp h1 { font-size: 28px; letter-spacing: -.02em; }
.getapp-sub { color: var(--ink-3); margin: 6px 0 22px; max-width: 620px; }
.getapp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.getapp-card { padding: 20px 22px; }
.getapp-card h2 { font-size: 16px; display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.getapp-card h2 svg { width: 20px; height: 20px; color: var(--brand); }
.getapp-card .hint { margin: 10px 0 0; display: block; }
.steps-list { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; color: var(--ink-2); }
.ok-line { display: flex; gap: 8px; align-items: center; color: var(--green); font-weight: 600; margin: 0; }
.ok-line svg { width: 18px; height: 18px; }
.qr-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.qr-row p { margin: 0 0 6px; font-size: 14px; }
.qr { width: 168px; height: 168px; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: #fff; image-rendering: pixelated; }
@media (max-width: 760px) { .getapp-grid { grid-template-columns: 1fr; } .getapp { padding: 16px 16px 40px; } }
