:root {
  --bg: #f3f5f9;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --accent: #3b82f6;
  --border: #e5e7eb;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { margin: 0; font-size: 1.25rem; }

.logout {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
}
.logout:hover { color: var(--text); }

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.card-header h2 { margin: 0; }

.chart-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 16px 0 6px;
}

.toggle-group {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.toggle-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.toggle-btn.active {
  background: var(--accent);
  color: white;
}

.toggle-btn:not(.active):hover {
  background: var(--border);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label { font-size: 0.8rem; color: var(--muted); }
.stat-value { font-size: 1.4rem; font-weight: 600; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}

.record-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
}

.record-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--muted);
  gap: 4px;
  flex: 1 1 120px;
}

.record-form input,
.record-form select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  width: 100%;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { opacity: 0.9; }

.record-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.record-table th, .record-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.record-table .memo { color: var(--muted); }
.record-table .empty { text-align: center; color: var(--muted); padding: 20px; }

.delete-btn {
  background: transparent;
  color: var(--danger);
  padding: 4px 8px;
  font-size: 0.85rem;
}
.delete-btn:hover { background: rgba(239,68,68,0.1); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.login-card h1 { margin-top: 0; }

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.login-card input {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.error { color: var(--danger); font-size: 0.85rem; margin: 0; }
