:root {
  --bg: #ffffff;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #6b7684;
  --line: #dde3ea;
  --primary: #1b6b3a;
  --primary-2: #22883f;
  --accent: #f4c20d;
  --accent-dark: #b88e00;
  --accent-text: #2b2300;
  --danger: #c0392b;
  --ok: #1e8449;
  --warn: #b7791f;
  --annual: #1b5e20;
  --half: #7cb342;
  --refresh: #6a1b9a;
  --other: #1976d2;
  --pending: #ffe082;
  --holiday: repeating-linear-gradient(135deg, #fff 0 3px, #cfd6de 3px 4px);
  --pubholiday: #fde7e7;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 15px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
a { color: var(--primary-2); }

#topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: #fff; color: var(--text); border-bottom: 1px solid var(--line); border-top: 3px solid var(--primary); }
#topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
#topbar .logo { background: var(--accent); color: var(--accent-text); border-radius: 6px; padding: 2px 7px; font-size: 13px; }
#topbar #companyName { font-size: 14px; font-weight: 600; color: var(--primary); }
#nav-desktop { display: flex; gap: 4px; margin-left: 12px; }
#nav-desktop button { background: transparent; border: 0; color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; }
#nav-desktop button:hover { color: var(--text); background: #f4f6f4; }
#nav-desktop button.active { color: var(--primary); font-weight: 700; box-shadow: inset 0 -3px 0 var(--accent); border-radius: 6px 6px 0 0; }
#topbar .who { margin-left: auto; font-size: 14px; white-space: nowrap; }
#topbar .link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0 0 0 6px; }

#view { max-width: 1200px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }

#nav-mobile { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.04);
  padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
#nav-mobile button { flex: 1; border: 0; background: none; padding: 8px 4px 6px; color: var(--muted); font-size: 11px; display: flex;
  flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
#nav-mobile button .ico { width: 22px; height: 22px; display: block; }
#nav-mobile button .ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#nav-mobile button.active { color: var(--primary); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
@media (min-width: 900px) { #nav-mobile { display: none !important; } }
@media (max-width: 899px) { #nav-desktop { display: none; } #topbar #companyName { display: none; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; }
.btn { background: var(--primary); color: #fff; border: 0; border-radius: 8px; padding: 9px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: #e8f3ea; color: var(--primary); }
.btn.accent { background: var(--accent); color: var(--accent-text); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 6px; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; width: 100%; }
.field textarea { min-height: 70px; resize: vertical; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline input[type=checkbox] { width: auto; }
.checks { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 0 6px; }
.checks .check { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.checks input[type=checkbox] { width: 18px; height: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 500px) { .grid2 { grid-template-columns: 1fr; } }

/* 로그인 */
.login-wrap { position: fixed; inset: 0; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 16px; background: #fff; }
.login-card { width: 100%; max-width: 400px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-top: 4px solid var(--primary); box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.login-head { background: #fff; padding: 26px 26px 10px; display: flex; align-items: center; gap: 14px; }
.login-head .mark { width: 46px; height: 46px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; flex: none; }
.login-head .mark svg { width: 28px; height: 28px; }
.login-head .co { font-size: 13px; color: var(--muted); }
.login-head h1 { font-size: 21px; margin: 2px 0 0; color: var(--primary); }
.login-body { padding: 10px 26px 26px; }
.login-body .btn { width: 100%; padding: 12px; font-size: 16px; margin-top: 4px; }
.login-foot { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.6; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
@media (max-width: 480px) { .login-wrap { align-items: flex-start; padding-top: 48px; } }

/* 월간표 */
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-nav .title { font-size: 18px; font-weight: 700; min-width: 120px; text-align: center; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 3px; border: 1px solid #0001; }
.board-wrap { overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table.board { border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 100%; }
table.board th, table.board td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: center; padding: 0; height: 30px; min-width: 30px; }
table.board th { background: #fafbfa; font-weight: 600; position: sticky; top: 0; z-index: 2; }
table.board th.sun, table.board td.sun-h { color: var(--danger); }
table.board th.sat { color: var(--primary-2); }
table.board td.name, table.board th.name { position: sticky; left: 0; background: #fff; z-index: 3; min-width: 96px; text-align: left; padding: 0 8px; font-weight: 600; white-space: nowrap; }
table.board th.name { z-index: 4; background: #fafbfa; }
table.board td.holiday { background: var(--holiday); }
table.board td.holiday.pub { background: var(--pubholiday); position: relative; overflow: visible; }
table.board td.holiday.pub .hol-name { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); writing-mode: vertical-rl; text-orientation: upright;
  white-space: nowrap; font-size: 11px; letter-spacing: 2px; color: #a33; z-index: 1; pointer-events: none; line-height: 1; }
table.board.compact td.holiday.pub .hol-name { font-size: 11px; }
table.board td.cell { cursor: pointer; }
table.board td.cell:hover { outline: 2px solid var(--accent-dark); outline-offset: -2px; }
table.board th.today { box-shadow: inset 0 0 0 2px var(--accent); }
table.board td.cell.today { background: #fff9e0; }
table.board td.mark-ANNUAL { background: var(--annual); color: var(--annual-text, #fff); }
table.board td.mark-HALF_AM, table.board td.mark-HALF_PM { background: var(--half); color: var(--half-text, #fff); font-size: 10px; line-height: 1.1; }
table.board td.mark-REFRESH { background: var(--refresh); color: var(--refresh-text, #fff); font-size: 10px; line-height: 1.1; }
table.board td.mark-OTHER { background: var(--other); color: var(--other-text, #fff); font-size: 10px; }
table.board td.mark-PENDING { background: var(--pending); color: var(--pending-text, #5a4300); font-size: 10px; line-height: 1.1; }
.color-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 4px 0 8px; }
.color-pick { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.color-pick input[type=color] { width: 34px; height: 28px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: #fff; cursor: pointer; }
table.board td.bal { font-weight: 700; min-width: 44px; background: #fbfcfd; }
table.board td.bal.low { color: var(--danger); }
.board-foot { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* 잔여 카드 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; border-left: 4px solid var(--accent); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; white-space: nowrap; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 500; }

/* 목록 */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.item .main { flex: 1; min-width: 180px; }
.item .t { font-weight: 600; }
.item .s { font-size: 12px; color: var(--muted); }
.badge { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; }
.badge.PENDING { background: #fff3cd; color: #7a5a00; }
.badge.APPROVED { background: #d4edda; color: #155724; }
.badge.REJECTED { background: #f8d7da; color: #721c24; }
.badge.CANCELLED { background: #e2e3e5; color: #383d41; }
.type-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.type-dot.ANNUAL { background: var(--annual); } .type-dot.HALF_AM, .type-dot.HALF_PM { background: var(--half); }
.appr { display: flex; flex-wrap: wrap; gap: 6px; }
.appr .step { font-size: 12px; border-radius: 6px; padding: 3px 8px; background: #eef2f5; color: var(--muted); }
.appr .step.done { background: #e2f3e6; color: #155724; }
.appr .step.skip { background: #f1f1f1; color: #888; text-decoration: line-through; }
.appr .step.next { background: var(--pending); color: #5a4300; font-weight: 600; }
.type-dot.REFRESH { background: var(--refresh); } .type-dot.OTHER { background: var(--other); }

table.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
table.plain th, table.plain td { border-bottom: 1px solid var(--line); padding: 8px 8px; text-align: left; vertical-align: middle; white-space: nowrap; }
table.plain th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.plain th.num, table.plain td.num { text-align: right; font-variant-numeric: tabular-nums; width: 58px; }
table.plain th.grp { text-align: center; border-bottom: 0; padding-bottom: 2px; }
table.plain th.grp.sub, table.plain td.sub, table.plain th.sub { color: #8a94a0; font-size: 12px; }
table.plain td.sub { background: #fafbfa; }
table.plain td.act, table.plain th.act { text-align: right; width: 1%; }
table.plain td.act .row { justify-content: flex-end; flex-wrap: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }


.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--accent); font-weight: 700; }

/* 모달 */
#modal-root .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 600px) { #modal-root .backdrop { align-items: center; } }
#modal-root .modal { background: #fff; width: 100%; max-width: 480px; max-height: 92vh; overflow: auto; border-radius: 14px 14px 0 0; padding: 18px; }
@media (min-width: 600px) { #modal-root .modal { border-radius: 14px; } }
#modal-root .modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

#toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); }

/* 인쇄 */
.print-only { display: none; }
@media print {
  body { background: #fff; }
  #topbar, #nav-mobile, .no-print, #toast { display: none !important; }
  #view { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; margin: 0; }
  .board-wrap { overflow: visible; border: 0; }
  table.board { font-size: 10px; }
  table.board th, table.board td { height: 26px; min-width: 22px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-only { display: block; }
  .print-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 8px; }
  .print-head h1 { font-size: 18px; margin: 0; }
  .sign { border-collapse: collapse; font-size: 11px; }
  .sign td { border: 1px solid #000; text-align: center; vertical-align: middle; }
  .sign td.lab { width: 24px; }
  .sign td.box { width: 70px; height: 44px; }
  @page { size: A4 landscape; margin: 10mm; }
}

/* 홈 화면 설치 안내 띠 */
.install-bar { position: fixed; left: 12px; right: 12px; bottom: 64px; z-index: 30; display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 12px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.install-bar .link-x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 0 2px; }
@media (min-width: 900px) { .install-bar { bottom: 16px; max-width: 480px; left: auto; right: 16px; } }

/* 주간/월간 전환, 주간표(휴대폰) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 6px 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.active { background: var(--primary); color: #fff; }
table.board.compact { width: 100%; table-layout: fixed; }
table.board.compact th, table.board.compact td { min-width: 0; height: 34px; font-size: 11px; }
table.board.compact td.name, table.board.compact th.name { min-width: 0; width: 64px; padding: 0 6px; font-size: 12px; }
table.board.compact td.cell { font-size: 10px; }
.month-nav .title { min-width: 0; }
