:root {
  color-scheme: dark;
  --bg: #020617;
  --panel: #0f172a;
  --panel-2: #111c31;
  --line: #273449;
  --text: #f8fafc;
  --muted: #94a3b8;
  --indigo: #6366f1;
  --indigo-soft: #25255f;
  --amber: #f59e0b;
  --amber-soft: #4b3212;
  --green: #34d399;
  --red: #fb7185;
  --cyan: #22d3ee;
  --shadow: 0 22px 55px rgb(0 0 0 / 35%);
}

* { box-sizing: border-box; }
html { font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.hidden { display: none !important; }
/* display:none은 스크린리더에서도 사라진다. 시각적으로만 감출 때는 이 클래스를 쓴다. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.shell { width: min(100%, 760px); min-height: 100vh; margin: 0 auto; background: var(--panel); box-shadow: var(--shadow); }
.topbar { position: sticky; top: 0; z-index: 20; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); background: rgb(15 23 42 / 94%); backdrop-filter: blur(12px); }
.brand-row, .between, .inline { display: flex; align-items: center; }
.brand-row, .between { justify-content: space-between; gap: 14px; }
.inline { gap: 8px; flex-wrap: wrap; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: linear-gradient(135deg, var(--indigo), #4338ca); font-weight: 900; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 3px; font-size: 18px; }
h2 { margin-bottom: 10px; font-size: 15px; }
h3 { margin-bottom: 8px; font-size: 13px; }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; color: var(--muted); background: #0b1220; }
.badge.good { color: var(--green); border-color: rgb(52 211 153 / 35%); }
.badge.warn { color: #fbbf24; border-color: rgb(245 158 11 / 35%); }
.network { padding: 8px 20px; border-bottom: 1px solid var(--line); font-size: 12px; text-align: center; }
.network.online { color: var(--green); background: rgb(6 78 59 / 30%); }
.network.offline { color: #fde68a; background: rgb(120 53 15 / 40%); }
main { padding: 18px 20px 44px; display: grid; gap: 16px; }
.card { padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel-2); }
.card.hero { background: linear-gradient(135deg, #312e81, #172554 65%, #0f172a); }
.card.car { background: linear-gradient(135deg, #78350f, #422006 65%, #0f172a); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: #070d19; }
.segment { min-height: 42px; padding: 8px; border: 1px solid transparent; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 700; }
.segment[aria-pressed="true"] { color: white; border-color: rgb(99 102 241 / 55%); background: var(--indigo-soft); }
.mode-car .segment[aria-pressed="true"] { border-color: rgb(245 158 11 / 55%); background: var(--amber-soft); }
label { display: block; margin-bottom: 5px; color: #cbd5e1; font-size: 12px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 42px; padding: 10px 11px; color: var(--text); background: #070d19; border: 1px solid var(--line); border-radius: 11px; }
textarea { min-height: 78px; resize: vertical; }
.field { min-width: 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 13px; }
.btn { min-height: 42px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 11px; color: white; background: #1e293b; font-weight: 750; }
.btn.primary { border-color: transparent; background: var(--indigo); }
.mode-car .btn.primary { color: #1c1202; background: var(--amber); }
.btn.success { color: #022c22; border-color: transparent; background: var(--green); }
.btn.danger { color: #fecdd3; border-color: rgb(251 113 133 / 40%); background: rgb(136 19 55 / 25%); }
.btn.ghost { background: transparent; }
.btn.small-btn { min-height: 34px; padding: 6px 9px; font-size: 11px; }
.checkline { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.checkline input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--indigo); }
.notice { padding: 11px 12px; border-left: 3px solid var(--cyan); border-radius: 8px; color: #cbd5e1; background: rgb(8 47 73 / 35%); font-size: 12px; line-height: 1.55; }
.notice.warn { border-left-color: var(--amber); background: rgb(69 26 3 / 35%); }
.records { display: grid; gap: 9px; }
.record { padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #080f1d; }
.record-title { font-weight: 800; font-size: 13px; }
.record-meta { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 13px; }
.loader { width: 28px; height: 28px; margin: 5px auto 14px; border: 3px solid var(--line); border-top-color: var(--indigo); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
dialog { width: min(calc(100% - 28px), 520px); padding: 0; color: var(--text); border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / 72%); backdrop-filter: blur(4px); }
.dialog-body { padding: 18px; display: grid; gap: 12px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 22px; width: min(calc(100% - 32px), 520px); transform: translateX(-50%); padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: white; background: #111827; box-shadow: var(--shadow); }
.toast.error { border-color: rgb(251 113 133 / 50%); color: #fecdd3; }
.skeleton { height: 14px; border-radius: 6px; background: #1e293b; }
@media (max-width: 560px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar, main { padding-left: 14px; padding-right: 14px; }
  .brand-row { align-items: flex-start; }
}

/* ---------------------------------------------------------------------------
   유틸리티 클래스
   strict CSP(style-src 'self')에서는 style 속성이 차단되므로, 인라인 스타일을
   전부 이 클래스들로 대체한다. 새 마크업에도 style= 를 쓰지 않는다.
   --------------------------------------------------------------------------- */
.mb0 { margin-bottom: 0; }
.mt12 { margin-top: 12px; }
.center { text-align: center; }
.stack { display: grid; gap: 16px; }
.form-stack { display: grid; gap: 11px; margin-top: 14px; }
.cols3 { grid-template-columns: repeat(3, 1fr); }
.hint { margin: 6px 0 0; }
.hero-sub { color: #c7d2fe; }
.month-input { width: 150px; min-height: 36px; padding: 6px 8px; }
.btn-link { display: inline-grid; place-items: center; text-decoration: none; }

/* ---------------------------------------------------------------------------
   관리자 화면(admin.html) 공용 요소
   임직원 화면과 같은 팔레트·카드·버튼 체계를 그대로 쓰고, 관리 화면에만
   필요한 표·상태 배지·변경 전후 비교만 추가한다.
   --------------------------------------------------------------------------- */
.shell.wide { width: min(100%, 1080px); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #080f1d; }
.stat-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.stat-label { margin-top: 4px; color: var(--muted); font-size: 11px; }
.stat.alert .stat-value { color: #fbbf24; }

.table-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: 13px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th, table.data td { padding: 9px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th { position: sticky; top: 0; color: var(--muted); background: #0b1220; font-size: 11px; font-weight: 700; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.wrap { white-space: normal; min-width: 160px; overflow-wrap: anywhere; }
table.data td.num { text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.active { color: var(--green); background: rgb(6 78 59 / 45%); }
.pill.amended { color: #fbbf24; background: rgb(120 53 15 / 45%); }
.pill.voided { color: var(--red); background: rgb(136 19 55 / 40%); }
.pill.pending { color: var(--cyan); background: rgb(8 47 73 / 55%); }
.pill.rejected { color: var(--muted); background: #1e293b; }

.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.diff-box { padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: #080f1d; }
.diff-box.after { border-color: rgb(52 211 153 / 40%); }
.diff-key { color: var(--muted); font-size: 11px; }
.diff-val { margin-top: 2px; font-size: 12px; overflow-wrap: anywhere; }

.filters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.tabbar { display: grid; grid-auto-flow: column; gap: 8px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: #070d19; overflow-x: auto; }
.tab { min-height: 40px; padding: 8px 12px; border: 1px solid transparent; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 700; white-space: nowrap; }
.tab[aria-selected="true"] { color: white; border-color: rgb(99 102 241 / 55%); background: var(--indigo-soft); }

@media (max-width: 720px) {
  .stat-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .diff { grid-template-columns: 1fr; }
}

/* ===========================================================================
   모바일 앱 셸 (참조 프로토타입 레이아웃 재현)
   참조본은 Tailwind CDN + inline onclick 구조였다. Zero-CDN 정책과 strict CSP를
   지키기 위해 같은 형태를 순수 CSS + addEventListener로 다시 구현한다.
   =========================================================================== */
.shell.app { width: min(100%, 460px); position: relative; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.shell.app main { padding: 16px 16px 96px; }

/* 상단 신원 바 */
.id-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.id-left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar-btn { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 11px; background: #1e293b; }
.id-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.id-name { font-size: 14px; font-weight: 800; letter-spacing: -.3px; }
.chip { padding: 1px 7px; border: 1px solid var(--line); border-radius: 6px; font-size: 10px; color: var(--muted); background: #0b1220; }
.chip.brand { color: #c7d2fe; border-color: rgb(99 102 241 / 40%); background: rgb(49 46 129 / 55%); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.clock-sm { margin-top: 2px; font-size: 11px; color: var(--muted); }

/* 출근 상태 필 */
.status-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--muted); background: #1e293b; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; }
.status-pill.on { color: var(--green); border-color: rgb(52 211 153 / 40%); background: rgb(6 78 59 / 40%); }
.status-pill.on .dot { background: var(--green); }

/* GPS / IP 바 */
.sensor-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 11px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 10px; background: rgb(2 6 23 / 80%); font-size: 10px; color: var(--muted); }
.sensor { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.sensor svg { flex: 0 0 auto; }
.sensor.gps svg { color: var(--green); }
.sensor.ip svg { color: var(--cyan); }
.sensor-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 히어로 카드 */
.hero-card { position: relative; overflow: hidden; padding: 18px; border-radius: 18px; border: 1px solid rgb(99 102 241 / 30%); background: linear-gradient(135deg, #4f46e5, #3730a3 55%, #0f172a); box-shadow: var(--shadow); }
.hero-card.car { border-color: rgb(245 158 11 / 30%); background: linear-gradient(135deg, #b45309, #78350f 55%, #0f172a); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; color: #c7d2fe; font-weight: 600; }
.hero-card.car .hero-top { color: #fde68a; }
.hero-tag { padding: 2px 9px; border: 1px solid rgb(165 180 252 / 25%); border-radius: 999px; background: rgb(30 27 75 / 60%); font-size: 11px; }
.hero-card.car .hero-tag { border-color: rgb(252 211 77 / 25%); background: rgb(69 26 3 / 60%); }
.hero-title { margin-top: 12px; font-size: 20px; font-weight: 900; letter-spacing: -.6px; }
.hero-desc { margin-top: 3px; font-size: 12px; color: #c7d2fe; }
.hero-card.car .hero-desc { color: #fde68a; }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 15px; padding-top: 13px; border-top: 1px solid rgb(165 180 252 / 28%); }
.hero-card.car .hero-actions { border-top-color: rgb(252 211 77 / 28%); }
.tag-btn { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px; border: 1px solid rgb(165 180 252 / 30%); border-radius: 11px; color: white; background: rgb(99 102 241 / 22%); font-size: 12px; font-weight: 800; }
.hero-card.car .tag-btn { border-color: rgb(252 211 77 / 30%); background: rgb(245 158 11 / 22%); }
.tag-btn.finish { color: #022c22; border-color: transparent; background: var(--green); }
.tag-btn:active:not(:disabled) { transform: scale(.985); }

/* 목록형 액션 행 */
.row-btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: rgb(2 6 23 / 60%); text-align: left; }
.row-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-icon { flex: 0 0 auto; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: var(--cyan); background: rgb(34 211 238 / 10%); }
.row-icon.amber { color: var(--amber); background: rgb(245 158 11 / 12%); }
.row-icon.green { color: var(--green); background: rgb(52 211 153 / 12%); }
.row-title { font-size: 12px; font-weight: 800; }
.row-sub { margin-top: 2px; font-size: 10px; color: var(--muted); }
.row-value { flex: 0 0 auto; padding: 4px 9px; border-radius: 9px; font-size: 11px; font-weight: 800; color: var(--cyan); background: rgb(34 211 238 / 10%); }

/* 하단 내비게이션 */
.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 40; width: min(100%, 460px); display: flex; align-items: center; justify-content: space-around; gap: 4px; padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgb(2 6 23 / 96%); backdrop-filter: blur(14px); }
.nav-btn { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 48px; padding: 5px 8px; border: 1px solid transparent; border-radius: 11px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 600; }
.nav-btn[aria-current="page"] { color: #a5b4fc; }
.nav-btn .nav-count { position: absolute; }
.nav-toggle { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; padding: 5px 12px; border: 1px solid rgb(99 102 241 / 42%); border-radius: 14px; color: #c7d2fe; background: rgb(99 102 241 / 20%); }
.nav-toggle.car { border-color: rgb(245 158 11 / 45%); color: #fde68a; background: rgb(245 158 11 / 18%); }
.nav-toggle-main { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; color: white; }
.nav-toggle-sub { margin-top: 1px; font-size: 9px; font-weight: 600; }
.nav-btn:active:not(:disabled), .nav-toggle:active:not(:disabled) { transform: scale(.96); }

/* 인증/가입 화면 */
.auth-shell { width: min(100%, 460px); min-height: 100vh; margin: 0 auto; padding: 24px 20px 40px; background: var(--panel); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
.auth-head { display: flex; align-items: center; gap: 12px; }
.auth-mark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 15px; color: white; background: var(--indigo); box-shadow: 0 10px 24px rgb(99 102 241 / 30%); }
.auth-title { margin: 0; font-size: 19px; font-weight: 900; letter-spacing: -.5px; }
.auth-sub { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.form-section { display: grid; gap: 10px; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: rgb(2 6 23 / 55%); }
.form-section h2 { margin: 0; font-size: 13px; }
.pw-meter { height: 6px; margin-top: 6px; border-radius: 999px; background: #1e293b; overflow: hidden; }
.pw-meter > span { display: block; height: 100%; width: 0; background: var(--red); transition: width .18s ease, background .18s ease; }
.pw-meter.ok > span { background: var(--green); }
.pw-meter.mid > span { background: var(--amber); }
.check-row { display: flex; align-items: flex-start; gap: 9px; font-size: 12px; color: #cbd5e1; line-height: 1.5; }
.check-row input { margin-top: 2px; width: 18px; height: 18px; flex: 0 0 auto; }

@media (max-width: 380px) {
  .nav-toggle-main span { display: none; }
  .hero-actions { grid-template-columns: 1fr; }
}
.nav-btn.alert { color: #fbbf24; }
