:root {
  --navy: #0f172a;
  --navy-2: #1e293b;
  --navy-3: #334155;
  --bg: #f5f5f4;
  --card: #ffffff;
  --border: #e7e5e4;
  --border-2: #d6d3d1;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #a8a29e;
  --orange: #f97316;
  --orange-d: #ea580c;
  --orange-l: #fb923c;
  --orange-t: #fff7ed;
  --green: #10b981;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-bd: #fecaca;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Barlow", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.display {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700;
  font-style: italic;
}

button { font: inherit; cursor: pointer; }
input { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.topbar { background: var(--navy); color: #fff; }

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { height: 22px; width: auto; display: block; }
.brand .section {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 20px;
  line-height: 1;
  color: var(--orange-l);
  border-left: 1px solid #475569;
  padding-left: 10px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.clockbox { text-align: right; }
.clock {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700;
  font-style: italic;
  font-size: 28px;
  line-height: 1;
  color: var(--orange-l);
}
.clock-date { font-size: 12px; color: #94a3b8; margin-top: 3px; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 0;
  background: var(--navy-2);
  color: #fff;
  flex: none;
}
.iconbtn:hover { background: var(--navy-3); }

.hazard {
  height: 8px;
  background: repeating-linear-gradient(-45deg, #facc15 0 12px, #1e293b 12px 24px);
}

.page {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  flex: 1;
}
.page.wide { max-width: 960px; padding-top: 24px; }

.page-title { font-size: 40px; line-height: 1.05; }
.page-sub { margin-top: 10px; color: var(--muted); max-width: 60ch; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  margin-top: 28px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.icon { width: 20px; height: 20px; flex: none; }
.icon.sm { width: 16px; height: 16px; }

.field-label { font-weight: 600; display: block; margin: 22px 0 8px; }
.field-label:first-child { margin-top: 0; }

.type-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }

.type-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  transition: border-color 0.15s, background 0.15s;
}
.type-btn:hover { border-color: var(--border-2); }
.type-btn .icon { width: 26px; height: 26px; color: var(--muted); }
.type-btn .t-name { font-weight: 600; display: block; }
.type-btn .t-desc { font-size: 12px; color: var(--muted); display: block; }
.type-btn.selected { border-color: var(--orange); background: var(--orange-t); }
.type-btn.selected .icon { color: var(--orange-d); }

.input {
  width: 100%;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 12px 14px;
  font-size: 18px;
  outline: none;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-color: var(--orange); }

.err { color: var(--red); font-size: 14px; margin-top: 7px; }

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 26px;
  border: 0;
  border-radius: 12px;
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  background: var(--orange);
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--orange-d); }
.btn-primary:disabled { background: var(--border-2); cursor: default; }

.foot-row {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 7px 12px;
  font-weight: 500;
  color: #334155;
  text-decoration: none;
  white-space: nowrap;
}
.btn-ghost:hover { background: #fafaf9; }

.success-wrap { text-align: center; padding-top: 24px; }
.success-wrap .big-check { width: 92px; height: 92px; color: var(--green); }
.success-title { font-size: 52px; margin-top: 14px; }
.success-sub { color: var(--muted); margin-top: 6px; }

.receipt {
  max-width: 440px;
  margin: 30px auto 0;
  text-align: left;
}
.receipt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.receipt-name { font-size: 21px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-id { color: var(--muted); font-size: 14px; margin-top: 2px; }
.receipt-time {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 16px;
  color: #334155;
}
.receipt-time .icon { color: var(--orange); }

.safety { color: var(--muted); font-size: 14px; margin-top: 24px; }

.btn-dark {
  margin-top: 22px;
  border: 0;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  padding: 13px 32px;
}
.btn-dark:hover { background: var(--navy-2); }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.Subcontractor { background: #fef3c7; color: #92400e; }
.badge.Visitor { background: #e0f2fe; color: #075985; }
.badge.Employee { background: #d1fae5; color: #065f46; }

.login-wrap { max-width: 420px; margin: 48px auto 0; }
.login-wrap .card { margin-top: 18px; }
.login-logo { height: 30px; width: auto; display: block; margin: 0 auto; }
.login-title { text-align: center; font-size: 34px; margin-top: 18px; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 20px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.stat .n { font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-style: italic; font-size: 34px; line-height: 1; }
.stat .n.hl { color: var(--orange); }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

.toolbar { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.toolbar-row { display: flex; flex-direction: column; gap: 10px; }

.searchbox { position: relative; flex: 1; }
.searchbox .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--faint); width: 16px; height: 16px; pointer-events: none;
}
.searchbox .input { padding: 10px 12px 10px 38px; font-size: 15px; }

.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-navy {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; border-radius: 11px; padding: 10px 16px;
  background: var(--navy); color: #fff; font-weight: 600;
}
.btn-navy:hover { background: var(--navy-2); }
.btn-navy:disabled { background: var(--border-2); cursor: default; }

.btn-outline {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-2); border-radius: 11px; padding: 10px 16px;
  background: #fff; color: #334155; font-weight: 600;
}
.btn-outline:hover { background: #fafaf9; }
.btn-outline:disabled { color: var(--border-2); cursor: default; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border-2);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
}
.chip:hover { background: #fafaf9; }
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.confirm-inline {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--red-bg); border: 1px solid var(--red-bd);
  border-radius: 11px; padding: 6px 10px;
}
.confirm-inline span { color: var(--red); font-size: 13px; font-weight: 600; }
.confirm-yes { border: 0; border-radius: 8px; background: var(--red); color: #fff; padding: 5px; display: inline-flex; }
.confirm-no { border: 1px solid var(--border-2); border-radius: 8px; background: #fff; color: var(--muted); padding: 5px; display: inline-flex; }

.table-wrap { display: none; margin-top: 18px; background: #fff; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead tr { background: #fafaf9; border-bottom: 1px solid var(--border); }
th { padding: 12px 16px; font-size: 13px; color: var(--muted); font-weight: 600; }
td { padding: 12px 16px; border-bottom: 1px solid #f5f5f4; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td.c-name { font-weight: 600; }
td.c-id, td.c-time { color: var(--muted); }
td.c-act { text-align: right; white-space: nowrap; }

.rowdel {
  border: 0; background: transparent; color: var(--faint);
  border-radius: 8px; padding: 6px; display: inline-flex;
}
.rowdel:hover { color: var(--red); background: var(--red-bg); }

.cardlist { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.rec-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 15px 16px; }
.rec-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.rec-name { font-weight: 700; }
.rec-id { color: var(--muted); font-size: 14px; margin-top: 1px; }
.rec-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-top: 1px solid #f5f5f4; margin-top: 12px; padding-top: 12px;
}
.rec-time { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.rec-time .icon { width: 14px; height: 14px; color: var(--orange); }

.empty {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  text-align: center; padding: 44px 20px; margin-top: 18px;
}
.empty .icon { width: 40px; height: 40px; color: var(--border-2); }
.empty .e-title { font-weight: 600; margin-top: 10px; color: #334155; }
.empty .e-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

.tz-note { margin-top: 14px; font-size: 13px; color: var(--faint); }

@media (min-width: 560px) {
  .brand img { height: 26px; }
  .type-grid { grid-template-columns: repeat(3, 1fr); }
  .type-btn { flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .toolbar-row { flex-direction: row; align-items: center; }
}

@media (min-width: 760px) {
  .page-title { font-size: 48px; }
  .table-wrap { display: block; }
  .cardlist { display: none; }
}

.tabs { display: flex; gap: 8px; margin-top: 20px; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-2); border-radius: 11px; padding: 10px 18px;
  background: #fff; color: var(--muted); font-weight: 600;
}
.tab:hover { background: #fafaf9; }
.tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.link-back {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--muted);
  font-weight: 600; padding: 0; margin-bottom: 14px;
}
.link-back:hover { color: var(--text); }

.ind-id-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px;
}
.ind-id-text { color: var(--muted); font-size: 14px; }
.ind-id-text strong { color: var(--text); }

.ind-h { font-size: 26px; }
.ind-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 4px 18px; }
.form-grid .field-label { margin-top: 16px; }
.lbl-note { color: var(--faint); font-weight: 400; font-size: 13px; }

.check-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 2px; border-bottom: 1px solid #f5f5f4;
  cursor: pointer; font-size: 15px; color: #334155;
}
.check-item:last-of-type { border-bottom: 0; }
.check-item input {
  width: 20px; height: 20px; flex: none; margin-top: 1px;
  accent-color: var(--orange); cursor: pointer;
}
.check-item strong { color: var(--text); }
.decl-agree { border-bottom: 0; margin-top: 12px; }

.decl { margin: 10px 0 4px 18px; color: #334155; font-size: 15px; }
.decl li { margin-bottom: 8px; }

.sig-box {
  border: 2px dashed var(--border-2); border-radius: 12px;
  background: #fff; overflow: hidden;
}
.sig-box canvas { display: block; touch-action: none; cursor: crosshair; }
.sig-actions { margin-top: 10px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.modal {
  background: #fff; border-radius: 18px; padding: 22px;
  width: 100%; max-width: 680px; max-height: 88vh; overflow: auto;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-title { font-size: 24px; font-weight: 700; }
.modal-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.iconbtn.dark { background: var(--bg); color: var(--text); }
.iconbtn.dark:hover { background: var(--border); }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 12px 18px; margin-top: 18px; }
.detail-item .k, .detail-block .k { font-size: 12px; color: var(--faint); font-weight: 600; letter-spacing: 0.03em; }
.detail-item .v, .detail-block .v { margin-top: 2px; color: var(--text); }
.detail-block { margin-top: 16px; }
.sig-img {
  display: block; margin-top: 6px; max-width: 320px; width: 100%;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
}

.rec-actions { margin-top: 10px; }
.view-btn { padding: 6px 12px; font-size: 14px; gap: 5px; }
td .view-btn { margin-right: 6px; }

@media (min-width: 560px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

.site-strip {
  display: flex; align-items: center; gap: 12px;
  background: var(--navy); color: #fff;
  border-radius: 14px; padding: 14px 16px; margin-bottom: 26px;
}
.site-strip .icon { width: 26px; height: 26px; color: var(--orange-l); }
.site-strip-text { min-width: 0; }
.site-strip-label { font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.site-strip-name {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700; font-style: italic; font-size: 24px; line-height: 1.1; margin-top: 2px;
}
.site-strip-addr { font-size: 14px; color: #cbd5e1; margin-top: 2px; }

.site-list { padding: 6px 8px; }
.site-pick {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 12px; border-bottom: 1px solid var(--border);
  text-decoration: none; border-radius: 10px;
}
.site-pick:last-child { border-bottom: 0; }
.site-pick:hover { background: var(--orange-t); }
.site-pick-text { min-width: 0; }
.site-pick-name { display: block; font-weight: 700; font-size: 19px; }
.site-pick-addr { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.site-pick .icon { color: var(--faint); }
.site-pick:hover .icon { color: var(--orange-d); }

.big-check.closed { color: var(--red); }
.success-wrap .btn-dark { display: inline-block; text-decoration: none; }

.tabs-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 20px;
}
.tabs-row .tabs { margin-top: 0; flex-wrap: wrap; }

.site-select-wrap {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border-2); border-radius: 11px; padding: 0 6px 0 12px;
}
.site-select-wrap .icon { color: var(--orange); }
.select {
  font: inherit; font-weight: 600; color: var(--text);
  border: 0; background: transparent; padding: 10px 6px; outline: none; max-width: 260px;
}

td.c-site, .rec-site { color: var(--orange-d); font-weight: 600; font-size: 14px; }
.rec-site { margin-top: 3px; }
td.c-loc { white-space: nowrap; }
.loc {
  display: inline-flex; align-items: center; gap: 5px;
  color: #334155; text-decoration: none; font-size: 14px; font-weight: 500;
}
.loc .icon { width: 14px; height: 14px; color: var(--green); }
.loc:hover { text-decoration: underline; }
.loc.far, .loc.far .icon { color: var(--red); }
.loc.none { color: var(--faint); }

.panel-hint { flex: 1; color: var(--muted); font-size: 14px; max-width: 70ch; }

.site-form { margin-top: 18px; padding: 22px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 20px; }
.slug-row { display: flex; align-items: stretch; }
.slug-prefix {
  display: flex; align-items: center; font-size: 13px; color: var(--muted);
  background: #fafaf9; border: 2px solid var(--border); border-right: 0;
  border-radius: 12px 0 0 12px; padding: 0 10px; max-width: 55%; min-width: 0;
}
.slug-prefix span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slug-row .input { border-radius: 0 12px 12px 0; min-width: 0; }
.input:disabled { background: #fafaf9; color: var(--muted); }

.badge.Active { background: #d1fae5; color: #065f46; }
.badge.Closed { background: #f1f5f9; color: #475569; }
tr.row-closed td.c-name, .rec-card.row-closed .rec-name { color: var(--muted); }
td.c-num { font-weight: 600; }
td .c-sub { font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.site-link {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: #334155;
  text-decoration: none; background: #f5f5f4; padding: 3px 8px; border-radius: 6px; display: inline-block;
}
.site-link:hover { text-decoration: underline; }
.site-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.site-actions .view-btn { margin-right: 0; text-decoration: none; }
.rec-actions .site-actions { justify-content: flex-start; }

.poster-body { background: #e7e5e4; display: block; }
.poster-tools {
  max-width: 794px; margin: 0 auto; padding: 16px 20px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.poster-tools .btn-outline { text-decoration: none; }
.poster-tip { font-size: 13px; color: var(--muted); }
.poster {
  width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto 32px; background: #fff;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.12); display: flex; flex-direction: column;
}
.poster-top { background: var(--navy); color: #fff; padding: 22px 32px; display: flex; align-items: center; justify-content: space-between; }
.poster-top img { height: 34px; width: auto; display: block; }
.poster-kicker {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700; font-style: italic; font-size: 30px; color: var(--orange-l);
}
.poster-inner { padding: 30px 32px 28px; display: flex; flex-direction: column; align-items: center; text-align: center; flex: 1; }
.poster-title { font-size: 54px; line-height: 1; }
.poster-site { margin-top: 14px; }
.poster-site-name { font-size: 30px; font-weight: 700; }
.poster-site-addr { color: var(--muted); font-size: 18px; margin-top: 4px; }
.poster-qr { margin-top: 26px; border: 3px solid var(--navy); border-radius: 20px; padding: 14px; background: #fff; }
.poster-qr img { display: block; width: 300px; height: 300px; }
.poster-url { margin-top: 14px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 17px; color: #334155; word-break: break-all; }
.poster-steps { margin: 26px 0 0; padding: 0; list-style: none; text-align: left; width: 100%; max-width: 560px; counter-reset: step; }
.poster-steps li {
  position: relative; padding: 12px 0 12px 56px; border-top: 1px solid var(--border);
  font-size: 18px; color: #334155; counter-increment: step;
}
.poster-steps li:last-child { border-bottom: 1px solid var(--border); }
.poster-steps li::before {
  content: counter(step); position: absolute; left: 0; top: 10px; width: 38px; height: 38px; border-radius: 50%;
  background: var(--orange); color: #fff; font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-weight: 700; font-style: italic; font-size: 24px; display: flex; align-items: center; justify-content: center;
}
.poster-foot { margin-top: auto; padding-top: 22px; color: var(--muted); font-size: 14px; }
.poster-missing { max-width: 560px; margin: 40px auto; padding: 0 20px; }

@media (max-width: 820px) {
  .poster { width: auto; min-height: 0; margin: 0 12px 24px; }
  .poster-title { font-size: 40px; }
  .poster-qr img { width: 240px; height: 240px; }
}

@media print {
  @page { size: A4 portrait; margin: 10mm; }
  body.poster-body { background: #fff; }
  .poster-tools, .poster-missing { display: none !important; }
  .poster { width: 190mm; height: 277mm; min-height: 0; margin: 0; box-shadow: none; }
  .poster-top { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .poster-steps li::before, .hazard, .site-strip { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
