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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  min-height: 100vh;
  padding: 16px;
}

.container {
  max-width: 700px;
  margin: 0 auto;
}

h1 {
  font-size: 1.5rem;
  color: #1e40af;
  margin-bottom: 16px;
  text-align: center;
}

h2 {
  font-size: 1rem;
  color: #334155;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form-row input[type="text"] {
  flex: 1 1 140px;
  min-width: 120px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
}

.form-row input[type="date"] {
  flex: 1 1 140px;
  min-width: 130px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.95rem;
}

.form-row button,
button {
  padding: 8px 18px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
}

.form-row button:hover,
button:hover {
  background: #2563eb;
}

.error-msg {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 6px;
  min-height: 18px;
}

.count-badge {
  font-size: 0.8rem;
  background: #dbeafe;
  color: #1e40af;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: normal;
}

.empty-msg {
  text-align: center;
  color: #94a3b8;
  padding: 20px 0;
  font-size: 0.9rem;
}

.customer-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.customer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  flex-wrap: wrap;
}

.customer-item.alert-high {
  border-left: 4px solid #ef4444;
  background: #fff5f5;
}

.customer-item.alert-mid {
  border-left: 4px solid #f59e0b;
  background: #fffbeb;
}

.customer-name {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1 1 120px;
  min-width: 100px;
}

.customer-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 2 1 180px;
}

.stat-line {
  font-size: 0.82rem;
  color: #475569;
}

.stat-line span {
  font-weight: 600;
  color: #1e293b;
}

.days-badge {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  background: #dbeafe;
  color: #1d4ed8;
  white-space: nowrap;
}

.days-badge.high {
  background: #fee2e2;
  color: #b91c1c;
}

.days-badge.mid {
  background: #fef3c7;
  color: #92400e;
}

.btn-history {
  background: #e2e8f0;
  color: #334155;
  font-size: 0.8rem;
  padding: 5px 12px;
}

.btn-history:hover {
  background: #cbd5e1;
}

.btn-delete-customer {
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.8rem;
  padding: 5px 12px;
}

.btn-delete-customer:hover {
  background: #fca5a5;
}

/* モーダル */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  font-size: 1rem;
  color: #1e293b;
}

.close-btn {
  background: none;
  color: #64748b;
  font-size: 1.3rem;
  padding: 2px 8px;
  line-height: 1;
}

.close-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.history-list {
  overflow-y: auto;
  flex: 1;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #334155;
}

.btn-del-visit {
  background: none;
  color: #94a3b8;
  font-size: 0.8rem;
  padding: 2px 6px;
}

.btn-del-visit:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
}

.modal-footer input[type="date"] {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.9rem;
}

.modal-footer button {
  white-space: nowrap;
  font-size: 0.9rem;
}

@media (max-width: 480px) {
  .customer-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .days-badge {
    align-self: flex-end;
  }

  .form-row {
    flex-direction: column;
  }

  .form-row input,
  .form-row button {
    width: 100%;
  }
}
