:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf7;
  --surface-strong: #ffffff;
  --ink: #181612;
  --muted: #6f6a60;
  --line: #d8d0c3;
  --accent: #0c6b58;
  --accent-strong: #08483c;
  --amber: #bd7618;
  --red: #a8352e;
  --blue: #2f5f91;
  --shadow: 0 18px 42px rgba(34, 27, 19, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  background: #171512;
  color: #fffaf0;
  border-bottom: 4px solid var(--accent);
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #99d3c5;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.12;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
}

.summary {
  margin-bottom: 0;
  color: #d9d2c7;
  line-height: 1.55;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.visit-button,
.result-button,
.secondary-page-button,
.remove-expense {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  background: #f4c542;
  color: #171512;
}

.secondary-button {
  background: transparent;
  color: #fffaf0;
  border-color: rgba(255, 250, 240, 0.36);
}

.secondary-button.active-nav,
.primary-button.active-nav {
  border-color: #f4c542;
  box-shadow: inset 0 0 0 1px #f4c542;
}

.secondary-page-button {
  background: #f5f2eb;
  color: var(--ink);
  border-color: var(--line);
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.wide-button {
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.72fr);
  gap: 18px;
  padding: 18px;
}

.map-panel,
.tool-surface,
.route-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.map-panel {
  min-width: 0;
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head.compact {
  padding: 16px 16px 0;
  margin-bottom: 8px;
}

.route-count,
.visited-count {
  flex: 0 0 auto;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.map-wrap {
  width: 100%;
  aspect-ratio: 1 / 1.05;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ebe6dc;
}

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

.hall-bg {
  fill: #fffdf7;
  stroke: #2c2821;
  stroke-width: 8;
}

.hall-muted {
  fill: #ddd7cc;
}

.hall-label {
  fill: #7a7469;
  font-size: 72px;
  font-weight: 900;
}

.booth-dot {
  fill: #c4baab;
  stroke: #fffdf7;
  stroke-width: 7;
}

.booth-dot.search {
  fill: var(--blue);
}

.booth-dot.route {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 12;
}

.booth-dot.visited {
  fill: #928b80;
}

.route-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 18;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.78;
}

.route-line.primary {
  stroke: var(--accent);
}

.route-line.revisit {
  stroke: #d96f24;
  stroke-dasharray: 34 20;
  opacity: 0.9;
}

.route-line.legend-line {
  stroke-width: 12;
}

.legend-bg {
  fill: rgba(255, 253, 247, 0.94);
  stroke: #2c2821;
  stroke-width: 4;
}

.legend-text {
  fill: #27231e;
  font-size: 32px;
  font-weight: 900;
}

.route-label {
  fill: #fff;
  font-size: 46px;
  font-weight: 900;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.booth-label {
  fill: #27231e;
  font-size: 34px;
  font-weight: 900;
  text-anchor: middle;
}

.map-note {
  margin: 12px 4px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.control-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tool-surface {
  padding: 16px;
}

.field-group {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

.field-group label {
  font-size: 13px;
  font-weight: 900;
}

select,
input[type="search"],
input[inputmode="numeric"],
.budget-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: var(--surface-strong);
  color: var(--ink);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #faf7ef;
  font-size: 13px;
  font-weight: 800;
}

.toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.search-results {
  margin-top: 12px;
  display: grid;
  gap: 7px;
}

.result-button {
  width: 100%;
  height: auto;
  min-height: 38px;
  padding: 8px 10px;
  background: #edf4f1;
  border-color: #bed7cf;
  color: var(--accent-strong);
  text-align: left;
}

.route-panel {
  overflow: hidden;
}

.route-list {
  list-style: none;
  margin: 0;
  padding: 0 12px 12px;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 392px);
  min-height: 280px;
  overflow: auto;
}

.route-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.route-item.active {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.route-item.visited {
  opacity: 0.58;
}

.stop-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.route-main {
  min-width: 0;
}

.route-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.booth-title {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.35;
}

.booth-meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.goods {
  margin: 0;
  color: #3d382f;
  font-size: 13px;
  line-height: 1.55;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 900;
  background: #eee8dd;
  color: #4b4438;
}

.badge.high {
  background: #f8e3df;
  color: var(--red);
}

.badge.medium {
  background: #faedd9;
  color: var(--amber);
}

.badge.low {
  background: #e5edf7;
  color: var(--blue);
}

.badge.limited {
  background: #efe7be;
  color: #6b5600;
}

.visit-button {
  min-width: 58px;
  background: #f5f2eb;
  color: var(--ink);
  border-color: var(--line);
}

.visit-button.done {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.empty-state {
  padding: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.page-panel {
  margin: 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.page-panel[hidden],
.app-shell[hidden] {
  display: none;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-summary {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.page-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.page-search {
  margin-bottom: 0;
}

.page-count {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-weight: 900;
  white-space: nowrap;
}

.all-booth-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 260px);
  overflow: auto;
  padding-right: 2px;
}

.all-booth-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.all-booth-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.all-booth-row.visited {
  opacity: 0.62;
}

.all-booth-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  line-height: 1.45;
}

.all-booth-main strong {
  font-size: 13px;
}

.all-booth-main span {
  color: #3d382f;
  font-size: 13px;
}

.hall-chip {
  min-width: 38px;
  border-radius: 999px;
  padding: 4px 8px;
  background: #edf4f1;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

.budget-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.budget-card,
.expense-panel {
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.budget-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.budget-summary div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: #faf7ef;
}

.budget-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.budget-summary strong {
  font-size: 22px;
  line-height: 1.2;
}

.over-budget {
  color: var(--red);
}

.expense-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.expense-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ef;
}

.expense-item div {
  display: grid;
  gap: 4px;
}

.expense-item span {
  color: var(--muted);
  font-weight: 800;
}

.remove-expense {
  min-height: 34px;
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions button {
    flex: 1 1 180px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .page-head,
  .page-toolbar,
  .budget-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    flex-direction: column;
  }

  .secondary-page-button {
    width: 100%;
  }

  .map-wrap {
    min-height: 430px;
  }

  .route-list {
    max-height: none;
  }
}

@media (max-width: 600px) {
  .app-header,
  .app-shell {
    padding: 14px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .map-wrap {
    min-height: 360px;
    aspect-ratio: 0.86 / 1;
  }

  .route-topline {
    flex-direction: column;
  }

  .budget-summary {
    grid-template-columns: 1fr;
  }

  .visit-button {
    width: 100%;
  }
}
