* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

body {
  background: #f0f2f5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.app-container {
  max-width: 550px;
  width: 100%;
  background: #ffffff;
  border-radius: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
  padding: 1.5rem 1.3rem 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

h1 {
  font-size: 1.7rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.4px;
}

.user-badge {
  background: #4f46e5;
  color: white;
  padding: 0.5rem 1.2rem;
  border-radius: 2rem;
  font-weight: 700;
  font-size: 1rem;
}
.user-badge.viewonly {
  background: #94a3b8;
}

.notice {
  padding: 0.7rem 1rem;
  border-radius: 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
}
.notice-locked {
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
}
.notice-viewonly {
  background: #fef9c3;
  border: 1px solid #fde047;
  color: #854d0e;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: #64748b;
  font-size: 0.9rem;
}

.balance-grid {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.person-card {
  background: #ffffff;
  border: 1.5px solid #e8ecf1;
  border-radius: 1.3rem;
  padding: 1rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.person-card.you {
  border-color: #4f46e5;
  background: #faf9ff;
}

.person-info {
  display: flex;
  flex-direction: column;
}
.person-name {
  font-size: 1.3rem;
  font-weight: 650;
  color: #0f172a;
}
.debt-label {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.grand-total {
  font-size: 1.8rem;
  font-weight: 700;
  text-align: right;
}
.negative { color: #dc2626; }
.positive { color: #16a34a; }
.zero-balance { color: #64748b; }

.add-section {
  background: #f8fafc;
  border-radius: 1.5rem;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.add-section.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.section-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: #334155;
}

.row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

select, input {
  background: #fff;
  border: 1px solid #dce2e8;
  border-radius: 1rem;
  padding: 0.7rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #0f172a;
  outline: none;
  flex: 1;
  min-width: 90px;
}
select:focus, input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.amount-inp { max-width: 130px; }
.reason-inp { flex: 2; }

.btn {
  background: #1e293b;
  color: white;
  border: none;
  border-radius: 2rem;
  padding: 0.7rem 1.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #0f172a; }
.btn:active { transform: scale(0.97); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #475569;
  font-weight: 500;
}
.checkbox-row input {
  width: auto;
  accent-color: #4f46e5;
  flex: none;
}

.expenses-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.expense-card {
  background: #fff;
  border: 1px solid #eef2f6;
  border-radius: 1rem;
  padding: 0.8rem 1rem;
}
.expense-card .card-header {
  font-weight: 650;
  color: #0f172a;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.expense-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 0.85rem;
  gap: 0.5rem;
}
.expense-item:last-child { border-bottom: none; }
.expense-desc {
  flex: 2;
  color: #334155;
}
.expense-arrow {
  color: #94a3b8;
  margin: 0 0.3rem;
  font-size: 0.7rem;
}
.expense-amount {
  font-weight: 600;
  white-space: nowrap;
}
.expense-date {
  font-size: 0.65rem;
  color: #94a3b8;
  white-space: nowrap;
  min-width: 70px;
  text-align: right;
}
.amt-red { color: #b91c1c; }
.amt-green { color: #15803d; }

.footer-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
}
.note {
  font-size: 0.65rem;
  color: #9ca3af;
}
.synced {
  font-size: 0.65rem;
  color: #16a34a;
  font-weight: 600;
}