:root {
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --text: #172033;
  --muted: #667085;
  --border: #e5e7eb;
  --bg: #f5f7fb;
  --white: #ffffff;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1000px;
  margin: 0 auto;
  padding: 18px 16px 90px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 1.05rem;
  font-weight: 800;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
}

.page-header h2,
.page-header h3 {
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 720px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  margin-bottom: 12px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
}

.stat-label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-muted {
  background: #f3f4f6;
  color: var(--muted);
}

.btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.btn:hover { filter: brightness(0.98); }

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-outline {
  background: var(--white);
  color: var(--text);
  border-color: var(--border);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.list {
  display: grid;
  gap: 10px;
}

.room-card,
.person-card,
.history-card,
.transaction-card {
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 14px;
  padding: 14px;
}

.room-card {
  cursor: pointer;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #edf2f7;
  display: grid;
  place-items: center;
  font-weight: 800;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  text-align: center;
  padding: 28px 20px;
}

.logo {
  font-size: 52px;
  margin-bottom: 6px;
}

.login-card h1 {
  margin: 0;
  font-size: 2rem;
}

.login-card p {
  color: var(--muted);
}

.auth-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.form {
  display: grid;
  gap: 10px;
}

.form-group {
  display: grid;
  gap: 6px;
}

.form label {
  font-size: 0.8rem;
  font-weight: 700;
}

.form input,
.form select,
.form textarea {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 9px;
  padding: 10px 12px;
  background: #fff;
}

.form textarea { min-height: 84px; resize: vertical; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.56);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}

.modal.hidden {
  display: none;
}

.sheet {
  width: min(680px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--white);
  border-radius: 18px 18px 0 0;
  padding: 18px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sheet-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: #111827;
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 40;
}

.toast.visible {
  opacity: 1;
}

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.97);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.nav-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
}

.nav button {
  flex: 1;
  min-height: 64px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.nav button.active {
  color: var(--primary);
}

.nav button span {
  display: block;
  font-size: 1.4rem;
  margin-bottom: 3px;
}

.hidden {
  display: none !important;
}

@media (min-width: 700px) {
  .sheet {
    border-radius: 18px;
  }
}
