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

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

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

h1 {
  text-align: center;
  color: #1565C0;
  font-size: 1.5rem;
  margin-bottom: 16px;
  padding: 16px 0 8px;
}

h2 {
  font-size: 1rem;
  color: #1565C0;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid #BBDEFB;
}

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

/* 予算設定 */
.budget-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.budget-input-row input {
  flex: 1;
}

.budget-display {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.budget-item {
  flex: 1;
  text-align: center;
  background: #E3F2FD;
  border-radius: 8px;
  padding: 10px 6px;
}

.budget-item.highlight {
  background: #1565C0;
  color: #fff;
}

.budget-item .label {
  display: block;
  font-size: 0.72rem;
  margin-bottom: 4px;
  opacity: 0.8;
}

.budget-item .value {
  display: block;
  font-size: 1.05rem;
  font-weight: bold;
}

.budget-item.highlight .label {
  color: #BBDEFB;
}

.progress-bar-wrap {
  background: #E3F2FD;
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-bar {
  height: 100%;
  background: #2196F3;
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s, background 0.3s;
}

.progress-bar.over {
  background: #e53935;
}

.progress-label {
  font-size: 0.78rem;
  color: #666;
  text-align: right;
}

/* フォーム */
.form-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.form-row:last-child {
  margin-bottom: 0;
}

input[type="number"],
input[type="text"],
select {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #BBDEFB;
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border 0.2s;
}

input:focus,
select:focus {
  border-color: #2196F3;
}

button {
  padding: 10px 16px;
  background: #2196F3;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}

button:hover {
  background: #1565C0;
}

/* カテゴリ集計 */
#category-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #E3F2FD;
  border-radius: 99px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.cat-chip .cat-name {
  color: #1565C0;
  font-weight: bold;
}

.cat-chip .cat-amount {
  color: #333;
}

.empty-cat {
  color: #aaa;
  font-size: 0.9rem;
}

/* 支出一覧 */
#expense-list {
  margin-bottom: 12px;
}

.expense-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
  gap: 8px;
}

.expense-item:last-child {
  border-bottom: none;
}

.expense-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.expense-cat-badge {
  background: #2196F3;
  color: #fff;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.expense-memo {
  font-size: 0.88rem;
  color: #555;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expense-date {
  font-size: 0.75rem;
  color: #aaa;
}

.expense-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.expense-amount {
  font-weight: bold;
  font-size: 1rem;
  color: #1565C0;
  white-space: nowrap;
}

.delete-btn {
  background: none;
  color: #e53935;
  border: 1px solid #e53935;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

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

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

.danger-btn {
  background: #fff;
  color: #e53935;
  border: 1px solid #e53935;
  width: 100%;
}

.danger-btn:hover {
  background: #e53935;
  color: #fff;
}

/* 予算超過時 */
#remaining-budget.over {
  color: #ff8f8f;
}

@media (max-width: 375px) {
  h1 {
    font-size: 1.25rem;
  }

  .budget-display {
    flex-direction: column;
  }

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

  button {
    width: 100%;
  }
}
