:root {
  --bg: #f8f9fa;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6c757d;
  --primary: #2d5016;
  --primary-light: #e8f0e0;
  --accent: #c41e3a;
  --border: #dee2e6;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* Bilingual text */
.ja { display: block; font-size: 0.85em; color: var(--text-muted); }
h1 .ja, h2 .ja { font-weight: 400; }
.subtitle .ja { font-size: 0.9em; }

/* Header */
header {
  background: var(--primary);
  color: white;
  padding: 40px 0 30px;
  text-align: center;
}
header h1 { font-size: 1.6rem; margin-bottom: 8px; }
header h1 .ja { color: rgba(255,255,255,0.7); }
header .subtitle { font-size: 0.95rem; opacity: 0.9; }
header .subtitle .ja { color: rgba(255,255,255,0.6); }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.15rem; margin-bottom: 16px; border-bottom: 2px solid var(--primary-light); padding-bottom: 8px; }
.card h3 { font-size: 1rem; margin-bottom: 12px; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 0.9rem; font-weight: 500; }
.field label .ja { font-size: 0.8em; font-weight: 400; }

input, select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
  background: white;
  width: 100%;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 0;
}
.input-with-unit input {
  border-radius: 4px 0 0 4px;
  border-right: none;
}
.input-with-unit .unit {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0 4px 4px 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.hint { font-size: 0.8rem; color: var(--text-muted); }

/* Upload */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-icon { font-size: 2rem; margin-bottom: 8px; }
.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
}

.status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.9rem;
}
.status.loading { background: #fff3cd; color: #856404; }
.status.success { background: var(--primary-light); color: var(--primary); }
.status.error { background: #f8d7da; color: #721c24; }

/* Button */
.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  margin: 20px 0;
  transition: background 0.2s;
}
.btn-primary:hover { background: #1e3a0f; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary .ja { color: rgba(255,255,255,0.7); }

/* Results */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric {
  text-align: center;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg);
}
.metric.highlight { background: var(--primary-light); }
.metric-value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.metric.highlight .metric-value { color: var(--primary); }
.metric-label { font-size: 0.85rem; margin-top: 4px; }
.metric-label .ja { font-size: 0.9em; }

.metric-value.negative { color: var(--accent); }

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.breakdown table { width: 100%; font-size: 0.85rem; border-collapse: collapse; }
.breakdown td { padding: 5px 0; }
.breakdown td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown tr.total { border-top: 2px solid var(--text); font-weight: 600; }
.breakdown tr.total td { padding-top: 8px; }

/* Footer */
footer {
  text-align: center;
  padding: 30px 0;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
footer a { color: var(--primary); }

/* Mobile */
@media (max-width: 600px) {
  header h1 { font-size: 1.3rem; }
  .form-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .breakdown-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
}
