:root {
  --bg: #f4f6f9; --card: #ffffff; --ink: #17212b; --muted: #5d6b7a; --line: #dfe4ea; --soft: #eef2f6;
  --primary: #1f4e79; --primary-ink: #ffffff; --primary-soft: #e3edf7;
  --ok: #1e7b4c; --ok-soft: #e2f4ea; --warn: #9a5b00; --warn-soft: #fff1d6; --bad: #b42318; --bad-soft: #fde7e4;
  --info: #1d5fb8; --info-soft: #e3eefc; --sample: #c2410c; --sample-soft: #ffedd5; --ai: #6b3fa0; --ai-soft: #f1e9fb;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

/* 상단 */
.top { position: sticky; top: 0; z-index: 20; background: var(--primary); color: var(--primary-ink); }
.top-in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: -.3px; font-size: 16px; white-space: nowrap; }
.brand small { font-weight: 500; opacity: .8; margin-left: 6px; }
.top .spacer { flex: 1; }
.top select { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 5px 8px; }
.top select option { color: var(--ink); }
.top .who { font-size: 13px; opacity: .9; white-space: nowrap; }
.top .linkbtn { background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.mode { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.mode.sample { background: var(--sample); color: #fff; }
.mode.live { background: #2f9e62; color: #fff; }
nav.tabs { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 50px; z-index: 19; }
nav.tabs .in { max-width: 1280px; margin: 0 auto; display: flex; gap: 2px; padding: 0 10px; overflow-x: auto; scrollbar-width: none; }
nav.tabs a { padding: 11px 12px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 3px solid transparent; }
nav.tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
nav.tabs a .cnt { background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; margin-left: 4px; }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.banner.sample { background: var(--sample-soft); color: #7c2d12; border: 1px solid #fdba74; }
.banner.warn { background: var(--warn-soft); color: #6b3e00; border: 1px solid #f5c26b; }
.banner.bad { background: var(--bad-soft); color: #7a1a12; border: 1px solid #f3a59c; }
.banner.info { background: var(--info-soft); color: #123d75; border: 1px solid #a9c7f0; }
.banner.ai { background: var(--ai-soft); color: #4a2673; border: 1px solid #cdb4ef; }
.banner.ok { background: var(--ok-soft); color: #0f5132; border: 1px solid #9fd8b8; }

/* 카드·그리드 */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.card-h .spacer { flex: 1; }
.section { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 8px; }
.empty { color: var(--muted); padding: 14px; text-align: center; background: var(--soft); border-radius: 8px; font-size: 14px; }

/* KPI */
.kpi-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 10px; }
.kpi-nums div { background: var(--soft); border-radius: 8px; padding: 8px; text-align: center; }
.kpi-nums b { display: block; font-size: 24px; letter-spacing: -.5px; }
.kpi-nums span { font-size: 12px; color: var(--muted); }
.bar { position: relative; height: 12px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); border-radius: 99px; }
.bar i.s { background: repeating-linear-gradient(45deg, #fb923c, #fb923c 4px, #fdba74 4px, #fdba74 8px); }
.bar em { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--bad); }
.bar.thin { height: 8px; }

/* 칩·배지 */
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--soft); color: var(--muted); white-space: nowrap; line-height: 20px; }
.chip.planned { background: #eef1f5; color: #475467; }
.chip.in_progress { background: var(--info-soft); color: var(--info); }
.chip.needs_check { background: var(--warn-soft); color: var(--warn); }
.chip.done { background: var(--ok-soft); color: var(--ok); }
.chip.on_hold { background: var(--bad-soft); color: var(--bad); }
.chip.sample { background: var(--sample-soft); color: var(--sample); }
.chip.ai { background: var(--ai-soft); color: var(--ai); }
.chip.late { background: var(--bad); color: #fff; }
.chip.branch { background: var(--primary-soft); color: var(--primary); }
.chip.unassigned { background: #fff; color: var(--bad); border: 1px dashed var(--bad); }
.chip.type { background: #fff; border: 1px solid var(--line); color: var(--ink); }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; cursor: pointer; font-weight: 600; font-size: 14px; min-height: 36px; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: #173d61; }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.warn { background: #fff; color: var(--warn); border-color: #f0c36d; }
.btn.bad { background: #fff; color: var(--bad); border-color: #f3a59c; }
.btn.sm { padding: 3px 9px; min-height: 28px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 6px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--primary); color: #fff; }

/* 업무 카드 */
.task { border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: #fff; cursor: pointer; display: block; width: 100%; text-align: left; }
.task:hover { border-color: #9fb3c8; }
.task.is-late { border-left: 4px solid var(--bad); }
.task.is-ai { border-left: 4px solid var(--ai); background: #fcfaff; }
.task .t-title { font-weight: 700; margin: 3px 0; overflow-wrap: anywhere; }
.task .t-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.task .t-how { font-size: 13px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list { display: grid; gap: 8px; }

/* 단계 표시 */
.steps { display: flex; gap: 4px; margin-top: 6px; }
.steps span { flex: 1; text-align: center; font-size: 11px; padding: 2px 0; border-radius: 4px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.steps span.on { background: var(--info); color: #fff; }
.steps span.past { background: #b7cdea; color: #123d75; }
.steps.done span { background: var(--ok); color: #fff; }

/* 표 */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--soft); }
.tbl-wrap { overflow-x: auto; }

/* 달력 */
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-day { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-height: 120px; min-width: 0; }
.cal-day.today { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cal-day .d { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.cal-day.today .d { color: var(--primary); }
.cal-day.out { background: #fafbfc; opacity: .6; }
.cal-item { display: block; width: 100%; text-align: left; font-size: 12px; border: 0; border-left: 3px solid var(--line); background: var(--soft); border-radius: 4px; padding: 2px 5px; margin-bottom: 3px; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-item.done { border-left-color: var(--ok); text-decoration: line-through; color: var(--muted); }
.cal-item.in_progress { border-left-color: var(--info); }
.cal-item.needs_check { border-left-color: #e0a100; background: var(--warn-soft); }
.cal-item.on_hold { border-left-color: var(--bad); }
.cal-item.ai { border-left-color: var(--ai); background: var(--ai-soft); }
.cal-item.late { background: var(--bad-soft); }
.cal-ev { font-size: 11.5px; padding: 2px 5px; border-radius: 4px; margin-bottom: 3px; background: #e8f5ee; color: #135c38; font-weight: 600; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cal-ev.unconfirmed { background: var(--warn-soft); color: var(--warn); border: 1px dashed #e0a100; }
.cal-month .cal-day { min-height: 92px; }
.cal-month .more { font-size: 11px; color: var(--muted); }
.cal-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 4px; font-weight: 700; }

/* 경로 탭 */
.ch-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.ch-tabs button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 12px; cursor: pointer; font-weight: 600; font-size: 13px; }
.ch-tabs button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.ch-tabs button .n { font-size: 11px; opacity: .8; margin-left: 4px; }
.draft { white-space: pre-wrap; background: var(--soft); border-radius: 8px; padding: 10px; font-size: 13.5px; max-height: 220px; overflow: auto; overflow-wrap: anywhere; }
.links a { overflow-wrap: anywhere; }
.chain { display: flex; gap: 6px; align-items: stretch; flex-wrap: wrap; }
.chain .node { flex: 1 1 130px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff; cursor: pointer; font-size: 13px; min-width: 0; text-align: left; }
.chain .arrow { align-self: center; color: var(--muted); }

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-h { display: flex; gap: 8px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; border-radius: 12px 12px 0 0; z-index: 1; }
.modal-h h2 { flex: 1; overflow-wrap: anywhere; }
.modal-b { padding: 14px 16px 18px; }
.x { border: 0; background: var(--soft); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; flex: none; }
.step { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; }
.step > .sh { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 8px; }
.step > .sh .num { width: 22px; height: 22px; border-radius: 99px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.step.cur { border-color: var(--info); box-shadow: 0 0 0 2px var(--info-soft); }

/* 폼 */
label.f { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
label.f > input, label.f > select, label.f > textarea { display: block; width: 100%; margin-top: 3px; }
input[type=text], input[type=password], input[type=date], input[type=url], input[type=number], input[type=time], input:not([type]), select, textarea { border: 1px solid #c8d1db; border-radius: 8px; padding: 7px 9px; background: #fff; min-height: 36px; max-width: 100%; }
textarea { min-height: 90px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #7aa7e0; outline-offset: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.req { color: var(--bad); font-size: 12px; font-weight: 700; }

/* 로그인 */
.login { max-width: 380px; margin: 8vh auto; }
.login .card { padding: 22px; }
.login h1 { font-size: 20px; margin-bottom: 4px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #17212b; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 80; max-width: calc(100% - 32px); white-space: pre-wrap; font-size: 14px; box-shadow: 0 8px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--bad); }

@media (max-width: 960px) { .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) {
  main { padding: 12px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .top-in { padding: 8px 12px; gap: 6px; }
  .brand small { display: none; }
  nav.tabs { top: 0; position: relative; }
  .top { position: relative; }
  .cal-week { grid-template-columns: 1fr; }
  .cal-week .cal-day { min-height: 0; }
  .cal-week .cal-day.empty-day { display: none; }
  .cal-month .cal-day { min-height: 54px; padding: 3px; }
  .cal-month .cal-item, .cal-month .cal-ev { display: none; }
  .cal-month .dots { display: flex !important; }
  .cal-head, .cal-month { gap: 3px; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
  .modal-h { border-radius: 0; }
  table.t.resp thead { display: none; }
  table.t.resp tr { display: block; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; padding: 6px; }
  table.t.resp td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 4px 6px; }
  table.t.resp td::before { content: attr(data-l); color: var(--muted); font-size: 12px; font-weight: 600; flex: none; }
}
.dots { display: none; gap: 2px; flex-wrap: wrap; margin-top: 2px; }
.dots i { width: 6px; height: 6px; border-radius: 99px; background: var(--info); }
.dots i.done { background: var(--ok); } .dots i.late { background: var(--bad); } .dots i.ev { background: #2f9e62; } .dots i.ai { background: var(--ai); }
.cal-month .cal-day { cursor: pointer; }

.chlist { display: grid; gap: 2px; }
.chrow { display: grid; grid-template-columns: 170px 120px 170px 70px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.chrow .chnext { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (max-width: 720px) {
  .chrow { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 8px; }
  .chrow .bar { grid-column: 1 / -1; order: 3; }
  .chrow .chnext { grid-column: 1 / -1; order: 4; }
  table.t th, table.t td { padding: 6px 5px; font-size: 13px; }
}
