:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1d2733;
  --ink-2: #4a5868;
  --muted: #8592a3;
  --line: #dfe4ea;
  --line-2: #eef1f5;
  --brand: #1f4e79;
  --brand-2: #2e75b6;
  --brand-soft: #e8f0f9;
  --accent: #ffc000;
  --ok: #2e8b57;
  --err: #c0392b;
  --grid: #e3e7ec;
  --cell-line: #9aa5b1;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .16);
  --font: "Pretendard", "Malgun Gothic", "맑은 고딕", -apple-system, "Segoe UI", sans-serif;
  --mono: "Cascadia Mono", Consolas, "D2Coding", monospace;
  --cell-font: Arial, "Malgun Gothic", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 13px/1.45 var(--font); display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; cursor: pointer; }
.muted { color: var(--muted); }

/* ── 상단 ── */
.top { flex: none; height: 56px; display: flex; align-items: center; gap: 20px; padding: 0 18px; background: var(--brand); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18); z-index: 20; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; white-space: nowrap; }
.brand b { font-weight: 700; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; }
.ver { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: rgba(255,255,255,.16); }
.search { position: relative; flex: 1; max-width: 720px; }
.search input { width: 100%; height: 38px; border: 0; border-radius: 8px; padding: 0 44px 0 38px; font: 14px var(--font); color: var(--ink); background: #fff; outline: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.05); }
.search input:focus { box-shadow: 0 0 0 3px rgba(255,192,0,.55); }
.search .ico { position: absolute; left: 11px; top: 10px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; }
.search kbd { position: absolute; right: 10px; top: 9px; font: 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; background: #fafbfc; }
.results { position: absolute; top: 44px; left: 0; right: 0; background: #fff; color: var(--ink); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 70vh; overflow: auto; padding: 6px; }
.res { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 7px; }
.res:hover, .res.sel { background: var(--brand-soft); }
.res .nm { font-weight: 600; font-size: 14px; }
.res .sub { font-size: 12px; color: var(--ink-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }
.res .acts { display: flex; gap: 6px; }
.res-empty { padding: 14px; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 4px; background: var(--line-2); color: var(--ink-2); }
.badge.dart { background: #e3f0ff; color: #1659a6; }
.badge.edgar { background: #fdeee4; color: #b4501a; }
.badge.db { background: #e2f4ea; color: #1f7a48; }
.badge.cat { background: #fff4d1; color: #8a6100; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 5px 11px; font-size: 12px; }
.btn:hover { border-color: var(--brand-2); color: var(--brand-2); }
.btn.pri { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.pri:hover { background: var(--brand); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.jobbtn { display: flex; align-items: center; gap: 8px; border: 0; background: rgba(255,255,255,.14); color: #fff; padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
.jobbtn.done .spin { border-color: #7ee2a8; animation: none; }
.jobbtn.err .spin { border-color: #ff9b8f; animation: none; }
.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 본문 ── */
.body { flex: 1; display: flex; min-height: 0; }
.side { flex: none; width: 250px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 8px; font-weight: 700; }
.filter { margin: 0 12px 8px; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 0 9px; font: 12px var(--font); outline: none; }
.filter:focus { border-color: var(--brand-2); }
.tree { flex: 1; overflow: auto; padding: 0 6px 16px; }
.cat { margin-top: 4px; }
.cat > summary { list-style: none; display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 6px; font-weight: 700; color: var(--ink-2); cursor: pointer; user-select: none; }
.cat > summary::-webkit-details-marker { display: none; }
.cat > summary::before { content: ""; width: 0; height: 0; border: 4px solid transparent; border-left: 5px solid var(--muted); transition: transform .15s; margin-right: 2px; }
.cat[open] > summary::before { transform: rotate(90deg) translateX(2px); }
.cat > summary:hover { background: var(--line-2); }
.cat .seq { font: 11px var(--mono); color: var(--muted); }
.cat .n { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--muted); }
.co { display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; border: 0; background: none; padding: 6px 8px 6px 24px; border-radius: 6px; color: var(--ink); }
.co:hover { background: var(--line-2); }
.co.sel { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.co .dots { margin-left: auto; display: flex; gap: 3px; }
.co .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.co .dot.on.fs { background: #2e75b6; }
.co .dot.on.note { background: #70ad47; }
.co .dot.on.ratio { background: #ffc000; }
.tree-empty { padding: 18px 14px; color: var(--muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.empty { flex: 1; display: grid; place-items: center; padding: 24px; }
.empty-card { text-align: center; background: var(--panel); border-radius: 14px; padding: 36px 44px; box-shadow: var(--shadow); max-width: 560px; }
.empty-card h2 { margin: 0 0 10px; font-size: 18px; }
#view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.co-head { display: flex; justify-content: space-between; align-items: flex-end; padding: 16px 20px 10px; background: var(--panel); }
.co-head h1 { margin: 0; font-size: 20px; }
.co-meta { margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-2); }
.tabs { display: flex; gap: 2px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tab { border: 0; background: none; padding: 9px 16px 10px; font-weight: 600; color: var(--ink-2); border-bottom: 3px solid transparent; display: flex; gap: 7px; align-items: center; }
.tab .c { font-size: 11px; font-weight: 400; color: var(--muted); }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand-2); }
.tab:disabled { opacity: .4; cursor: default; }
.subtabs { display: flex; gap: 6px; padding: 8px 16px 0; flex-wrap: wrap; }
.subtabs:empty { display: none; }
.stab { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 3px 11px; font-size: 12px; color: var(--ink-2); }
.stab.on { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.sheet-bar { display: flex; gap: 14px; align-items: center; padding: 8px 18px; font-size: 12px; }
.sheet-bar #sheetInfo { margin-right: auto; }
.tog { display: flex; gap: 5px; align-items: center; color: var(--ink-2); cursor: pointer; }
.sheet-wrap { flex: 1; overflow: auto; margin: 0 16px 16px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.sheet { position: relative; width: max-content; }

/* ── 시트 표 (Excel 모양) ── */
table.xl { border-collapse: collapse; table-layout: fixed; font: 12px/1.25 var(--cell-font); color: #000; }
table.xl td { height: 20px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: clip; border: 0; vertical-align: bottom; }
table.xl td.ov { overflow: visible; }
table.xl td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.xl td.rn { position: sticky; left: 0; z-index: 2; background: #f3f5f8; color: #8b96a3; text-align: center; font: 10.5px var(--mono); border-right: 1px solid var(--grid); padding: 0 2px; }
table.xl.norn td.rn, table.xl.norn col.rn { display: none; }
table.xl td.lnk { color: #1f5fbf; text-decoration: underline; cursor: pointer; }
table.xl td.err { color: var(--err); }
table.xl td.f { cursor: help; }
table.xl tr:hover td:not(.rn) { box-shadow: inset 0 0 0 9999px rgba(46, 117, 182, .045); }
.chart-box { position: absolute; background: #fff; border: 1px solid #d9d9d9; border-radius: 2px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.chart-box svg { display: block; }
.hide-charts .chart-box { display: none; }

/* ── 로그 서랍 ── */
.drawer { position: fixed; right: 18px; bottom: 18px; width: min(620px, calc(100vw - 36px)); max-height: 56vh; display: flex; flex-direction: column; background: #101820; color: #d6e1ea; border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 40; overflow: hidden; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #17222d; }
.steps { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.step { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #243341; color: #8ea2b3; }
.step.on { background: var(--accent); color: #2b2100; font-weight: 700; }
.step.ok { background: #1f5139; color: #9be3bd; }
.x { border: 0; background: none; color: #8ea2b3; font-size: 20px; line-height: 1; padding: 0 4px; }
.log { margin: 0; padding: 10px 14px; overflow: auto; font: 11.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-all; flex: 1; }
.log .w { color: #ffd479; } .log .e { color: #ff9b8f; } .log .s { color: #8fd3ff; font-weight: 700; }

.tip { position: fixed; z-index: 50; max-width: 520px; background: #1d2733; color: #fff; font: 11.5px/1.45 var(--mono); padding: 6px 9px; border-radius: 6px; pointer-events: none; white-space: pre-wrap; word-break: break-all; box-shadow: var(--shadow-lg); }

@media (max-width: 760px) {
  .top { gap: 10px; padding: 0 10px; }
  .brand span:not(.logo) { display: none; }
  .side { width: 180px; }
  .search kbd { display: none; }
}

/* ═══════ facts HTML 화면 (하이브2) ═══════ */
.vtag { margin-left: 6px; font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 4px; background: #e8f0f9; color: var(--brand-2); letter-spacing: .02em; }
.vtag.big { font-size: 11px; vertical-align: middle; padding: 2px 7px; }
.co.virt { padding-left: 34px; }
.fv { flex: 1; overflow: auto; padding: 16px 20px 28px; }
.fv-load { padding: 40px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); }
.k-l { font-size: 12px; color: var(--ink-2); }
.k-v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.k-v.neg { color: var(--err); }
.k-s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.fcard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px 16px; margin-bottom: 14px; min-width: 0; }
.fcard > header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.fcard h3 { margin: 0; font-size: 15px; margin-right: auto; }
.fcard h4 { margin: 4px 0 6px; font-size: 13px; color: var(--ink-2); }
.fsub { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.fcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); gap: 14px; }
.fcols > .fcard { margin-bottom: 0; }
.fcols + .fcard, .fcols { margin-bottom: 14px; }
.fgrid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 12px; }
.fgrid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-top: 12px; }
.fsplit { display: grid; grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); gap: 16px; align-items: center; margin-bottom: 12px; }
.fc { overflow: hidden; border: 1px solid var(--line-2); border-radius: 8px; }
.fc svg { width: 100%; height: auto; display: block; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 4px 11px; font-size: 12px; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand-2); color: #fff; }
.mix-bar { display: flex; height: 16px; border-radius: 5px; overflow: hidden; background: var(--line-2); }
.mix-bar i { display: block; height: 100%; }
.mix ul { list-style: none; margin: 10px 0 6px; padding: 0; display: grid; gap: 4px; font-size: 12.5px; }
.mix li { display: flex; align-items: center; gap: 7px; }
.mix li b { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.mix li span { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.tw { overflow-x: auto; border: 1px solid var(--line-2); border-radius: 8px; }
table.ft { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.ft th, table.ft td { padding: 5px 9px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-2); }
table.ft thead th { background: #f6f8fb; color: var(--ink-2); font-weight: 600; position: sticky; top: 0; z-index: 1; }
table.ft thead th.yr { border-bottom: 1px solid var(--line); text-align: center; }
table.ft thead th a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
table.ft thead th a:hover { color: var(--brand-2); }
table.ft th.lb { text-align: left; position: sticky; left: 0; background: #fff; z-index: 2; min-width: 120px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; color: var(--ink); }
table.ft thead th.lb { background: #f6f8fb; z-index: 3; }
table.ft th.lb small { margin-left: 5px; color: var(--muted); font-weight: 400; font-size: 10.5px; }
table.ft tbody tr:hover td, table.ft tbody tr:hover th.lb { background: #f5f9fe; }
table.ft tr.tot th, table.ft tr.tot td { font-weight: 700; border-top: 1px solid var(--line); background: #fbfcfd; }
table.ft tr.grp td { text-align: left; font-weight: 700; color: var(--brand); background: #f3f7fc; position: sticky; left: 0; }
table.ft td.neg { color: var(--err); }
table.ft td.up { color: #1f7a48; background: rgba(46, 139, 87, .07); }
table.ft td.dn { color: var(--err); background: rgba(192, 57, 43, .06); }
table.ft td.sp, table.ft th.sp { text-align: center; padding: 2px 8px; }
.spark { display: block; margin: 0 auto; }
.mhead, .mrow { display: grid; grid-template-columns: minmax(0, 1.6fr) 90px 22px 80px 120px; gap: 8px; align-items: center; }
.mhead { font-size: 11px; color: var(--muted); padding: 0 2px 6px; border-bottom: 1px solid var(--line); }
.mhead span:nth-child(n+2) { text-align: right; }
.mrow { padding: 6px 2px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.m-n { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-v { text-align: right; font-weight: 700; font-size: 14px; }
.m-v small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.m-v.neg { color: var(--err); }
.m-d { text-align: center; font-size: 11px; color: var(--muted); }
.m-d.up { color: #1f7a48; } .m-d.dn { color: var(--err); }
.m-a { text-align: right; color: var(--ink-2); font-size: 12px; }
@media (max-width: 900px) { .fsplit { grid-template-columns: 1fr; } .fcols { grid-template-columns: 1fr; } }
