:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); }

.app-shell { max-width: 1080px; margin: 0 auto; padding: 16px; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.app-header h1 { font-size: 18px; margin: 0; }
.app-header .badge { font-size: 12px; color: var(--text-muted); }

.tabs {
  display: flex; gap: 4px; overflow-x: auto; margin: 14px 0;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  padding: 10px 14px; border: none; background: none; cursor: pointer;
  font-size: 14px; color: var(--text-muted); white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.card h2 { margin-top: 0; font-size: 16px; }
.card h3 { font-size: 14px; color: var(--text-muted); margin: 0 0 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

label { display: block; font-size: 13px; color: var(--text-muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--text);
}
input[type=file] { font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: none; background: var(--primary); color: #fff; font-size: 14px; cursor: pointer;
  font-weight: 500;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #eef2f7; color: var(--text); }
.btn.secondary:hover { background: #e2e8f0; }
.btn.danger { background: #fee2e2; color: var(--danger); }
.btn.danger:hover { background: #fecaca; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: #f8fafc; }
.num-input { width: 80px; padding: 5px 6px; }

.toast-wrap {
  position: fixed; top: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: fadein .15s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px);} to { opacity: 1; transform: translateY(0);} }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center;
  justify-content: center; z-index: 500; padding: 16px;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto;
}
.modal.modal-wide { max-width: 760px; }
.modal.modal-wide .payslip-doc { border: none; padding: 0; }
.modal h3 { margin-top: 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.pill.draft { background: #fef3c7; color: #92400e; }
.pill.sent { background: #dcfce7; color: #166534; }

/* 인사정보 아코디언 */
.acc-list { display: flex; flex-direction: column; gap: 8px; }
.acc-item { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.acc-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.acc-row .acc-name { font-size: 14px; font-weight: 700; white-space: nowrap; }
.acc-row .acc-id { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.acc-row .acc-wage { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--primary-dark); font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-row .acc-chevron { color: var(--text-muted); font-size: 11px; transition: transform .15s ease; }
.acc-item.open .acc-chevron { transform: rotate(180deg); }
.acc-detail { display: none; padding: 0 14px 14px; border-top: 1px solid var(--border); }
.acc-item.open .acc-detail { display: block; }
.acc-detail dl { display: grid; grid-template-columns: 76px 1fr; row-gap: 8px; margin: 12px 0; font-size: 13px; }
.acc-detail dt { color: var(--text-muted); }
.acc-detail dd { margin: 0; word-break: break-all; }
.acc-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.acc-fields label { font-size: 11px; color: var(--text-muted); }
.acc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (prefers-reduced-motion: reduce) { .acc-item.open .acc-chevron { transition: none; } }

/* 카메라 스캐너 */
.scanner-wrap { position: relative; width: 100%; max-width: 420px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: #000; }
.scanner-wrap video { width: 100%; display: block; }
.scanner-frame {
  position: absolute; inset: 15%; border: 3px solid #22c55e; border-radius: 12px; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(0,0,0,.35);
}
.scan-result { text-align: center; padding: 10px; font-size: 13px; color: var(--text-muted); }

/* 갤러리 */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }
.gallery figcaption { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.gallery .del-btn {
  position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff; border: none;
  border-radius: 50%; width: 22px; height: 22px; cursor: pointer; font-size: 12px;
}

/* 달력 */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--text-muted); padding: 4px 0; }
.cal-cell {
  min-height: 64px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; font-size: 11px;
  background: #fff; cursor: pointer;
}
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell .d { font-size: 12px; color: var(--text-muted); }
.cal-cell .g { margin-top: 6px; font-weight: 700; font-size: 14px; color: var(--primary); }
.cal-cell.today { border-color: var(--primary); }
.cal-cell:hover { background: #f1f5f9; }
.cal-legend { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

.qr-box { text-align: center; }
.qr-box #qrcode-container { display: inline-block; padding: 14px; background: #fff; border-radius: 12px; border: 1px solid var(--border); }

.empty-state { text-align: center; color: var(--text-muted); padding: 30px 10px; font-size: 13px; }

.landing { max-width: 640px; margin: 60px auto; text-align: center; padding: 0 16px; }
.landing h1 { font-size: 26px; }
.landing p { color: var(--text-muted); }
.landing .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 30px; }
@media (max-width: 560px) { .landing .cards { grid-template-columns: 1fr; } }
.landing .cards a {
  display: block; padding: 26px; background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 16px;
}
.landing .cards a:hover { border-color: var(--primary); }
.landing .cards .sub { display: block; font-weight: 400; font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.muted { color: var(--text-muted); font-size: 12px; }
.hidden { display: none !important; }

/* 급여명세서 문서 뷰 */
.payslip-doc { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.payslip-doc-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.payslip-doc-header h2 { margin: 0; font-size: 20px; }
.payslip-doc h3 { font-size: 13px; color: var(--text-muted); margin: 20px 0 8px; }
.payslip-info-table { margin-bottom: 4px; }
.payslip-info-table th { width: 22%; background: #f8fafc; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.payslip-info-table td { width: 28%; font-size: 13px; }
.payslip-breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .payslip-breakdown { grid-template-columns: 1fr; } }
.payslip-breakdown table thead th { background: #f8fafc; text-align: center; font-size: 12px; }
.payslip-breakdown td:last-child { text-align: right; }
.payslip-breakdown tr.total-row td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: none; }
.payslip-netpay {
  display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding: 14px 16px;
  background: #eff6ff; border-radius: var(--radius); font-size: 15px; font-weight: 700; color: var(--primary-dark);
}
.payslip-netpay span { font-size: 20px; }
.payslip-doc-footer { text-align: right; margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.payslip-doc-footer div:last-child { font-weight: 600; color: var(--text); margin-top: 2px; }
