:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #1d2433;
  --muted: #6b7486;
  --line: #e2e6ee;
  --accent: #2f5bea;
  --accent-soft: #e8eefe;
  --danger: #d23b3b;
  --side: #17203a;
  --side-text: #c9d1e6;
  --c-events: #2f5bea;
  --c-meetings: #8a3ffc;
  --c-trips: #0f9d74;
  --c-holiday: #d97706;
  --c-video: #0b8043;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 220px; flex: none; background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px 14px; font-weight: 700; color: #fff; font-size: 17px; letter-spacing: .3px; }
.brand small { display: block; font-weight: 400; color: var(--side-text); font-size: 12px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 8px; }
.nav a {
  display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 8px;
  color: var(--side-text); text-decoration: none; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.07); }
.nav a.on { background: var(--accent); color: #fff; }
.nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 10px 6px; }
.side .me { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; }
.side .me a { color: var(--side-text); margin-right: 10px; }
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.topbar { display: none; }

h1 { font-size: 21px; margin: 0; }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.head .grow { flex: 1; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.greet { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 15px; }
.greet .date { color: var(--muted); }
.greet .hello { font-weight: 600; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff;
  color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #c4cbd8; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.meet { background: #0b8043; border-color: #0b8043; color: #fff; }
.btn.small { padding: 3px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .6; cursor: default; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.panel h2 .grow { flex: 1; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat { font-size: 22px; font-weight: 700; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 10px 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
ul.plain li:last-child { border-bottom: 0; }
ul.plain .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; min-width: 86px; }
ul.plain .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* tags */
.tag {
  display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.tag.meetings { background: #f1e8ff; color: var(--c-meetings); }
.tag.trips { background: #e1f5ee; color: var(--c-trips); }
.tag.video_meetings { background: #e3f4ea; color: var(--c-video); }
.monthzip { margin-bottom: 14px; padding: 12px 16px; }
.monthzip summary { cursor: pointer; }
.mz-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; margin-top: 8px; }
.mz-item { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.mz-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tag.gray { background: #eef0f4; color: var(--muted); }
.tag.warn { background: #fff1dc; color: #b45309; }
.tag.done { background: #e1f5ee; color: #0f7a5a; }
.pin { color: #d97706; }

/* filters + table */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.list th { background: #f8f9fc; font-weight: 600; color: var(--muted); font-size: 12.5px; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #f6f8ff; }
table.list td.num, table.list th.num { text-align: right; }
table.list td.wrap { white-space: normal; min-width: 200px; }
table.list tfoot td { font-weight: 700; background: #f8f9fc; }

/* forms */
input, select, textarea {
  font: inherit; color: inherit; border: 1px solid #cfd5e1; border-radius: 8px; padding: 7px 10px;
  background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form .full { grid-column: 1 / -1; }
.form label.f { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.form label.f .req { color: var(--danger); }
.form .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; padding-top: 24px; cursor: pointer; }
.meet-row { display: flex; gap: 8px; }
.meet-row input { flex: 1; }
.actions { display: flex; gap: 8px; margin-top: 20px; }

/* detail */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.dl .item .k { font-size: 12px; color: var(--muted); }
.dl .item .v { min-height: 21px; word-break: break-word; }
.dl .full { grid-column: 1 / -1; }
.pre { white-space: pre-wrap; }
.meta { color: var(--muted); font-size: 12.5px; margin-top: 16px; }
.files li { align-items: center !important; }
.files img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.drop {
  border: 2px dashed #cfd5e1; border-radius: var(--radius); padding: 16px; text-align: center;
  color: var(--muted); margin-top: 10px; cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }

/* calendar */
.cal { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head, .cal-body { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); background: #f8f9fc; border-bottom: 1px solid var(--line); }
.cal-head div:first-child, .cal-day.sun .d { color: var(--danger); }
.cal-head div:last-child, .cal-day.sat .d { color: var(--accent); }
.cal-day { min-height: 118px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px 5px; cursor: pointer; overflow: hidden; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.other { background: #fafbfd; }
.cal-day.other .d { opacity: .45; }
.cal-day .d { font-size: 12.5px; font-weight: 600; padding: 1px 4px; display: inline-block; border-radius: 10px; }
.cal-day.today .d { background: var(--accent); color: #fff !important; }
.chip {
  display: block; font-size: 12px; padding: 1px 6px; margin-top: 2px; border-radius: 5px; color: #fff;
  background: var(--c-events); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.chip:hover { filter: brightness(1.1); }
.chip.meetings { background: var(--c-meetings); }
.chip.trips { background: var(--c-trips); }
.chip.video_meetings { background: var(--c-video); }
.chip.휴가 { background: var(--c-holiday); }
.chip.마감 { background: var(--danger); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* chat (메신저) */
.nav .badge { margin-left: auto; }
.top-chat { margin-left: auto; font-size: 19px; text-decoration: none !important; display: flex; align-items: center; gap: 2px; }
.badge { background: #e5483b; color: #fff; border-radius: 10px; font-size: 11px; line-height: 18px; padding: 0 6px; min-width: 18px; text-align: center; font-weight: 700; }
.main.chat-main { padding-bottom: 16px; }
.chat {
  display: grid; grid-template-columns: 250px minmax(0, 1fr); height: calc(100vh - 48px);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.chat-rooms { border-right: 1px solid var(--line); overflow-y: auto; }
.room { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none !important; }
.room:hover { background: #f6f8ff; }
.room.on { background: var(--accent-soft); }
.avatar { width: 38px; height: 38px; flex: none; border-radius: 13px; background: #d9e2fb; color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.rmeta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rmeta .pv { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rside { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.rside .tm { font-size: 11px; color: var(--muted); }
.chat-conv { display: flex; flex-direction: column; min-height: 0; }
.chat-conv.over { outline: 3px dashed var(--accent); outline-offset: -6px; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 10px 14px; background: #dde5ef; }
.chat-msgs .more { text-align: center; margin: 4px 0 8px; }
.date-sep { text-align: center; margin: 14px 0 8px; }
.date-sep span { background: rgba(0,0,0,.12); color: #fff; font-size: 12px; padding: 3px 12px; border-radius: 12px; }
.msg-name { font-size: 12.5px; margin: 8px 0 3px 2px; color: #3d4556; }
.msg { display: flex; align-items: flex-end; gap: 6px; margin: 3px 0; }
.msg.mine { flex-direction: row-reverse; }
.bubble { max-width: min(70%, 560px); background: #fff; padding: 7px 11px; border-radius: 4px 14px 14px 14px; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.05); }
.mine .bubble { background: #fee500; border-radius: 14px 4px 14px 14px; }
.bubble.file { padding: 4px; background: #fff; }
.mine .bubble.file { background: #fff6b0; }
.chat-img { display: block; max-width: 240px; max-height: 280px; border-radius: 10px; }
.chat-file { display: inline-flex; gap: 6px; align-items: baseline; padding: 6px 8px; color: var(--text); }
.chat-file small { color: var(--muted); }
.msg-time { font-size: 11px; color: #5f6b7d; flex: none; }
.chat-input { display: flex; gap: 6px; align-items: flex-end; padding: 8px; border-top: 1px solid var(--line); background: #fff; }
.chat-input textarea { resize: none; max-height: 120px; min-height: 38px; line-height: 1.45; }
.chat-attach { padding: 7px 10px; font-size: 16px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login h1 { margin-bottom: 4px; }
.login .field { margin-top: 12px; }
.login .field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.login .btn { width: 100%; justify-content: center; margin-top: 18px; padding: 10px; }
.err { color: var(--danger); margin-top: 10px; min-height: 20px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 8px; transition: .2s; pointer-events: none; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.bad { background: var(--danger); }

@media (max-width: 860px) {
  .side { position: fixed; left: -240px; z-index: 30; transition: left .2s; }
  .shell.open .side { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 20; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; }
  .main { padding: 16px 16px 50px; }
  .form, .dl { grid-template-columns: minmax(0, 1fr); }
  .cal-day { min-height: 74px; }
  .chip { font-size: 10.5px; padding: 0 3px; }
  .chk { padding-top: 0; }
  .dash-head .greet { font-size: 14px; flex: 1 1 100%; margin-bottom: 2px; }
  .dash-head { gap: 6px; }
  .dash-head .btn { padding: 5px 9px; font-size: 12.5px; }
  .main.chat-main { padding: 0; }
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 46px); height: calc(100dvh - 46px); border: 0; border-radius: 0; }
  .chat.show-list .chat-conv { display: none; }
  .chat:not(.show-list) .chat-rooms { display: none; }
  .chat-back { display: inline-flex; }
  .bubble { max-width: 78%; }
  .chat-img { max-width: 200px; }
}

/* 사진 찍기 · 명함 썸네일 (v1.6) */
.cam-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.cam-btn { cursor: pointer; }
.cam-shot { display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; }
.panel .cam-btn { margin: 8px 0; }
td.thumb-cell { width: 76px; padding-top: 4px; padding-bottom: 4px; }
img.lthumb { width: 68px; height: 42px; object-fit: cover; border-radius: 4px; border: 1px solid #ddd; display: block; }

/* 오늘의 일정 · 주간업무보고 (v1.7) */
textarea.memo { width: 100%; box-sizing: border-box; font: inherit; line-height: 1.6; background: #fffdf3; border: 1px solid #eadfa8; border-radius: 6px; padding: 10px 12px; resize: vertical; }
textarea.memo.big { min-height: 340px; }
.note-st { font-size: 12px; font-weight: 400; margin-right: 6px; }
.note-panel h2 { white-space: nowrap; flex-wrap: nowrap; }
.note-panel h2 .muted { white-space: nowrap; }
.notes-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.note-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.note-nav input[type=date] { width: auto; }
.filters .seg { display: inline-flex; }
.note-cal { margin-top: 12px; }
.note-list li.on { background: #eef2ff; border-radius: 4px; }
.note-list li a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg .btn + .btn { margin-left: -1px; }
.wk { padding: 12px 0; border-bottom: 1px solid #eee; }
.wk:last-child { border-bottom: 0; }
.wk h3 { margin: 0 0 8px; font-size: 15px; }
.wk.cur h3 { color: #2b5ce6; }
.wr { border: 1px solid #e6e8ef; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.wr-head { display: flex; align-items: center; margin-bottom: 6px; }
.wr-head .grow { flex: 1; }
.wr-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.wr-cols .k { font-size: 12px; color: #667; margin-bottom: 2px; font-weight: 600; }
.wr-miss { font-size: 13px; margin-top: 4px; }
.ymonth summary { cursor: pointer; display: flex; align-items: center; gap: 10px; }
.ymonth summary .btn { margin-left: auto; }
table.wgrid { border-collapse: collapse; font-size: 12px; }
table.wgrid th, table.wgrid td { border: 1px solid #e6e8ef; padding: 3px 4px; text-align: center; min-width: 18px; }
table.wgrid tbody th { text-align: left; white-space: nowrap; padding-right: 8px; }
table.wgrid .cur { background: #eef2ff; }
table.wgrid td a { color: #1a9e55; font-weight: 700; text-decoration: none; }
@media (max-width: 760px) {
  .notes-wrap { grid-template-columns: 1fr; }
  .wr-cols { grid-template-columns: 1fr; }
  textarea.memo.big { min-height: 260px; }
}
