:root {
  --bg: #f7f7fb;
  --card-bg: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --positive: #16a34a;
  --negative: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

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

.top-bar a {
  color: inherit;
  text-decoration: none;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-page {
  max-width: 360px;
  margin: 80px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.card h2,
.card h3 {
  margin-top: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  text-align: left;
}

input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--card-bg);
  color: var(--text);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 1rem;
  cursor: pointer;
}

button:hover {
  background: var(--primary-dark);
}

.link-btn {
  background: none;
  color: var(--muted);
  padding: 0;
  text-decoration: underline;
}

.link-btn:hover {
  background: none;
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.error {
  color: var(--negative);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-item a {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}

.expense-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.expense-main {
  display: flex;
  justify-content: space-between;
}

.expense-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.expense-actions button {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  padding: 6px 10px;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

legend {
  padding: 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.participant-family {
  margin-bottom: 10px;
}

.family-toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.member-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-left: 24px;
  margin-top: 4px;
}

.member-list label {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  margin-bottom: 0;
  font-weight: normal;
}

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

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

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

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

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --card-bg: #1a1d24;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: #2a2e37;
  }
}
