:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1d252d;
  --muted: #687480;
  --line: #dce2e8;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --soft: #eef7f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Noto Sans KR", sans-serif;
  line-height: 1.5;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto 64px;
}

.panel,
.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 24px;
  margin-bottom: 18px;
}

.intro-panel,
.section-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

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

.notice {
  margin: 14px 0 0;
  font-size: 14px;
}

.step-indicator {
  display: flex;
  gap: 8px;
}

.step {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.step.is-active {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}

.field-wide {
  grid-column: span 2;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c7d0d9;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.18);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #1d252d;
  color: white;
}

.compact-button {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  padding: 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.metric-card strong {
  font-size: 24px;
}

.visual-panel {
  margin-bottom: 18px;
}

.regional-summary-panel {
  margin-bottom: 18px;
}

.regional-summary-text {
  min-height: 220px;
  max-height: 520px;
  overflow: auto;
  margin: 18px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 16px;
  color: var(--text);
  font: 14px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.map-canvas {
  width: 100%;
  height: 420px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.chart-shell {
  width: 100%;
  height: 280px;
  margin-top: 16px;
}

.period-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.period-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.period-card > span {
  color: var(--muted);
  font-weight: 800;
}

.period-card > strong {
  display: block;
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0;
}

.period-card dl {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
}

.period-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.period-card dt,
.period-card dd {
  margin: 0;
}

.period-card dt {
  color: var(--muted);
  font-weight: 700;
}

.period-card dd {
  color: var(--text);
  font-weight: 800;
  text-align: right;
}

.period-insight {
  margin: 14px 0 0;
  border-radius: 8px;
  background: #f8fafb;
  padding: 14px 16px;
  color: var(--text);
  font-weight: 700;
  line-height: 1.6;
}

.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chart-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
}

.chart-tab.is-active {
  border-color: var(--primary);
  background: #e7f3f1;
  color: var(--primary);
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
}

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-tab {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 8px 12px;
}

.filter-tab.is-active {
  background: var(--soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 16px;
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f8fafb;
  color: #44505c;
  font-weight: 700;
}

.sort-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 280px;
  min-width: 280px;
  max-width: 280px;
  background: var(--panel);
}

th.sticky-col {
  z-index: 2;
  background: #f8fafb;
}

.listing-cell {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.thumb-wrap,
.listing-thumb,
.thumb-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: block;
  flex: 0 0 auto;
}

.listing-thumb {
  object-fit: cover;
  background: #dce2e8;
}

.listing-thumb.is-hidden {
  display: none;
}

.thumb-placeholder {
  background: linear-gradient(135deg, #dce2e8, #eef2f5);
  border: 1px solid #c7d0d9;
}

.listing-text {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.listing-name {
  display: block;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.rate-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.rate-high {
  background: #15803d;
}

.rate-medium {
  background: #c2410c;
}

.rate-low,
.rate-unknown {
  background: var(--danger);
}

.rate-unknown {
  background: var(--muted);
}

.break-even-panel {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: #f8fafb;
}

.break-even-panel span {
  color: var(--muted);
  font-weight: 700;
}

.break-even-panel strong {
  color: var(--accent-dark);
  font-size: 28px;
}

tr.is-highlighted td {
  background: #fff7ed;
}

a {
  color: var(--accent-dark);
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-panel > div:last-child {
  flex: 1;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.progress-steps li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  color: var(--muted);
  font-size: 13px;
  background: #fff;
}

.progress-steps li.is-active {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--soft);
  font-weight: 700;
}

.progress-steps li.is-complete {
  color: #15803d;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.progress-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce2e8;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.loader {
  width: 32px;
  height: 32px;
  border: 4px solid #d9eeeb;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.error-panel {
  border-color: #f2b8b5;
  color: var(--danger);
  background: #fff5f5;
}

.hidden {
  display: none !important;
}

.negative {
  color: var(--danger);
}

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

@media (max-width: 860px) {
  .intro-panel,
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid,
  .summary-grid,
  .period-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: span 1;
  }

  .table-toolbar,
  .break-even-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .map-canvas {
    height: 340px;
  }

  .progress-steps {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    margin-top: 20px;
  }

  .panel,
  .metric-card {
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }

  .sticky-col {
    width: 230px;
    min-width: 230px;
    max-width: 230px;
  }

  .listing-name {
    max-width: 160px;
  }

  .map-canvas {
    height: 300px;
  }

  .chart-shell {
    height: 240px;
  }
}
