/* 버터치즈 피규어빌리지 — 직원 출퇴근·급여 정산 */
:root {
  --butter: #f5b301;
  --butter-dark: #d99700;
  --butter-soft: #fff3cc;
  --brown: #2a2018;
  --brown-soft: #4a3c2f;
  --cream: #fffaf0;
  --line: #ece3d3;
  --ink: #241d16;
  --muted: #877b6c;
  --ok: #1f8a4c;
  --ok-soft: #e5f6ec;
  --warn: #b76b00;
  --warn-soft: #fff1d6;
  --danger: #c73b3b;
  --danger-soft: #fdecec;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(42, 32, 24, 0.08);
  --font: "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  line-height: 1.5;
}
body.staff { background: linear-gradient(180deg, #fff6dd 0%, var(--cream) 260px); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; }
button { font-family: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  background: rgba(255, 250, 240, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.02em; }
.brand .dot {
  width: 22px; height: 22px; border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, #ffe07a, var(--butter));
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.08);
}
.brand small { font-weight: 600; color: var(--muted); font-size: 12px; }

.page { max-width: 560px; margin: 0 auto; padding: 16px 16px 96px; }

.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 11px 16px; border-radius: 12px; font-weight: 700; font-size: 15px;
  cursor: pointer; transition: transform .06s ease, box-shadow .15s ease, background .15s;
  min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brown); border-color: var(--brown); color: #fff; }
.btn.butter { background: var(--butter); border-color: var(--butter); color: var(--brown); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #f0c9c9; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.small { padding: 7px 11px; min-height: 34px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ------------------------------------------------------------------ forms */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--brown-soft); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="time"], select, textarea {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink);
  font-size: 16px; /* iOS 자동 확대 방지 */
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(245,179,1,.45); border-color: var(--butter); }
textarea { min-height: 74px; resize: vertical; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-row { display: flex; flex-wrap: wrap; gap: 6px; }
.check-row label {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 14px; cursor: pointer; background: #fff;
}
.check-row input { accent-color: var(--butter-dark); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.ok-text { color: var(--ok); font-size: 13px; }

/* ------------------------------------------------------------------ login */
.login-wrap { max-width: 440px; margin: 0 auto; padding: 28px 16px 60px; }
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: 24px;
  padding: 26px 22px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card p { margin-bottom: 18px; }

/* ------------------------------------------------------------------ cards */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-head h3 { font-size: 16px; }
.section-title { font-size: 15px; font-weight: 800; margin: 18px 2px 8px; color: var(--brown-soft); }

/* today status */
.today-card { text-align: center; padding: 20px 16px 22px; }
.today-date { font-size: 13px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.today-name { font-size: 15px; font-weight: 700; margin-top: 2px; }
.big-action {
  display: block; width: 168px; height: 168px; margin: 14px auto 10px;
  border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 32% 28%, #ffe188, var(--butter) 62%, var(--butter-dark));
  color: var(--brown); font-family: inherit; font-weight: 900; font-size: 23px; letter-spacing: -0.02em;
  box-shadow: 0 14px 28px rgba(217, 151, 0, .32), inset 0 -6px 0 rgba(0,0,0,.07);
  transition: transform .08s ease, box-shadow .15s ease;
}
.big-action:active { transform: scale(.97); box-shadow: 0 8px 18px rgba(217,151,0,.28); }
.big-action.working { background: radial-gradient(circle at 32% 28%, #ffd8a8, #ef9d4a 62%, #d07f2b); box-shadow: 0 14px 28px rgba(208,127,43,.3), inset 0 -6px 0 rgba(0,0,0,.07); }
.big-action.on-break { background: radial-gradient(circle at 32% 28%, #b9e6c9, #4fae74 62%, #2f8d55); color: #fff; }
.big-action.done { background: linear-gradient(180deg, #efe9dd, #e3dbcb); color: var(--muted); box-shadow: none; font-size: 19px; }
.big-sub { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.gps-line { margin-top: 10px; font-size: 12px; color: var(--muted); min-height: 17px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 800;
  background: var(--butter-soft); color: var(--brown);
}
.status-pill.working { background: var(--warn-soft); color: var(--warn); }
.status-pill.break { background: #e6f2ff; color: #2166a8; }
.status-pill.done { background: #eceae4; color: #6b6152; }

/* timeline */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { font-variant-numeric: tabular-nums; font-weight: 800; width: 46px; color: var(--brown-soft); }
.timeline .label { flex: 1; }
.timeline .dur { color: var(--muted); font-size: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: #fffdf7; border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; }
.stat b { display: block; font-size: 17px; letter-spacing: -0.02em; }
.stat span { font-size: 11px; color: var(--muted); }

/* tabs */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around; gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 800; padding: 6px 0; border-radius: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar button .ico { font-size: 19px; line-height: 1; }
.tabbar button.active { color: var(--brown); background: var(--butter-soft); }

.tab { display: none; }
.tab.active { display: block; }

/* calendar */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-nav b { font-size: 16px; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head span { text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; padding-bottom: 2px; }
.cal-grid button {
  border: 1px solid transparent; background: #fff; border-radius: 10px; min-height: 52px;
  padding: 4px 2px; cursor: pointer; font-family: inherit; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.cal-grid button.empty { background: transparent; cursor: default; }
.cal-grid button .d { font-size: 12px; font-weight: 700; }
.cal-grid button .h { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-grid button.has { border-color: var(--line); background: #fffdf6; }
.cal-grid button.short { background: var(--warn-soft); border-color: #f2d9a8; }
.cal-grid button.miss { background: var(--danger-soft); border-color: #f2c7c7; }
.cal-grid button.today { outline: 2px solid var(--butter); outline-offset: -1px; }

.list { list-style: none; padding: 0; margin: 0; }
.list li {
  display: flex; align-items: center; gap: 10px; padding: 11px 2px;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .sub { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 800; background: #f0ece3; color: #6b6152;
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }

.money { font-variant-numeric: tabular-nums; }
.money.big { font-size: 27px; font-weight: 900; letter-spacing: -0.03em; }
.pay-rows { margin-top: 10px; }
.pay-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: 14px; border-bottom: 1px dashed var(--line); }
.pay-row:last-child { border-bottom: 0; }
.pay-row.total { font-weight: 900; border-top: 2px solid var(--brown); border-bottom: 0; margin-top: 4px; padding-top: 10px; }
.pay-row .formula { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.alert { border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-top: 10px; }
.alert.warn { background: var(--warn-soft); color: #7a4a00; }
.alert.danger { background: var(--danger-soft); color: #8f2b2b; }
.alert.ok { background: var(--ok-soft); color: #196a3c; }
.alert.info { background: #eef4ff; color: #2a4d84; }

/* modal */
.modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(30, 22, 14, .45);
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.modal .sheet {
  background: #fff; width: 100%; max-width: 600px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.18);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h3 { font-size: 17px; }
.close-x { border: 0; background: #f3efe6; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; cursor: pointer; }

/* --------------------------------------------------------------- payslip */
.payslip { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: #fff; }
.payslip h2 { font-size: 20px; text-align: center; letter-spacing: .12em; margin-bottom: 2px; }
.payslip .period { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.pl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; }
.pl-grid div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted #eee6d8; padding: 3px 0; min-width: 0; }
.pl-grid div.wide { grid-column: span 2; }
.pl-grid .k { color: var(--muted); white-space: nowrap; }
.pl-grid div > span:last-child { text-align: right; word-break: keep-all; }
.pl-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
.pl-table th, .pl-table td { border: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.pl-table th:first-child, .pl-table td:first-child { width: 92px; white-space: nowrap; }
.pl-table th:last-child, .pl-table td:last-child { width: 92px; }
.pl-table th { background: #fbf6ea; font-size: 12px; }
.pl-table td.amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pl-foot { margin-top: 12px; font-size: 12px; color: var(--muted); }
.pl-sign { margin-top: 18px; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- admin */
body.admin { background: #f6f3ec; }
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px; background: var(--brown); color: #f7efe1;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { color: #fff; margin-bottom: 20px; }
.sidebar .brand small { color: #cdbfa9; display: block; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav button {
  text-align: left; border: 0; background: transparent; color: #e6d9c5;
  padding: 11px 12px; border-radius: 11px; font-size: 14.5px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.sidebar nav button.active { background: var(--butter); color: var(--brown); }
.sidebar .badge-count { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.sidebar .foot { margin-top: 24px; font-size: 11px; color: #b7a892; line-height: 1.6; }
.admin-main { flex: 1; min-width: 0; padding: 20px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.admin-head h1 { font-size: 22px; }
.admin-tabs { display: none; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; }
.admin-tabs button {
  border: 1px solid var(--line); background: #fff; padding: 9px 13px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.admin-tabs button.active { background: var(--brown); color: #fff; border-color: var(--brown); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.kpi b { font-size: 25px; letter-spacing: -0.03em; display: block; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 700; }
.kpi.hl { background: var(--butter-soft); border-color: #f0ddab; }

.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { background: #fbf7ee; font-size: 12px; color: var(--brown-soft); position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fffdf6; }
table.data tfoot td { font-weight: 900; background: #fbf7ee; }

.store-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end;
  margin-bottom: 10px; padding: 10px 12px 12px; border: 1px solid var(--line);
  border-radius: 14px; background: #fffdf7;
}
.store-row .span2 { grid-column: span 2; }
.store-row .store-actions { grid-column: span 2; display: flex; gap: 6px; justify-content: flex-end; }
@media (min-width: 700px) {
  .modal { align-items: center; }
  .modal .sheet { border-radius: 22px; max-height: 88vh; }
}

.admin-login { max-width: 420px; margin: 8vh auto; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .admin-tabs { display: flex; }
  .admin-main { padding: 14px 12px 90px; }
}

@media print {
  body { background: #fff; }
  .topbar, .tabbar, .no-print, .sidebar, .admin-tabs, .admin-head .btn { display: none !important; }
  .page, .admin-main { padding: 0; max-width: none; }
  .modal { position: static; background: #fff; display: block; padding: 0; }
  .modal .sheet { box-shadow: none; border-radius: 0; max-height: none; padding: 0; }
  .payslip { border: 0; padding: 0; }
  .pl-table th { background: #f2f2f2 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pl-table, .pl-table th, .pl-table td { border-color: #999; }
  body.printing .page, body.printing .topbar, body.printing .tabbar { display: none !important; }
  body.printing .payslip { border: 0; }
}

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 86px; transform: translate(-50%, 14px);
  max-width: 88vw; padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 700;
  background: var(--brown); color: #fff; box-shadow: 0 12px 30px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  z-index: 80; text-align: center; line-height: 1.45;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #1f8a4c; }
.toast.err { background: #b93b3b; }
body.admin .toast { bottom: 24px; }
