:root {
  --bg: #f4f5f7;
  --panel: #fff;
  --line: #e3e5e8;
  --text: #1f2328;
  --muted: #6b7280;
  --brand: #0f766e;
  --brand-weak: #e6f4f2;
  --danger: #c2410c;
  --warn-bg: #fff7e6;
  --warn: #9a5b00;
  --side: #17202a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; display: flex; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 14px/1.5 "Pretendard", "Malgun Gothic", system-ui, sans-serif;
}
.side { width: 200px; background: var(--side); color: #cfd6dd; flex-shrink: 0; }
.brand { padding: 18px 20px; font-weight: 700; font-size: 17px; color: #fff; letter-spacing: -0.3px; }
.nav-label { padding: 16px 20px 4px; font-size: 11px; color: #7d8894; }
.side a { display: block; padding: 8px 20px; color: inherit; text-decoration: none; }
.side a:hover { background: #222d38; }
.side a.active { background: var(--brand); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 20px;
}
.run-state { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #9ca3af; }
.dot.on { background: #16a34a; box-shadow: 0 0 0 4px #dcfce7; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.current { padding: 8px 20px; color: var(--muted); font-size: 13px; min-height: 36px; }
.view { padding: 0 20px 40px; }

h2 { font-size: 18px; margin: 4px 0 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 6px;
  padding: 6px 12px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c4c8cd; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f1c6b3; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }
.link.danger { color: var(--danger); }

input[type=text], input[type=number], input[type=password], select {
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit; background: #fff;
}
input.num { width: 90px; text-align: right; }
input.tiny { width: 60px; text-align: right; }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
th { background: #f9fafb; font-weight: 600; font-size: 12px; color: #4b5563; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr.off td { color: #9ca3af; }
td.r, th.r { text-align: right; }
.bulk-row td { background: var(--brand-weak); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eef0f2; color: #374151; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: #fde8e1; color: var(--danger); }

.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { display: none; }
.toggle span { position: absolute; inset: 0; background: #d1d5db; border-radius: 22px; cursor: pointer; transition: .15s; }
.toggle span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.toggle input:checked + span { background: var(--brand); }
.toggle input:checked + span::after { transform: translateX(18px); }

.form-grid { display: grid; grid-template-columns: 140px 1fr; gap: 10px 12px; align-items: center; max-width: 560px; }
.form-grid input { width: 100%; }

dialog { border: 0; border-radius: 10px; padding: 0; width: min(720px, 92vw); max-height: 85vh; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-body { padding: 16px 18px; overflow: auto; max-height: 62vh; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.camp { margin-bottom: 12px; }
.camp-name { font-weight: 600; margin-bottom: 4px; }
.camp label { display: block; padding: 3px 0 3px 18px; }

.hours { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; }
.hours label { border: 1px solid var(--line); border-radius: 6px; text-align: center; padding: 6px 0; cursor: pointer; user-select: none; }
.hours label.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.hours input { display: none; }

.log-list { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.log-item { display: flex; gap: 16px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.log-item:last-child { border-bottom: 0; }
.log-ts { color: var(--muted); width: 150px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.up { color: #b91c1c; font-weight: 600; }
.down { color: #1d4ed8; font-weight: 600; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 10; max-width: 90vw;
}
.toast.err { background: var(--danger); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.login-wrap { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 20; padding: 16px; }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px; width: min(360px, 100%); display: grid; gap: 10px; }
.login-box input { width: 100%; padding: 9px 10px; }
.login-box .btn { padding: 9px; }
.brand-dark { font-weight: 700; font-size: 18px; }
.login-err { color: var(--danger); min-height: 18px; }

@media (max-width: 760px) {
  body { flex-direction: column; }
  .side { width: 100%; }
  .side nav { display: flex; flex-wrap: wrap; }
  .nav-label { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}
