/* ─────────────────────────────────────────────
   KP AGENT HQ — KP Works 톤 통일 테마
   (KP Works의 --ground/--surface/--accent 팔레트를 그대로 옮김)
   ───────────────────────────────────────────── */

:root {
  /* KP Works 팔레트 그대로 */
  --ground: #eff0f1;
  --surface: #ffffff;
  --surface-2: #f5f6f7;
  --ink: #191c1f;
  --muted: #666c72;
  --line: #dfe1e4;
  --line-strong: #c8ccd1;
  --accent: #343a40;          /* 다크그레이 — 버튼·선택 (KP Works와 동일) */
  --accent-ink: #1f2429;
  --accent-soft: #e6e8ea;
  --on-accent: #ffffff;
  --brand: #0a2c74;           /* 로고 네이비 (KP Works 로고와 동일) */
  --warn: #8c6414;
  --crit: #a33a2a;
  --ok: #1f7a3d;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;

  /* 구버전 템플릿 호환용 별칭 */
  --text-muted: var(--muted);
  --status-active: var(--ok);

  font-family: "Malgun Gothic", "맑은 고딕", -apple-system, BlinkMacSystemFont,
               "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: inherit;
  background: var(--ground);
  color: var(--ink);
  min-height: 100vh;
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-chip {
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  height: 32px;
}

.logo-chip img {
  height: 22px;
  width: auto;
}

.header-title {
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.header-title span { color: var(--brand); }

.header-subtitle {
  font-size: 11.5px;
  color: var(--muted);
  margin-left: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.header-right .status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  display: inline-block;
}

.header-nav {
  display: flex;
  gap: 2px;
}

.header-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.header-nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.header-nav a.active {
  color: var(--on-accent);
  background: var(--accent);
}

/* ── Status Bar ── */
.status-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 28px;
  display: flex;
  align-items: center;
  gap: 0;
}

.status-block {
  flex: 1;
  padding: 10px 22px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-block:first-child { border-left: none; }

.status-label {
  font-family: 'Malgun Gothic', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.status-label .dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block;
}

.status-label .dot.blue { background: var(--brand); }
.status-label .dot.yellow { background: var(--warn); }
.status-label .dot.green { background: var(--ok); }
.status-label .dot.gray { background: var(--line-strong); }
.status-label .dot.red { background: var(--crit); }

.status-value {
  font-family: 'Malgun Gothic', sans-serif;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}

.status-bar-right {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── Main ── */
.main {
  padding: 26px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ── Section Headers ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  margin-top: 8px;
}

.section-title {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--brand);
  border-radius: 2px;
}

.section-count {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

/* ── Module Cards ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.15s;
}

.module-card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-icon { font-size: 24px; line-height: 1; }

.card-badges { display: flex; gap: 6px; }

.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  letter-spacing: 0.2px;
}

.badge-program { background: var(--surface-2); color: var(--accent-ink); }
.badge-ai { background: #ECEBFA; color: #4338A8; }
.badge-ready { background: #E9F6EE; color: var(--ok); }
.badge-dev { background: #FBF3E4; color: var(--warn); }
.badge-planned { background: var(--surface-2); color: var(--muted); }

.card-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--ink);
}

.card-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
  min-height: 40px;
}

.card-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.card-action:hover { filter: brightness(1.15); }

.card-action.disabled {
  background: var(--surface-2);
  color: var(--muted);
  border-color: var(--line);
  cursor: not-allowed;
}

.card-action.running {
  background: var(--warn);
  border-color: var(--warn);
  cursor: wait;
}

/* ── Add Card ── */
.add-card {
  background: transparent;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 170px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--muted);
}

.add-card:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.add-card-icon { font-size: 26px; margin-bottom: 8px; opacity: 0.5; }
.add-card-text { font-size: 13px; font-weight: 700; }

.footer {
  text-align: center;
  padding: 20px;
  font-size: 11.5px;
  color: var(--muted);
}

/* ══════════════════════════════════════════
   BOTS / ORG CHART PAGE
   ══════════════════════════════════════════ */

.org-section { margin-bottom: 30px; }

/* ── Orchestrator Banner ── */
.orch-banner {
  background: var(--accent);
  border-radius: var(--radius-lg);
  padding: 18px 26px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

.orch-ceo {
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 12px 22px;
  text-align: center;
  min-width: 130px;
}

.orch-ceo-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.3px;
}

.orch-ceo-name {
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  margin-top: 2px;
}

.orch-divider {
  width: 1px;
  height: 46px;
  background: rgba(255,255,255,0.2);
}

.orch-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
}

.orch-info { flex: 1; }

.orch-name { font-size: 15.5px; font-weight: 700; color: #fff; }
.orch-role { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 1px; }
.orch-activity { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 4px; }

.orch-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 99px;
  letter-spacing: 0.2px;
}

.orch-status-badge.idle { background: rgba(31,122,61,0.25); color: #6FDB94; }
.orch-status-badge.busy { background: rgba(140,100,20,0.3); color: #F0C060; }
.orch-status-badge.offline { background: rgba(163,58,42,0.25); color: #F0A090; }

/* ── Team Cards ── */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}

.team-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.team-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 800;
  font-size: 13.5px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-card-header .count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-light, var(--line));
}

.member-row:last-child { border-bottom: none; }

.member-avatar {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px; flex: none;
}

.member-avatar.bot { border-radius: 50%; background: var(--brand); }
.member-avatar.empty { background: var(--surface-2); color: var(--muted); border: 2px dashed var(--line-strong); }

.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.member-role { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.member-activity { font-size: 11px; color: var(--muted); margin-top: 2px; }

.member-status {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
}
.member-status.idle { background: var(--ok); }
.member-status.busy { background: var(--warn); box-shadow: 0 0 0 3px rgba(140,100,20,0.15); }
.member-status.offline { background: var(--crit); }

/* ── bots.html 전용 클래스 (조직도 세부) ── */
.team-name { font-size: 14px; font-weight: 800; color: var(--ink); }
.team-sub-label { font-size: 11px; color: var(--muted); margin-top: 1px; }
.team-headcount { font-size: 18px; font-weight: 800; color: var(--ink); }
.team-headcount-label { font-size: 10px; color: var(--muted); font-weight: 700; margin-left: 2px; }

.team-mini-stats {
  display: flex;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.team-mini-stat {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  border-left: 1px solid var(--line);
}
.team-mini-stat:first-child { border-left: none; }
.team-mini-stat-value { font-size: 17px; font-weight: 800; }
.team-mini-stat-value.active { color: var(--warn); }
.team-mini-stat-value.standby { color: var(--ok); }
.team-mini-stat-value.offline { color: var(--crit); }
.team-mini-stat-label { font-size: 10px; color: var(--muted); font-weight: 600; margin-top: 2px; }

.online-rate {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
.online-rate-label { font-size: 11px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.online-rate-track {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.online-rate-fill { height: 100%; background: var(--brand); border-radius: 99px; }
.online-rate-pct { font-size: 11.5px; font-weight: 800; color: var(--ink); white-space: nowrap; }

.live-desks-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.3px;
}
.live-desks-header .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); display: inline-block; }

.sub-section { padding-bottom: 4px; }
.empty-slot { padding: 14px 18px; color: var(--muted); font-size: 12.5px; text-align: center; }

.member-avatar-box {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 13px; flex: none;
  background: var(--accent);
}
.member-avatar-box.leader { background: var(--brand); }
.member-avatar-box.planner { background: #6C63C5; }
.member-avatar-box.designer { background: #C5637A; }
.member-avatar-box.ops { background: #3C8F6B; }
.member-avatar-box.default { background: var(--accent); }

.member-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.member-row .member-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.member-role-text { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.member-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.member-status-badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.member-status-badge.idle { background: #E9F6EE; color: var(--ok); }
.member-status-badge.idle .dot { background: var(--ok); }
.member-status-badge.busy { background: #FBF3E4; color: var(--warn); }
.member-status-badge.busy .dot { background: var(--warn); }
.member-status-badge.offline { background: #FBEAE7; color: var(--crit); }
.member-status-badge.offline .dot { background: var(--crit); }

/* ── 재고관리 파이프라인 실행 패널 ── */
.job-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.job-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13.5px;
  font-weight: 800;
}
.job-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
}
.job-status-badge.running { background: #FBF3E4; color: var(--warn); }
.job-status-badge.success { background: #E9F6EE; color: var(--ok); }
.job-status-badge.failed { background: #FBEAE7; color: var(--crit); }
.job-log {
  background: var(--accent-ink);
  color: #d7e0e8;
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 12px;
  line-height: 1.6;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  max-height: 340px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}
