:root {
  --ocean: #0077b6;
  --ocean-dark: #005f8e;
  --ocean-light: #90e0ef;
  --income: #2ecc71;
  --expense: #e74c3c;
  --bg: #f0f8ff;
  --card: #ffffff;
  --text: #1a1a2e;
  --sub: #6b7280;
  --border: #e2e8f0;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, 'Segoe UI', 'PingFang TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--ocean-dark), var(--ocean));
  color: white;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,119,182,0.3);
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo { font-size: 1.2rem; font-weight: 700; letter-spacing: 1px; }
nav { display: flex; gap: 4px; }
nav a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.2s;
}
nav a:hover { background: rgba(255,255,255,0.15); color: white; }
nav a.active { background: rgba(255,255,255,0.25); color: white; font-weight: 600; }

/* Main */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
h1 { font-size: 1.6rem; color: var(--ocean-dark); margin-bottom: 4px; }
h2 { font-size: 1.1rem; color: var(--text); margin-bottom: 16px; }
h3 { font-size: 1rem; margin-bottom: 12px; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  border: 1px solid var(--border);
}

/* Form */
.form-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.form-row label {
  width: 110px;
  font-weight: 500;
  color: var(--sub);
  flex-shrink: 0;
}
.form-row input, .form-row select {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 1rem;
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--ocean);
}

/* Type toggle */
.type-toggle { display: flex; gap: 8px; }
.type-btn {
  padding: 8px 20px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--sub);
  transition: all 0.2s;
}
.type-btn.active[data-type="income"] {
  background: var(--income);
  border-color: var(--income);
  color: white;
  font-weight: 600;
}
.type-btn.active[data-type="expense"] {
  background: var(--expense);
  border-color: var(--expense);
  color: white;
  font-weight: 600;
}

/* Buttons */
.btn-submit {
  width: 100%;
  background: linear-gradient(135deg, var(--ocean), var(--ocean-dark));
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-submit:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-submit:active { transform: translateY(0); }

.btn-filter {
  background: var(--ocean);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  transition: opacity 0.2s;
}
.btn-filter:hover { opacity: 0.85; }

.btn-export {
  background: linear-gradient(135deg, #059669, #047857);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.btn-export:hover { opacity: 0.85; }

.btn-del {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s;
  margin-left: auto;
  flex-shrink: 0;
}
.btn-del:hover { color: var(--expense); }

/* Summary card */
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
}
.summary-row:last-child { border-bottom: none; }
.net-row { font-weight: 600; font-size: 1.05rem; }

/* Values */
.income-val { color: var(--income); font-weight: 600; }
.expense-val { color: var(--expense); font-weight: 600; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 28px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.95rem;
  z-index: 999;
  transition: opacity 0.3s;
}
.toast.hidden { display: none; }
.toast.success { background: var(--income); color: white; }
.toast.error { background: var(--expense); color: white; }

/* Filter */
.filter-card { display: flex; gap: 12px; align-items: center; }
.filter-card select {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  min-width: 0;
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.data-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  color: var(--sub);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tfoot td {
  background: #f8fafc;
  border-top: 2px solid var(--border);
  font-weight: 600;
}
.data-table .empty-row td { color: #ccc; }
.data-table tr:hover td { background: #fafeff; }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
}
.badge.income { background: #d1fae5; color: #059669; }
.badge.expense { background: #fee2e2; color: #dc2626; }

/* Bar */
.bar-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bar {
  height: 8px;
  background: linear-gradient(90deg, var(--ocean-light), var(--ocean));
  border-radius: 4px;
  min-width: 2px;
  transition: width 0.5s;
}
.bar-wrap span { font-size: 0.8rem; color: var(--sub); white-space: nowrap; }

/* Record summary */
.record-summary {
  display: flex;
  gap: 24px;
  padding: 16px 12px 4px;
  font-size: 0.9rem;
  color: var(--sub);
}

/* Breakdown grid */
.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Item list */
.item-list { list-style: none; }
.item-list li {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.item-list li:last-child { border-bottom: none; }

.empty { color: var(--sub); text-align: center; padding: 20px 0; }

@media (max-width: 600px) {
  .form-row { flex-direction: column; align-items: flex-start; }
  .form-row label { width: auto; }
  .form-row input, .form-row select { width: 100%; }
  .breakdown-grid { grid-template-columns: 1fr; }
  nav a { padding: 6px 8px; font-size: 0.8rem; }
}
