:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --text: #121a27;
  --muted: #5b687c;
  --border: #dfe4ec;
  --accent: #1d5bd8;
  --accent-soft: #e6eeff;
  --teal: #0f9f8f;
  --amber: #d98a1c;
  --danger: #cf3f3f;
  --grade-a: #11905a;
  --grade-b: #1d5bd8;
  --grade-c: #c98a12;
  --grade-d: #7d8799;
  --grade-x: #a4acba;
  --radar-bg: #0b1628;
  --radar-grid: rgba(52, 209, 191, 0.22);
  --radar-text: #9fb3cc;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c111a;
    --surface: #141b27;
    --surface-2: #1b2433;
    --text: #e6ebf3;
    --muted: #93a0b4;
    --border: #273246;
    --accent: #6d9bff;
    --accent-soft: #1d2a45;
    --grade-a: #3cc98b;
    --grade-b: #6d9bff;
    --grade-c: #e7b74c;
    --grade-d: #8d97a8;
    --grade-x: #5d6778;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c111a;
  --surface: #141b27;
  --surface-2: #1b2433;
  --text: #e6ebf3;
  --muted: #93a0b4;
  --border: #273246;
  --accent: #6d9bff;
  --accent-soft: #1d2a45;
  --grade-a: #3cc98b;
  --grade-b: #6d9bff;
  --grade-c: #e7b74c;
  --grade-d: #8d97a8;
  --grade-x: #5d6778;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3 { margin: 0; line-height: 1.3; }
h2 { font-size: 17px; font-weight: 700; }
p { margin: 0; }

.muted { color: var(--muted); }

/* ---------- 상단 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; }
.brand strong { display: block; font-size: 17px; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 12px; color: var(--muted); }

.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }

.pill {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.pill:empty { display: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }

.banner {
  margin: 16px 28px 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--border));
  background: color-mix(in srgb, var(--amber) 10%, var(--surface));
  font-size: 14px;
}

main { padding: 20px 28px 8px; max-width: 1440px; margin: 0 auto; }

.tab-panel { display: grid; gap: 18px; }
.tab-panel[hidden] { display: none; }

/* ---------- 공통 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: 0.55; cursor: progress; }

.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.field.grow { flex: 1 1 220px; }
.field input, .field select, .field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  width: 100%;
}
.field textarea { resize: vertical; min-height: 64px; }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }

/* ---------- 툴바·KPI ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- 레이더 ---------- */
.radar-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; }
.side { display: grid; gap: 18px; align-content: start; }

.radar-card { background: var(--radar-bg); border-color: #1a2a44; color: #e6ebf3; }
.radar-card .card-head p { color: var(--radar-text); }
.radar { width: 100%; max-width: 560px; margin: 0 auto; aspect-ratio: 1; }
.radar-loading { color: var(--radar-text); height: 100%; align-items: center; }
.radar svg { width: 100%; height: 100%; display: block; overflow: visible; }
.radar .dot { cursor: pointer; transition: r 0.15s ease, opacity 0.15s ease; }
.radar .dot:hover, .radar .dot:focus { stroke: #fff; stroke-width: 2; outline: none; }
.radar .sweep { transform-origin: 0 0; animation: sweep 6s linear infinite; }
@keyframes sweep { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .radar .sweep { animation: none; opacity: 0; } }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--radar-text); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }

.radar-tip {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0f1e36;
  border: 1px solid #2b4163;
  color: #e6ebf3;
  font-size: 12px;
  line-height: 1.45;
}

.deadlines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.deadlines li button {
  width: 100%;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.deadlines li button:hover { border-color: var(--accent); }
.deadlines li button > span:last-child { min-width: 0; }
.deadlines .dday { font-weight: 800; color: var(--danger); font-variant-numeric: tabular-nums; }
.deadlines .t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deadlines .a { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 64px; gap: 10px; align-items: center; font-size: 13px; width: 100%; }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-row .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 목록 ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: var(--text); }

.bid-list { display: grid; gap: 8px; }
.bid-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 150px 88px 36px;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.bid-row:hover { border-color: var(--accent); }
.bid-row.excluded { opacity: 0.6; }

.score-badge {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  color: #fff;
  font-weight: 800;
  line-height: 1.05;
}
.score-badge b { font-size: 18px; font-variant-numeric: tabular-nums; }
.score-badge span { font-size: 10px; opacity: 0.9; }
.g-A { background: var(--grade-a); }
.g-B { background: var(--grade-b); }
.g-C { background: var(--grade-c); }
.g-D { background: var(--grade-d); }
.g-X { background: var(--grade-x); }

.bid-main { min-width: 0; }
.bid-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bid-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.tag i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bid-amount { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.bid-dday { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.bid-dday.urgent { color: var(--danger); }
.star { font-size: 18px; color: var(--muted); text-align: center; }
.star.on { color: var(--amber); }

/* ---------- 서랍 ---------- */
.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer[hidden] { display: none; }
.drawer-scrim { position: absolute; inset: 0; background: rgba(8, 12, 20, 0.55); }
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(760px, 100%);
  background: var(--bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 26px 28px 40px;
  animation: slide-in 0.2s ease;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .drawer-panel { animation: none; } }
.drawer-close { position: sticky; top: 0; float: right; z-index: 2; }

.d-head { display: grid; grid-template-columns: 88px 1fr; gap: 16px; align-items: center; margin-bottom: 18px; padding-right: 44px; }
.ring { width: 88px; height: 88px; }
.d-head h3 { font-size: 20px; letter-spacing: -0.01em; }
.d-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.d-section { margin-top: 16px; }
.d-section > h4 { font-size: 13px; color: var(--muted); font-weight: 700; margin: 0 0 8px; letter-spacing: 0.02em; }

.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.facts div { background: var(--surface); padding: 10px 12px; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.breakdown { display: grid; gap: 8px; }
.bd-row { display: grid; grid-template-columns: 90px 1fr 54px; gap: 10px; align-items: center; font-size: 13px; }
.bd-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.reasons { margin: 10px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

.d-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.d-actions select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.files { display: flex; flex-wrap: wrap; gap: 6px; }
.file { font-size: 12px; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); text-decoration: none; color: var(--text); }
a.file:hover { outline: 1px solid var(--accent); }

.ai-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.ai-box textarea { width: 100%; min-height: 90px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 13px; resize: vertical; }
.ai-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; }

.verdict { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 12px; margin-bottom: 14px; }
.verdict b { font-size: 15px; white-space: nowrap; padding: 4px 10px; border-radius: 8px; color: #fff; }
.verdict.GO { background: color-mix(in srgb, var(--grade-a) 12%, var(--surface)); }
.verdict.GO b { background: var(--grade-a); }
.verdict.CONDITIONAL { background: color-mix(in srgb, var(--grade-c) 14%, var(--surface)); }
.verdict.CONDITIONAL b { background: var(--grade-c); }
.verdict.NO_GO { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.verdict.NO_GO b { background: var(--danger); }

.memo h5 { font-size: 14px; margin: 16px 0 6px; }
.memo p, .memo li { font-size: 14px; }
.memo ul, .memo ol { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.memo .outline li b { display: block; }
.memo .outline li span { color: var(--muted); }
.memo .note { font-size: 12px; color: var(--muted); margin-top: 14px; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 12px 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tag.badge { padding: 0 7px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); color: var(--accent); font-weight: 600; }

.similar { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.similar li { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.similar .sim { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; text-align: center; }
.similar b { display: block; font-size: 14px; }
.similar .muted { font-size: 12px; }

/* ---------- 팀 실적 ---------- */
.team-card h4 { font-size: 13px; color: var(--muted); margin: 0 0 10px; }
.team-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.team-stats > div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.team-stats span { font-size: 12px; color: var(--muted); }
.team-stats b { font-size: 19px; letter-spacing: -0.01em; }
.team-stats small { font-size: 12px; color: var(--muted); }
.team-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; }
.team-grid .bar-row { grid-template-columns: 110px 1fr 86px; }
.clients { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 14px; }
.clients li span:last-child { margin-left: 8px; font-size: 12px; }

/* ---------- 파이프라인 ---------- */
.board { display: grid; grid-template-columns: repeat(6, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--surface-2); border-radius: 12px; padding: 10px; min-height: 260px; display: flex; flex-direction: column; gap: 8px; }
.col.drop { outline: 2px dashed var(--accent); }
.col h3 { font-size: 13px; display: flex; justify-content: space-between; color: var(--muted); padding: 2px 4px 4px; }
.col .sum { font-size: 11px; color: var(--muted); padding: 0 4px; margin-top: -6px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; cursor: grab; }
.pcard:active { cursor: grabbing; }
.pcard .t { font-size: 13px; font-weight: 700; line-height: 1.4; }
.pcard .m { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.pcard select { margin-top: 8px; width: 100%; font-size: 12px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }

/* ---------- 설정 ---------- */
.settings #profile-fields { display: grid; gap: 14px; }
.settings .grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings .grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.settings fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px 14px; margin: 0; }
.settings legend { font-size: 13px; font-weight: 700; padding: 0 6px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- 모달·토스트·푸터 ---------- */
.modal { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(760px, calc(100% - 32px)); background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(8, 12, 20, 0.5); }
.modal-inner { padding: 22px; display: grid; gap: 10px; }
.modal textarea { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: var(--text);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { max-width: 1440px; margin: 0 auto; padding: 18px 28px 32px; font-size: 12px; color: var(--muted); }

/* ---------- 반응형 ---------- */
@media (max-width: 1080px) {
  .radar-layout { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  #theme-toggle { margin-left: auto; }
  main { padding: 14px 16px 8px; }
  .banner { margin: 12px 16px 0; }
  .footer { padding: 16px; }
  .card { padding: 14px; }
  .toolbar-actions { margin-left: 0; width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .bid-row { grid-template-columns: 50px minmax(0, 1fr) 30px; gap: 10px; }
  .bid-row .bid-amount, .bid-row .bid-dday { display: none; }
  .score-badge { width: 46px; height: 46px; }
  .drawer-panel { padding: 18px 16px 32px; }
  .facts { grid-template-columns: 1fr; }
  .settings .grid2, .settings .grid4 { grid-template-columns: 1fr 1fr; }
  .team-stats, .team-grid { grid-template-columns: 1fr; }
  .board { grid-template-columns: repeat(6, 78vw); }
}
