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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f6fa;
  color: #333;
  min-height: 100vh;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 4px;
}

.subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 20px;
}

h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: #1a1a2e;
}

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

/* 設定カード */
.settings-card .settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-card label {
  font-size: 0.9rem;
  color: #555;
  white-space: nowrap;
}

.settings-card input {
  width: 80px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  text-align: center;
}

.unit {
  font-size: 0.85rem;
  color: #888;
}

.note {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #aaa;
}

/* フォーム */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.82rem;
  color: #666;
  font-weight: 500;
}

.form-group input {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #4a6cf7;
}

.btn-add {
  width: 100%;
  padding: 12px;
  background: #4a6cf7;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-add:hover {
  background: #3a5cd7;
}

/* フィルター */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-btn {
  padding: 7px 16px;
  border: 1px solid #ddd;
  border-radius: 20px;
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  color: #555;
  transition: all 0.2s;
}

.filter-btn.active {
  background: #4a6cf7;
  border-color: #4a6cf7;
  color: #fff;
}

/* 顧客一覧 */
.customer-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

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

.customer-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  border-left: 4px solid #4caf50;
  position: relative;
}

.customer-card.danger {
  border-left-color: #e53935;
  background: #fff8f8;
}

.customer-card.warning {
  border-left-color: #ff9800;
  background: #fffaf3;
}

.customer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.customer-name {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
}

.status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.status-ok {
  background: #e8f5e9;
  color: #2e7d32;
}

.status-ng {
  background: #ffebee;
  color: #c62828;
}

.customer-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  font-size: 0.72rem;
  color: #999;
}

.detail-value {
  font-size: 0.88rem;
  font-weight: 600;
  color: #333;
}

.cost-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #f0f0f0;
  flex-wrap: wrap;
}

.cost-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cost-label {
  font-size: 0.72rem;
  color: #999;
}

.cost-value {
  font-size: 0.95rem;
  font-weight: 700;
}

.cost-value.danger {
  color: #e53935;
}

.cost-value.ok {
  color: #2e7d32;
}

.cost-rate-bar {
  flex: 1;
  min-width: 100px;
}

.bar-track {
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}

.bar-fill.ok {
  background: #4caf50;
}

.bar-fill.ng {
  background: #e53935;
}

.btn-delete {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: #ccc;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s;
}

.btn-delete:hover {
  color: #e53935;
}

/* 集計 */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.summary-item {
  background: #f8f9fe;
  border-radius: 8px;
  padding: 12px;
}

.summary-label {
  display: block;
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 4px;
}

.summary-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1a1a2e;
}

.summary-value.danger {
  color: #e53935;
}

.summary-unit {
  font-size: 0.85rem;
  color: #888;
  margin-left: 2px;
}

/* レスポンシブ */
@media (max-width: 480px) {
  h1 {
    font-size: 1.3rem;
  }

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

  .customer-details {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .filter-bar {
    flex-wrap: wrap;
  }
}
