/* ═══════════════════════════════════════════════════════════
   SPLITEASE — Design System
   Palette: Fresh Teal + Warm Neutrals
   Fonts: Bricolage Grotesque + Plus Jakarta Sans
═══════════════════════════════════════════════════════════ */

:root {
  /* Brand */
  --brand: #1DB584;
  --brand-dark: #17956D;
  --brand-light: #E8F8F2;
  --brand-mid: #A8E6D0;

  /* Semantic */
  --owe: #E8534A;
  --owe-light: #FEF0EF;
  --lent: #1DB584;
  --lent-light: #E8F8F2;
  --settled: #8A94A6;
  --settled-light: #F4F5F7;

  /* Neutrals */
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F0F2F5;
  --border: #E4E7EC;
  --border-strong: #C9CDD6;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-muted: #9CA3AF;
  --text-inverse: #FFFFFF;

  /* Sidebar */
  --sidebar-bg: #0F1923;
  --sidebar-text: #CBD5E1;
  --sidebar-active: #1DB584;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-width: 260px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12), 0 4px 8px rgba(0,0,0,0.06);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.16);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}
a { text-decoration: none; color: var(--brand); cursor: pointer; }
a:hover { color: var(--brand-dark); }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

/* ── Screens ── */
.screen { min-height: 100vh; }
.screen.hidden { display: none !important; }
.screen.active { display: flex; }

/* ══════════════════════════════════════════════
   AUTH SCREEN
══════════════════════════════════════════════ */
#auth-screen {
  display: flex;
  min-height: 100vh;
}

.auth-container {
  width: 480px;
  min-width: 480px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 56px;
  position: relative;
  z-index: 2;
}

.auth-brand {
  text-align: center;
  margin-bottom: 40px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.brand-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.brand-tagline {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 20px;
}

.demo-accounts {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.demo-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 12px;
}

.demo-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-demo {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  transition: all var(--transition);
}

.btn-demo:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

/* Auth Visual Panel */
.auth-visual {
  flex: 1;
  background: linear-gradient(135deg, #0F1923 0%, #1a2d3d 50%, #0d2818 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-visual::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(29,181,132,0.15) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.visual-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 40px;
}

.visual-card {
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 320px;
  animation: floatIn 0.6s ease forwards;
  opacity: 0;
}

.vc1 { animation-delay: 0.1s; }
.vc2 { animation-delay: 0.25s; }
.vc3 { animation-delay: 0.4s; }

@keyframes floatIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.vc-icon { font-size: 28px; }
.vc-info { flex: 1; }
.vc-info span { display: block; font-size: 14px; font-weight: 600; color: #fff; }
.vc-info small { font-size: 12px; color: rgba(255,255,255,0.5); }
.vc-amount { font-size: 14px; font-weight: 700; color: #fff; text-align: right; }
.vc-amount .owe { display: block; font-size: 11px; font-weight: 500; color: #FF8A80; }
.vc-amount .lent { display: block; font-size: 11px; font-weight: 500; color: #69F0AE; }
.vc-amount .settled { display: block; font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.4); }

.visual-stat {
  text-align: center;
  margin-top: 8px;
  animation: floatIn 0.6s ease 0.55s forwards;
  opacity: 0;
}

.stat-num {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 42px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -2px;
}

.stat-label {
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════
   FORMS
══════════════════════════════════════════════ */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.1px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(29,181,132,0.12);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-error {
  background: var(--owe-light);
  color: var(--owe);
  border: 1px solid rgba(232,83,74,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

.input-with-prefix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  pointer-events: none;
}

.input-with-prefix .form-input {
  padding-left: 28px;
}

.currency-inline-select {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 50px;
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 10px 0 0 10px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  outline: none;
  z-index: 1;
  padding: 0 2px;
  appearance: none;
  -webkit-appearance: none;
}
.currency-inline-select:focus {
  border-color: var(--brand);
  background: var(--surface);
}



/* ══════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px rgba(29,181,132,0.3);
}

.btn-primary:hover {
  background: var(--brand-dark);
  box-shadow: 0 4px 12px rgba(29,181,132,0.4);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--owe-light);
  color: var(--owe);
  border: 1.5px solid rgba(232,83,74,0.2);
}

.btn-danger:hover {
  background: var(--owe);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-full { width: 100%; justify-content: center; }
.btn-full.btn-primary { margin-top: 4px; }

/* ══════════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════════ */
#app-screen {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-header {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header .brand-name { color: #fff; font-size: 18px; }

.sidebar-close {
  display: none;
  color: rgba(255,255,255,0.4);
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
}

.sidebar-close:hover { color: #fff; }

.sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  padding: 12px 12px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: rgba(29,181,132,0.15);
  color: var(--brand);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--owe);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}

.sidebar-groups {
  padding: 0 12px 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 12px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.25);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 1px;
}

.sidebar-group-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-group-icon {
  font-size: 16px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer .btn-ghost {
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
}

.sidebar-footer .btn-ghost:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
}

/* Main Wrapper */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-menu {
  display: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.topbar-menu:hover { background: var(--surface-2); color: var(--text-primary); }

.topbar-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
  letter-spacing: -0.3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px;
}

/* Pages */
.page { display: none; }
.page.active { display: block; }
.page.hidden { display: none; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.8px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ══════════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════════ */
.balance-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.balance-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  border: 1.5px solid var(--border);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.balance-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.bc-total-owed::before { background: var(--brand); }
.bc-total-owe::before { background: var(--owe); }
.bc-net::before { background: #7C3AED; }

.balance-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.bc-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.bc-amount {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 4px;
}

.bc-total-owed .bc-amount { color: var(--brand); }
.bc-total-owe .bc-amount { color: var(--owe); }
.bc-net .bc-amount { color: #7C3AED; }

.bc-sub {
  font-size: 12px;
  color: var(--text-muted);
}

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

.dash-section {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  padding: 20px;
}

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

.section-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.section-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
}

/* Balance List */
.balance-list { display: flex; flex-direction: column; gap: 2px; }

.balance-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  cursor: pointer;
}

.balance-item:hover { background: var(--surface-2); }

.balance-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.balance-info { flex: 1; min-width: 0; }
.balance-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.balance-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.balance-amount {
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}

.balance-amount.positive { color: var(--brand); }
.balance-amount.negative { color: var(--owe); }
.balance-amount.zero { color: var(--text-muted); }

.balance-amount small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.7;
}

/* Activity List */
.activity-list { display: flex; flex-direction: column; gap: 2px; }

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  cursor: pointer;
}

.activity-item:hover { background: var(--surface-2); }

.activity-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--surface-2);
}

.activity-icon.type-expense { background: var(--brand-light); }
.activity-icon.type-payment { background: #EDE9FE; }
.activity-icon.type-group { background: #FEF3C7; }

.activity-info { flex: 1; min-width: 0; }
.activity-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}
.activity-desc strong { font-weight: 700; }
.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.activity-amount {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.activity-amount.positive { color: var(--brand); }
.activity-amount.negative { color: var(--owe); }

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

.empty-state-icon { font-size: 36px; margin-bottom: 10px; }
.empty-state-text { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.empty-state-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ══════════════════════════════════════════════
   FRIENDS PAGE
══════════════════════════════════════════════ */
.friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.friend-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition);
  cursor: pointer;
}

.friend-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--brand-mid);
}

.friend-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.friend-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.friend-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.friend-email {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.friend-balance {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
}

.friend-balance.owe {
  background: var(--owe-light);
  color: var(--owe);
}

.friend-balance.lent {
  background: var(--lent-light);
  color: var(--lent);
}

.friend-balance.settled {
  background: var(--settled-light);
  color: var(--settled);
}

.friend-balance-label { font-weight: 500; }
.friend-balance-amount { font-weight: 700; }

.friend-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ══════════════════════════════════════════════
   GROUPS PAGE
══════════════════════════════════════════════ */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.group-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.group-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}

.group-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.group-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.group-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: var(--surface-2);
  flex-shrink: 0;
}

.group-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.group-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.group-stats {
  display: flex;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.group-stat {
  flex: 1;
  text-align: center;
}

.group-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.group-stat-value.positive { color: var(--brand); }
.group-stat-value.negative { color: var(--owe); }

.group-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Group Detail */
.group-detail-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

.group-detail-header {
  flex: 1;
}

.group-detail-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-detail-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.back-btn {
  color: var(--text-muted);
  font-size: 13px;
  gap: 4px;
}

.back-btn:hover { color: var(--text-primary); }

/* Expense List */
.expense-list { display: flex; flex-direction: column; gap: 2px; }

.expense-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px solid var(--border);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all var(--transition);
}

.expense-item:hover {
  border-color: var(--brand-mid);
  box-shadow: var(--shadow-sm);
}

.expense-emoji {
  font-size: 24px;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.expense-info { flex: 1; min-width: 0; }
.expense-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.expense-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.expense-amounts { text-align: right; }
.expense-total {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.expense-share {
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}
.expense-share.positive { color: var(--brand); }
.expense-share.negative { color: var(--owe); }
.expense-share.neutral { color: var(--text-muted); }

/* Group Sidebar Cards */
.group-balances-card,
.group-members-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
}

.card-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  letter-spacing: -0.2px;
}

.members-list { display: flex; flex-direction: column; gap: 8px; }

.member-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.member-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.member-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.member-you-badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--brand-light);
  color: var(--brand);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.mt-8 { margin-top: 8px; }

/* ══════════════════════════════════════════════
   ACTIVITY PAGE
══════════════════════════════════════════════ */
.activity-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 7px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  transition: all var(--transition);
}

.filter-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.filter-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.activity-list-full .activity-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  margin-bottom: 6px;
  border-radius: var(--radius-md);
}

.activity-list-full .activity-item:hover {
  border-color: var(--brand-mid);
}

/* ══════════════════════════════════════════════
   ACCOUNT PAGE
══════════════════════════════════════════════ */
.account-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: auto auto;
  gap: 20px;
  align-items: start;
}

.account-profile-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  grid-row: 1;
}

.account-avatar-large {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  margin: 0 auto 14px;
}

.account-name {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.account-email {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.account-joined {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.account-settings-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  grid-column: 2;
  grid-row: 1 / 3;
}

.account-stats-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  grid-column: 1;
  grid-row: 2;
}

.account-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.account-stat {
  text-align: center;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}

.account-stat-value {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.account-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-lg { max-width: 580px; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal::-webkit-scrollbar { width: 4px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  background: var(--surface-2);
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--border);
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 18px;
  line-height: 1.5;
}

.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* Expense Form Specifics */
.expense-form-top {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 18px;
}

.expense-icon-picker {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
  margin-bottom: 0;
  align-self: flex-end;
  padding-bottom: 2px;
}

.expense-icon-picker:hover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.flex-1 { flex: 1; }

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.icon-picker-grid span {
  font-size: 22px;
  text-align: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.icon-picker-grid span:hover { background: var(--border); }

/* Split Section */
.split-section {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
}

.split-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.split-header .form-label { margin-bottom: 0; }

.split-type-tabs {
  display: flex;
  gap: 4px;
  background: var(--border);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.split-tab {
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.split-tab.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.split-participants {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.split-participant {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
}

.split-participant.included {
  border-color: var(--brand-mid);
  background: var(--brand-light);
}

.split-participant-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.split-participant-check.checked {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.split-participant-check.checked::after {
  content: '✓';
  font-size: 11px;
  font-weight: 700;
}

.split-participant-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.split-participant-input {
  width: 90px;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  outline: none;
  transition: border-color var(--transition);
}

.split-participant-input:focus { border-color: var(--brand); }

.split-participant-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 90px;
  text-align: right;
}

.split-summary {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.split-summary.error { color: var(--owe); }
.split-summary.ok { color: var(--brand); }

/* Settle Up */
.settle-arrow {
  display: flex;
  justify-content: center;
  color: var(--brand);
  margin: -6px 0;
}

/* Group Type Grid */
.group-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.group-type-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.group-type-option:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.group-type-option.selected {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand);
}

.gt-icon { font-size: 22px; }

/* Member Checkboxes */
.member-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.member-checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}

.member-checkbox-item:hover { border-color: var(--brand-mid); }
.member-checkbox-item.selected {
  border-color: var(--brand);
  background: var(--brand-light);
}

.member-checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}

.member-checkbox-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.member-checkbox-email {
  font-size: 12px;
  color: var(--text-muted);
}

/* Friend Search Result */
.friend-search-result {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--brand-mid);
  background: var(--brand-light);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.friend-found-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.friend-not-found {
  font-size: 13px;
  color: var(--owe);
  font-weight: 500;
  padding: 2px 0;
}

/* Expense Detail */
.expense-detail-section {
  margin-bottom: 18px;
}

.expense-detail-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.expense-detail-split-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.expense-detail-split-item:last-child { border-bottom: none; }

/* ══════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text-primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
}

.toast.success { background: var(--brand-dark); }
.toast.error { background: var(--owe); }
.toast.info { background: #3B82F6; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

/* ══════════════════════════════════════════════
   SIDEBAR OVERLAY (mobile)
══════════════════════════════════════════════ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.hidden { display: none; }

/* ══════════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════════ */
.hidden { display: none !important; }

.avatar-color-0 { background: #1DB584; }
.avatar-color-1 { background: #3B82F6; }
.avatar-color-2 { background: #8B5CF6; }
.avatar-color-3 { background: #F59E0B; }
.avatar-color-4 { background: #EF4444; }
.avatar-color-5 { background: #EC4899; }
.avatar-color-6 { background: #06B6D4; }
.avatar-color-7 { background: #84CC16; }
.avatar-color-8 { background: #F97316; }
.avatar-color-9 { background: #6366F1; }

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .balance-cards { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .group-detail-layout { grid-template-columns: 1fr; }
  .group-sidebar-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .group-sidebar-col .group-balances-card,
  .group-sidebar-col .group-members-card { margin-bottom: 0; }
  .account-layout { grid-template-columns: 1fr; }
  .account-settings-card { grid-column: 1; grid-row: 2; }
  .account-stats-card { grid-column: 1; grid-row: 3; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .sidebar-close { display: flex; }
  .topbar-menu { display: flex; }

  .auth-container {
    width: 100%;
    min-width: unset;
    padding: 32px 24px;
  }

  .auth-visual { display: none; }

  .balance-cards { grid-template-columns: 1fr; gap: 10px; }
  .form-row { grid-template-columns: 1fr; }
  .group-type-grid { grid-template-columns: repeat(2, 1fr); }
  .main-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .topbar-actions .btn-outline { display: none; }
  .friends-grid { grid-template-columns: 1fr; }
  .groups-grid { grid-template-columns: 1fr; }
  .group-sidebar-col { grid-template-columns: 1fr; }
  .split-type-tabs { flex-wrap: wrap; }
  .icon-picker-grid { grid-template-columns: repeat(6, 1fr); }
  .modal { border-radius: var(--radius-lg); }
}

@media (max-width: 480px) {
  .page-title { font-size: 22px; }
  .bc-amount { font-size: 24px; }
  .topbar-title { font-size: 16px; }
}