* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --blue: #2563eb;
}
body {
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.hidden { display: none !important; }

/* ---------- 로그인 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08);
}
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 20px; }
.tabs { display: flex; margin-bottom: 18px; border-radius: 10px; background: #eef1f6; padding: 4px; }
.tab { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.tab.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form input, .form select { padding: 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; background: #fff; }
.form input:focus, .form select:focus { outline: none; border-color: var(--primary); }

/* ---------- 버튼 ---------- */
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: #f3f4f6; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn.danger { background: transparent; border: 1px solid var(--border); color: #dc2626; }
.btn.danger:hover { background: #fef2f2; border-color: #fca5a5; }
.room-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-size: 12px; font-weight: 700; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.msg { margin-top: 14px; font-size: 13px; text-align: center; min-height: 18px; color: var(--red); }
.msg.ok { color: var(--green); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.back-link { font-size: 13px; color: var(--muted); text-align: center; text-decoration: none; margin-top: 4px; }
.back-link:hover { color: var(--text); }
.auth-links { margin-top: 16px; text-align: center; font-size: 13px; }
.auth-links a { color: var(--primary); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-links .dot { color: var(--border); margin: 0 8px; }

/* ---------- 상단바 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; padding: 14px 22px; border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; color: var(--primary); }
.user-box { display: flex; align-items: center; gap: 10px; }
#user-label { font-size: 14px; color: var(--muted); }

/* ---------- 네비 ---------- */
.navbar { display: flex; gap: 6px; padding: 10px 22px; background: #fff; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.navbar button { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); }
.navbar button.active { background: #eef2ff; color: var(--primary); font-weight: 600; }

/* ---------- 메인 ---------- */
.main { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 16px; margin-bottom: 14px; }
.section-title { font-size: 14px; color: var(--muted); margin-bottom: 10px; }

/* 출퇴근 액션 */
.status-banner { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.status-pill { padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 14px; }
.pill-working { background: #dcfce7; color: var(--green); }
.pill-off { background: #f3f4f6; color: var(--muted); }
.pill-outside { background: #fef3c7; color: var(--amber); }
.pill-none { background: #f3f4f6; color: var(--muted); }

.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.action-grid .big {
  padding: 22px 10px; font-size: 16px; border-radius: 14px; color: #fff; border: 0; cursor: pointer; font-weight: 700;
}
.act-in { background: var(--green); }
.act-out { background: var(--red); }
.act-field { background: var(--amber); }
.act-return { background: var(--blue); }
.action-grid .big:hover { filter: brightness(.95); }
.memo-row { display: flex; gap: 8px; }
.memo-row input { flex: 1; padding: 11px; border: 1px solid var(--border); border-radius: 10px; }

/* 테이블 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f9fafb; color: var(--muted); font-weight: 600; }
tr:hover td { background: #fafbfc; }
.badge { padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.b-internal { background: #dbeafe; color: #1d4ed8; }
.b-external { background: #fef3c7; color: #b45309; }
.b-in { background: #dcfce7; color: var(--green); }
.b-out { background: #fee2e2; color: var(--red); }
.b-field { background: #fef3c7; color: var(--amber); }
.b-return { background: #dbeafe; color: var(--blue); }
.b-memo { background: #f3e8ff; color: #7c3aed; }
.role-tag { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #eef2ff; color: var(--primary); }

/* 필터 */
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* 토스트 */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 100;
}
.toast.err { background: var(--red); }

/* ---------- 업무(Task) ---------- */
textarea { width: 100%; padding: 11px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; resize: vertical; margin-top: 8px; }
textarea:focus { outline: none; border-color: var(--primary); }
.task-form { margin-top: 12px; }
.task-form input[type="text"], .task-form > input { width: 100%; padding: 11px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; }
.task-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
.task-meta b { color: var(--text); }
.task-desc { margin-top: 8px; white-space: pre-wrap; font-size: 14px; color: var(--text); background: #f9fafb; padding: 12px; border-radius: 10px; }

.check-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-box { border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.check-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.check-on { color: var(--green); font-weight: 600; font-size: 13px; }
.check-off { color: var(--muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #eef2ff; color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.chip.owner { background: #dcfce7; color: var(--green); font-weight: 600; }
.chip-x { cursor: pointer; color: var(--red); font-weight: 700; }

.steps { display: flex; flex-direction: column; gap: 10px; }
.step-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: #fff; }
.step-head { display: flex; align-items: center; gap: 10px; }
.step-num { color: var(--muted); font-size: 13px; width: 22px; }
.step-title { flex: 1; font-size: 14.5px; font-weight: 600; }
.step-title.done { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.step-ctrl { display: flex; gap: 2px; }
.step-checks { display: flex; gap: 18px; flex-wrap: wrap; margin: 10px 0 0 32px; padding-top: 10px; border-top: 1px dashed var(--border); }
.step-check { display: inline-flex; align-items: center; font-size: 13px; }
.step-check .check-title { background: #eef2ff; color: var(--primary); border-radius: 6px; padding: 1px 7px; font-weight: 700; margin-right: 6px; }
.step-files { margin: 10px 0 0 32px; display: flex; flex-direction: column; gap: 4px; }
.step-upload { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.step-upload input[type="file"] { font-size: 12px; }
.mini { border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; font-size: 12px; padding: 3px 7px; color: var(--muted); }
.mini:hover { background: #f3f4f6; color: var(--text); }

.logs { display: flex; flex-direction: column; gap: 10px; }
.log-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.log-time { font-weight: 600; font-size: 13px; color: var(--primary); min-width: 110px; }
.log-body { flex: 1; }
.log-content { font-size: 14px; white-space: pre-wrap; }
.log-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.log-files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.log-file { display: inline-flex; align-items: center; gap: 4px; background: #f3f4f6; padding: 3px 8px; border-radius: 8px; font-size: 12.5px; }
.log-upload { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.log-upload input[type="file"] { font-size: 12px; }
.log-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.log-form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.log-date { padding: 9px 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; }
.log-sel { padding: 9px 8px; border: 1px solid var(--border); border-radius: 10px; font-size: 13px; background: #fff; }
.log-colon { color: var(--muted); }
.log-dur { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* ---------- 차트 (통계) ---------- */
.bars { display: flex; flex-direction: column; gap: 9px; margin-top: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { width: 130px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.bar-track { flex: 1; background: #f1f3f7; border-radius: 6px; height: 20px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 6px; }
.bar-stack { display: flex; height: 100%; border-radius: 6px; overflow: hidden; }
.bar-seg { display: block; height: 100%; }
.bar-val { width: 92px; text-align: right; font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.log-step { display: inline-block; background: #eef2ff; color: var(--primary); font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px; margin-right: 6px; }
.usum { margin-top: 14px; }
.usum-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; font-weight: 700; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.usum-total { color: var(--primary); }

@media (max-width: 600px) {
  .bar-label { width: 84px; }
  .bar-val { width: 70px; }
}

/* ---------- 채팅 ---------- */
.nav-badge { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; margin-left: 6px; }
.chat-card { padding: 0; overflow: hidden; }
.chat-wrap { display: flex; height: 560px; }
.chat-list { width: 240px; border-right: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; }
.chat-contact { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.chat-contact:hover { background: #f9fafb; }
.chat-contact.active { background: #eef2ff; }
.cc-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.cc-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-unread { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; flex-shrink: 0; }
.cc-preview { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-empty { padding: 40px 20px; text-align: center; color: var(--muted); margin: auto; line-height: 1.6; }
.chat-loading { padding: 30px; text-align: center; color: var(--muted); margin: auto; font-size: 13px; }
.chat-header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #f7f8fb; }
.msg { display: flex; flex-shrink: 0; }
.msg.mine { justify-content: flex-end; }
.bubble { max-width: 72%; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; }
.msg.mine .bubble { background: #2563eb; color: #fff; border-color: #2563eb; }
.msg-content { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg-file { display: inline-block; font-size: 13px; color: var(--primary); text-decoration: none; margin-top: 2px; }
.msg.mine .msg-file { color: #fff; text-decoration: underline; }
.msg-fsize { font-size: 11px; opacity: .7; margin-left: 6px; }
.msg-time { font-size: 10.5px; opacity: .6; margin-top: 4px; text-align: right; }
.chat-input { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-file-btn { cursor: pointer; font-size: 20px; line-height: 1; padding: 4px; user-select: none; }
.chat-file-name { font-size: 11.5px; color: var(--muted); max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-text { flex: 1; resize: none; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px; font-family: inherit; margin: 0; }
.chat-text:focus { outline: none; border-color: var(--primary); }
.chat-sticker-btn { cursor: pointer; font-size: 20px; line-height: 1; padding: 4px; background: none; border: 0; }

/* 인라인 이미지(짤) 메시지 */
.bubble.has-img { max-width: min(280px, 72%); }
.bubble-img { padding: 4px; background: transparent !important; border: 0 !important; }
/* 이미지는 항상 말풍선 너비 안에서 표시 (넘침/시간겹침 방지) */
.msg-img { max-width: 100%; max-height: 300px; width: auto; height: auto; border-radius: 10px; display: block; cursor: pointer; }
.bubble.has-img .msg-content { margin-bottom: 6px; }
.bubble.has-img .msg-time { margin-top: 4px; }
.bubble-img .msg-time { color: var(--muted); }

/* 짤 보관함 패널 */
.sticker-picker { border-top: 1px solid var(--border); background: #fff; max-height: 230px; overflow-y: auto; padding: 10px 12px; }
.sticker-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.sticker-add { cursor: pointer; font-size: 12.5px; color: var(--primary); font-weight: 600; }
.sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.sticker-cell { position: relative; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.sticker-cell img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.sticker-del { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; font-size: 11px; cursor: pointer; }
.sticker-empty, .sticker-loading { grid-column: 1/-1; color: var(--muted); font-size: 13px; padding: 16px; text-align: center; }

@media (max-width: 600px) {
  .chat-wrap { height: 70vh; }
  .chat-list { width: 120px; }
}

.files { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.file-name { color: var(--primary); text-decoration: none; font-size: 14px; }
.file-name:hover { text-decoration: underline; }
.file-meta { font-size: 12px; color: var(--muted); margin-left: auto; }

@media (max-width: 600px) {
  .action-grid { grid-template-columns: repeat(2, 1fr); }
  .check-wrap { grid-template-columns: 1fr; }
  .log-item { flex-direction: column; gap: 4px; }
  .log-time { min-width: auto; }
}
