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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #16a34a;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

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

/* Header */
header {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  padding: 40px 0 48px;
  text-align: center;
}
header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.subtitle {
  font-size: 1rem;
  opacity: 0.9;
  line-height: 1.6;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin: 20px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.card h2 {
  font-size: 1.2rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Forms */
.form-grid {
  display: grid;
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-group label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}
input[type="number"], input[type="text"], select {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.input-with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-with-unit input {
  flex: 1;
}
.unit {
  font-size: 0.9rem;
  color: var(--text-light);
  white-space: nowrap;
}
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}
.hint {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 12px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: var(--border);
  color: var(--text);
}
.btn-secondary:hover { background: #cbd5e1; }
.btn-add {
  background: none;
  color: var(--primary);
  border: 1.5px dashed var(--primary);
  width: 100%;
  padding: 12px;
  margin-top: 12px;
  border-radius: 8px;
}
.btn-add:hover { background: #eff6ff; }
.btn-large {
  padding: 14px 40px;
  font-size: 1.1rem;
}
.btn-danger {
  background: none;
  color: var(--danger);
  padding: 4px 8px;
  font-size: 0.8rem;
}
.center { text-align: center; margin: 24px 0; }

/* Items list */
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #f8fafc;
  border-radius: 8px;
  margin-bottom: 8px;
}
.item-info {
  flex: 1;
}
.item-name {
  font-weight: 500;
  font-size: 0.95rem;
}
.item-detail {
  font-size: 0.8rem;
  color: var(--text-light);
}
.item-amount {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 12px;
  white-space: nowrap;
}

/* Result */
.result-card {
  border: 2px solid var(--primary);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.result-summary {
  text-align: center;
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 8px;
}
.result-summary .total-claimed {
  font-size: 0.9rem;
  color: var(--text-light);
}
.result-summary .total-fair {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 4px 0;
}
.result-summary .savings {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  display: inline-block;
  margin-top: 8px;
}
.savings.high { background: #fee2e2; color: var(--danger); }
.savings.medium { background: #fef3c7; color: #b45309; }
.savings.low { background: #dcfce7; color: var(--success); }

.result-item {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.result-item:last-child { border-bottom: none; }
.result-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.result-item-name { font-weight: 600; }
.result-badge {
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 600;
}
.badge-overpay { background: #fee2e2; color: var(--danger); }
.badge-fair { background: #dcfce7; color: var(--success); }
.badge-unnecessary { background: #fce7f3; color: #be185d; }
.badge-check { background: #fef3c7; color: #b45309; }
.result-item-detail {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.6;
}
.result-amounts {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.9rem;
}
.result-amounts .claimed {
  text-decoration: line-through;
  color: var(--text-light);
}
.result-amounts .fair {
  font-weight: 700;
  color: var(--primary);
}

/* Advice */
.advice-box {
  background: #eff6ff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 20px;
  font-size: 0.9rem;
  line-height: 1.8;
}
.advice-box h3 { margin-bottom: 8px; font-size: 1rem; }
.advice-box ul { padding-left: 20px; }
.advice-box li { margin-bottom: 4px; }

/* Letter */
.letter-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 0.85rem;
  line-height: 1.8;
  white-space: pre-wrap;
  margin: 12px 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 16px; }
.modal .form-group { margin-bottom: 14px; }
.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Disclaimer */
.disclaimer {
  background: #fffbeb;
  border: 1px solid #fde68a;
  font-size: 0.85rem;
}
.disclaimer h3 { margin-bottom: 8px; font-size: 0.95rem; }
.disclaimer ul { padding-left: 20px; }
.disclaimer li { margin-bottom: 4px; }

/* Ad */
.ad-unit {
  margin: 20px 0;
  text-align: center;
  min-height: 100px;
}

/* Footer */
footer {
  text-align: center;
  padding: 32px 0;
  color: var(--text-light);
  font-size: 0.8rem;
}
.footer-links {
  margin-top: 8px;
}
.footer-links a {
  color: var(--primary);
  text-decoration: none;
}
.footer-links span { margin: 0 8px; }

/* Responsive */
@media (max-width: 480px) {
  header { padding: 28px 0 36px; }
  header h1 { font-size: 1.4rem; }
  .card { padding: 18px; }
  .radio-group { flex-direction: column; gap: 8px; }
}
