:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e3e6ea;
  --ink: #1f2933;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --sell: #0f9d58;
  --buy: #d9534f;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
.topbar {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); padding: 0 20px; height: 56px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab {
  padding: 8px 16px; border-radius: 8px 8px 0 0; cursor: pointer;
  border: none; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.tab.active { background: var(--bg); color: var(--brand-ink); }
.icon-btn { border: 1px solid var(--line); background: var(--card); padding: 7px 12px; border-radius: 8px; cursor: pointer; }

.container { max-width: 1180px; margin: 0 auto; padding: 20px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 16px;
}
.period { display: flex; align-items: center; gap: 8px; }
.period label { color: var(--muted); font-weight: 600; }
.search { flex: 1; min-width: 160px; }
.search input { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

input, select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--ink);
}
button { font-size: 14px; cursor: pointer; border-radius: 8px; padding: 8px 14px; border: 1px solid transparent; font-weight: 600; }
button.primary { background: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-ink); }
button.secondary { background: #eef2ff; color: var(--brand-ink); }
button.ghost { background: var(--card); border: 1px solid var(--line); color: var(--ink); }
button.ghost:hover { background: #f0f2f5; }

/* 요약 카드 */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.sum-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.sum-card .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.sum-card .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.sum-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.sum-card.sell .value { color: var(--sell); }
.sum-card.buy .value { color: var(--buy); }
.sum-card.profit .value.pos { color: var(--sell); }
.sum-card.profit .value.neg { color: var(--buy); }

/* 표 */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.tx-table { width: 100%; border-collapse: collapse; }
.tx-table th, .tx-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tx-table th { background: #fafbfc; color: var(--muted); font-size: 12px; font-weight: 700; }
.tx-table td.num, .tx-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tx-table tbody tr:hover { background: #f7f9fc; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.sell { background: #e6f4ea; color: var(--sell); }
.badge.buy { background: #fdecea; color: var(--buy); }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 4px 8px; font-size: 12px; }
.link-btn { color: var(--brand); background: none; border: none; text-decoration: underline; padding: 0; cursor: pointer; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* 모달 */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; width: 640px; max-width: 100%; padding: 22px 24px; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal h3 { margin: 0 0 16px; }
.modal h4 { margin: 0 0 8px; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label, .map-grid label, .modal label.full { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.form-grid label input, .form-grid label select, .map-grid label select, .modal label.full input, .modal label.full select { font-weight: 400; color: var(--ink); }
.form-grid label.wide { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.setting-block { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.setting-block:last-of-type { border-bottom: none; }
.modal label.full { margin-bottom: 10px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }
.hint a { color: var(--brand); }

.extract-status { padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.extract-status.loading { background: #eff6ff; color: var(--brand-ink); }
.extract-status.done { background: #e6f4ea; color: var(--sell); }
.extract-status.error { background: #fdecea; color: var(--buy); }

.receipt-preview { margin-top: 14px; }
.receipt-preview img { max-width: 100%; max-height: 280px; border-radius: 8px; border: 1px solid var(--line); }
.receipt-preview embed { width: 100%; height: 360px; border-radius: 8px; border: 1px solid var(--line); }

.company-row { display: grid; grid-template-columns: 2fr 1.3fr 1fr; gap: 8px; margin-bottom: 8px; }
.company-row input { font-size: 13px; }
.user-list { margin: 10px 0; }
.user-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; font-size: 14px; }
.user-row button { padding: 4px 10px; font-size: 12px; color: var(--buy); }

.map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.csv-preview { font-size: 12px; overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.csv-preview table { border-collapse: collapse; width: 100%; }
.csv-preview td { padding: 6px 8px; border: 1px solid var(--line); white-space: nowrap; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #1f2933; color: #fff; padding: 12px 20px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow); font-weight: 600; }

/* ===== 통합 대시보드 셸 ===== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #111827; color: #e5e7eb; display: flex; flex-direction: column;
  padding: 14px 10px; position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.logo { font-weight: 700; font-size: 16px; padding: 8px 10px 16px; color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; color: #cbd5e1; border: none; padding: 10px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.nav-item span { flex: 1; }
.nav-item:hover { background: #1f2937; color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-sep { font-size: 11px; color: #6b7280; padding: 14px 12px 6px; font-weight: 700; letter-spacing: .5px; }
.nav-item.settings { margin-top: 8px; border-top: 1px solid #1f2937; border-radius: 0; padding-top: 14px; }

.content { flex: 1; min-width: 0; padding: 20px 28px; max-width: 1240px; }
.content-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.content-head h1 { font-size: 22px; margin: 0; }
.company-select { display: flex; gap: 6px; flex-wrap: wrap; }
.company-select .tab {
  padding: 7px 14px; border-radius: 8px; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 13px; font-weight: 600;
}
.company-select .tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.view-desc { color: var(--muted); margin: 0 0 16px; }

/* 대시보드 카드 */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.dash-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); }
.dash-card h3 { margin: 0 0 4px; font-size: 16px; }
.dash-card .biztype { color: var(--muted); font-size: 12px; margin-bottom: 14px; }
.dash-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.metric { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.metric .m-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.metric .m-value { font-size: 18px; font-weight: 700; margin-top: 2px; }
.metric .m-value.sell { color: var(--sell); }
.metric .m-value.buy { color: var(--buy); }
.metric .m-value.pos { color: var(--sell); }
.metric .m-value.neg { color: var(--buy); }
.dash-okr { border-top: 1px solid var(--line); padding-top: 12px; }
.dash-okr .o-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: var(--ink); }
.dash-okr .o-empty { font-size: 12px; color: var(--muted); }

/* 진척 막대 */
.bar { height: 8px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.bar.ok > span { background: var(--sell); }
.bar.warn > span { background: #e0a106; }
.bar.bad > span { background: var(--buy); }

/* OKR 모듈 */
.okr-toolbar { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.okr-toolbar label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
.okr-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
.okr-panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 16px; }
button.sm { padding: 6px 12px; font-size: 13px; }

.okr-item { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.okr-item .obj { font-weight: 700; margin-bottom: 4px; }
.okr-item .obj-prog { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.okr-item .obj-prog .pct { font-size: 13px; font-weight: 700; color: var(--brand-ink); white-space: nowrap; }
.kr { margin: 8px 0; }
.kr .kr-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.kr .kr-val { color: var(--muted); font-variant-numeric: tabular-nums; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; }
.item-actions button { padding: 4px 10px; font-size: 12px; }

.kpi-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.kpi-item .k-top { display: flex; justify-content: space-between; align-items: baseline; }
.kpi-item .k-name { font-weight: 700; }
.kpi-item .k-pct { font-weight: 700; }
.kpi-item .k-val { font-size: 12px; color: var(--muted); margin: 4px 0 8px; font-variant-numeric: tabular-nums; }

.kr-head { font-size: 13px; font-weight: 700; margin: 16px 0 8px; }
.kr-row { display: grid; grid-template-columns: 2fr 1fr 1fr 0.8fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.kr-row input { font-size: 13px; }
.kr-row .kr-del { padding: 6px 10px; background: #fdecea; color: var(--buy); border: none; border-radius: 8px; }

.scaffold { text-align: center; padding: 60px 20px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 14px; }
.scaffold-icon { font-size: 48px; }
.scaffold h2 { color: var(--ink); margin: 12px 0 8px; }
.scaffold-hint { font-size: 13px; margin-top: 10px; }

/* JMC GROUP 추가 */
.summary.big { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 20px; }
.sum-card.profit .value { color: var(--ink); }
.dash-card.link { cursor: pointer; transition: box-shadow .12s, transform .12s; }
.dash-card.link:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); transform: translateY(-1px); }
.dash-card h3 .code, .biztype .code, .entity-h .code, .panel-head .code { font-size: 11px; background: #eef2ff; color: var(--brand-ink); padding: 1px 7px; border-radius: 6px; font-weight: 700; vertical-align: middle; }
.dash-metrics.big { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.sec-h { font-size: 15px; margin: 22px 0 10px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.total-row td { background: #fafbfc; border-top: 2px solid var(--line); }
.tx-table td.num.neg { color: var(--buy); }
.tx-table td.num.pos { color: var(--sell); }

.entity-group { margin-bottom: 22px; }
.entity-h { font-size: 15px; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.okr-item .owner { font-size: 12px; color: var(--muted); font-weight: 600; }
.okr-cols-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }

.st { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.st-wait { background: #f1f3f5; color: #6b7280; }
.st-go { background: #e6f0ff; color: var(--brand-ink); }
.st-check { background: #fff6e0; color: #a16207; }
.st-done { background: #e6f4ea; color: var(--sell); }
.st-late { background: #fdecea; color: var(--buy); }

.dec-list { margin: 8px 0 14px; padding-left: 22px; }
.dec-list li { margin: 4px 0; line-height: 1.5; }

/* 대출 카드 + 진행 파이프라인 */
.loan-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.loan-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.loan-name { font-weight: 700; font-size: 15px; }
.loan-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.loan-amt { text-align: right; white-space: nowrap; }
.la-target { font-size: 18px; font-weight: 700; }
.la-exp { font-size: 12px; color: var(--sell); }
.loan-docs { font-size: 12px; color: var(--muted); margin-top: 12px; }
.pipeline { display: flex; align-items: center; }
.pstep { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.pdot { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; background: #eef0f3; color: var(--muted); border: 2px solid #eef0f3; }
.plabel { font-size: 11px; color: var(--muted); font-weight: 600; }
.pstep.done .pdot { background: var(--sell); border-color: var(--sell); color: #fff; }
.pstep.cur .pdot { background: #fff; border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.pstep.cur .plabel, .pstep.done .plabel { color: var(--ink); }
.pline { flex: 1; height: 2px; background: #e3e6ea; margin: 0 2px 18px; }
.pstep.done + .pline { background: var(--sell); }

/* 수익률 계산기 */
.calc { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); align-items: center; }
.calc-inputs { display: flex; flex-direction: column; gap: 10px; }
.calc-inputs label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.calc-out { display: flex; flex-direction: column; gap: 10px; }
.co-item { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.co-l { font-size: 13px; color: var(--muted); font-weight: 600; }
.co-v { font-size: 20px; font-weight: 700; }
.co-v.pos { color: var(--sell); }
.co-v.neg { color: var(--buy); }

@media (max-width: 700px) {
  .calc { grid-template-columns: 1fr; }
  .plabel { display: none; }
}

@media (max-width: 900px) {
  .okr-cols { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
  .sidebar { width: 60px; }
  .logo { font-size: 0; padding: 8px; }
  .nav-item span, .nav-sep { display: none; }
  .content { padding: 16px; }
}
