:root {
  --bg: #f7f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --owed: #16a34a;
  --owes: #dc2626;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

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

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

header.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

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

h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin-top: 0; }

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

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
  margin-top: 12px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: white;
  color: var(--text);
}

input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 1rem;
  font-weight: 600;
}

button.primary {
  background: var(--primary);
  color: white;
  width: 100%;
  margin-top: 16px;
}

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

button.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  width: 100%;
  margin-top: 8px;
}

button.link {
  background: none;
  color: var(--primary);
  padding: 4px 0;
  font-weight: 500;
}

button.small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

button:disabled { opacity: 0.6; cursor: not-allowed; }

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 8px;
  min-height: 1.2em;
}

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

.project-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}

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

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
}

.tabs button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.balance-row:last-child { border-bottom: none; }

.balance-amount.owed { color: var(--owed); font-weight: 700; }
.balance-amount.owes { color: var(--owes); font-weight: 700; }
.balance-amount.even { color: var(--muted); font-weight: 700; }

.expense-item, .settlement-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

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

.expense-desc { font-weight: 600; }
.expense-meta { color: var(--muted); font-size: 0.85rem; }
.expense-amount { font-weight: 700; white-space: nowrap; margin-left: 12px; }

.receipt-preview {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 12px;
  display: none;
}

.scan-status {
  font-size: 0.85rem;
  color: var(--primary);
  margin-top: 8px;
  min-height: 1.2em;
}

.invite-code {
  font-family: monospace;
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 1rem;
}

.hidden { display: none !important; }
