:root {
  color-scheme: light;
  --bg: #edf2ef;
  --paper: #fffdf8;
  --paper-soft: #f5f8f2;
  --line: #d7dfd7;
  --line-strong: #95a99b;
  --text: #17221d;
  --muted: #5b6860;
  --faint: #7b8982;
  --green: #2f936b;
  --green-soft: #def2e8;
  --red: #c94f5b;
  --red-soft: #f9e2e5;
  --orange: #d7783f;
  --orange-soft: #f8e6d8;
  --yellow: #d4ad37;
  --yellow-soft: #f5edcb;
  --blue: #327ea2;
  --blue-soft: #e0f0f4;
  --slate: #4b5f69;
  --ink: #12221d;
  --shadow: 0 18px 42px rgba(28, 43, 35, 0.15);
  --soft-shadow: 0 8px 22px rgba(28, 43, 35, 0.08);
  font-family:
    "Pretendard Variable", "Pretendard", "Noto Sans KR", "Segoe UI", system-ui,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.safe-price-app {
  width: 100%;
  height: 100vh;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 78px minmax(0, 1fr) 26px;
  background:
    linear-gradient(90deg, rgba(24, 40, 31, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 40, 31, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, #f6f8f3 0%, #e6eee9 100%);
  background-size: 44px 44px, 44px 44px, auto;
}

.topbar {
  min-width: 0;
  display: grid;
  grid-template-columns: 330px minmax(350px, 1fr) 480px;
  gap: 14px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(120, 136, 124, 0.28);
  background: rgba(255, 253, 248, 0.97);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9);
}

.brand,
.top-actions,
.workspace,
.left-panel,
.right-panel,
.map-stage,
.verification-dock,
.statusbar,
.dock-metrics {
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-symbol {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(50, 126, 162, 0.34);
  border-radius: 15px;
  background:
    linear-gradient(135deg, rgba(47, 147, 107, 0.98), rgba(50, 126, 162, 0.92)),
    #fff;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.18);
}

.brand-symbol span {
  width: 22px;
  height: 22px;
  display: block;
  border: 4px solid #fffdf8;
  border-right-color: #f1c84c;
  border-radius: 50%;
}

.brand p,
.panel header span,
.map-alert span,
.verification-dock header span,
.dock-metrics span,
.source-list span,
.admin-metrics span {
  margin: 0;
  color: var(--faint);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0;
}

.brand h1 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.12;
  letter-spacing: 0;
}

.view-tabs {
  min-width: 0;
  height: 46px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #eef2ec;
}

.view-tabs button {
  min-width: 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 820;
  letter-spacing: 0;
  white-space: nowrap;
}

.view-tabs button.is-active {
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--soft-shadow);
}

.top-actions {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) 86px 112px;
  gap: 8px;
  align-items: center;
}

.search-field {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.search-field span {
  width: 14px;
  height: 14px;
  position: relative;
  flex: 0 0 auto;
  border: 2px solid var(--blue);
  border-radius: 50%;
}

.search-field span::after {
  content: "";
  width: 7px;
  height: 2px;
  position: absolute;
  right: -6px;
  bottom: -4px;
  border-radius: 999px;
  background: var(--blue);
  transform: rotate(42deg);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.subtle-button,
.primary-button,
.panel header button,
.map-toolbar button,
.prompt-row button,
.modal footer button,
.upload-drop button {
  min-height: 40px;
  border: 1px solid rgba(115, 132, 119, 0.34);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-weight: 850;
}

.primary-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffdf8;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 378px;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.left-panel,
.right-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}

.panel {
  border: 1px solid rgba(112, 132, 116, 0.32);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--soft-shadow);
}

.panel header,
.verification-dock header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel header strong,
.verification-dock header strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  line-height: 1.25;
}

.event-picker,
.layer-panel,
.route-panel,
.trust-card,
.ai-card,
.admin-card,
.data-card {
  padding: 14px;
}

.event-picker header em,
.ai-card header em {
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.event-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.event-button {
  min-width: 0;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.event-button.is-active {
  border-color: rgba(50, 126, 162, 0.52);
  background: var(--blue-soft);
  box-shadow: 0 0 0 2px rgba(50, 126, 162, 0.11);
}

.event-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.event-dot.red {
  background: var(--red);
}

.event-dot.orange {
  background: var(--orange);
}

.event-dot.green {
  background: var(--green);
}

.event-button strong,
.event-button small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-button strong {
  font-size: 13px;
}

.event-button small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.event-button em {
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.layer-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.layer-list label {
  display: grid;
  grid-template-columns: 18px 13px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 13px;
  font-weight: 720;
}

.layer-list input {
  width: 17px;
  height: 17px;
  accent-color: var(--green);
}

.swatch,
.map-legend i {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 3px;
}

.swatch.blue {
  background: var(--blue);
}

.swatch.red,
.map-legend .red {
  background: var(--red);
}

.swatch.green,
.map-legend .green {
  background: var(--green);
}

.swatch.yellow,
.map-legend .yellow {
  background: var(--yellow);
}

.map-legend .orange {
  background: var(--orange);
}

.map-legend .gray {
  background: #9aa59f;
}

.route-steps {
  display: grid;
  gap: 9px;
  margin: 12px 0 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.route-steps li::marker {
  color: var(--green);
  font-weight: 900;
}

.map-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(112, 132, 116, 0.34);
  border-radius: 22px;
  background: #dcecef;
  box-shadow: var(--shadow);
}

.map-toolbar {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 5;
  display: grid;
  gap: 7px;
}

.map-toolbar button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 13px;
  background: rgba(255, 253, 248, 0.95);
}

.map-alert {
  position: absolute;
  left: 66px;
  top: 16px;
  z-index: 5;
  width: min(410px, calc(100% - 96px));
  padding: 14px 16px;
  border: 1px solid rgba(112, 132, 116, 0.3);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: var(--soft-shadow);
}

.map-alert strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  line-height: 1.15;
}

.map-alert p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tour-map {
  width: 100%;
  height: 100%;
  display: block;
}

.map-loading {
  position: absolute;
  left: 50%;
  top: 47%;
  z-index: 4;
  display: grid;
  place-items: center;
  gap: 9px;
  min-width: 210px;
  padding: 18px 20px;
  border: 1px solid rgba(112, 132, 116, 0.32);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--soft-shadow);
  color: var(--ink);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.map-loading span {
  width: 30px;
  height: 30px;
  border: 4px solid var(--green-soft);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: map-loading-spin 0.82s linear infinite;
}

.map-loading strong {
  font-size: 13px;
}

.map-loading.is-hidden {
  display: none;
}

@keyframes map-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.map-grid path {
  fill: none;
  stroke: rgba(70, 92, 84, 0.14);
  stroke-width: 1;
}

.region-shape {
  fill: rgba(251, 255, 244, 0.84);
  fill-rule: evenodd;
  stroke: rgba(70, 92, 84, 0.3);
  stroke-width: 1.1;
  vector-effect: non-scaling-stroke;
}

.region-shape.red {
  fill: rgba(201, 79, 91, 0.32);
  stroke: rgba(201, 79, 91, 0.76);
}

.region-shape.orange {
  fill: rgba(215, 120, 63, 0.3);
  stroke: rgba(215, 120, 63, 0.76);
}

.region-shape.green {
  fill: rgba(47, 147, 107, 0.26);
  stroke: rgba(47, 147, 107, 0.76);
}

.region-shape.is-active {
  stroke: #12221d;
  stroke-width: 2.4;
}

.boundary-label {
  fill: rgba(36, 53, 45, 0.74);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(255, 253, 248, 0.92);
  stroke-width: 4px;
  pointer-events: none;
}

.signal-ring {
  fill: none;
  stroke-width: 12;
  stroke-opacity: 0.18;
  pointer-events: none;
}

.signal-ring.red {
  stroke: var(--red);
}

.signal-ring.orange {
  stroke: var(--orange);
}

.signal-ring.green {
  stroke: var(--green);
}

.map-pin {
  cursor: pointer;
  outline: none;
}

.map-pin circle {
  stroke: #fffdf8;
  stroke-width: 5;
  filter: url(#pinShadow);
}

.map-pin path {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.map-pin text {
  fill: #fff;
  font-size: 16px;
  font-weight: 950;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.map-pin.red circle {
  fill: var(--red);
}

.map-pin.orange circle {
  fill: var(--orange);
}

.map-pin.green circle {
  fill: var(--green);
}

.map-pin.is-active circle {
  stroke-width: 8;
}

.safe-price-app.hide-reports .region-shape.red,
.safe-price-app.hide-reports .signal-ring.red,
.safe-price-app.hide-reports .map-pin.red,
.safe-price-app.hide-good .region-shape.green,
.safe-price-app.hide-good .signal-ring.green,
.safe-price-app.hide-good .map-pin.green {
  opacity: 0.22;
}

.map-legend {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 5;
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid rgba(112, 132, 116, 0.28);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.93);
  box-shadow: var(--soft-shadow);
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
}

.verification-dock {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 6;
  padding: 14px;
  border: 1px solid rgba(112, 132, 116, 0.32);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.grade-pill {
  flex: 0 0 auto;
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.grade-pill.red {
  background: var(--red-soft);
  color: var(--red);
}

.grade-pill.orange {
  background: var(--orange-soft);
  color: var(--orange);
}

.grade-pill.green {
  background: var(--green-soft);
  color: var(--green);
}

.dock-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.dock-metrics article {
  min-width: 0;
  padding: 10px;
  border-radius: 14px;
  background: #f2f6f0;
}

.dock-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  line-height: 1;
}

.dock-metrics small {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-rows {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  max-height: 142px;
  overflow: auto;
}

.price-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(88px, 1fr) 88px 88px 56px 92px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(112, 132, 116, 0.22);
  border-radius: 12px;
  background: #fff;
  font-size: 12px;
}

.price-row strong,
.price-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.price-row span {
  color: var(--muted);
}

.empty-row {
  padding: 14px;
  border: 1px dashed rgba(112, 132, 116, 0.34);
  border-radius: 13px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.row-badge {
  justify-self: end;
  padding: 6px 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.row-badge.red {
  background: var(--red);
}

.row-badge.orange {
  background: var(--orange);
}

.row-badge.green {
  background: var(--green);
}

.trust-card p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.evidence-list,
.source-list,
.admin-metrics {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.evidence-item,
.source-item,
.admin-metric {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(112, 132, 116, 0.22);
  border-radius: 12px;
  background: #fff;
}

.evidence-item {
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
}

.evidence-item strong,
.source-item strong,
.admin-metric strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.ai-answer {
  margin-top: 12px;
  padding: 14px;
  border-radius: 15px;
  background: #edf6f3;
  color: #20342e;
  font-size: 13px;
  line-height: 1.55;
}

.prompt-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.prompt-row button {
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-metric strong {
  display: block;
  margin-top: 3px;
  font-size: 22px;
}

.source-item small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.mobile-report-button {
  display: none;
}

.modal[hidden],
.toast[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(18, 34, 29, 0.38);
}

.report-dialog {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  overflow: hidden;
  border: 1px solid rgba(112, 132, 116, 0.32);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.report-dialog header,
.report-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.report-dialog footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.report-dialog h2 {
  margin: 3px 0 0;
  font-size: 20px;
}

.report-dialog header span {
  color: var(--faint);
  font-size: 11px;
  font-weight: 780;
}

.report-dialog header button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.report-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 14px;
  padding: 16px;
}

.upload-drop,
.ocr-result {
  min-width: 0;
  padding: 16px;
  border: 1px dashed rgba(85, 103, 92, 0.42);
  border-radius: 17px;
  background: #fff;
}

.upload-drop p {
  margin: 8px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.ocr-result {
  border-style: solid;
  background: var(--paper-soft);
}

.ocr-result span {
  color: var(--faint);
  font-size: 11px;
  font-weight: 780;
}

.ocr-result strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.ocr-result dl {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.ocr-result div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.ocr-result dt {
  color: var(--muted);
}

.ocr-result dd {
  margin: 0;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 42px;
  z-index: 50;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.45;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  overflow: hidden;
  padding: 0 14px;
  border-top: 1px solid rgba(16, 32, 27, 0.18);
  background: var(--ink);
  color: #e8f2eb;
}

.statusbar span {
  flex: 0 0 auto;
  font-size: 11px;
  white-space: nowrap;
}

@media (max-width: 1240px) {
  .topbar {
    grid-template-columns: 300px minmax(320px, 1fr);
  }

  .top-actions {
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) 90px 112px;
  }

  .safe-price-app {
    grid-template-rows: 132px minmax(0, 1fr) 26px;
  }

  .workspace {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .right-panel {
    display: none;
  }
}

@media (max-width: 820px) {
  html,
  body {
    overflow: auto;
  }

  .safe-price-app {
    min-height: 100vh;
    height: auto;
    grid-template-rows: auto auto auto;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .brand h1 {
    font-size: 18px;
  }

  .view-tabs {
    height: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-actions {
    grid-template-columns: minmax(0, 1fr) 78px 96px;
    grid-column: auto;
  }

  .subtle-button,
  .primary-button {
    font-size: 13px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    overflow: visible;
  }

  .left-panel {
    order: 2;
    overflow: visible;
  }

  .event-picker,
  .layer-panel,
  .route-panel {
    display: none;
  }

  .map-stage {
    order: 1;
    height: 740px;
    min-height: 740px;
    border-radius: 18px;
  }

  .map-toolbar,
  .map-legend {
    display: none;
  }

  .map-alert {
    left: 12px;
    right: 12px;
    top: 12px;
    width: auto;
  }

  .tour-map {
    height: 430px;
    margin-top: 112px;
  }

  .verification-dock {
    left: 10px;
    right: 10px;
    bottom: 10px;
    padding: 12px;
  }

  .dock-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dock-metrics article:last-child {
    display: none;
  }

  .price-row {
    grid-template-columns: minmax(80px, 1fr) 78px 72px;
    gap: 6px;
  }

  .price-row span:nth-of-type(2),
  .price-row span:nth-of-type(3) {
    display: none;
  }

  .right-panel {
    order: 3;
    display: flex;
    overflow: visible;
  }

  .report-body {
    grid-template-columns: 1fr;
  }

  .statusbar {
    min-height: 38px;
    flex-wrap: wrap;
    padding: 8px 10px;
  }
}
