:root {
  color-scheme: light;
  --fg: #1a1a1a;
  --muted: #5a5a5a;
  --border: #d8d8d8;
  --bg: #ffffff;
  --bg-alt: #f7f7f7;
  --accent: #1f5fa8;
  --danger-bg: #fff4e5;
  --danger-border: #e0a94f;
  --positive: #1a7a3c;
  --negative: #b3311f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--fg);
  background: var(--bg-alt);
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.page-header {
  padding: 16px 0 8px;
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}

.tagline {
  color: var(--muted);
  margin: 0;
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 1.1rem;
  margin: 0 0 8px;
}

.section-desc {
  color: var(--muted);
  margin: 0 0 12px;
  font-size: 0.92rem;
}

input[type="file"] {
  display: block;
  width: 100%;
}

.notice {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.92rem;
}

.notice-warning {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #7a4a00;
}

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.demo-controls label {
  font-size: 0.92rem;
  color: var(--muted);
}

select,
button {
  font: inherit;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
}

button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
}

button:hover {
  filter: brightness(1.05);
}

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

.summary-line {
  font-weight: 600;
  margin: 0 0 12px;
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-fully {
  background: #e3f4e9;
  color: var(--positive);
}

.status-partial {
  background: var(--danger-bg);
  color: #7a4a00;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.metric {
  background: var(--bg-alt);
  border-radius: 6px;
  padding: 10px 12px;
}

.metric .metric-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.metric .metric-value {
  display: block;
  font-size: 1.05rem;
  font-weight: 600;
}

.amount-positive {
  color: var(--positive);
}

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

.cause-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.cause-item {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.cause-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.cause-label {
  font-weight: 600;
}

.cause-explanation {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 6px 0 0;
}

.evidence-details {
  margin-top: 8px;
  font-size: 0.85rem;
}

.evidence-details summary {
  cursor: pointer;
  color: var(--accent);
}

.evidence-ids {
  margin: 6px 0 0;
  word-break: break-all;
}

#csvMappingSection h3 {
  font-size: 0.95rem;
  margin: 16px 0 6px;
}

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

.mapping-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
}

.mapping-row label {
  color: var(--muted);
}

.mapping-row .required-mark {
  color: var(--negative);
}

.period-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  margin-bottom: 12px;
}

.period-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  color: var(--muted);
}

.period-grid input[type="date"] {
  font: inherit;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.csv-error-summary {
  font-weight: 600;
  margin: 0 0 8px;
}

.csv-error-list {
  margin: 0 0 12px;
  padding-left: 18px;
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
}

.csv-confirm-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-secondary {
  background: var(--bg);
  color: var(--fg);
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .cause-item-head {
    flex-direction: column;
  }
  .mapping-grid,
  .period-grid {
    grid-template-columns: 1fr;
  }
  .csv-confirm-actions {
    flex-direction: column;
  }
  .csv-confirm-actions button {
    width: 100%;
  }
}
