/* TRACE — 디지털 흔적 복원 시스템 · 공용 스타일 */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e3e7ee;
  --border-strong: #d2d8e2;
  --text-1: #17203a;
  --text-2: #5a6478;
  --text-3: #9199ab;
  --accent: #1f56c9;
  --accent-hover: #1a48a8;
  --accent-soft: #eef3fd;
  --sidebar: #101a30;
  --sidebar-2: #18264a;
  --sidebar-text: #8e9ab5;
  --danger: #cc3a2e;
  --danger-soft: #fdeceb;
  --warn: #b96a05;
  --warn-soft: #fdf3e2;
  --ok: #157a55;
  --ok-soft: #e9f6f0;
  --info-soft: #e8f0fb;
  --purple: #6d4fc4;
  --purple-soft: #f1eefb;
  --teal: #0f7c86;
  --teal-soft: #e7f4f5;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(23, 32, 58, .06);
  --mono: "JetBrains Mono", "D2Coding", Consolas, monospace;
}

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

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.icon { width: 16px; height: 16px; flex: none; }
.icon-sm { width: 14px; height: 14px; flex: none; }
.icon-lg { width: 20px; height: 20px; flex: none; }

.mono { font-family: var(--mono); font-size: .92em; letter-spacing: 0; }

/* ===== 레이아웃 ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px;
  flex: none;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2d63e0, #173a8f);
  display: grid;
  place-items: center;
  color: #fff;
}

.brand-text strong {
  display: block;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .14em;
}

.brand-text span { display: block; font-size: 10.5px; letter-spacing: -.01em; }

.side-scroll { flex: 1; overflow-y: auto; padding: 14px 12px; }

.nav-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 14px 10px 6px;
  color: #5d6a8a;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--sidebar-text);
  margin-bottom: 2px;
  border-left: 2px solid transparent;
}

.nav-item:hover { background: rgba(255, 255, 255, .05); color: #dfe5f2; }

.nav-item.active {
  background: var(--sidebar-2);
  color: #fff;
  font-weight: 600;
  border-left: 2px solid #4d82f0;
  border-radius: 4px 8px 8px 4px;
}

.nav-count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(255, 255, 255, .09);
  border-radius: 5px;
  padding: 1px 7px;
  color: #aeb9d4;
}

.nav-item.active .nav-count { background: rgba(77, 130, 240, .25); color: #b9d0fb; }

.side-case {
  margin: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: var(--radius);
  font-size: 12px;
}

.side-case .mono { color: #fff; font-weight: 700; font-size: 12.5px; }
.side-case p { margin-top: 3px; color: #77839f; font-size: 11.5px; }
.side-case div:last-child { margin-top: 8px; }

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 12px;
}

.side-user strong { display: block; color: #e8ecf5; font-size: 13px; }

.avatar {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  background: #2d4a8a;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ===== 상단 바 ===== */
.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.crumbs strong { color: var(--text-1); font-weight: 600; }
.crumbs .icon-sm { color: var(--text-3); }

.top-search {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 260px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-3);
  font-size: 13px;
}

.top-search kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  background: #fff;
  color: var(--text-3);
}

.top-time { font-family: var(--mono); font-size: 12px; color: var(--text-2); }

.icon-btn {
  position: relative;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-2);
}

.icon-btn .dot {
  position: absolute;
  top: 7px; right: 8px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid #fff;
}

/* ===== 페이지 본문 ===== */
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.page-head .sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.page-head .head-id { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 700; letter-spacing: .06em; }
.head-actions { margin-left: auto; display: flex; gap: 8px; }

/* 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-1);
}

.btn:hover { background: #f7f9fc; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eef1f6; color: var(--text-1); }

/* 카드 */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 { font-size: 14.5px; font-weight: 700; }
.card-head .hint { color: var(--text-3); font-size: 12px; }
.card-head .card-link { margin-left: auto; color: var(--accent); font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.card-body { padding: 18px; }

/* 배지 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}

.badge .dot8 { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-high { background: var(--danger-soft); color: var(--danger); }
.badge-med { background: var(--warn-soft); color: var(--warn); }
.badge-low { background: var(--info-soft); color: var(--accent); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-neutral { background: #eef1f6; color: var(--text-2); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }

/* 통계 카드 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }

.stat { padding: 16px 18px; }
.stat .label { font-size: 12px; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; display: flex; align-items: baseline; gap: 8px; }
.stat .delta { font-size: 11.5px; color: var(--text-3); font-weight: 500; }
.icon-wrap { display: grid; place-items: center; flex: none; }
.stat .icon-wrap { width: 26px; height: 26px; border-radius: 7px; margin-left: auto; }
.icon-wrap.red { background: var(--danger-soft); color: var(--danger); }
.icon-wrap.blue { background: var(--accent-soft); color: var(--accent); }
.icon-wrap.teal { background: var(--teal-soft); color: var(--teal); }
.icon-wrap.green { background: var(--ok-soft); color: var(--ok); }

/* 테이블 */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafbfd;
  white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfd; }
.table .num { font-family: var(--mono); font-size: 12.5px; }
.table .file-cell { display: flex; align-items: center; gap: 9px; font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.table .file-cell .icon { color: var(--text-3); }

/* 그리드 조합 */
.grid-2-1 { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.grid-1-2 { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.stack { display: grid; gap: 16px; }

/* 메타 목록 */
.meta-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.meta-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.meta-row dt { color: var(--text-2); flex: none; }
.meta-row dd { font-weight: 600; text-align: right; }

/* 진행 단계 */
.steps { display: grid; gap: 0; }
.step { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.step:last-child { padding-bottom: 0; }
.step::before {
  content: "";
  position: absolute;
  left: 11px; top: 26px; bottom: 2px;
  width: 2px;
  background: var(--border);
}
.step:last-child::before { display: none; }
.step.done::before { background: #bfe0cf; }
.step-ic {
  width: 24px; height: 24px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eef1f6;
  color: var(--text-3);
  z-index: 1;
}
.step.done .step-ic { background: var(--ok-soft); color: var(--ok); }
.step.now .step-ic { background: var(--accent-soft); color: var(--accent); }
.step .step-t { font-size: 13px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.step .step-d { font-size: 12px; color: var(--text-3); margin-top: 1px; }

/* 최근 사건 리스트 */
.mini-case { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.mini-case:last-child { border-bottom: 0; }
.mini-case .id { font-family: var(--mono); font-size: 12px; color: var(--text-2); font-weight: 600; }
.mini-case .t { font-weight: 600; flex: 1; }
.mini-case .date { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

/* 수평 분포 바 */
.hbar { margin-bottom: 12px; }
.hbar:last-child { margin-bottom: 0; }
.hbar .hbar-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.hbar .hbar-top b { font-family: var(--mono); font-weight: 600; color: var(--text-2); }
.hbar .track { height: 8px; border-radius: 5px; background: #eef1f6; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 5px; }

/* 필터 칩 */
.chip-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.chip .mono { font-size: 11.5px; color: var(--text-3); }
.chip.active { background: var(--accent-soft); border-color: #b9cdf2; color: var(--accent); }
.chip.active .mono { color: var(--accent); }

/* ===== 타임라인 ===== */
.tl { position: relative; padding-left: 26px; }
.tl::before {
  content: "";
  position: absolute;
  left: 8px; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(to bottom, #c9d4ea, #e3e7ee);
}
.tl-group { font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--text-3); letter-spacing: .08em; margin: 14px 0 10px; }
.tl-group:first-child { margin-top: 0; }

.tl-item { position: relative; margin-bottom: 12px; }
.tl-item::before {
  content: "";
  position: absolute;
  left: -23px; top: 22px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--text-3);
  z-index: 1;
}
.tl-item.sev-high::before { border-color: var(--danger); }
.tl-item.sev-med::before { border-color: var(--warn); }
.tl-item.sev-low::before { border-color: var(--accent); }

.tl-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tl-card.key { border-color: #efb9b4; box-shadow: 0 0 0 3px rgba(204, 58, 46, .07); }

.tl-top { display: flex; align-items: center; gap: 10px; padding: 11px 16px; }
.tl-time { font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--text-1); }
.tl-type {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  padding: 2px 8px;
  border-radius: 5px;
  background: #eef1f6;
  color: var(--text-2);
}
.tl-type.red { background: var(--danger-soft); color: var(--danger); }
.tl-type.amber { background: var(--warn-soft); color: var(--warn); }
.tl-type.blue { background: var(--accent-soft); color: var(--accent); }
.tl-type.teal { background: var(--teal-soft); color: var(--teal); }
.tl-title { font-weight: 700; font-size: 13.5px; }
.tl-keytag { margin-left: auto; font-size: 10.5px; font-weight: 800; color: var(--danger); letter-spacing: .05em; }

.tl-body { padding: 0 16px 12px; font-size: 12.5px; color: var(--text-2); }
.tl-body .kv { display: flex; gap: 6px; margin-top: 3px; }
.tl-body .kv b { color: var(--text-3); font-weight: 600; flex: none; width: 58px; }
.tl-body .kv span { font-family: var(--mono); font-size: 12px; }

.tl-foot { display: flex; gap: 14px; padding: 8px 16px; border-top: 1px dashed var(--border); background: #fafbfd; font-size: 11.5px; color: var(--text-3); }
.tl-foot span { display: inline-flex; align-items: center; gap: 5px; }
.tl-foot .mono { font-size: 11px; }

/* ===== SVG 그래프 ===== */
.graph-wrap {
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  background-position: -1px -1px;
  border-radius: 0 0 var(--radius) var(--radius);
}
.graph-wrap svg { display: block; width: 100%; height: auto; }

.gnode circle.bg { fill: #fff; stroke-width: 2; }
.gnode text.nlabel { font-size: 12px; font-weight: 700; fill: var(--text-1); paint-order: stroke; stroke: #fff; stroke-width: 4; }
.gnode text.nsub { font-size: 10px; fill: var(--text-3); font-family: var(--mono); paint-order: stroke; stroke: #fff; stroke-width: 3; }
.gedge { stroke: #b6c1d6; stroke-width: 1.6; }
.gedge.red { stroke: #e08c85; }
.gedge-label { font-size: 10.5px; fill: var(--text-2); font-family: var(--mono); }
.gedge-label[fill="#cc3a2e"] { fill: var(--danger); }

/* ===== 복원 결과 플로우 ===== */
.flow { position: relative; padding-left: 34px; }
.flow::before {
  content: "";
  position: absolute;
  left: 15px; top: 18px; bottom: 18px;
  width: 2px;
  background: var(--border);
}
.flow-stage { position: relative; padding-bottom: 14px; }
.flow-stage:last-child { padding-bottom: 0; }
.flow-num {
  position: absolute;
  left: -34px; top: 14px;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--text-3);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--text-2);
  z-index: 1;
}
.flow-stage.red .flow-num { border-color: var(--danger); color: var(--danger); }
.flow-stage.amber .flow-num { border-color: var(--warn); color: var(--warn); }
.flow-stage.blue .flow-num { border-color: var(--accent); color: var(--accent); }

.flow-head { display: flex; align-items: center; gap: 10px; }
.flow-head .t { font-weight: 800; font-size: 14.5px; }
.flow-head .time { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.flow-head .conf { margin-left: auto; font-size: 11.5px; color: var(--ok); font-weight: 700; }
.flow-desc { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.flow-evi { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.evi-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fafbfd;
  color: var(--text-2);
}

/* 게이지 */
.gauge { text-align: center; }
.gauge .num { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.gauge .cap { font-size: 11.5px; color: var(--text-3); }

/* 발견 목록 */
.finding { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.finding:last-child { border-bottom: 0; }
.finding .f-ic { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; }
.finding b { display: block; font-size: 13px; }
.finding p { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }

.foot-note {
  margin-top: 28px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-3);
}

@media (max-width: 1180px) {
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 모션 (절제된 강조 — 진입 1회 + 호버만, 반짝이는 루프 없음) ===== */
.nav-item, .btn, .table td { transition: background-color .15s ease, color .15s ease; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes draw { from { stroke-dashoffset: 500; } }
@keyframes grow { from { transform: scaleY(0); } }
@keyframes fillx { from { transform: scaleX(0); } }
@keyframes dash-spin { to { stroke-dashoffset: -80; } }

/* 카드·통계 진입 */
.content .card, .content .stat { animation: rise .45s ease-out both; }
.content .card:nth-child(2), .content .stat:nth-child(2) { animation-delay: .06s; }
.content .card:nth-child(3), .content .stat:nth-child(3) { animation-delay: .12s; }
.content .card:nth-child(n+4), .content .stat:nth-child(n+4) { animation-delay: .18s; }

/* 대시보드 바차트 성장 */
.chart rect { transform-box: fill-box; transform-origin: bottom center; animation: grow .5s cubic-bezier(.2,.7,.3,1) both; }
.chart rect:nth-child(-n+4) { animation-delay: .25s; }
.chart rect:nth-child(n+5):nth-child(-n+8) { animation-delay: .33s; }
.chart rect:nth-child(n+9):nth-child(-n+12) { animation-delay: .41s; }
.chart rect:nth-child(n+13) { animation-delay: .49s; }

/* 수평 분포바 */
.hbar .fill { transform-origin: left center; animation: fillx .55s cubic-bezier(.2,.7,.3,1) .3s both; }

/* 타임라인 */
.tl-item { animation: rise .4s ease-out both; animation-delay: .08s; }

/* 복원 플로우 */
.flow-stage { animation: rise .4s ease-out both; }
.flow-stage:nth-child(2) { animation-delay: .06s; }
.flow-stage:nth-child(3) { animation-delay: .12s; }
.flow-stage:nth-child(4) { animation-delay: .18s; }
.flow-stage:nth-child(5) { animation-delay: .24s; }

/* 관계 그래프: 엣지 그려지기 → 라벨 → 노드 */
svg > g:first-child .gedge:not([stroke-dasharray]) { stroke-dasharray: 500 500; animation: draw .7s ease-out forwards; }
svg .gedge[stroke-dasharray] { animation: fade .4s ease-out .8s both; }
svg .gedge-label { animation: fade .4s ease-out .55s both; }
svg > g.gnode { animation: fade .3s ease-out both; cursor: pointer; }
svg > g.gnode:nth-child(3) { animation-delay: .4s; }
svg > g.gnode:nth-child(4) { animation-delay: .46s; }
svg > g.gnode:nth-child(5) { animation-delay: .52s; }
svg > g.gnode:nth-child(6) { animation-delay: .58s; }
svg > g.gnode:nth-child(7) { animation-delay: .64s; }
svg > g.gnode:nth-child(8) { animation-delay: .7s; }
svg > g.gnode:nth-child(9) { animation-delay: .76s; }

/* 선택 노드: 점선 링 은은한 회전 + 노드 호버 */
circle[stroke-dasharray="4 4"] { animation: dash-spin 16s linear infinite; }
.gnode circle.bg { transition: transform .15s ease; transform-box: fill-box; transform-origin: center; }
.gnode:hover circle.bg { transform: scale(1.08); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
