:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --ink: #1f2330;
  --muted: #6b7280;
  --line: #e7e9f0;
  --brand: #6366f1;
  --brand-d: #4f46e5;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(30, 35, 60, 0.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.55;
}
small { color: var(--muted); }
button { font-family: inherit; cursor: pointer; }

/* ---- 상단바 ---- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 26px; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; font-size: 11px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
}
.nav-btn:hover { background: #f0f1f7; color: var(--ink); }
.nav-btn.active { background: var(--brand); color: #fff; }
.local-badge {
  margin-left: auto; font-size: 12px; color: var(--ok);
  background: #ecfdf5; border: 1px solid #d1fae5; padding: 5px 10px; border-radius: 999px;
}

/* ---- 레이아웃 ---- */
.view { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.page-title { font-size: 22px; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 22px; font-size: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 820px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .nav-btn { padding: 8px 11px; }
}
.section-h { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---- 스탯 카드 ---- */
.stat { text-align: left; }
.stat .num { font-size: 30px; font-weight: 800; color: var(--brand-d); }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---- 버튼 ---- */
.btn {
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px;
}
.btn:hover { background: var(--brand-d); }
.btn.ghost { background: #fff; color: var(--brand-d); }
.btn.ghost:hover { background: #f0f1f7; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--bad); border-color: #fca5a5; }
.btn.danger:hover { background: #fef2f2; }

/* ---- 드롭존 ---- */
.dropzone {
  border: 2px dashed #c7cbe0; border-radius: var(--radius); background: #fafbff;
  padding: 38px 20px; text-align: center; color: var(--muted); transition: .15s;
}
.dropzone.drag { border-color: var(--brand); background: #eef0ff; color: var(--brand-d); }
.dropzone .big { font-size: 40px; }
.dropzone strong { color: var(--ink); }

/* ---- 진행 ---- */
.progress { margin-top: 14px; }
.progress .pr-item { font-size: 13px; padding: 4px 0; display: flex; gap: 8px; align-items: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.err { background: var(--bad); } .dot.run { background: var(--warn); }

/* ---- 테이블 ---- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tbl tr:hover td { background: #fafbff; }
.tbl .nm { font-weight: 600; cursor: pointer; color: var(--brand-d); }
.ttype { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.ttype.xlsx { background: #ecfdf5; color: #047857; }
.ttype.docx { background: #eff6ff; color: #1d4ed8; }
.ttype.pptx { background: #fff7ed; color: #c2410c; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; background: #f0f1f7; color: #4b5563; padding: 2px 8px; border-radius: 999px; }

/* ---- 검색/QA ---- */
.searchbar { display: flex; gap: 8px; margin-bottom: 18px; }
.searchbar input, .qa-input textarea, select.sel {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px;
  font-family: inherit; font-size: 14px; background: #fff;
}
select.sel { flex: none; }
.qa-input { display: flex; gap: 8px; align-items: flex-start; }
.qa-input textarea { resize: vertical; min-height: 48px; }
.answer { white-space: pre-wrap; background: #f8f9ff; border: 1px solid #e6e8fb; border-radius: 12px; padding: 16px; margin-top: 8px; }
.mode-badge { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.source { border-left: 3px solid var(--brand); padding: 8px 12px; margin: 8px 0; background: #fafbff; border-radius: 0 8px 8px 0; }
.source .src-meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.hit { padding: 12px 0; border-bottom: 1px solid var(--line); }
.hit .src-meta { font-size: 12px; color: var(--muted); }
.hl { background: #fff3bf; border-radius: 3px; }

/* ---- 차트 ---- */
.chart { width: 100%; height: auto; }
.chart .ax { font-size: 10px; fill: #9aa0b5; }
.chart-empty { color: var(--muted); text-align: center; padding: 40px 10px; font-size: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; font-size: 12px; color: #4b5563; }
.legend.col { flex-direction: column; gap: 6px; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend .lg i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .blab { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btrack { background: #f0f1f7; border-radius: 6px; height: 14px; overflow: hidden; }
.bfill { display: block; height: 100%; border-radius: 6px; }
.bsub { font-size: 12px; color: var(--muted); }
.heatwrap { overflow-x: auto; }
.heat { border-collapse: collapse; font-size: 11px; }
.heat th { color: var(--muted); font-weight: 600; padding: 3px 5px; white-space: nowrap; }
.heat th.hrow { text-align: right; position: sticky; left: 0; background: var(--card); }
.heat td { width: 30px; height: 22px; border: 1px solid #fff; border-radius: 3px; }
.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; }
.dctr { font-size: 22px; font-weight: 800; fill: var(--ink); }

/* ---- 모달 ---- */
.modal { position: fixed; inset: 0; background: rgba(20,22,35,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: var(--radius); max-width: 760px; width: 100%; max-height: 85vh; overflow: auto; padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-box h3 { margin-bottom: 6px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; font-size: 13.5px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.preview { background: #f8f9fb; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13px; max-height: 240px; overflow: auto; white-space: pre-wrap; }
.mini-tbl { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; }
.mini-tbl td, .mini-tbl th { border: 1px solid var(--line); padding: 4px 7px; }

/* ---- 토스트 ---- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast .t { background: #1f2330; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); opacity: 0; animation: tin .25s forwards; }
.toast .t.ok { background: #065f46; } .toast .t.err { background: #991b1b; }
@keyframes tin { to { opacity: 1; } }

.empty-state { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty-state .big { font-size: 46px; margin-bottom: 10px; }
.hero { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; border-radius: 18px; padding: 30px; margin-bottom: 22px; }
.hero h1 { font-size: 24px; margin-bottom: 8px; }
.hero p { opacity: .92; font-size: 14px; max-width: 640px; }
.quick { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.quick button { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.3); padding: 10px 16px; border-radius: 10px; font-weight: 600; }
.quick button:hover { background: rgba(255,255,255,.28); }
