:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1b1f24;
  --muted: #646c78;
  --accent: #2a78d6;
  --accent-soft: #e6f0fb;
  --danger: #d23c5a;
  --ok: #2f9e6a;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --surface: #191d23; --surface-2: #222730; --border: #2d333d;
    --text: #e8ebef; --muted: #9aa3af; --accent: #3987e5; --accent-soft: #1d2e44;
    --danger: #ef5d78; --ok: #3fbf83; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --surface: #191d23; --surface-2: #222730; --border: #2d333d;
  --text: #e8ebef; --muted: #9aa3af; --accent: #3987e5; --accent-soft: #1d2e44;
  --danger: #ef5d78; --ok: #3fbf83; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }

/* ───── 레이아웃 ───── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted);
  white-space: nowrap; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.usermenu { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.usermenu .who { color: var(--muted); font-size: 14px; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
.demo-banner { background: #fff4d6; color: #6b4e00; text-align: center; font-size: 13px; padding: 6px 16px; }
:root[data-theme="dark"] .demo-banner { background: #3a2f10; color: #f3d27a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .demo-banner { background: #3a2f10; color: #f3d27a; } }

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding-top: 10px; gap: 8px 12px; }
  .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  .usermenu .who { display: none; }
  main { padding-top: 14px; }
}

/* ───── 공통 컴포넌트 ───── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head a { font-size: 13px; text-decoration: none; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { margin-right: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); font-size: 14px; padding: 6px 0; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }
.error { color: var(--danger); }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); padding: 7px 14px; border-radius: 8px;
  cursor: pointer; font-weight: 500; text-decoration: none; color: var(--text); min-height: 36px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 6px 9px; border-radius: 8px; color: var(--muted); min-height: 34px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

label.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 8px 10px;
  font-size: 15px; color: var(--text); min-height: 38px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
textarea { resize: vertical; line-height: 1.6; }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); cursor: pointer; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.avatar { width: 28px; height: 28px; border-radius: 50%; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }

/* 목록 */
.list { display: grid; gap: 2px; }
.item { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: default; min-width: 0; }
.item.click { cursor: pointer; }
.item.click:hover { background: var(--surface-2); }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 13px; color: var(--muted); }
.when { font-size: 13px; color: var(--muted); white-space: nowrap; min-width: 74px; }

/* 통계 */
.stat .num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ───── 로그인 ───── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login h1 { font-size: 20px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.login form { display: grid; gap: 12px; margin-top: 18px; }

/* ───── 업무일지 ───── */
.datebar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.datebar .label { font-weight: 600; min-width: 128px; text-align: center; }
.datebar input[type=date] { width: auto; }
.tabs { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 9px; gap: 2px; }
.tabs a { padding: 5px 12px; border-radius: 7px; text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.editor textarea { min-height: 220px; }
.save-state { font-size: 13px; color: var(--muted); }
.save-state.dirty { color: #c48a12; }
.save-state.saved { color: var(--ok); }
.jcard .content { white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.jcard.missing { background: transparent; box-shadow: none; border-style: dashed; }
.jhead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.jhead .name { font-weight: 600; }

/* ───── 캘린더 ───── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 3px 10px; font-size: 13px; cursor: pointer; user-select: none; }
.chip.off { opacity: .45; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.cal .wd { background: var(--surface-2); text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 0; }
.cal .wd.sun, .cal .day.sun .dnum { color: var(--danger); }
.cal .wd.sat, .cal .day.sat .dnum { color: var(--accent); }
.cal .day { background: var(--surface); min-height: 108px; padding: 4px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal .day:hover { background: var(--surface-2); }
.cal .day.other { background: var(--bg); }
.cal .day.other .dnum { opacity: .45; }
.cal .day.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.dnum { font-size: 12px; font-weight: 600; padding: 1px 4px; align-self: flex-start; border-radius: 6px; }
.day.today .dnum { background: var(--accent); color: #fff !important; }
.ev { font-size: 12px; line-height: 1.35; padding: 1px 5px; border-radius: 4px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ev.soft { background: transparent !important; color: var(--text); padding-left: 3px; display: flex; align-items: center; gap: 4px; }
.more { font-size: 11px; color: var(--muted); padding-left: 5px; }
@media (max-width: 720px) {
  .cal .day { min-height: 64px; padding: 3px 2px; }
  .ev { font-size: 10.5px; padding: 0 3px; }
  .ev.soft .t { display: none; }
}
.daypanel { margin-top: 14px; }

/* ───── 공지 ───── */
.notice .body { white-space: pre-wrap; word-break: break-word; margin-top: 8px; font-size: 14.5px; }
.notice.pinned { border-color: var(--accent); }

/* ───── 표 ───── */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.inactive td { opacity: .5; }

/* ───── 모달·토스트 ───── */
.overlay { position: fixed; inset: 0; background: rgba(10,14,20,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.25); border: 1px solid var(--border); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.modal-body { padding: 8px 16px 12px; overflow-y: auto; }
.modal footer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 72px 1fr; gap: 6px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 6px; pointer-events: none; }
.toast { background: #1b1f24; color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.toast.error { background: var(--danger); }
.hint { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 13.5px; color: var(--muted); }
.hint ol { margin: 6px 0 0; padding-left: 20px; }

/* ───── 일지 댓글 ───── */
.jgrid { align-items: start; }
.comments { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.cmt { display: flex; gap: 8px; align-items: flex-start; }
.cmt .avatar { width: 24px; height: 24px; font-size: 10px; }
.cmt-head { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.cmt-head .icon-btn { margin-left: auto; font-size: 12px; padding: 2px 6px; min-height: 0; }
.cmt-body { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.cmt-form { display: flex; gap: 6px; }
.cmt-form .btn { flex: none; white-space: nowrap; }
.cmt-form input { min-height: 34px; padding: 6px 10px; font-size: 14px; }
