:root {
    --primary: #2f5bea;
    --primary-dark: #2346c2;
    --bg: #f3f5fa;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #d9dee8;
    --danger-bg: #fdecec;
    --danger-text: #b42318;
    --success-bg: #e7f6ec;
    --success-text: #1a7f37;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* 로그인 */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(135deg, #e8eeff 0%, var(--bg) 60%);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border-radius: 16px;
    padding: 40px 32px 28px;
    box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}

.brand { text-align: center; margin-bottom: 28px; }

.brand-mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand h1 { margin: 0; font-size: 22px; }
.subtitle { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.login-form { display: flex; flex-direction: column; }
.login-form label { font-size: 13px; font-weight: 600; margin: 12px 0 6px; }

.login-form input {
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.15);
}

.login-form button {
    margin-top: 24px;
    height: 46px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.login-form button:hover { background: var(--primary-dark); }

.alert {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--danger-bg);
    color: var(--danger-text);
    font-size: 14px;
}

.footer { margin: 24px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.alert-success { background: var(--success-bg); color: var(--success-text); }

/* 공통 레이아웃 */
.topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; min-width: 0; }
.topbar .logo { font-weight: 700; color: var(--text); text-decoration: none; }
.topbar nav { display: flex; gap: 4px; min-width: 0; max-width: 100%; overflow-x: auto; }
.topbar nav a {
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    white-space: nowrap;
}
.topbar nav a:hover { background: var(--bg); color: var(--text); }
.topbar nav a.active { background: #e8eeff; color: var(--primary); font-weight: 600; }
.topbar-user { font-size: 14px; }
.topbar-user a { color: var(--primary); }

.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head h2 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }

/* 버튼 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--text);
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger-text); border-color: #f3c4c0; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-link { border-color: transparent; background: none; color: var(--muted); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
form.inline { display: inline; }

/* 검색 */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input {
    flex: 1;
    max-width: 320px;
    min-width: 0;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

/* 표 */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { background: #f8f9fc; color: var(--muted); font-weight: 600; font-size: 13px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .col-actions { text-align: right; }
.table .empty { text-align: center; color: var(--muted); padding: 32px; }
.row-inactive td { color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-admin { background: #e8eeff; color: var(--primary); }
.badge-employee { background: #eef0f3; color: #4b5563; }

/* 폼 */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.form { display: flex; flex-direction: column; max-width: 480px; }
.form label { font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.form label:first-of-type { margin-top: 0; }
.form input[type="text"], .form input[type="password"], .form select {
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
}
.form input:focus, .form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.15);
}
.form .checkbox { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 18px; }
.form .req { color: var(--danger-text); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* 근태 상태 / 요약 */
.badge-absent { background: var(--danger-bg); color: var(--danger-text); }
.badge-working { background: #fff4e0; color: #b25e09; }
.badge-done { background: var(--success-bg); color: var(--success-text); }

.today-head { display: flex; justify-content: space-between; align-items: center; }
.stat-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.stat { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 22px; font-weight: 700; white-space: nowrap; }
.stat-cards .stat { padding: 16px 20px; }

.search-bar input[type="month"], .search-bar input[type="date"] { flex: 0 1 auto; }
.day-sat { color: var(--primary); }
.day-sun { color: var(--danger-text); }

.topbar ~ .page .alert a, .attend-card a { color: var(--primary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.passkey-register { margin-bottom: 16px; }
.passkey-register p { margin-top: 0; line-height: 1.6; }
.passkey-register .search-bar { margin-bottom: 0; flex-wrap: wrap; }
.passkey-register .search-bar input { flex: 1 1 200px; }
.passkey-register .alert { margin: 12px 0 0; }
.passkey-reset { margin-top: 16px; }
.passkey-reset .muted { margin: 8px 0 0; }
.passkey-reset .form-actions { margin-top: 12px; }

/* 출퇴근 (휴대폰 화면) */
.attend-card { text-align: center; }
.attend-card > p { margin: 0 0 8px; }
.attend-date { font-size: 15px; font-weight: 600; }
.attend-clock { font-size: 48px; font-weight: 700; letter-spacing: 1px; }
.attend-user { font-size: 17px; margin-top: 16px !important; }
.attend-step { margin: 20px 0 12px !important; font-size: 14px; }
.attend-step.done { color: var(--success-text); font-weight: 600; }
.attend-card .alert { text-align: left; margin-top: 12px; }
.attend-help { margin-top: 16px !important; }
.btn-xl { width: 100%; height: 56px; font-size: 18px; border-radius: 12px; }
.btn-out { background: #1f2937; border-color: #1f2937; color: #fff; font-weight: 600; }
.btn-out:hover { background: #111827; }

/* QR 키오스크 */
.kiosk {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    text-align: center;
}
.kiosk h1 { margin: 0 0 8px; font-size: 26px; }
.kiosk-date { margin: 0; color: var(--muted); font-size: 18px; }
.kiosk-clock { margin: 4px 0 24px; font-size: 56px; font-weight: 700; }
.kiosk-qr {
    width: min(360px, 80vw);
    aspect-ratio: 1;
    padding: 16px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}
.kiosk-qr svg { width: 100%; height: 100%; display: block; }
.kiosk-progress { width: min(360px, 80vw); height: 4px; margin-top: 12px; background: var(--border); border-radius: 2px; overflow: hidden; }
.kiosk-progress div { height: 100%; background: var(--primary); transition: width 1s linear; }
.kiosk-guide { margin-top: 20px; font-size: 17px; }
.kiosk-error { color: var(--danger-text); }
.login-help { margin: 16px 0 0; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.5; }
.attend-first { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.attend-first .muted { margin: 0 0 10px; }
.attend-first .btn-xl { height: 48px; font-size: 15px; }
.passkey-register .alert-success { margin: 0 0 12px; }

/* 출퇴근 달력 */
.calendar { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-row + .cal-row { border-top: 1px solid var(--border); }
.cal-head > div { padding: 10px 0; text-align: center; background: #f8f9fc; color: var(--muted); font-size: 13px; font-weight: 600; }
.cal-head .day-sat { color: var(--primary); }
.cal-head .day-sun { color: var(--danger-text); }
.cal-cell { min-height: 104px; padding: 8px; display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; }
.cal-cell + .cal-cell { border-left: 1px solid var(--border); }
.cal-other { background: #fafbfd; }
.cal-other > * { opacity: 0.45; }
.cal-top { display: flex; justify-content: space-between; align-items: center; gap: 4px; margin-bottom: 4px; }
.cal-day { font-weight: 600; }
.cal-today .cal-day {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 24px; border-radius: 999px; background: var(--primary); color: #fff;
}
.cal-badge { padding: 1px 6px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-time { display: flex; justify-content: space-between; gap: 4px; font-variant-numeric: tabular-nums; }
.cal-label { color: var(--muted); }
.cal-duration { margin-top: auto; padding-top: 4px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cal-short { display: none; }
.cal-done { box-shadow: inset 0 3px 0 var(--success-text); }
.cal-working { box-shadow: inset 0 3px 0 #b25e09; }
.cal-absent { box-shadow: inset 0 3px 0 var(--danger-text); background: #fff8f7; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-dot { width: 10px; height: 10px; border-radius: 2px; box-shadow: none; }
.cal-dot.cal-done { background: var(--success-text); }
.cal-dot.cal-working { background: #b25e09; }
.cal-dot.cal-absent { background: var(--danger-text); }

/* 좁은 화면: 상태 배지는 칸 위쪽 색 띠로, 근무시간은 H:MM 으로 줄인다 */
@media (max-width: 760px) {
    .cal-cell { min-height: 84px; padding: 6px 4px; font-size: 11px; }
    .cal-badge, .cal-label { display: none; }
    .cal-time { justify-content: center; }
    .cal-duration { text-align: center; }
    .cal-long { display: none; }
    .cal-short { display: inline; }
    .cal-top { justify-content: center; }
}
