/* ───────── 기본 ───────── */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --line: #e3e7ef;
  --text: #1c2333;
  --sub: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eaf0fe;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --violet: #7c3aed;
  --violet-soft: #f1eafe;
  --sidebar: #171f31;
  --sidebar-2: #202a42;
  --radius: 10px;
}
html, body { height: 100%; }
body {
  font-family: "Segoe UI", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
#layout { display: flex; height: 100vh; }

/* ───────── 사이드바 ───────── */
#sidebar {
  width: 264px; min-width: 264px; background: var(--sidebar); color: #dfe5f1;
  display: flex; flex-direction: column; padding: 16px 12px; gap: 14px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 8px; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg,#3b82f6,#7c3aed);
  color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.brand-title { font-weight: 700; font-size: 15px; color: #fff; }
.brand-sub { font-size: 11px; color: #8b96ad; }

.side-section { display: flex; flex-direction: column; gap: 6px; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: #8b96ad; padding: 0 6px; text-transform: uppercase; }
.side-label .hint { font-weight: 400; text-transform: none; letter-spacing: 0; }
.conn-list { display: flex; flex-direction: column; gap: 4px; }
.conn-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; border: 1px solid transparent; transition: background .12s;
}
.conn-item:hover { background: var(--sidebar-2); }
.conn-item.active { background: var(--sidebar-2); border-color: #35415f; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.conn-dot.api { background: #4ade80; }
.conn-dot.session { background: #fbbf24; }
.conn-name { flex: 1; font-size: 13px; color: #eef1f7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-gear { opacity: 0; font-size: 12px; color: #8b96ad; }
.conn-item:hover .conn-gear { opacity: 1; }
.side-empty { font-size: 12px; color: #6b7793; padding: 4px 8px; }
.side-footer { margin-top: auto; padding: 8px 6px 0; border-top: 1px solid #2a3450; }
.side-footer .hint { font-size: 10px; color: #5d6983; word-break: break-all; }

/* ───────── 메인 ───────── */
#main { flex: 1; overflow-y: auto; }
#view { max-width: 1240px; margin: 0 auto; padding: 26px 30px 60px; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 21px; font-weight: 800; }
.page-sub { color: var(--sub); font-size: 13px; }
.spacer { flex: 1; }

/* 뱃지 */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.badge.api { background: var(--green-soft); color: var(--green); }
.badge.session { background: var(--amber-soft); color: var(--amber); }
.badge.gray { background: #eef0f4; color: var(--sub); }

/* 카드 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat-num { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat-label { font-size: 12px; color: var(--sub); font-weight: 600; }
.stat-extra { font-size: 12px; color: var(--sub); margin-top: 6px; }

.proj-card { cursor: pointer; transition: box-shadow .12s, transform .12s; }
.proj-card:hover { box-shadow: 0 4px 16px rgba(23,31,49,.08); transform: translateY(-1px); }
.proj-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.proj-meta { font-size: 12px; color: var(--sub); }

/* 진행률 바 */
.bar { height: 8px; background: #edf0f5; border-radius: 6px; overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; font-size: 12px; color: var(--sub); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* 버튼 */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--text);
  font: inherit; font-weight: 600; font-size: 13px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s;
}
.btn:hover { background: #f6f8fb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4fd8; }
.btn-danger { background: #fff; border-color: #f3c1c1; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-green:hover { background: #128a3e; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }
.icon-btn { border: none; background: none; cursor: pointer; font-size: 14px; color: var(--sub); padding: 4px 6px; }
.icon-btn:hover { color: var(--text); }

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 18px 0; }
.tab { padding: 9px 16px; font-weight: 700; font-size: 13.5px; color: var(--sub); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-color: var(--accent); }

/* 툴바 */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=text], .toolbar select {
  font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.toolbar input[type=text] { min-width: 220px; }

/* 테이블 */
.tbl-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11.5px; color: var(--sub); font-weight: 700; letter-spacing: .03em;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; position: sticky; top: 0; white-space: nowrap;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: #f7f9fd; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { color: var(--sub); font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 14px; white-space: nowrap; }

/* 상세 드로어 */
.drawer-back { position: fixed; inset: 0; background: rgba(15,20,35,.45); z-index: 40; display: flex; justify-content: flex-end; }
.drawer { width: min(720px, 94vw); background: var(--bg); height: 100%; overflow-y: auto; padding: 20px 22px; box-shadow: -8px 0 30px rgba(0,0,0,.2); }
.drawer .card { margin-bottom: 12px; }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.drawer-title { font-size: 17px; font-weight: 800; flex: 1; }

/* 체크리스트 라인 */
.cl-section { margin-bottom: 14px; }
.cl-section-head { font-weight: 700; font-size: 13.5px; padding: 8px 4px; color: var(--text); display: flex; gap: 8px; align-items: center; }
.cl-line { display: flex; align-items: flex-start; gap: 9px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; margin-bottom: 6px; }
.cl-line.header-line { background: #f2f4f9; font-weight: 700; border-style: dashed; }
.cl-line .desc { flex: 1; line-height: 1.45; }
.cl-line .desc .sub { color: var(--sub); font-size: 12px; margin-top: 2px; }
.cl-line input[type=checkbox] { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--accent); }
.ans { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 12px; white-space: nowrap; }
.ans.passed { background: var(--green-soft); color: var(--green); }
.ans.failed { background: var(--red-soft); color: var(--red); }
.ans.na { background: #eef0f4; color: var(--sub); }
.ans.none { background: #fff; color: #b6bcc9; border: 1px dashed #d5dae4; }

.bulkbar {
  position: sticky; bottom: 0; background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; display: flex; align-items: center; gap: 8px; box-shadow: 0 -4px 18px rgba(23,31,49,.06);
}

/* 폼 */
label { display: block; font-size: 12px; font-weight: 700; color: var(--sub); margin: 12px 0 5px; }
input[type=text], input[type=password], input[type=date], textarea, select, input:not([type]) {
  width: 100%; font: inherit; font-size: 13.5px; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--text);
}
textarea { resize: vertical; font-family: inherit; }
input:focus, textarea:focus, select:focus { outline: 2px solid #bcd0fb; border-color: var(--accent); }

/* 모달 */
.modal-back { position: fixed; inset: 0; background: rgba(15,20,35,.5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: var(--bg); width: min(620px, 96vw); max-height: 92vh; border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 15px; padding: 15px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.modal-body { padding: 6px 18px 18px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; padding: 13px 18px; background: #fff; border-top: 1px solid var(--line); }

.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-card { display: flex; gap: 9px; padding: 11px; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; margin: 0; }
.mode-card p { font-size: 11.5px; color: var(--sub); font-weight: 400; margin-top: 3px; line-height: 1.45; }
.mode-card b { font-size: 13px; }
.mode-card input { width: auto; accent-color: var(--accent); }
.mode-card.checked { border-color: var(--accent); background: var(--accent-soft); }

.callout { background: var(--accent-soft); border: 1px solid #cdddfc; color: #23406e; border-radius: 9px; padding: 11px 13px; font-size: 12.5px; line-height: 1.65; margin-top: 9px; }
.callout code { background: #fff; padding: 1px 5px; border-radius: 4px; }
.callout.warn { background: var(--amber-soft); border-color: #f3ddb0; color: #7a4c07; }

/* 토스트 */
#toastWrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1c2333; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: pop .18s ease; max-width: 80vw; }
.toast.err { background: #b91c1c; }
.toast.ok { background: var(--green); }
@keyframes pop { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none; } }

/* 로딩 */
.loading { display: flex; align-items: center; gap: 10px; color: var(--sub); padding: 30px; justify-content: center; font-weight: 600; }
.spin { width: 18px; height: 18px; border: 3px solid #d8dfeb; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--sub); padding: 40px 20px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }

.mono { font-family: Consolas, "D2Coding", monospace; font-size: 12px; }
pre.mono { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; max-height: 400px; white-space: pre-wrap; word-break: break-all; }

/* ───────── DCR 폼 ───────── */
.dcr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.dcr-grid label { margin-top: 0; }
.dcr-persons { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.dcr-person { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; margin: 0; font-weight: 500; }
.dcr-person.on { background: var(--green-soft); border-color: #a5d6b0; }
.dcr-person input { width: auto; accent-color: var(--green); }
.dcr-person .hint { margin-left: auto; font-size: 11px; }
.dcr-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.dcr-row { display: flex; gap: 6px; align-items: center; }
.dcr-row input { flex: 1; padding: 6px 9px; font-size: 13px; }
.dcr-row .icon-btn { flex: 0 0 auto; color: var(--red); }

/* 진행 오버레이 */
.progress-back { position: fixed; inset: 0; background: rgba(15,20,35,.55); z-index: 80; display: flex; align-items: center; justify-content: center; }
.progress-box { background: #fff; border-radius: 14px; padding: 24px 28px; width: min(420px, 92vw); text-align: center; }
.progress-box .bar { margin: 14px 0 8px; height: 10px; }

/* ───────── 모바일 / 반응형 ───────── */
#navToggle, #navBack { display: none; }

@media (max-width: 820px) {
  /* 사이드바 → 오프캔버스 드로어 (햄버거로 열고 닫음) */
  #sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 60;
    width: 82vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.28);
  }
  body.nav-open #sidebar { transform: none; }

  /* 배경 딤 */
  #navBack {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(10,15,28,.5); opacity: 0; pointer-events: none; transition: opacity .22s;
  }
  body.nav-open #navBack { opacity: 1; pointer-events: auto; }

  /* 햄버거 버튼 (좌상단 고정) */
  #navToggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; top: 10px; left: 12px; z-index: 45;
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--sidebar); color: #fff; border: none; font-size: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,.22); cursor: pointer;
  }

  #main { width: 100%; }
  #view { max-width: 100%; padding: 62px 14px 48px; }
  .page-head { margin-bottom: 14px; }
  .page-title { font-size: 19px; }

  /* 여러 열 폼 → 한 열 */
  .dcr-grid { grid-template-columns: 1fr; }
  .mode-pick { grid-template-columns: 1fr; }

  /* 툴바 입력이 화면 폭을 넘지 않게 */
  .toolbar { gap: 6px; }
  .toolbar input[type=text], .toolbar select { min-width: 0; flex: 1 1 100%; }

  /* 탭 가로 스크롤 (좁을 때 줄바꿈 대신 스와이프) */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
}

@media (max-width: 430px) {
  #view { padding: 60px 10px 40px; }
  .card { padding: 14px; }
  .modal-body { padding: 6px 12px 14px; }
  .stat-num { font-size: 22px; }
}
