/* ============ tokens ============ */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f9fafc;
  --border: #e4e8ef;
  --border-strong: #cbd2dc;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-dim: #9aa3af;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbe7ff;
  --success: #16a34a;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow: 0 4px 12px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);

  --font: ui-sans-serif, system-ui, -apple-system, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
code.dim { color: var(--text-muted); background: transparent; padding: 0; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.text-center { text-align: center; }
.text-success { color: var(--success); font-weight: 600; }
.hidden { display: none !important; }
.inline { display: inline; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 24px;
  padding: 12px 20px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 3px; background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a { color: var(--text-muted); padding: 6px 12px; border-radius: var(--radius-sm); font-weight: 500; }
.topnav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topnav a.is-active { color: var(--primary); background: var(--primary-soft); }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.role-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
.role-admin { background: var(--primary-soft); color: var(--primary); }
.role-worker { background: var(--info-soft); color: var(--info); }

.page { max-width: 1280px; margin: 0 auto; padding: 28px 20px 60px; }
.page-header { margin-bottom: 24px; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.page-header p { margin: 0; }
.link-back { display: inline-block; margin-bottom: 8px; font-size: 13px; color: var(--text-muted); }

body.page-centered {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8edf5 100%);
}
body.page-centered .topbar { display: none; }
.page-auth { width: 100%; max-width: 420px; padding: 0; }
.auth-card { background: var(--surface); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow); }
.auth-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.auth-sub { margin: 0 0 24px; color: var(--text-muted); }

.error-status { font-size: 56px; font-weight: 800; color: var(--danger); text-align: center; margin-bottom: 4px; }
.error-message { text-align: center; color: var(--text-muted); margin: 0 0 24px; }

.complete-check {
  width: 64px; height: 64px; margin: 0 auto 20px;
  background: var(--success); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 700;
}

.card { background: var(--surface); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); margin-bottom: 20px; }
.card-title { margin: 0 0 16px; font-size: 14px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; line-height: 1.1; }
.stat-unit { font-size: 18px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-card-action { display: flex; flex-direction: column; justify-content: center; gap: 8px; }

.form { display: flex; flex-direction: column; gap: 14px; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: end; gap: 12px; }
.form-row { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-inline .form-row { flex: 1 1 160px; }
.label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.input {
  font: inherit; color: var(--text);
  padding: 9px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.input-sm { padding: 5px 8px; font-size: 13px; width: 80px; }
.hint { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); }
.hint p { margin: 6px 0 4px; }
.hint-list { margin: 4px 0 6px; padding-left: 20px; }
.hint-list li { margin: 2px 0; }
.hint-list code, .hint code { background: var(--surface-2, #f4f4f6); padding: 1px 4px; border-radius: 3px; }
.code-block { background: var(--surface-2, #f4f4f6); border: 1px solid var(--border); padding: 8px 10px; border-radius: 4px; font-family: var(--mono); font-size: 12px; overflow-x: auto; margin: 4px 0; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s, color .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.table { width: 100%; border-collapse: collapse; }
.table thead th {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  text-align: left; padding: 10px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table-scroll { overflow-x: auto; }
.table-detail code { font-size: 12px; }

.link { color: var(--primary); font-weight: 500; }
.pager { display: flex; align-items: center; gap: 12px; padding: 8px 0; }

.badge { display: inline-block; padding: 2px 8px; font-size: 11px; font-weight: 700; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em; }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }
.badge-success { background: rgba(34, 197, 94, 0.15); color: #15803d; }

/* 작업자 상세 — captcha 썸네일 */
.captcha-thumb { display: block; max-width: 180px; max-height: 56px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2, #f4f4f6); image-rendering: -webkit-optimize-contrast; }

/* 불일치 더보기 버튼 */
.reconcile-more { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; }

/* 모달 */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.5); }
.modal-panel { position: relative; background: var(--surface, #fff); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); max-width: 480px; width: calc(100% - 32px); max-height: calc(100vh - 64px); display: flex; flex-direction: column; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-sub { padding: 6px 18px 0; margin: 0; font-size: 12px; }
.modal-body { padding: 12px 18px 18px; overflow-y: auto; flex: 1 1 auto; }
.table-compact th, .table-compact td { padding: 6px 8px; font-size: 13px; }
body.modal-open { overflow: hidden; }

.meter { display: inline-block; width: 120px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; vertical-align: middle; }
.meter-lg { width: 100%; height: 8px; }
.meter-bar { height: 100%; background: linear-gradient(90deg, #3b82f6, #6366f1); transition: width .3s; }
.meter-text { font-size: 12px; color: var(--text-muted); margin-left: 8px; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

.page-label { max-width: 560px; }
.label-shell { display: flex; flex-direction: column; gap: 20px; }
.label-progress { background: var(--surface); padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--border); display: flex; align-items: center; gap: 14px; }
.label-progress .meter { flex: 1; min-width: 0; }
.label-progress-text { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.label-progress-text strong { color: var(--text); font-size: 15px; }

.captcha-frame { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.captcha-img { max-width: 100%; display: block; image-rendering: -webkit-optimize-contrast; }

.label-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.captcha-input {
  font-family: var(--mono); font-size: 32px; font-weight: 700;
  width: 100%; max-width: 280px;
  padding: 14px 16px; text-align: center; letter-spacing: 0.4em;
  border: 2px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-2); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.captcha-input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .15); background: var(--surface); }
.label-actions { display: flex; gap: 10px; width: 100%; }
.label-actions .btn { flex: 1; }
.label-actions .btn-primary { flex: 2; }

.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 12px; }
.progress-bar { height: 100%; background: var(--primary); width: 0; transition: width .2s; }
.log {
  font-family: var(--mono); font-size: 12px;
  background: #111827; color: #e2e8f0;
  padding: 12px 14px; border-radius: var(--radius-sm);
  max-height: 240px; overflow: auto; margin-top: 12px; white-space: pre-wrap;
}

#toast-host { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow); min-width: 240px; max-width: 360px; animation: toast-in .2s ease-out; }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
