:root {
  --bg: #f4f7f8; --card: #ffffff; --text: #17262e; --muted: #64757f; --line: #dde5e9;
  --primary: #0f766e; --primary-ink: #ffffff; --primary-soft: #dff3f0;
  --danger: #c62828; --danger-soft: #fde8e8; --warn: #a15c07; --warn-soft: #fdf1d9; --ok: #15803d; --ok-soft: #dcf5e4;
  --sat: #1d5fb8; --sun: #c62828; --shade: #f0f4f6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a1f; --card: #172830; --text: #e6eef1; --muted: #93a7b1; --line: #26404b;
    --primary: #2bb3a6; --primary-ink: #04201d; --primary-soft: #14423e;
    --danger: #ff8a80; --danger-soft: #4a2323; --warn: #f0b95a; --warn-soft: #43321a; --ok: #6fd58c; --ok-soft: #1c3a27;
    --sat: #7fb2ff; --sun: #ff8a80; --shade: #1c313a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--primary); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1; }

/* 카드·폼 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.card + .card { margin-top: 12px; }
label.f { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=month], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  font-size: 16px; min-height: 44px;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.sm { min-height: 34px; padding: 0 10px; font-size: .88rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--shade); color: var(--muted); white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); } .chip.primary { background: var(--primary-soft); color: var(--primary); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--primary-soft); color: var(--text); font-size: .93rem; }
.notice.warn { background: var(--warn-soft); } .notice.danger { background: var(--danger-soft); }

/* 로그인 */
.login { max-width: 400px; margin: 0 auto; padding: 8vh 20px 40px; }
.logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin: 0 auto 14px; }

/* 직원 화면 */
.emp { max-width: 520px; margin: 0 auto; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 0 10px; }
.topbar .name { font-weight: 700; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 5;
}
.tabs button { flex: 1; border: 0; background: none; padding: 10px 0 9px; font-size: .78rem; color: var(--muted); cursor: pointer; }
.tabs button .ic { display: block; font-size: 1.35rem; line-height: 1.2; }
.tabs button[aria-current=page] { color: var(--primary); font-weight: 700; }
.clock { font-size: 2.6rem; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; text-align: center; }
.punch-btn {
  width: 100%; min-height: 84px; font-size: 1.5rem; border-radius: 18px; border: 0; font-weight: 800; cursor: pointer;
  background: var(--primary); color: var(--primary-ink);
}
.punch-btn.out { background: #b45309; color: #fff; }
.punch-btn:disabled { opacity: .6; }
.stat { display: flex; gap: 10px; }
.stat > div { flex: 1; background: var(--shade); border-radius: 10px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 1.35rem; } .stat span { font-size: .78rem; color: var(--muted); }
.list > div { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.list > div:last-child { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips .chip { padding: 5px 10px; font-size: .88rem; background: var(--primary-soft); color: var(--primary); cursor: pointer; }
.rec { width: 100%; border-collapse: collapse; font-size: .92rem; }
.rec td, .rec th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.rec tr.dim td { color: var(--muted); } .rec tr.sat td:first-child { color: var(--sat); } .rec tr.sun td:first-child { color: var(--sun); }

/* 원장 화면 */
.adm { max-width: 1240px; margin: 0 auto; padding: 0 16px 40px; }
.adm header { display: flex; align-items: center; gap: 12px; padding: 14px 0; flex-wrap: wrap; }
.adm nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.adm nav button { border: 0; background: none; padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; color: var(--muted); min-height: 44px; }
.adm nav button[aria-current=page] { background: var(--primary-soft); color: var(--primary); }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .82rem; white-space: nowrap; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid { border-collapse: separate; border-spacing: 0; font-size: .82rem; min-width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 4px 6px; min-width: 92px; vertical-align: top; text-align: center; background: var(--card); }
.grid thead th { position: sticky; top: 0; background: var(--shade); z-index: 2; font-weight: 700; padding: 8px 6px; }
.grid th.d, .grid td.d { position: sticky; left: 0; z-index: 1; min-width: 76px; text-align: left; background: var(--shade); font-weight: 600; }
.grid thead th.d { z-index: 3; }
.grid tr.sat td.d { color: var(--sat); } .grid tr.sun td.d { color: var(--sun); }
.grid tr.sun td:not(.d) { background: var(--shade); }
.grid tr.closure td:not(.d) { background: var(--warn-soft); }
.grid td.cell { cursor: pointer; height: 46px; }
.grid td.cell:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.grid .t { display: block; font-variant-numeric: tabular-nums; }
.grid .hrs { display: block; color: var(--muted); font-size: .75rem; }
.grid .open { color: var(--danger); font-weight: 700; }
.grid tfoot td { background: var(--shade); font-weight: 700; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; align-items: center; }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; } }
.cols2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.cols2 > .card + .card { margin-top: 0; }

/* 다이얼로그·토스트 */
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 24px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .body { padding: 18px; max-height: 80vh; overflow: auto; }
dialog .foot { display: flex; gap: 8px; justify-content: flex-end; padding: 0 18px 18px; flex-wrap: wrap; }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; pointer-events: none; }
#toast div { background: #17262e; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: .93rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 88vw; }
#toast div.bad { background: #b3261e; }
.big-ok { text-align: center; padding: 18px 8px; }
.big-ok .mark { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 2rem; margin: 0 auto 10px; }
.pin { font-size: 2rem; font-weight: 800; letter-spacing: .15em; text-align: center; padding: 10px; background: var(--shade); border-radius: 12px; font-variant-numeric: tabular-nums; }

.row input[type=date], .row input[type=time] { width: auto; flex: 1; min-width: 120px; }
.adm .row input[type=time] { flex: none; }
