:root {
    --bg: #f5f5f7; --fg: #1d1d1f; --muted: #86868b; --line: #d2d2d7;
    --primary: #0066cc; --primary-dark: #004499; --success: #34c759; --success-dark: #248a3d;
    --danger: #d70015; --warn-bg: #fff8e6; --card: #fff; --radius: 14px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; background: var(--bg); color: var(--fg); line-height: 1.5; font-size: 14px; }

/* 레이아웃 */
.sidebar { position: fixed; left: 0; top: 0; height: 100%; width: 220px; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-right: 1px solid var(--line); padding: 20px 0; display: flex; flex-direction: column; }
.sidebar .brand { padding: 4px 24px 20px; font-weight: 700; letter-spacing: .04em; color: var(--muted); font-size: 12px; }
.sidebar a { display: block; padding: 12px 24px; color: var(--fg); text-decoration: none; transition: background .2s; }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { color: var(--primary); background: var(--bg); font-weight: 600; }
.sidebar .logout { margin-top: auto; padding: 12px 24px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.sidebar .user { color: var(--muted); font-size: 13px; }
.content { margin-left: 220px; padding: 40px; max-width: 1280px; }

/* 카드 */
.card { background: var(--card); border-radius: var(--radius); padding: 28px; box-shadow: 0 4px 6px rgba(0,0,0,.06); margin-bottom: 28px; }
.card h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.card-header h2 { margin-bottom: 2px; }
.hint { color: var(--muted); font-size: 13px; margin: -6px 0 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* 폼 */
.form-row { display: flex; gap: 20px; margin-bottom: 18px; }
.form-group { flex: 1; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.form-group select, .form-group input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fff; transition: border .2s, box-shadow .2s; }
.form-group select:focus, .form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0,102,204,.12); }

/* 버튼 */
.btn { padding: 11px 22px; border: none; border-radius: 10px; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .2s; color: #fff; }
.btn-primary { background: var(--primary); } .btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); } .btn-success:hover { background: var(--success-dark); }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); } .btn-secondary:hover { background: #eef5ff; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 13px; padding: 0; }
.btn[disabled] { opacity: .5; cursor: progress; }

/* 표 */
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 500; color: var(--muted); background: var(--bg); white-space: nowrap; }
tbody tr:hover { background: var(--bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.deposit { color: var(--primary); } .withdraw { color: var(--danger); }
tr.row-warn { background: var(--warn-bg); }
tfoot .total td { font-weight: 700; background: #f8f9fa; border-top: 2px solid var(--line); }

/* 페이지네이션 */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 22px; flex-wrap: wrap; }
.pagination a { padding: 7px 13px; border-radius: 8px; font-size: 13px; border: 1px solid var(--line); color: var(--fg); text-decoration: none; background: #fff; }
.pagination a:hover:not(.disabled) { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a.disabled { opacity: .35; pointer-events: none; }
.pagination .page-size { font-size: 13px; color: var(--muted); margin-left: 10px; }
.pagination select { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); font-size: 13px; }

/* 플래시 / 오류 */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: 14px; }
.flash-error { background: #fff1f0; color: #a8071a; border: 1px solid #ffa39e; }
.flash-message, .flash-info { background: #e6f4ff; color: #0958d9; border: 1px solid #91caff; }
.error-card { text-align: center; padding: 60px 28px; }
.error-code { font-size: 48px; font-weight: 700; color: var(--muted); }
.error-card h1 { font-size: 22px; margin-bottom: 10px; }
.error-card p { color: var(--muted); margin-bottom: 20px; }
.error-detail { text-align: left; background: var(--bg); padding: 12px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; margin-bottom: 20px; }
.error-card .btn { display: inline-block; text-decoration: none; }

/* 로그인 */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; padding: 40px; border-radius: 18px; box-shadow: 0 4px 12px rgba(0,0,0,.08); width: 100%; max-width: 380px; }
.login-card h1 { font-size: 22px; font-weight: 600; text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .form-group { margin-bottom: 18px; }

@media (max-width: 768px) {
    .sidebar { position: relative; width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; padding: 8px; }
    .sidebar .brand { display: none; }
    .sidebar .logout { margin: 0 0 0 auto; border: none; padding: 8px 16px; }
    .content { margin-left: 0; padding: 16px; }
    .form-row { flex-direction: column; gap: 12px; }
    table { display: block; overflow-x: auto; }
}

/* ── 루틴 업무 ─────────────────────────────────────────────────────── */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { font-size: 28px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.page-head p { margin: 0; }
.btn-sm { padding: 7px 14px; font-size: 13px; text-decoration: none; display: inline-block; }
.two-col { display: flex; flex-wrap: wrap; gap: 28px; align-items: stretch; }
.two-col .card { margin-bottom: 28px; min-width: 0; }
.col-main { flex: 3 1 460px; }
.col-side { flex: 2 1 320px; }
.form-card h2 { margin-bottom: 16px; }
.inline-form { margin-bottom: 16px; padding: 16px; background: var(--bg); border-radius: 10px; }
.inline-form .form-row { margin-bottom: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; padding: 20px 24px; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 0 4px; }
.stat + .stat { border-left: 1px solid var(--line); padding-left: 20px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value.accent { color: var(--primary); }
.stat-sub { color: var(--muted); font-size: 12px; }

.group-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 0 6px; }
.group-title.warn { color: var(--danger); }
.task-list, .dday-list, .deposit-list { list-style: none; margin: 0; padding: 0; }
.task-list li, .dday-list li, .deposit-list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #ececf0; }
.task-form { display: flex; gap: 12px; align-items: flex-start; width: 100%; }
.task-form input[type=checkbox] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); flex: none; cursor: pointer; }
.task-form label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; cursor: pointer; }
.task-title { font-weight: 500; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.task.overdue .task-title { color: var(--danger); }
.task-meta { color: var(--muted); font-size: 12px; }
.pill { flex: none; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; white-space: nowrap; background: #f2f2f5; color: #3a3a3c; }
.cat-rec.pill, .cal-ev.cat-rec { background: #e6f0ff; color: #0050a0; }
.cat-tax.pill, .cal-ev.cat-tax { background: #fff1e0; color: #8a4b00; }
.cat-pay.pill, .cal-ev.cat-pay { background: #f3ecff; color: #5b2fa0; }
.cat-invoice.pill, .cal-ev.cat-invoice { background: #eaf6ec; color: #1f6b33; }
.cat-admin.pill, .cal-ev.cat-admin { background: #f2f2f5; color: #3a3a3c; }
.cat-text { font-size: 11px; font-weight: 600; }
.cat-text.cat-rec { color: #0050a0; } .cat-dot.cat-rec { background: #0050a0; }
.cat-text.cat-tax { color: #8a4b00; } .cat-dot.cat-tax { background: #8a4b00; }
.cat-text.cat-pay { color: #5b2fa0; } .cat-dot.cat-pay { background: #5b2fa0; }
.cat-text.cat-invoice { color: #1f6b33; } .cat-dot.cat-invoice { background: #1f6b33; }
.cat-text.cat-admin { color: #3a3a3c; } .cat-dot.cat-admin { background: #3a3a3c; }
.cat-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; color: var(--muted); }

.dday { flex: none; width: 64px; text-align: center; font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; padding: 4px 0; border-radius: 8px; background: #f2f2f5; color: #3a3a3c; }
.dday.red, .dday.over { background: #ffe9e7; color: #a8071a; }
.dday.yellow { background: #fff8e6; color: #7a5200; }
.dday.unknown { background: #fff1e0; color: #8a4b00; }
.dday-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dday-title { font-weight: 500; }
.deposit-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.deposit-list li.late .dday-title { color: var(--danger); }
.st-received { background: #eaf6ec; color: #1f6b33; }
.st-waiting { background: #f2f2f5; color: #3a3a3c; }
.st-expected { background: #fff8e6; color: #7a5200; }
.wl-progress { background: #fff8e6; color: #7a5200; }
.wl-ongoing { background: #f2f2f5; color: #3a3a3c; }
.wl-hold { background: #ffe9e7; color: #a8071a; }
.wl-done { background: #eaf6ec; color: #1f6b33; }

.scroll-x { overflow-x: auto; }
.week { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: 12px; min-width: 1000px; }
.week-day { border-radius: 12px; padding: 12px; background: var(--bg); border: 1px solid transparent; display: flex; flex-direction: column; gap: 8px; min-height: 150px; }
.week-day.today { background: #eef5ff; border-color: var(--primary); }
.week-day.weekend .week-head strong { color: var(--muted); }
.week-head { display: flex; justify-content: space-between; align-items: baseline; }
.week-item { background: #fff; border-radius: 8px; padding: 8px 10px; box-shadow: 0 1px 2px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 2px; font-size: 13px; line-height: 1.35; }
.week-item.done { opacity: .55; text-decoration: line-through; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-cell { min-height: 84px; border-radius: 8px; padding: 6px; background: #fff; border: 1px solid #ececf0; display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow: hidden; }
.cal-cell.past { background: #fafafa; }
.cal-cell.out { opacity: .35; }
.cal-cell.off .cal-day { color: var(--danger); }
.cal-cell.today { background: #eef5ff; border: 2px solid var(--primary); }
.cal-day { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-cell.past .cal-day { color: #8e8e93; }
.cal-ev { font-size: 11px; line-height: 1.3; padding: 1px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev.done { opacity: .5; text-decoration: line-through; }

@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .stat + .stat { border-left: none; padding-left: 4px; } }
@media (max-width: 768px) { .cal-cell { min-height: 56px; } .cal-ev { display: none; } .cal-cell .cal-day::after { content: ''; } }
