/* 단타 스캐너 내부 검증 대시보드 — 디자인 시스템
   읽기 전용 SPA. 색/간격/타이포 토큰을 한곳에 모아 시안과 동일한 룩을 유지한다. */

:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e9edf4;
  --line-2: #eef1f7;

  --indigo: #4f46e5;
  --indigo-2: #6366f1;
  --indigo-soft: #eef2ff;
  --blue: #3b82f6;
  --green: #10b981;
  --green-soft: #dcfce7;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --red: #f43f5e;
  --red-soft: #ffe4e6;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.10);

  --sidebar-w: 248px;
  --font: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- 상단 네비게이션 ---------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 22px;
  height: 62px; padding: 0 26px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-2));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}
.brand .logo svg { width: 18px; height: 18px; }
.brand .name { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }

.topnav { display: flex; align-items: center; gap: 2px; flex: 1; }
.nav-sep { width: 1px; height: 20px; background: var(--line); margin: 0 9px; flex: none; }
.nav-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 13px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 13.5px;
  border: none; background: transparent; white-space: nowrap;
  transition: background .12s, color .12s;
}
.nav-item .ic-svg { width: 16px; height: 16px; }
.nav-item:hover { background: #f5f6fa; color: var(--ink-2); }
.nav-item.active { background: var(--indigo-soft); color: var(--indigo); }

.navright { display: flex; align-items: center; gap: 16px; flex: none; }
.switch-mini { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; padding-left: 38px; user-select: none; }
.switch-mini input { display: none; }
.switch-mini .track { position: absolute; left: 0; width: 32px; height: 18px; background: #cbd5e1; border-radius: 999px; transition: background .15s; }
.switch-mini .thumb { position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch-mini input:checked ~ .track { background: var(--indigo); }
.switch-mini input:checked ~ .thumb { transform: translateX(14px); }
.switch-mini .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.db-dot { display: inline-flex; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

/* ---------- 메인 / 페이지 헤더 ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: calc(100vh - 62px); }
.pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px 16px;
}
.pagetitle h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pagetitle h1 .info {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--muted-2);
  color: var(--muted-2);
  font-size: 10px;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
}
.pagetitle .sub { color: var(--muted); margin-top: 5px; font-size: 13.5px; }
.ic-svg { width: 16px; height: 16px; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  display: grid; place-items: center;
}
.iconbtn:hover { background: #f6f7fb; }
.iconbtn svg { width: 17px; height: 17px; }
.rofoot { margin-top: auto; padding: 18px 28px 24px; color: var(--muted-2); font-size: 12px; border-top: 1px solid var(--line-2); }
.rofoot #dbUrl { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; }

.controls { display: flex; align-items: center; gap: 10px; flex: none; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 13px;
  width: 280px;
  color: var(--muted-2);
}
.search input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  width: 100%;
  color: var(--ink);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 13px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
}
.pill.green { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }
.pill.amber { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.pill.slate { color: var(--ink-2); border-color: var(--line); background: #f8fafc; }
.updated { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.datepill {
  font-family: inherit;
  color: var(--ink-2);
  outline: none;
  cursor: pointer;
}
.datepill:focus { border-color: var(--indigo-2); box-shadow: 0 0 0 3px var(--indigo-soft); }
.pager .pg:not(.active):not(.ghost):hover { background: #f1f5f9; cursor: pointer; }
.pager .pg.ghost { cursor: pointer; }
.pager .pg.disabled { opacity: 0.4; pointer-events: none; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 11px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
}
.btn:hover { background: #f6f7fb; }
.btn.primary { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.btn.primary:hover { background: #4338ca; }
.avatar {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #1e293b, #475569);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
}

.content { padding: 4px 28px 12px; }

/* ---------- 그리드/카드 ---------- */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(6, 1fr); }
.kpis-5 { grid-template-columns: repeat(5, 1fr); }
.kpis-4 { grid-template-columns: repeat(4, 1fr); }
.kpis-3 { grid-template-columns: repeat(3, 1fr); }
.cols-3 { grid-template-columns: 1.1fr 1fr 1.1fr; }
.cols-even-3 { grid-template-columns: 1fr 1fr 1fr; }
.cols-detail { grid-template-columns: 1fr 372px; align-items: start; }
.cols-review { grid-template-columns: 1fr 1.4fr; }
.detail-col { position: sticky; top: 16px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.pad { padding: 18px; }

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 17px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi .head { display: flex; align-items: center; gap: 9px; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.kpi .head .ic {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; flex: none;
  background: var(--indigo-soft); color: var(--indigo);
}
.kpi .head .ic.green { background: var(--green-soft); color: #059669; }
.kpi .head .ic.amber { background: var(--amber-soft); color: #b45309; }
.kpi .head .ic.blue { background: #dbeafe; color: #2563eb; }
.kpi .head .ic.slate { background: #e2e8f0; color: #475569; }
.kpi .val { font-size: 23px; font-weight: 800; letter-spacing: -0.03em; margin-top: 11px; color: var(--ink); }
.kpi .val.sm { font-size: 18px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.kpi .sub .up { color: var(--green); font-weight: 700; }
.kpi .sub .down { color: var(--red); font-weight: 700; }
.kpi .legend-mini { display: flex; flex-direction: column; gap: 3px; margin-top: 9px; font-size: 11.5px; }
.kpi .legend-mini .ln { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.kpi .legend-mini .ln b { color: var(--ink-2); margin-left: auto; font-weight: 700; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
}
.section-title h3 { margin: 0; font-size: 15.5px; font-weight: 800; letter-spacing: -0.02em; }
.section-title h3 .muted { color: var(--muted-2); font-weight: 600; font-size: 12.5px; margin-left: 6px; }
.section-title .link { color: var(--indigo); font-weight: 700; font-size: 12.5px; }
.section-title .link.btnlike { border: 1px solid var(--line); padding: 6px 11px; border-radius: 9px; background: #fff; }

/* ---------- 표 ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 12px; border-bottom: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr.clickable { cursor: pointer; }
table.tbl tr.clickable:hover { background: #f8fafc; }
table.tbl tr.selected { background: var(--indigo-soft); }
table.tbl tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--indigo); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.t-strong { color: var(--ink); font-weight: 700; }

/* ---------- 배지 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.6;
}
.badge.green { background: var(--green-soft); color: #047857; }
.badge.amber { background: var(--amber-soft); color: #b45309; }
.badge.red { background: var(--red-soft); color: #be123c; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.indigo { background: var(--indigo-soft); color: var(--indigo); }
.badge.slate { background: #eef1f7; color: #475569; }
.badge.outline { background: #fff; border: 1px solid var(--line); color: var(--muted); }

.score-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 8px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.score-pill.hi { background: var(--green-soft); color: #047857; }
.score-pill.mid { background: var(--amber-soft); color: #b45309; }
.score-pill.lo { background: #f1f5f9; color: #64748b; }

.star { color: #f59e0b; }
.star.off { color: #cbd5e1; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { background: #f1f5f9; color: #475569; border-radius: 7px; padding: 2px 8px; font-size: 11px; font-weight: 600; }

.cell-reason { white-space: normal; max-width: 280px; color: var(--muted); line-height: 1.4; font-size: 12.5px; }

/* 표 안 누적 막대 */
.stack { display: flex; height: 20px; border-radius: 6px; overflow: hidden; min-width: 240px; }
.stack span { display: grid; place-items: center; font-size: 10.5px; font-weight: 700; color: #fff; }
.stack .s-green { background: #34d399; }
.stack .s-amber { background: #fbbf24; color: #7c2d12; }
.stack .s-red { background: #fb7185; }

/* ---------- 차트 ---------- */
.chart-legend { display: flex; flex-direction: column; gap: 12px; }
.chart-legend .ln { display: flex; align-items: flex-start; gap: 9px; }
.chart-legend .sw { width: 11px; height: 11px; border-radius: 3px; margin-top: 3px; flex: none; }
.chart-legend .ln .t { font-size: 12.5px; color: var(--muted); }
.chart-legend .ln .t b { display: block; color: var(--ink); font-size: 13.5px; font-weight: 700; }

.bars { display: flex; flex-direction: column; gap: 13px; }
.bars .row { display: grid; grid-template-columns: 70px 1fr 70px; align-items: center; gap: 12px; }
.bars .row .lab { font-size: 12.5px; color: var(--muted); }
.bars .row .track { background: #eef2f8; border-radius: 6px; height: 9px; overflow: hidden; }
.bars .row .fill { height: 100%; border-radius: 6px; background: var(--blue); }
.bars .row .v { font-size: 12.5px; color: var(--ink-2); font-weight: 700; text-align: right; }

/* ---------- 종목 상세 패널 ---------- */
.detail { display: flex; flex-direction: column; gap: 16px; }
.detail .dh { display: flex; align-items: center; gap: 8px; }
.detail .price { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
.detail .chg { font-weight: 700; }
.detail .chg.up { color: var(--green); }
.detail .chg.down { color: var(--red); }
.detail .metrics3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.detail .metrics3 .m { background: #f8fafc; border-radius: 10px; padding: 10px; }
.detail .metrics3 .m .k { font-size: 11px; color: var(--muted); }
.detail .metrics3 .m .v { font-size: 13.5px; font-weight: 700; margin-top: 3px; }
.chart-tabs { display: flex; gap: 6px; }
.chart-tabs .ct { padding: 4px 11px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); background: #fff; }
.chart-tabs .ct.active { background: var(--indigo-soft); color: var(--indigo); border-color: transparent; }

.checklist { display: flex; flex-direction: column; gap: 11px; }
.checklist .ck { display: flex; gap: 10px; }
.checklist .ck .mk { color: var(--green); flex: none; margin-top: 1px; }
.checklist .ck .tx b { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.checklist .ck .tx span { font-size: 12px; color: var(--muted); }

.risk-note {
  display: flex; gap: 9px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 11px;
  padding: 12px;
  font-size: 12.5px;
  color: #9a3412;
  line-height: 1.5;
}

/* ---------- 페이지네이션 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px 2px; }
.pager .info { font-size: 12.5px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; }
.pager .pg { min-width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 12.5px; font-weight: 600; display: grid; place-items: center; padding: 0 8px; }
.pager .pg.active { background: var(--indigo); color: #fff; border-color: var(--indigo); }
.pager .pg.ghost { border: none; background: transparent; color: var(--muted-2); }

/* ---------- 필터 바 ---------- */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.selectish { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.selectish .k { color: var(--muted); font-weight: 600; }
.selectish select { border: none; background: transparent; font-weight: 600; outline: none; color: var(--ink-2); font-family: inherit; }
.selectish input[type="date"] { border: none; background: transparent; font-weight: 600; outline: none; color: var(--ink-2); font-family: inherit; cursor: pointer; }

/* ---------- 빈 상태 ---------- */
.empty { text-align: center; color: var(--muted); padding: 44px 18px; }
.empty .ic { font-size: 30px; opacity: 0.5; }
.empty .t { font-weight: 700; color: var(--ink-2); margin-top: 10px; }
.empty .d { font-size: 12.5px; margin-top: 5px; }

/* ---------- 폼 (백테스트) ---------- */
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--indigo-2); box-shadow: 0 0 0 3px var(--indigo-soft); }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric { background: #f8fafc; border-radius: 12px; padding: 14px; }
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 21px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }

.notes { color: var(--muted); font-size: 12.5px; margin-top: 14px; }

.loading { padding: 40px; text-align: center; color: var(--muted-2); }

.mb16 { margin-bottom: 16px; }
.mb20 { margin-bottom: 20px; }

/* ==================== 반응형 (PC / 태블릿 / 모바일) ==================== */

/* 태블릿 (≤ 1100px): KPI 다열 축소, 2단 레이아웃을 1단으로 적층 */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpis-5, .kpis-4 { grid-template-columns: repeat(2, 1fr); }
  .kpis-3 { grid-template-columns: repeat(3, 1fr); }
  .cols-3, .cols-even-3, .cols-detail, .cols-review { grid-template-columns: 1fr; }
  .detail-col { position: static; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .search { width: 220px; }
}

/* 모바일 (≤ 680px): 상단 네비 아이콘만, 헤더 적층, 표 가로 스크롤 */
@media (max-width: 680px) {
  .navbar { gap: 10px; padding: 0 14px; height: 56px; }
  .brand .name { display: none; }
  .topnav { overflow-x: auto; scrollbar-width: none; gap: 0; }
  .topnav::-webkit-scrollbar { display: none; }
  .nav-item > span { display: none; }      /* 텍스트 숨김 → 아이콘 전용 */
  .nav-item { padding: 8px 9px; }
  .nav-sep { display: none; }
  .navright { gap: 10px; }
  .switch-mini .lbl { display: none; }

  .pagehead { flex-direction: column; align-items: stretch; padding: 16px 14px 12px; gap: 12px; }
  .pagetitle h1 { font-size: 21px; }
  .controls { flex-wrap: wrap; gap: 8px; }
  .search { width: 100%; order: -1; }
  .content { padding: 4px 14px 12px; }

  .kpis, .kpis-5, .kpis-4, .kpis-3 { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .metric-grid { grid-template-columns: 1fr 1fr; }
  .filterbar { gap: 8px; }
  .card.pad { padding: 14px; }

  /* 넓은 표는 카드 안에서 가로 스크롤 */
  .card { overflow-x: auto; }
  table.tbl { min-width: 560px; }
  .rofoot { padding: 16px 14px 22px; }
}

/* 소형 모바일 (≤ 430px): KPI 1열 */
@media (max-width: 430px) {
  .kpis, .kpis-5, .kpis-4, .kpis-3,
  .form-grid, .metric-grid { grid-template-columns: 1fr; }
  .pagetitle h1 { font-size: 19px; }
}
