:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a1f2b;
  --muted: #6b7385;
  --line: #e3e7ef;
  --primary: #2563eb;
  --in: #16a34a;
  --out: #dc2626;
  --warn: #b45309;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b;
    --card: #1a1f2a;
    --text: #e8ebf2;
    --muted: #949cae;
    --line: #2b3242;
    --primary: #5b8cff;
    --in: #22c55e;
    --out: #f05252;
    --warn: #f59e0b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }
#app.wide { max-width: 1040px; }
.loading { text-align: center; color: var(--muted); margin-top: 30vh; }

h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.top .who { font-weight: 700; font-size: 18px; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary);
  vertical-align: middle;
}
.badge.free { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.on { background: color-mix(in srgb, var(--in) 16%, transparent); color: var(--in); }
.badge.off { background: var(--line); color: var(--muted); }
.demo-banner {
  background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; margin-bottom: 14px;
}

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 8px 14px; border-radius: 10px;
}
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.danger { color: var(--out); }
button.link { border: 0; background: none; color: var(--primary); padding: 4px; }
button.ghost { border: 0; background: none; }

input, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.check input { width: auto; }
.seg { display: flex; gap: 8px; }
.seg label {
  flex: 1; margin: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center;
  color: var(--text); cursor: pointer;
}
.seg input { display: none; }
.seg label:has(input:checked) { border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* 로그인 */
.auth { max-width: 400px; margin: 8vh auto 0; }
.auth h1 { text-align: center; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); margin: 0 0 18px; }
.auth button.primary { width: 100%; margin-top: 18px; padding: 12px; }
.auth .switch { text-align: center; margin-top: 12px; }

/* 출퇴근 */
.clock-card { text-align: center; padding: 24px 18px; }
.clock-card .date { color: var(--muted); }
.clock { font-size: 52px; font-weight: 700; letter-spacing: 1px; margin: 4px 0 6px; }
.status { min-height: 24px; margin-bottom: 18px; }
.big {
  width: 100%; max-width: 360px; padding: 20px; font-size: 22px; font-weight: 700; border: 0; border-radius: 16px; color: #fff;
}
.big.in { background: var(--in); }
.big.out { background: var(--out); }

/* 기간 선택 */
.period { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.period .nav { display: flex; align-items: center; gap: 4px; }
.period .label { font-weight: 700; min-width: 130px; text-align: center; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabs button { border: 0; border-radius: 0; padding: 6px 14px; }
.tabs button.active { background: var(--primary); color: #fff; }

.sum { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sum div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.sum b { display: block; font-size: 18px; }
.sum .total { grid-column: 1 / -1; background: color-mix(in srgb, var(--primary) 12%, transparent); }
.sum .total b { font-size: 26px; color: var(--primary); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.empty { color: var(--muted); text-align: center; padding: 16px 0; }

/* 관리자 */
.admin-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.admin-tabs button { white-space: nowrap; }
.admin-tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td input, td select { padding: 6px 8px; min-width: 90px; }
tfoot td { font-weight: 700; }
details.emp { border-top: 1px solid var(--line); padding: 10px 0; }
details.emp summary { cursor: pointer; display: flex; justify-content: space-between; gap: 8px; list-style: none; }
details.emp summary::-webkit-details-marker { display: none; }
details.emp summary > span:first-child::before { content: '▸'; color: var(--muted); margin-right: 6px; }
details.emp[open] summary > span:first-child::before { content: '▾'; }
.row-actions { display: flex; gap: 4px; }
.warn { color: var(--warn); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }

dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--text);
  width: min(420px, calc(100% - 32px)); padding: 20px;
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog .toolbar { margin-top: 18px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1a1f2b; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--out); }
