:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1d2430; --muted: #5f6878; --line: #e3e6eb;
  --accent: #1f5eff; --accent-text: #ffffff; --ceo: #eef3ff; --agent: #ffffff; --system: #fff6e5;
  --input-bg: #ffffff; --input-line: #c5cbd4;
  /* 상태 색 (항상 글자 라벨과 함께 표시) */
  --st-received: #4f6a8f; --st-meeting: #7c4dcc; --st-in_progress: #9a5b00; --st-review: #0f7c8c;
  --st-reported: #1a7f45; --st-failed: #c53030; --st-closed: #697281; --st-attn: #9a5b00; --ok-text: #1a7f45;
  --warn-bg: #fff4e0; --warn-line: #f0c27a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1a1f27; --text: #e6e9ee; --muted: #a0a9b8; --line: #2b323d;
    --accent: #5b8cff; --ceo: #1f2a44; --agent: #1a1f27; --system: #3a2f17;
    --input-bg: #0e1116; --input-line: #4a5462;
    --st-received: #5f6b80; --st-meeting: #7d52c9; --st-in_progress: #9e6208; --st-review: #137786;
    --st-reported: #1d7f4c; --st-failed: #c03a3a; --st-closed: #5c6573; --st-attn: #e0a040; --ok-text: #4cc38a;
    --warn-bg: #3a2f17; --warn-line: #7a5a20;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.6; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--st-failed); font-weight: 600; min-height: 1.2em; margin: 0; }
button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 8px;
  padding: 10px 16px; font-size: 15px; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; color: var(--muted); padding: 4px 8px; }
button.ghost { background: none; color: var(--accent); border: 1px solid var(--line); }
button.small { padding: 6px 12px; font-size: 14px; }
button.danger { background: none; color: var(--st-failed); border: 1px solid var(--line); }
input, textarea { width: 100%; font: inherit; color: inherit; background: var(--input-bg);
  border: 1px solid var(--input-line); border-radius: 8px; padding: 10px; margin-top: 4px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* 상태 배지: 색 + 글자 */
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; color: #fff; white-space: nowrap; }
.badge.received { background: var(--st-received); } .badge.meeting { background: var(--st-meeting); }
.badge.in_progress { background: var(--st-in_progress); } .badge.review { background: var(--st-review); }
.badge.reported { background: var(--st-reported); } .badge.failed { background: var(--st-failed); }
.badge.closed { background: var(--st-closed); }
.badge.decision { background: none; color: var(--st-attn); border: 1px solid var(--st-attn); }

/* 로그인·설정 */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px;
  width: 100%; max-width: 380px; display: grid; gap: 14px; }
.card h1 { font-size: 20px; margin: 0; }
.card label { display: block; font-size: 14px; }

/* 상단 바 */
.topbar { display: flex; gap: 12px; align-items: center; padding: 8px 16px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { margin-right: 8px; }
.tabs { display: flex; gap: 4px; }
.tabs a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: 15px; }
.tabs a.active { background: var(--ceo); color: var(--text); font-weight: 600; }
.live { margin-left: auto; font-size: 13px; color: var(--ok-text); }
.live.off { color: var(--muted); }

/* 대시보드 */
.tab-panel { padding: 16px; max-width: 1400px; margin: 0 auto; }
.quick { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin-bottom: 16px; }
.quick textarea { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 14px; color: var(--muted); }
.tile .value { font-size: 30px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .hint { font-size: 12px; color: var(--muted); }
.section-title { font-size: 16px; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.count { font-size: 13px; color: var(--muted); font-weight: 400; }
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-height: 120px; }
.col-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.col-empty { font-size: 13px; color: var(--muted); padding: 6px 2px; }
.tcard { display: block; width: 100%; text-align: left; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 14px; text-decoration: none; }
.tcard:hover { border-color: var(--accent); }
.tcard .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard .m { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px 10px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { border-top: 1px solid var(--line); padding: 10px 2px; }
.plain-list li:first-child { border-top: 0; }
.plain-list .empty { color: var(--muted); font-size: 14px; }
.plain-list a { color: var(--text); font-weight: 600; text-decoration: none; }
.plain-list a:hover { color: var(--accent); }
.appr-body { font-size: 14px; margin: 6px 0; white-space: pre-wrap; }
.appr-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.appr-actions input { flex: 1 1 180px; margin: 0; padding: 6px 10px; }

/* 업무 대화방 */
.layout { display: grid; grid-template-columns: 340px 1fr; height: calc(100vh - 53px); padding: 0; max-width: none; }
.sidebar { border-right: 1px solid var(--line); overflow-y: auto; background: var(--panel); }
.new-task { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.task-list li.active { background: var(--ceo); }
.task-list .t-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-list .t-meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail { overflow-y: auto; padding: 16px 20px 24px; }
.detail .empty { margin-top: 40px; text-align: center; }
.detail-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.detail-head h2 { font-size: 18px; margin: 0; flex: 1 1 200px; }
.back { display: none; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; max-width: 880px; }
.msg.ceo { background: var(--ceo); align-self: flex-end; max-width: 640px; }
.msg.system { background: var(--system); }
.msg:not(.ceo):not(.system) { background: var(--agent); align-self: flex-start; }
.msg-head { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.msg-head strong { color: var(--text); }
.msg-body h2, .msg-body h3, .msg-body h4 { font-size: 16px; margin: 12px 0 4px; }
.msg-body p { margin: 6px 0; }
.msg-body ul, .msg-body ol { margin: 4px 0; padding-left: 22px; }
.msg-body table { border-collapse: collapse; margin: 8px 0; display: block; overflow-x: auto; }
.msg-body td { border: 1px solid var(--line); padding: 4px 8px; }
.msg-body pre { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; }
.working { color: var(--st-attn); font-weight: 600; margin: 12px 0 0; }
.callout { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 10px 14px; margin: 10px 0; }
.reply { display: grid; gap: 8px; margin-top: 14px; }

/* 직원 */
.staff-note { margin: 0 0 14px; }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.staff { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.staff.inactive { opacity: .72; }
.staff .name { font-size: 17px; font-weight: 700; }
.staff .dept { color: var(--muted); font-size: 14px; }
.staff .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
.pill.on { border-color: var(--ok-text); color: var(--ok-text); }

/* 휴대폰 */
@media (max-width: 760px) {
  .topbar { gap: 6px; flex-wrap: nowrap; padding: 8px 10px; }
  .tabs { gap: 2px; }
  .brand { display: none; }
  .live { font-size: 0; } .live::first-letter { font-size: 14px; }
  #btn-logout { font-size: 13px; padding: 4px; white-space: nowrap; }
  .tabs a { padding: 6px 7px; font-size: 14px; white-space: nowrap; }
  .tab-panel { padding: 12px; }
  .quick { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(5, 78vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .two-col { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: 0; }
  body.show-detail .sidebar { display: none; }
  body:not(.show-detail) .detail { display: none; }
  .back { display: inline-block; }
  .detail { padding: 12px 12px 24px; }
  .msg.ceo { max-width: 92%; }
}
