:root {
  --brand: #a50034;
  --brand-dark: #7d0027;
  --ink: #1f2328;
  --ink-soft: #5b6470;
  --line: #dde1e6;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --ok: #1d7a46;
  --danger: #c0262d;
  --radius: 10px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.5; }
[hidden] { display: none !important; }

/* 상단바: 로고가 흰 바탕이라 흰색. 브랜드색은 버튼·강조에만 사용 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; background: var(--surface); color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-weight: 700; font-size: 1.05rem; margin-right: auto; }
.topbar .logo { display: block; height: 26px; width: auto; margin-right: auto; }
.topbar .logo-mark { display: block; height: 28px; width: 28px; }
.topbar a, .topbar button {
  color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 6px; padding: .3rem .6rem; font: inherit; font-size: .82rem; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.topbar #who { font-size: .85rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

main { max-width: 720px; margin: 0 auto; padding: 1rem; }
section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
h2 { margin: 0 0 .75rem; font-size: 1.1rem; }

label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin: .6rem 0 .25rem; }
input, select {
  width: 100%; padding: .65rem .75rem; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
td select { width: auto; padding: .3rem .4rem; font-size: .85rem; }   /* 계정 목록의 권한 선택 */

.btn {
  display: inline-block; padding: .65rem 1rem; font: inherit; font-weight: 700;
  border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; margin-top: 1rem; }
.btn.small { padding: .3rem .55rem; font-size: .8rem; font-weight: 600; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }

.msg { min-height: 1.4em; margin-top: .6rem; font-size: .9rem; font-weight: 600; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

.stock-list { list-style: none; margin: 0; padding: 0; }
.stock-list li { display: flex; justify-content: space-between; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.stock-list li:last-child { border-bottom: 0; }
.stock-list .qty { font-weight: 700; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .5rem .4rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--ink-soft); font-weight: 600; }
td .btn + .btn { margin-left: .25rem; }
.tag { font-size: .75rem; padding: .1rem .4rem; border-radius: 4px; background: var(--bg); }
.tag.admin { background: var(--brand); color: #fff; }
.off { color: var(--ink-soft); text-decoration: line-through; }
.fail { color: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

textarea {
  width: 100%; padding: .65rem .75rem; font: inherit; resize: vertical;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
small { color: var(--ink-soft); font-weight: 400; }
.hint { margin: .4rem 0 0; font-size: .82rem; color: var(--ink-soft); }

/* 하단 메뉴 */
body.has-tabbar { padding-bottom: 4.2rem; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: .5rem 0 .45rem; font-size: .72rem; font-weight: 600;
  color: var(--ink-soft); text-decoration: none; border-top: 2px solid transparent;
}
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--brand); border-top-color: var(--brand); }

/* 관리자 화면 상단 탭 */
.subnav { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: 1rem; }
.subnav a, .subnav button {
  flex: none; padding: .45rem .8rem; font: inherit; font-size: .88rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink); text-decoration: none; cursor: pointer;
}
.subnav .on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 태그 색 */
.tag.geo-ok, .tag.work { background: #e3f4ea; color: var(--ok); }
.tag.geo-near, .tag.warn { background: #fdf0d8; color: #8a5a00; }
.tag.geo-far, .tag.bad { background: #fde5e6; color: var(--danger); }
.tag.geo-none { background: var(--bg); color: var(--ink-soft); }
.tag.wait { background: #e4edfb; color: #1f4f9c; }
.tag + .tag { margin-left: .2rem; }

/* 출퇴근 등록 */
.clock { font-size: 2.4rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.status-line { color: var(--ink-soft); margin: .2rem 0 .6rem; }
.btn.big { width: 100%; padding: 1rem; font-size: 1.15rem; margin-top: .9rem; }
.btn.out { background: var(--ink); border-color: var(--ink); }
.photo-pick { display: flex; align-items: center; gap: .75rem; margin-top: .8rem; }
.photo-pick img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.consent { border-color: var(--brand); }
.consent ul { margin: .4rem 0 .8rem; padding-left: 1.1rem; font-size: .88rem; color: var(--ink-soft); }
.row-btns { display: flex; gap: .5rem; flex-wrap: wrap; }

/* 월 요약·달력 */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.month-nav b { font-size: 1.05rem; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .9rem; }
.tile { background: var(--bg); border-radius: 8px; padding: .5rem .6rem; }
.tile span { display: block; font-size: .72rem; color: var(--ink-soft); }
.tile b { font-size: .95rem; }
.tile.warn b { color: #8a5a00; }
.tile.bad b { color: var(--danger); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: .75rem; color: var(--ink-soft); padding: .2rem 0; }
.cal-day {
  min-height: 3.4rem; padding: .2rem 0; font: inherit; color: var(--ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px;
}
.cal-day .num { font-size: .8rem; color: var(--ink-soft); }
.cal-day .hrs { font-size: .72rem; font-weight: 700; min-height: 1em; }
.cal-day.has { background: #fbf3f5; }
.cal-day.today { border-color: var(--brand); }
.cal-day.picked { outline: 2px solid var(--brand); }
.dots { display: flex; gap: 2px; min-height: 6px; }
.dots i, .legend i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
i.bad { background: var(--danger); } i.warn { background: #e09a00; } i.wait { background: #2f6fd6; }
.legend { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .75rem; color: var(--ink-soft); margin-top: .5rem; }

/* 기록 카드 */
.rec { border: 1px solid var(--line); border-radius: 8px; padding: .7rem; margin-top: .6rem; }
.rec-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; }
.rec-row { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; min-height: 2.2rem; }
.rec-row b { width: 2.2rem; font-size: .85rem; color: var(--ink-soft); }
.rec-row .time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3rem; }
.rec-foot { font-size: .88rem; margin-top: .3rem; }
.rec-actions { display: flex; gap: .4rem; margin-top: .4rem; }
.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; margin-left: auto; }
.rec-row a:has(.thumb) { margin-left: auto; }
.maplink { font-size: .8rem; }
.empty { color: var(--ink-soft); font-size: .9rem; padding: .5rem 0; }

/* 작업일보: 출근 기록 없는 날 사유 입력 */
.no-att { margin-top: .8rem; padding: .7rem .8rem; border: 1px solid var(--danger); border-radius: 8px; background: #fde5e6; }
.no-att b { color: var(--danger); font-size: .92rem; }

/* 작업일보 */
.report { border-bottom: 1px solid var(--line); padding: .75rem 0; }
.report:last-child { border-bottom: 0; }
.report p { margin: .3rem 0; white-space: pre-wrap; word-break: break-word; }
.report .issues { color: var(--danger); }
.photos { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .4rem; }
.photos .ph { position: relative; }
.photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.photos .ph button {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: 0; background: var(--ink); color: #fff; font-size: .8rem; line-height: 1; cursor: pointer;
}

/* 관리자: 정정 창, 지도 */
dialog { width: min(420px, calc(100% - 2rem)); border: 0; border-radius: var(--radius); padding: 1.2rem; }
dialog::backdrop { background: rgba(31,35,40,.5); }
#map { height: 300px; border-radius: 8px; border: 1px solid var(--line); margin-top: .6rem; z-index: 0; }
.site-item { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.site-item:last-child { border-bottom: 0; }
.home-menu { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.home-menu a {
  display: block; padding: 1rem; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 700;
}
.home-menu a small { display: block; margin-top: .15rem; }

/* 계정 화면 */
.kv { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--ink-soft); font-size: .9rem; }

/* 로그인 화면 */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-box { width: min(380px, 100%); background: var(--surface); border-top: 4px solid var(--brand); border-radius: var(--radius); padding: 1.8rem 1.5rem; box-shadow: 0 6px 24px rgba(31,35,40,.08); }
.login-box h1 { margin: 0 0 .2rem; font-size: 1.35rem; }
.login-box p { margin: 0 0 1rem; color: var(--ink-soft); font-size: .9rem; }

/* 달력: 연차·반차 */
.cal-day.leave { background: #eef3fb; }
.cal-day.leave .hrs { color: #1f4f9c; }

/* 결재 (베타) */
dialog.wide { width: min(640px, calc(100% - 2rem)); }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .6rem; }
.filters label { margin: .4rem 0 .15rem; }
.steps { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; font-size: .8rem; }
.step { display: inline-flex; align-items: center; gap: .2rem; padding: .1rem .45rem; border-radius: 999px; background: var(--bg); color: var(--ink-soft); white-space: nowrap; }
.step.done { background: #e3f4ea; color: var(--ok); }
.step.rejected { background: #fde5e6; color: var(--danger); }
.step.current { background: #fdf0d8; color: #8a5a00; }
.steps .arrow { color: var(--ink-soft); }
.tag.status-team, .tag.status-ceo { background: #fdf0d8; color: #8a5a00; }
.tag.status-approved { background: #e3f4ea; color: var(--ok); }
.tag.status-rejected { background: #fde5e6; color: var(--danger); }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.todo { border-color: var(--brand); background: #fbf3f5; }
.kv b { text-align: right; word-break: break-all; }
.file-list a { display: inline-block; margin: .2rem .4rem .2rem 0; font-size: .88rem; }
.file-list img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); vertical-align: middle; }
.inv-item { border: 1px solid var(--line); border-radius: 8px; padding: .4rem .6rem .6rem; margin-top: .5rem; background: var(--bg); }
.inv-item .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 .5rem; }
.inv-item label { margin-top: .3rem; }
.inv-item input { padding: .45rem .5rem; font-size: .9rem; }
.sign-line { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.sign-line:last-child { border-bottom: 0; }
.sign-line .who { min-width: 3rem; color: var(--ink-soft); }
@media print {
  body > *:not(dialog[open]) { display: none !important; }
  dialog[open] { position: static; width: 100%; max-width: none; box-shadow: none; padding: 0; }
  .no-print { display: none !important; }
}

/* 결재 서명 패드·서명 표시 */
.sign-pad { width: 100%; height: auto; aspect-ratio: 5 / 2; display: block; background: #fff; border: 1px dashed var(--ink-soft); border-radius: 8px; touch-action: none; cursor: crosshair; }
.sign-img { height: 40px; width: 100px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; flex: none; }
.sign-img.empty { display: inline-block; }
