:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1c1f3b;
  --muted: #6b7090;
  --line: #e7e9f0;
  --brand: #6161ff;      /* monday 보라 */
  --brand-2: #00c875;    /* 완료 그린 */
  --accent: #fdab3d;     /* 진행 옐로우 */
  --danger: #e2445c;     /* 지연 레드 */
  --info: #579bfc;       /* 블루 */
  --todo: #c4c7d4;
  --shadow: 0 1px 3px rgba(20, 24, 60, .06), 0 8px 24px rgba(20, 24, 60, .06);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Pretendard", "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

.app { display: grid; grid-template-columns: 264px 1fr; height: 100vh; }

/* ---------- 사이드바 ---------- */
.sidebar {
  background: #1f2147;
  color: #d8daf0;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  gap: 18px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), #a85cff);
  display: grid; place-items: center; font-size: 22px; color: #fff;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 16px; color: #fff; }
.brand-text span { font-size: 11.5px; color: #9a9dc8; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: 0; color: #c2c5e6;
  padding: 10px 12px; border-radius: 9px; font-size: 14.5px; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.ni-icon { width: 18px; text-align: center; opacity: .9; }

.nav-section-title {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: #7d80b0; margin-top: 6px; padding-left: 4px;
}
.core-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.core-list li {
  font-size: 12px; color: #aeb1d8; padding: 7px 10px;
  background: rgba(255,255,255,.04); border-radius: 8px;
}
.core-list b { color: #fff; font-weight: 600; margin-right: 4px; }

.sidebar-foot { margin-top: auto; }
.ghost-btn {
  width: 100%; background: rgba(255,255,255,.08); color: #e3e5f7;
  border: 1px solid rgba(255,255,255,.12); padding: 10px; border-radius: 9px; font-size: 13px;
}
.ghost-btn:hover { background: rgba(255,255,255,.16); }

/* ---------- 메인 ---------- */
.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-left h1 { font-size: 21px; }
.topbar-left p { font-size: 13px; color: var(--muted); margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.method-switch { display: flex; background: var(--bg); border-radius: 9px; padding: 3px; }
.ms-btn {
  border: 0; background: transparent; padding: 7px 13px; border-radius: 7px;
  font-size: 13px; color: var(--muted); font-weight: 500;
}
.ms-btn.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); font-weight: 600; }

.primary-btn {
  background: var(--brand); color: #fff; border: 0; padding: 10px 18px;
  border-radius: 9px; font-size: 14px; font-weight: 600;
}
.primary-btn:hover { filter: brightness(1.07); }
.danger-btn { background: #fff; color: var(--danger); border: 1px solid var(--danger); padding: 9px 16px; border-radius: 9px; font-size: 13px; }
.danger-btn:hover { background: var(--danger); color: #fff; }

.view-wrap { flex: 1; overflow-y: auto; padding: 24px 28px 60px; }

/* ---------- 대시보드 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.kpi .k-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 30px; font-weight: 800; margin-top: 8px; }
.kpi .k-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.panel-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.panel {
  background: var(--surface); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.panel h3 { font-size: 15px; margin-bottom: 16px; }
.panel.full { grid-column: 1 / -1; }

.progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress-row .pr-name { width: 90px; font-size: 13px; color: var(--muted); }
.bar { flex: 1; height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; }
.progress-row .pr-pct { width: 42px; text-align: right; font-size: 13px; font-weight: 600; }

.status-legend { display: flex; flex-direction: column; gap: 12px; }
.legend-item { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend-item .li-count { margin-left: auto; font-weight: 700; }
.stack-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin-bottom: 18px; }
.stack-bar > span { height: 100%; }

.ms-list { display: flex; flex-direction: column; gap: 10px; }
.ms-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; background: var(--bg); border-radius: 9px; }
.ms-diamond { color: var(--brand); font-size: 14px; }
.ms-item .mi-name { font-size: 13.5px; font-weight: 600; }
.ms-item .mi-date { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.ms-item .mi-dday { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; background: #ecedff; color: var(--brand); }

/* ---------- 테이블 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type=search], .toolbar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; color: var(--ink);
}
.toolbar input[type=search] { min-width: 220px; }
.toolbar .count-chip { margin-left: auto; font-size: 13px; color: var(--muted); }

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.data-table th, .data-table td { padding: 13px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); }
.data-table th { background: #fafbff; color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
.data-table tbody tr:hover { background: #fafbff; cursor: pointer; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.tname { font-weight: 600; display: flex; align-items: center; gap: 7px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-todo { background: #eef0f6; color: #7a7f9c; }
.badge-doing { background: #fff3e0; color: #d98c1a; }
.badge-done { background: #e3f7ed; color: #009d5b; }
.badge-blocked { background: #fdecef; color: var(--danger); }
.prio { font-weight: 700; font-size: 12px; }
.prio-high { color: var(--danger); }
.prio-mid { color: var(--accent); }
.prio-low { color: var(--muted); }
.mini-bar { width: 80px; height: 7px; background: var(--bg); border-radius: 5px; overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-bar > span { display: block; height: 100%; background: var(--brand); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; }
.owner-cell { display: flex; align-items: center; gap: 8px; }
.dep-tag { font-size: 11px; color: var(--info); }
.diamond { color: var(--brand); }

/* ---------- 간트 ---------- */
.gantt { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow-x: auto; }
.gantt-inner { min-width: 760px; }
.gantt-head { display: grid; position: sticky; top: 0; background: #fafbff; border-bottom: 1px solid var(--line); z-index: 2; }
.gantt-head .gh-label { padding: 12px 14px; font-size: 12px; color: var(--muted); font-weight: 600; border-right: 1px solid var(--line); }
.gantt-month { padding: 10px 6px; font-size: 11.5px; color: var(--muted); text-align: center; border-right: 1px solid var(--line); font-weight: 600; }
.gantt-row { display: grid; align-items: center; border-bottom: 1px solid var(--line); position: relative; }
.gantt-row:hover { background: #fafbff; }
.gantt-row .gr-label { padding: 11px 14px; font-size: 13px; border-right: 1px solid var(--line); display: flex; align-items: center; gap: 8px; overflow: hidden; }
.gr-label .grl-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.gantt-track { position: relative; height: 46px; }
.gantt-bar {
  position: absolute; top: 11px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; padding: 0 8px; font-size: 11px; color: #fff; font-weight: 600;
  overflow: hidden; white-space: nowrap; cursor: pointer;
}
.gantt-bar .gb-fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.28); }
.gantt-bar span { position: relative; }
.gantt-milestone {
  position: absolute; top: 12px; width: 22px; height: 22px;
  background: var(--brand); transform: rotate(45deg); border-radius: 4px; cursor: pointer;
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--brand);
}
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 1; }
.gantt-today::after { content: "오늘"; position: absolute; top: -2px; left: 4px; font-size: 10px; color: var(--danger); font-weight: 700; }

/* ---------- 칸반 ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.kb-col { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 120px; }
.kb-col.drag-over { outline: 2px dashed var(--brand); outline-offset: -2px; }
.kb-head { padding: 14px 16px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.kb-head .kb-count { margin-left: auto; font-size: 12px; color: var(--muted); background: var(--bg); padding: 2px 9px; border-radius: 12px; }
.kb-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.kb-card { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 9px; padding: 12px; box-shadow: 0 1px 2px rgba(20,24,60,.05); cursor: grab; }
.kb-card:active { cursor: grabbing; }
.kb-card.dragging { opacity: .4; }
.kb-card .kc-phase { font-size: 11px; color: var(--muted); }
.kb-card .kc-name { font-size: 13.5px; font-weight: 600; margin: 5px 0 9px; }
.kb-card .kc-foot { display: flex; align-items: center; gap: 8px; }
.kb-card .kc-date { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.kc-risk { font-size: 11px; color: var(--danger); margin-top: 8px; display: flex; gap: 5px; align-items: flex-start; }

/* ---------- 캘린더 ---------- */
.cal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.cal-head h3 { font-size: 17px; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 15px; color: var(--ink); }
.cal-nav button:hover { background: var(--bg); }
.cal-grid { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); background: #fafbff; border-bottom: 1px solid var(--line); }
.cal-dow div { padding: 11px; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-weeks { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 110px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px; position: relative; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.dim { background: #fbfbfd; }
.cal-cell .cc-date { font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-cell.today .cc-date { background: var(--brand); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.cal-event { font-size: 11px; padding: 3px 7px; border-radius: 5px; margin-top: 5px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }

/* ---------- 모달 ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,24,60,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; width: 100%; max-width: 620px; border-radius: 16px; box-shadow: 0 24px 60px rgba(20,24,60,.3); max-height: 92vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; }
.icon-btn { border: 0; background: var(--bg); width: 32px; height: 32px; border-radius: 8px; font-size: 14px; color: var(--muted); }
.modal-body { padding: 22px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span2 { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; font-family: inherit; color: var(--ink); background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.checkbox-field label { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; cursor: pointer; }
.checkbox-field input { width: 16px; height: 16px; }
.modal-foot { display: flex; align-items: center; gap: 10px; grid-column: 1 / -1; padding-top: 6px; }
.modal-foot .spacer { flex: 1; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .e-icon { font-size: 40px; opacity: .5; }
.empty p { margin-top: 10px; font-size: 14px; }

/* ---------- 반응형 ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; }
}
