:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --text: #1c2330;
  --muted: #6b7482;
  --border: #e2e5ea;
  --accent: #2458d6;
  --accent-soft: #e8eefc;
  --ok: #1f8a4c;
  --ok-soft: #e6f4ec;
  --bad: #c2362b;
  --bad-soft: #fbeceb;
  --warn-soft: #fff5e0;
  --bar: #6f8fe0;
  --bar-hot: #e0763a;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --surface: #1c2028; --surface-2: #232833; --text: #e6e9ee; --muted: #9aa3b0;
    --border: #2f3542; --accent: #7aa2ff; --accent-soft: #24304d; --ok: #5ccf8c; --ok-soft: #1d3326;
    --bad: #ff8278; --bad-soft: #3a2220; --warn-soft: #3a3120; --bar: #5e7fd0; --bar-hot: #e0864f;
  }
}
:root[data-theme="dark"] {
  --bg: #14171c; --surface: #1c2028; --surface-2: #232833; --text: #e6e9ee; --muted: #9aa3b0;
  --border: #2f3542; --accent: #7aa2ff; --accent-soft: #24304d; --ok: #5ccf8c; --ok-soft: #1d3326;
  --bad: #ff8278; --bad-soft: #3a2220; --warn-soft: #3a3120; --bar: #5e7fd0; --bar-hot: #e0864f;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Noto Sans KR", system-ui, sans-serif; font-size: 14px; line-height: 1.55;
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
.small { font-size: 12px; font-weight: 400; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.error { color: var(--bad); margin: 6px 0 0; min-height: 1em; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), var(--bar-hot)); flex: none; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.tag { font-size: 11px; font-weight: 500; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 99px; vertical-align: middle; }

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px;
  padding: 16px 24px 24px; align-items: start;
}
.workspace { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }

.row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 10px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.field.grow { flex: 1; min-width: 180px; }
select, input[type="date"], textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
.btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 8px; padding: 7px 14px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-ghost { background: transparent; }

.dropzone {
  border: 1.5px dashed var(--border); border-radius: 8px; padding: 12px; text-align: center;
  margin-bottom: 10px; cursor: pointer; background: var(--surface-2);
}
.dropzone p { margin: 0; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.hint { font-size: 12px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 12px 0 8px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 18px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; padding: 2px 9px; }
details summary { cursor: pointer; color: var(--accent); margin: 6px 0; }

.table-wrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; background: var(--surface-2); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
#cand-table tbody tr { cursor: pointer; }
#cand-table tbody tr:hover { background: var(--surface-2); }
#cand-table tr.selected { background: var(--accent-soft); }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; font-weight: 500; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.rec { background: var(--accent); color: #fff; }

.caps { display: grid; grid-template-columns: repeat(5, minmax(80px, 1fr)); gap: 8px; margin: 4px 0 10px; }
.caps label { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
input[type="number"] {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%;
}
.constraints-form .row { margin-bottom: 8px; }
.constraints-form .row .field { min-width: 170px; }
.chip.warn { background: var(--warn-soft); }
@media (max-width: 600px) { .caps { grid-template-columns: repeat(3, 1fr); } }

.rec { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.rec .stat .value { font-size: 17px; }
.rec-detail { margin-top: 10px; font-size: 13px; }
.basis { display: grid; grid-template-columns: 84px 1fr; gap: 3px 10px; margin: 10px 0 0; font-size: 12px; color: var(--muted); }
.basis dt { font-weight: 500; }
.basis dd { margin: 0; }
#cand-toggle { margin-top: 8px; font-size: 12.5px; }

.gantt { position: relative; }
.g-row { display: grid; grid-template-columns: 70px 1fr 150px; align-items: center; gap: 8px; margin: 5px 0; }
.g-name { font-size: 12.5px; }
.g-track { position: relative; height: 18px; background: var(--surface-2); border-radius: 4px; }
.g-bar { position: absolute; top: 2px; bottom: 2px; background: var(--bar); border-radius: 3px; }
.g-bar.hot { background: var(--bar-hot); }
.g-dates { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.g-line { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--bad); }
.g-axis { display: grid; grid-template-columns: 70px 1fr 150px; gap: 8px; font-size: 11.5px; color: var(--muted); }
.g-axis .ticks { position: relative; height: 16px; }
.g-axis .ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.g-legend { font-size: 12px; color: var(--muted); margin-top: 6px; }

.chat { position: sticky; top: 16px; display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 480px; }
.messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 10px; white-space: normal; word-break: keep-all; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; }
.msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); }
.msg.note { align-self: center; font-size: 12px; color: var(--muted); background: none; padding: 2px; }
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg ul { margin: 4px 0; padding-left: 18px; }
.steps { font-size: 12px; color: var(--muted); margin-bottom: 6px; border-left: 2px solid var(--border); padding-left: 8px; }
.steps summary { color: var(--muted); }
.step { margin: 2px 0; }
.step .ok { color: var(--ok); }
.step .bad { color: var(--bad); }
.step.check { color: #b7791f; }
.rec-inline { margin-top: 8px; font-size: 12.5px; background: var(--accent-soft); border-radius: 8px; padding: 7px 9px; }
.err-inline { background: var(--bad-soft); }
.meta { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.typing::after { content: "계산 중…"; color: var(--muted); font-size: 12.5px; }

.welcome p { color: var(--muted); margin: 0 0 8px; }
.examples { display: flex; flex-direction: column; gap: 6px; }
.examples button { text-align: left; font: inherit; font-size: 13px; cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 8px 10px; }
.examples button:hover { border-color: var(--accent); }

.composer { display: flex; gap: 8px; margin-top: 10px; }
.composer textarea { flex: 1; resize: none; }
.footnote { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; }
.topbar-actions { display: flex; gap: 8px; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .chat { position: static; height: 70vh; }
  .topbar { padding: 12px 16px; }
  .g-row, .g-axis { grid-template-columns: 56px 1fr 110px; }
}
