/* ==========================================================================
   Tricount Mini App — Telegram-themed, Tricount-inspired design
   ========================================================================== */

/* --- CSS Custom Properties (Telegram theme integration) --- */
:root {
  /* Fallback values for when not in Telegram */
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1a1a2e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #007aff);
  --btn: var(--tg-theme-button-color, #00b894);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --header-bg: var(--tg-theme-header-bg-color, #00b894);
  --section-bg: var(--tg-theme-section-bg-color, #ffffff);
  --section-header: var(--tg-theme-section-header-text-color, #8e8e93);
  --subtitle: var(--tg-theme-subtitle-text-color, #8e8e93);
  --destructive: var(--tg-theme-destructive-text-color, #ff3b30);

  /* Tricount brand */
  --accent: #00b894;
  --accent-dark: #00a884;
  --accent-light: #e8f8f5;
  --positive: #00b894;
  --negative: #e74c3c;
  --warning: #f39c12;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--secondary-bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

a { color: var(--link); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
}

.hidden { display: none !important; }

/* --- Header --- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 var(--space-sm);
  background: var(--accent);
  color: #fff;
}

.header-title {
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 var(--space-sm);
}

.header-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border-radius: var(--radius-full);
  transition: background 0.15s;
  flex-shrink: 0;
}
.header-btn:active { background: rgba(255,255,255,0.15); }
.header-lang-btn { width: 32px; height: 32px; font-size: 18px; }

/* --- Content area --- */
.content {
  padding: var(--space-md);
  padding-bottom: 100px;
  min-height: calc(100vh - 56px);
  animation: fadeIn 0.2s ease;
}

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

/* --- Cards --- */
.card {
  background: var(--section-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:active { transform: scale(0.98); }
.card + .card { margin-top: var(--space-sm); }

.card-body { padding: var(--space-md); }

/* --- Group Card --- */
.group-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  cursor: pointer;
}

.group-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Emoji picker */
.emoji-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.emoji-option {
  width: 100%;
  aspect-ratio: 1;
  font-size: 22px;
  border-radius: var(--radius-md);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.emoji-option.selected {
  background: var(--accent-light);
  outline: 2px solid var(--accent);
}
.emoji-option:active { background: var(--accent-light); }

.group-card-info { flex: 1; min-width: 0; }
.group-card-name {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-card-meta {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
}

.group-card-balance {
  font-size: 15px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.group-card-balance.positive { color: var(--positive); }
.group-card-balance.negative { color: var(--negative); }
.group-card-balance.zero { color: var(--hint); }

/* --- Tabs --- */
.tabs {
  display: flex;
  background: var(--section-bg);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.tab {
  flex: 1;
  padding: 10px 0;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--hint);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* --- Tab Content --- */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

/* --- Expense Card --- */
.expense-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  cursor: pointer;
}

.expense-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.expense-card-info { flex: 1; min-width: 0; }
.expense-card-desc {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.expense-card-meta {
  font-size: 13px;
  color: var(--hint);
  margin-top: 2px;
}

.expense-card-amount {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text);
}

/* --- Date separator --- */
.date-separator {
  font-size: 13px;
  font-weight: 600;
  color: var(--section-header);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: var(--space-lg) 0 var(--space-sm);
}
.date-separator:first-child { padding-top: 0; }

/* --- Balance Bars --- */
.balance-list { display: flex; flex-direction: column; gap: var(--space-sm); }

.balance-row {
  background: var(--section-bg);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}

.balance-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.balance-name {
  font-size: 15px;
  font-weight: 500;
}

.balance-amount {
  font-size: 15px;
  font-weight: 600;
}
.balance-amount.positive { color: var(--positive); }
.balance-amount.negative { color: var(--negative); }

.balance-bar-track {
  height: 8px;
  background: var(--secondary-bg);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.balance-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  position: absolute;
}
.balance-bar-fill.positive {
  background: var(--positive);
  left: 50%;
}
.balance-bar-fill.negative {
  background: var(--negative);
  right: 50%;
}

.balance-bar-center {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--hint);
  opacity: 0.3;
  transform: translateX(-50%);
}

/* --- Settlement Cards --- */
.settlement-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--section-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.settlement-card + .settlement-card { margin-top: var(--space-sm); }

.settlement-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.settlement-arrow-line {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--hint);
  font-size: 13px;
}

.settlement-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.settlement-person {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  min-width: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.settlement-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
}
.settlement-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.settlement-avatar-initial {
  font-size: 13px;
}

.settle-btn {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.settle-btn:active { opacity: 0.8; }

/* --- Settlement QR Dialog --- */
.settle-qr-dialog {
  text-align: center;
  padding: var(--space-sm) 0;
}
.settle-qr-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}
.settle-qr-amount {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: var(--space-md);
}
.settle-qr-img {
  max-width: 80%;
  max-height: 280px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}
.settle-qr-hint {
  font-size: 13px;
  color: var(--hint);
}

.settle-bank-btn {
  width: 100%;
  margin-bottom: var(--space-sm);
}
.settle-bank-account {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px;
  margin-bottom: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--secondary-bg);
  cursor: pointer;
}
.settle-bank-copy {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
}

/* --- Summary Section --- */
.summary-card {
  background: var(--section-bg);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}
.summary-card + .summary-card { margin-top: var(--space-sm); }

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.summary-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  overflow: hidden;
}
.summary-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.summary-avatar-initial {
  font-size: 12px;
}

.summary-name { font-weight: 600; font-size: 15px; }
.summary-net { font-weight: 700; font-size: 15px; }

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 14px;
  color: var(--hint);
}
.summary-row-value { font-weight: 500; color: var(--text); }

/* --- Summary Tabs --- */
.summary-tabs {
  display: flex;
  gap: 4px;
  background: var(--secondary-bg);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: var(--space-md);
}
.summary-tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--hint);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.summary-tab.active {
  background: var(--section-bg);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* --- Monthly Summary --- */
.monthly-card {
  background: var(--section-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.monthly-card + .monthly-card { margin-top: var(--space-sm); }

.monthly-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  cursor: pointer;
  user-select: none;
}
.monthly-info { flex: 1; }
.monthly-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.monthly-count {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}
.monthly-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}
.monthly-chevron {
  color: var(--hint);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.monthly-chevron.expanded {
  transform: rotate(180deg);
}

.monthly-detail {
  padding: 0 var(--space-md) var(--space-md);
}
.monthly-detail.hidden {
  display: none;
}

.monthly-member-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: var(--text);
  border-top: 1px solid var(--secondary-bg);
}
.monthly-member-amount {
  font-weight: 500;
}

/* --- Form Styles --- */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--section-header);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-sm);
}

.form-input {
  width: 100%;
  padding: 14px var(--space-md);
  background: var(--section-bg);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font-size: 16px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--hint); }

/* Large amount input */
.amount-input-wrapper {
  text-align: center;
  padding: var(--space-xl) 0;
}

.amount-currency {
  font-size: 24px;
  font-weight: 300;
  color: var(--hint);
  margin-bottom: var(--space-sm);
}

.amount-input {
  width: 100%;
  text-align: center;
  font-size: 48px;
  font-weight: 700;
  background: transparent;
  color: var(--text);
  caret-color: var(--accent);
}
.amount-input::placeholder {
  color: var(--hint);
  opacity: 0.4;
}

/* Grouped-thousands echo of what's typed (₫ 1.500.000) */
.amount-preview {
  min-height: 20px;
  margin-top: var(--space-xs);
  font-size: 15px;
  font-weight: 500;
  color: var(--hint);
  letter-spacing: 0.5px;
}

/* Zero-append chips — thousand-scale currencies (VND) */
.amount-quick {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.amount-quick-btn {
  min-width: 64px;
  padding: 8px 16px;
  border: 2px solid transparent;
  border-radius: var(--radius-xl);
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1px;
  transition: opacity 0.2s, transform 0.1s;
}
.amount-quick-btn:active { transform: scale(0.94); }
.amount-quick-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* --- Segmented Control --- */
.segmented {
  display: flex;
  background: var(--secondary-bg);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.segmented-btn {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--hint);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
}
.segmented-btn.active {
  background: var(--section-bg);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* --- Member Pill / Chip --- */
.member-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.member-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--secondary-bg);
  border-radius: var(--radius-xl);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s;
  cursor: pointer;
  border: 2px solid transparent;
}
.member-pill.selected {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}
.member-pill-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* --- Per-member split inputs --- */
.split-members-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.split-member-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--section-bg);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  box-shadow: var(--shadow-sm);
}

.split-member-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.split-member-input {
  width: 90px;
  text-align: right;
  padding: 8px 10px;
  background: var(--secondary-bg);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.split-member-check {
  width: 24px;
  height: 24px;
  border: 2px solid var(--hint);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  cursor: pointer;
  flex-shrink: 0;
}
.split-member-check.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 14px var(--space-lg);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  transition: all 0.15s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-secondary {
  background: var(--secondary-bg);
  color: var(--text);
}
.btn-destructive {
  background: #fff0f0;
  color: var(--destructive);
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
  width: auto;
}

/* --- FAB --- */
.fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  transition: transform 0.2s, box-shadow 0.2s;
}
.fab:active {
  transform: scale(0.9);
}

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 400px;
}

.toast {
  padding: 12px var(--space-md);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}
.toast.success { background: #00b894; color: #fff; }
.toast.error { background: #e74c3c; color: #fff; }
.toast.info { background: var(--section-bg); color: var(--text); }

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

/* --- Bottom Sheet --- */
.bottom-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  animation: fadeOverlay 0.2s ease;
}
@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 201;
  background: var(--section-bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 70vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.bottom-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--hint);
  opacity: 0.3;
  border-radius: 2px;
  margin: 10px auto;
}

.bottom-sheet-content { padding: var(--space-md); }

.bottom-sheet-option {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 14px var(--space-md);
  border-radius: var(--radius-md);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
  text-align: left;
  color: var(--text);
}
.bottom-sheet-option:active { background: var(--secondary-bg); }
.bottom-sheet-option.selected { color: var(--accent); font-weight: 600; }

/* --- Loading --- */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.6);
  z-index: 500;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--secondary-bg);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Inline spinner */
.spinner-inline {
  width: 24px;
  height: 24px;
  border: 2px solid var(--secondary-bg);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: var(--space-xl) auto;
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
  color: var(--hint);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.empty-state-text {
  font-size: 14px;
  line-height: 1.5;
}

/* --- Member list in members view --- */
.member-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--section-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.member-list-item + .member-list-item { margin-top: var(--space-sm); }

.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  overflow: hidden;
}

.member-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}

.member-info { flex: 1; min-width: 0; }
.member-display-name { font-weight: 500; font-size: 15px; }
.member-type { font-size: 12px; color: var(--hint); }

.member-bank {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  margin-top: 2px;
}

.member-qr-thumb {
  margin-top: 6px;
}
.member-qr-thumb img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--secondary-bg);
  cursor: pointer;
}

.member-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.member-action-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.member-action-btn:hover,
.member-action-btn:active {
  background: var(--secondary-bg);
  color: var(--accent);
}
.member-action-btn.danger:hover,
.member-action-btn.danger:active {
  color: var(--destructive);
}

/* --- Expense Detail --- */
.expense-detail-header {
  text-align: center;
  padding: var(--space-xl) 0;
}

.expense-detail-amount {
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
}

.expense-detail-desc {
  font-size: 18px;
  color: var(--hint);
  margin-top: var(--space-sm);
}

.expense-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--secondary-bg);
  font-size: 15px;
}
.expense-detail-row:last-child { border-bottom: none; }
.expense-detail-label { color: var(--hint); }
.expense-detail-value { font-weight: 500; }

.expense-splits-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--section-header);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: var(--space-lg) 0 var(--space-sm);
}

.expense-split-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px var(--space-md);
  background: var(--section-bg);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 14px;
}

/* --- Section Title --- */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--section-header);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-sm);
  margin-top: var(--space-lg);
}
.section-title:first-child { margin-top: 0; }

/* --- Create Group Form --- */
.create-group-form {
  padding: var(--space-md) 0;
}

/* --- Currency badge --- */
.currency-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 24px;
  padding: 0 6px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

/* --- Confirmation dialog inside bottom sheet --- */
.confirm-dialog {
  text-align: center;
  padding: var(--space-md) 0;
}
.confirm-dialog-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}
.confirm-dialog-text {
  font-size: 14px;
  color: var(--hint);
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}
.confirm-dialog-actions {
  display: flex;
  gap: var(--space-sm);
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-lg) 0;
}

.pagination-btn {
  padding: 8px 16px;
  background: var(--section-bg);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  color: var(--accent);
  transition: opacity 0.15s;
}
.pagination-btn:disabled { opacity: 0.4; color: var(--hint); }
.pagination-info { font-size: 14px; color: var(--hint); }

/* --- Transfer card inside group detail --- */
.transfer-card {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  font-size: 14px;
}

.transfer-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.transfer-info { flex: 1; }
.transfer-names { font-weight: 500; }
.transfer-date { font-size: 12px; color: var(--hint); }
.transfer-amount { font-weight: 600; color: var(--accent); }

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* --- Scrollbar styling --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hint); border-radius: 2px; opacity: 0.5; }

/* --- History View --- */
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  margin-bottom: 8px;
}

.history-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
}

.history-action-create {
  background: rgba(52, 199, 89, 0.15);
  color: #34c759;
}

.history-action-update {
  background: rgba(0, 122, 255, 0.15);
  color: #007aff;
}

.history-action-delete {
  background: rgba(255, 59, 48, 0.15);
  color: #ff3b30;
}

.history-body {
  flex: 1;
  min-width: 0;
}

.history-desc {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-time {
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}

.history-undo-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 13px;
}

/* ==========================================================================
   Form Mode Toggle (Expense / Payment)
   ========================================================================== */

.form-mode-toggle {
  display: flex;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border, rgba(0,0,0,0.1));
}

.mode-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--hint);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ==========================================================================
   Transfer / Payment Cards in Expense Timeline
   ========================================================================== */

.transfer-card {
  opacity: 0.9;
}

.transfer-amount {
  color: var(--hint);
}

/* ==========================================================================
   Category Picker (Add/Edit Expense Form)
   ========================================================================== */

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--secondary-bg);
  background: var(--section-bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.category-pill.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
}

.category-pill-icon {
  font-size: 16px;
  line-height: 1;
}

.category-pill-label {
  line-height: 1;
}

/* ==========================================================================
   Category Filter Bar (Expenses Tab)
   ========================================================================== */

.category-filter {
  display: flex;
  gap: 6px;
  padding: 8px 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-filter::-webkit-scrollbar {
  display: none;
}

.category-filter-btn {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--secondary-bg);
  background: var(--section-bg);
  color: var(--hint);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.category-filter-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 600;
}

/* ==========================================================================
   Category Summary (Summary View — By Category Tab)
   ========================================================================== */

.category-summary-total {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  padding: 12px 0 8px;
}

.category-summary-card {
  background: var(--section-bg);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
}

.category-summary-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.category-summary-icon {
  font-size: 20px;
  line-height: 1;
}

.category-summary-name {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.category-summary-amount {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.category-summary-bar-bg {
  height: 6px;
  border-radius: 3px;
  background: var(--secondary-bg);
  overflow: hidden;
  margin-bottom: 6px;
}

.category-summary-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.category-summary-meta {
  font-size: 12px;
  color: var(--hint);
}
