:root {
  color-scheme: light;
  --bg: #f1f4f8;
  --panel: #ffffff;
  --ink: #15202b;
  --muted: #6c7785;
  --line: #dfe5ec;
  --accent: #e85d22;
  --accent-strong: #c94412;
  --accent-soft: #fff1ea;
  --navy: #243447;
  --green: #138a67;
  --red: #c44747;
  --amber: #ba7a00;
  --shadow: 0 10px 30px rgba(32, 47, 65, 0.08);
  --radius: 18px;
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar {
  height: 74px; padding: 0 24px; background: #132333; color: #fff; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 1000; box-shadow: 0 6px 20px rgba(13, 29, 43, .18);
}
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-weight: 900; font-size: 24px; background: var(--accent); }
.brand-block strong { display: block; letter-spacing: .08em; }
.brand-block span { display: block; color: #b9c4cf; font-size: 12px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.status-chip { padding: 8px 11px; border-radius: 999px; font-size: 12px; color: #d9e2ea; border: 1px solid rgba(255,255,255,.18); }
.ghost-btn, .primary-btn, .map-tools button, .inline-control button {
  border: 0; border-radius: 10px; padding: 10px 13px; font-weight: 700;
}
.ghost-btn { background: rgba(255,255,255,.1); color: #fff; }
.primary-btn { background: var(--accent); color: #fff; }
.app-shell { display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: calc(100vh - 74px); }
.control-panel { background: #fbfcfd; border-right: 1px solid var(--line); padding: 15px 14px 28px; overflow-y: auto; max-height: calc(100vh - 74px); position: sticky; top: 74px; }
.panel-section { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; overflow: hidden; }
.section-title { width: 100%; border: 0; background: #fff; display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 9px; padding: 13px 14px; text-align: left; font-weight: 800; color: var(--ink); }
.step { width: 26px; height: 26px; border-radius: 8px; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 12px; }
.chevron { color: var(--muted); transition: transform .2s; }
.panel-section:not(.is-open) .chevron { transform: rotate(-90deg); }
.panel-section:not(.is-open) .section-body { display: none; }
.section-body { border-top: 1px solid var(--line); padding: 13px 14px 15px; }
.field-label { display: block; font-size: 12px; color: var(--muted); font-weight: 700; margin: 9px 0 6px; }
input, select { width: 100%; border: 1px solid #ced7e0; border-radius: 9px; background: #fff; padding: 9px 10px; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232,93,34,.12); }
.inline-control { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
.inline-control button { background: var(--navy); color: #fff; white-space: nowrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.two-col label { position: relative; font-size: 11px; color: var(--muted); font-weight: 700; }
.two-col input { margin-top: 5px; padding-right: 48px; color: var(--ink); font-weight: 700; }
.two-col small { position: absolute; right: 9px; bottom: 10px; font-size: 10px; color: #8c97a3; }
.compact-fields { margin-bottom: 8px; }
.helper, .legal-note { margin: 8px 0 0; font-size: 11px; line-height: 1.5; color: var(--muted); }
.selected-address { min-height: 45px; border-radius: 10px; background: #f4f7fa; padding: 10px; font-size: 12px; line-height: 1.5; }
.search-results { border: 1px solid var(--line); border-radius: 9px; margin-top: 6px; max-height: 160px; overflow-y: auto; background: #fff; }
.search-result { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: #fff; padding: 9px 10px; text-align: left; font-size: 12px; }
.search-result:last-child { border-bottom: 0; }
.confidence-row, .switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; font-size: 12px; font-weight: 700; }
.confidence-row select { width: 178px; }
.switch-row { justify-content: flex-start; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.price-grid { display: grid; grid-template-columns: 92px 1fr 1fr; gap: 7px; align-items: center; }
.price-grid label { font-size: 11px; font-weight: 700; color: var(--muted); }
.price-heading { font-size: 10px; text-align: center; color: var(--muted); font-weight: 800; }
.run-button { width: 100%; border: 0; border-radius: 13px; background: var(--accent); color: #fff; padding: 15px; font-weight: 900; font-size: 15px; box-shadow: 0 8px 20px rgba(232,93,34,.26); }
.workspace { padding: 20px; min-width: 0; }
.card { background: var(--panel); border: 1px solid rgba(215,222,230,.9); border-radius: var(--radius); box-shadow: var(--shadow); }
.map-card { overflow: hidden; }
.card-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; }
.card-header.compact { min-height: 62px; padding: 14px 17px 8px; }
.eyebrow { display: block; color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
h1, h2 { margin: 3px 0 0; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
.map-tools { display: flex; gap: 7px; }
.map-tools button { background: #eef2f5; color: var(--navy); font-size: 12px; }
.map { height: 360px; background: #dce4e7; border-top: 1px solid var(--line); }
.map-fallback { height: 180px; display: grid; place-items: center; text-align: center; padding: 25px; color: var(--muted); background: #eef2f4; }
.leaflet-container { font-family: inherit; }
.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.kpi-card { padding: 16px; min-height: 118px; }
.kpi-card span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.kpi-card strong { display: block; font-size: 24px; margin-top: 12px; letter-spacing: -.04em; }
.kpi-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.kpi-card.accent { background: linear-gradient(135deg, #fff5ef, #fff); border-color: #f0c7b5; }
.kpi-card.accent strong { color: var(--accent-strong); }
.analysis-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(290px, .8fr); gap: 14px; margin-top: 14px; }
.analysis-grid.lower { grid-template-columns: minmax(0, 1.45fr) minmax(320px, .85fr); }
.chart-card, .scenario-card, .simulation-card, .competitor-card, .assumption-card { min-width: 0; overflow: hidden; }
.chart-card canvas { width: 100%; height: 270px; display: block; padding: 0 12px 12px; }
.legend { font-size: 10px; color: var(--muted); white-space: nowrap; }
.traffic-dot, .entry-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin: 0 4px 0 9px; }
.traffic-dot { background: #cfd8e2; }
.entry-dot { background: var(--accent); }
.scenario-list { padding: 3px 16px 10px; }
.scenario-row { display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; align-items: center; padding: 13px 12px; border-radius: 12px; margin-bottom: 8px; background: #f7f9fb; }
.scenario-row span { grid-row: 1 / 3; font-size: 12px; font-weight: 900; }
.scenario-row strong { text-align: right; font-size: 19px; }
.scenario-row small { text-align: right; color: var(--muted); font-size: 10px; margin-top: 3px; }
.scenario-row.pessimistic span, .scenario-row.pessimistic strong { color: var(--red); }
.scenario-row.base { background: var(--accent-soft); }
.scenario-row.base span, .scenario-row.base strong { color: var(--accent-strong); }
.scenario-row.optimistic span, .scenario-row.optimistic strong { color: var(--green); }
.payback-box { margin: 0 16px 16px; border-top: 1px solid var(--line); padding-top: 13px; display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); }
.payback-box strong { font-size: 16px; color: var(--ink); }
.hour-selector { display: flex; align-items: center; gap: 7px; font-size: 10px; color: var(--muted); }
.hour-selector input { width: 100px; padding: 0; accent-color: var(--accent); }
.simulation-card canvas { width: 100%; height: 280px; display: block; background: linear-gradient(#a9d4ee 0 38%, #9fc27d 38% 48%, #3e4850 48% 100%); image-rendering: pixelated; }
.forecourt-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.forecourt-stats span { padding: 12px; font-size: 10px; color: var(--muted); text-align: center; border-right: 1px solid var(--line); }
.forecourt-stats span:last-child { border-right: 0; }
.forecourt-stats strong { display: block; margin-top: 4px; font-size: 14px; color: var(--ink); }
.source-badge { font-size: 10px; border-radius: 999px; padding: 6px 8px; background: #eef2f5; color: var(--muted); }
.table-wrap { max-height: 255px; overflow: auto; padding: 0 14px; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th, td { padding: 10px 7px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
th { position: sticky; top: 0; background: #fff; color: var(--muted); font-size: 10px; }
.competitor-summary { display: flex; justify-content: space-between; gap: 10px; padding: 13px 16px; font-size: 10px; color: var(--muted); }
.competitor-summary strong { color: var(--ink); }
.assumption-card { margin-top: 14px; }
.basis-grid { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 1px; background: var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.basis-item { background: #fff; padding: 14px; min-height: 80px; }
.basis-item span { display: block; color: var(--muted); font-size: 10px; }
.basis-item strong { display: block; margin-top: 8px; font-size: 17px; }
.basis-item small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.warnings { padding: 14px 16px 17px; display: grid; gap: 7px; }
.warning { border-left: 4px solid var(--amber); background: #fff8e8; padding: 9px 11px; border-radius: 8px; font-size: 11px; color: #765c1d; }
.warning.good { border-left-color: var(--green); background: #ecf8f4; color: #266452; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #172534; color: #fff; padding: 11px 15px; border-radius: 10px; box-shadow: 0 8px 25px rgba(0,0,0,.22); opacity: 0; pointer-events: none; transition: .2s; z-index: 2000; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .basis-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .control-panel { position: static; max-height: none; border-right: 0; }
  .workspace { padding: 12px; }
  .analysis-grid, .analysis-grid.lower { grid-template-columns: 1fr; }
  .map { height: 330px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; }
  .status-chip, .ghost-btn { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .basis-grid { grid-template-columns: repeat(2, 1fr); }
  .card-header { align-items: flex-start; flex-direction: column; }
  .map-tools { width: 100%; }
  .map-tools button { flex: 1; }
  .forecourt-stats { grid-template-columns: repeat(2, 1fr); }
}

/* v0.2.0 관전형 실시간 시뮬레이션 */
.secondary-wide-btn {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
}
.secondary-wide-btn:hover { background: #f6f3ea; }
.live-card {
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid #263744;
  background: #101923;
  color: #f5f1e8;
}
.live-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.live-card-header h2 { margin: 0 0 5px; font-size: 1.08rem; }
.live-card-header p { margin: 0; color: #aebdca; font-size: .88rem; }
.live-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.live-actions button,
.speed-control button {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.07);
  color: #eef4f8;
  border-radius: 9px;
  padding: 8px 11px;
  font-weight: 800;
  cursor: pointer;
}
.live-actions button:hover,
.speed-control button:hover { background: rgba(255,255,255,.13); }
.live-stage-shell { position: relative; background: #0a1118; }
#liveCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.live-event-panel {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: min(280px, 34%);
  max-height: 182px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 10px;
  background: rgba(8,13,18,.84);
  backdrop-filter: blur(5px);
  pointer-events: none;
}
.live-event-title {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  color: #dce7ef;
  font-size: .77rem;
  font-weight: 900;
}
.live-event-log { padding: 5px 8px 8px; }
.live-event-row {
  padding: 4px 2px;
  color: #c6d2db;
  font-size: .73rem;
  line-height: 1.3;
  border-bottom: 1px dashed rgba(255,255,255,.08);
}
.live-event-row:last-child { border-bottom: 0; }
.live-event-row.good { color: #a7efb2; }
.live-event-row.bad { color: #ffaaa3; }
.live-event-row.warn { color: #ffd47a; }
.live-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid rgba(255,255,255,.1);
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.speed-control { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.speed-control > span { margin-right: 4px; color: #aebdca; font-size: .8rem; font-weight: 800; }
.speed-control button.active {
  border-color: #f29a64;
  background: #e85d22;
  color: #fff;
}
.live-clock-block { text-align: right; }
.live-clock-block strong { display: block; font-size: 1.08rem; }
.live-clock-block span { color: #aebdca; font-size: .78rem; }
.live-summary-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 1px;
  background: rgba(255,255,255,.1);
}
.live-summary-grid > span {
  min-width: 0;
  padding: 11px 9px;
  background: #14202b;
}
.live-summary-grid > span small { display: block; margin-bottom: 4px; color: #9fb0bd; font-size: .7rem; }
.live-summary-grid > span strong { display: block; overflow: hidden; color: #fff4ce; font-size: .92rem; text-overflow: ellipsis; white-space: nowrap; }
.analysis-grid.lower.single { grid-template-columns: 1fr; }
#trafficSourceNote { display: block; margin-top: 7px; color: var(--muted); font-size: .76rem; line-height: 1.35; }

@media (max-width: 1050px) {
  .live-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .live-card-header, .live-toolbar { align-items: stretch; flex-direction: column; }
  .live-clock-block { text-align: left; }
  .live-event-panel { position: static; width: auto; max-height: 132px; border-radius: 0; border-right: 0; border-left: 0; }
  .live-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
