:root {
  --bg: #f4f5f8; --card: #fff; --ink: #1d2433; --muted: #6b7280; --line: #e3e6ec;
  --pri: #f08a5d; --pri-ink: #fff; --ok: #2f9e6e; --due: #d9534f; --part: #d38a12; --sel: #fff3ec;
  --radius: 14px; --tabh: 62px;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
body.noscroll { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; }
h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .center { text-align: center; }
.warn-text { color: var(--due); }

/* 상단·하단 */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; background: var(--ink); color: #fff; }
.top .muted { color: #b9c0cf; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand img { width: 26px; height: 26px; } .brand small { font-weight: 400; opacity: .7; }
main { max-width: 760px; margin: 0 auto; padding: 14px 12px 24px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; height: var(--tabh);
  padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); }
.tab { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--muted); cursor: pointer; }
.tab .ti { font-size: 19px; filter: grayscale(1); opacity: .7; }
.tab.on { color: var(--ink); font-weight: 700; } .tab.on .ti { filter: none; opacity: 1; }
.fab { position: fixed; right: 16px; bottom: calc(var(--tabh) + 16px + env(safe-area-inset-bottom)); z-index: 6; border: 0; border-radius: 28px;
  padding: 13px 20px; background: var(--pri); color: var(--pri-ink); font-weight: 700; box-shadow: 0 6px 18px rgba(240,138,93,.45); cursor: pointer; }
.foot { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; padding: 18px 12px calc(var(--tabh) + 70px); font-size: 13px; }
.foot .made { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }

/* 공통 */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--pri); border-color: var(--pri); color: var(--pri-ink); }
.btn.danger { color: var(--due); border-color: #f1c4c3; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; font-size: 22px; padding: 4px 10px; cursor: pointer; line-height: 1; }
.link { border: 0; background: none; color: #3b6fd8; cursor: pointer; padding: 4px; }
.tag { display: inline-block; font-size: 11.5px; padding: 2px 7px; border-radius: 20px; background: #eef0f4; color: var(--muted); }
.tag.ok { background: #e3f5ec; color: var(--ok); } .tag.due { background: #fde8e7; color: var(--due); } .tag.part { background: #fdf1dc; color: var(--part); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.memo { white-space: pre-wrap; background: #f7f8fa; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.empty-box { text-align: center; background: #fff; border-radius: var(--radius); padding: 24px 16px; color: var(--muted); line-height: 1.9; }
.empty-box .btn { margin: 8px 0; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.dot.unpaid { background: var(--due); } .dot.paid { background: var(--ok); }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin: 6px 2px 12px; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; white-space: nowrap; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.tbl tr[data-promo] { cursor: pointer; } .tbl tr[data-promo]:hover { background: #fafbfc; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }

/* 요약 */
.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.summary > div, .stat { background: #fff; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.card .summary > div { background: #f7f8fa; }
.summary span, .stat span { font-size: 12px; color: var(--muted); }
.summary b, .stat b { font-size: 16px; }
.summary .warn b, .stat.warn b { color: var(--due); }
.summary.small3 { grid-template-columns: repeat(3, 1fr); }
.summary.small4 { grid-template-columns: repeat(2, 1fr); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat-grid .stat { background: #f7f8fa; }
.ded-list { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.ded-list b { color: var(--ink); font-weight: 600; }
@media (min-width: 640px) {
  .summary { grid-template-columns: repeat(4, 1fr); }
  .summary.small4 { grid-template-columns: repeat(4, 1fr); }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 달력 */
.month-nav { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.month-nav h2 { flex: 1; text-align: center; font-size: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; background: #fff; border-radius: var(--radius); padding: 8px; }
.wd { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0 4px; }
.sun { color: var(--due); } .sat { color: #3b6fd8; }
.cell { position: relative; min-height: 62px; border: 0; border-radius: 8px; background: #fafbfc; padding: 4px 3px 3px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cell.empty { background: none; cursor: default; }
.cell .dnum { font-size: 12.5px; font-weight: 600; }
.cell.today .dnum { background: var(--ink); color: #fff; border-radius: 10px; padding: 0 6px; align-self: flex-start; }
.cell.sel { background: var(--sel); outline: 2px solid var(--pri); }
.cell .bar { display: block; height: 4px; border-radius: 2px; }
.cell .amt { font-size: 10.5px; color: var(--ink); margin-top: auto; letter-spacing: -.3px; }
.cell .dot { position: absolute; top: 5px; right: 4px; width: 6px; height: 6px; }
.cell .dot.paid { right: 12px; }
.day-panel { background: #fff; border-radius: var(--radius); padding: 14px; margin-top: 12px; }
.day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.day-panel h4 { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.shift-card { width: 100%; text-align: left; border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 10px; background: #fff; padding: 9px 11px; margin-bottom: 7px; cursor: pointer; display: grid; gap: 2px; }
.sc-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; } .sc-top .tag { margin-left: auto; }
.sc-mid { font-size: 13px; } .sc-amt { font-weight: 700; }
.row-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 2px; text-align: left; cursor: pointer; }
.row-btn:last-child { border-bottom: 0; }

/* 지급 */
.group { margin-bottom: 10px; }
.group-title { display: flex; align-items: center; justify-content: space-between; font-size: 14px; padding: 4px 0 4px 8px; border-left: 4px solid var(--c); margin-bottom: 4px; }
.pick { display: grid; grid-template-columns: 22px 78px 1fr auto; align-items: center; gap: 6px; padding: 7px 2px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.pick input { width: 18px; height: 18px; }
.pick-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-amt { text-align: right; font-weight: 600; }
.pay-row { width: 100%; display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; align-items: center; border: 0; border-left: 4px solid var(--c); background: #fafbfc; border-radius: 8px; padding: 9px 10px; margin-bottom: 6px; text-align: left; cursor: pointer; }
.pr-name, .pr-amt { display: flex; flex-direction: column; } .pr-amt { text-align: right; }
.pr-name small, .pr-amt small { font-size: 11.5px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.actions .danger { margin-right: auto; }

/* 회사 */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 7px 14px; cursor: pointer; font-weight: 600; border-left: 5px solid var(--c, var(--line)); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); border-left-color: var(--c); }
.chip.add { border-style: dashed; color: var(--muted); border-left-width: 1px; }
.co-title { border-left: 5px solid var(--c); padding-left: 8px; }

/* 통계 */
.seg { display: flex; gap: 6px; align-items: center; margin-bottom: 12px; }
.seg button { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 14px; cursor: pointer; }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg select { margin-left: auto; }
.barcol { width: 30%; min-width: 80px; }
.hbar { display: block; height: 6px; border-radius: 3px; margin: 2px 0; }
.hbar.g { background: #c9cfdb; } .hbar.n { background: var(--pri); }
.hbar.sample { display: inline-block; width: 16px; }

/* 폼·모달 */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(15,20,30,.45); display: none; align-items: flex-end; justify-content: center; }
.modal.open { display: flex; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; animation: up .18s ease-out; }
.sheet.wide { max-width: 680px; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
@media (min-width: 640px) { .modal { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-body { overflow-y: auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
form label.check.inline { align-self: end; margin-bottom: 18px; }
input, select, textarea { border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; background: #fff; color: var(--ink); font-size: 15px; min-width: 0; width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f8c8b1; border-color: var(--pri); }
input.money { text-align: right; }
input.bad { border-color: var(--due); background: #fff5f5; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 4px; margin: 4px 0 12px; }
legend { font-size: 13px; font-weight: 700; padding: 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 6px; }
.grid4 input[type=time] { padding: 8px 4px; font-size: 14px; }
@media (max-width: 380px) { .grid4 { grid-template-columns: 1fr 1fr; } }
.newbox { background: #fff8f4; border: 1px dashed #f3c2aa; border-radius: 10px; padding: 10px 10px 0; margin-bottom: 10px; }
.total { display: flex; justify-content: space-between; align-items: center; padding: 8px 2px; border-top: 1px dashed var(--line); font-size: 14px; }
.total.big { font-size: 16px; } .total.big b { font-size: 19px; color: var(--pri); }
.promo-hint { background: #eef7f2; border-radius: 10px; padding: 9px 11px; font-size: 13.5px; margin-bottom: 8px; line-height: 1.7; }
.alloc { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.alloc-row { display: grid; grid-template-columns: 1fr auto 120px; gap: 8px; align-items: center; font-size: 14px; }
.alloc-row.off > span { opacity: .55; }
.alloc-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0; font-size: 13px; flex-wrap: wrap; }
.ded label { margin-bottom: 8px; }
.swatches { display: flex; gap: 8px; margin: 0 0 12px; }
.sw { margin: 0 !important; cursor: pointer; }
.sw input { position: absolute; opacity: 0; }
.sw span { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.sw input:checked + span { box-shadow: 0 0 0 2px var(--ink); }
.sw input:focus-visible + span { outline: 2px solid var(--pri); }

/* 로그인·로딩 */
#login, #loading { min-height: 80vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 26px 22px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.06); }
.login-card form { text-align: left; margin-top: 14px; }
.login-icon { width: 56px; height: 56px; }
.login-card h1 { font-size: 21px; margin: 8px 0 4px; }
.login-links { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid #e3e6ec; border-top-color: var(--pri); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabh) + 84px); transform: translateX(-50%) translateY(20px); z-index: 30; background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--due); }

/* 보정 */
fieldset { min-width: 0; }
.cell .amt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.seg button { white-space: nowrap; }
.seg select { width: auto; }
.sec-head h2 { white-space: nowrap; }
.sec-head select { width: auto; }
