/* ============================================================
   PHAM FAMILY FUND — Design System
   Font: Inter (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ───────────────────────────────────────────── */
:root {
  --primary:        #E8431A;
  --primary-light:  #FF6B35;
  --primary-dark:   #C23010;
  --primary-10:     rgba(232,67,26,.10);
  --primary-20:     rgba(232,67,26,.20);

  --gold:           #F59E0B;
  --gold-10:        rgba(245,158,11,.12);

  --success:        #10B981;
  --success-10:     rgba(16,185,129,.12);
  --warning:        #F59E0B;
  --warning-10:     rgba(245,158,11,.12);
  --danger:         #EF4444;
  --danger-10:      rgba(239,68,68,.12);
  --purple:         #8B5CF6;
  --purple-10:      rgba(139,92,246,.12);

  --bg:             #F4F5F7;
  --surface:        #FFFFFF;
  --surface-2:      #F9FAFB;
  --border:         #E5E7EB;
  --border-2:       #F3F4F6;

  --text:           #111827;
  --text-2:         #374151;
  --text-muted:     #6B7280;
  --text-faint:     #9CA3AF;

  --sidebar-width:  250px;
  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      16px;
  --shadow:         0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10), 0 8px 32px rgba(0,0,0,.08);
  --shadow-lg:      0 12px 40px rgba(0,0,0,.16);
  --transition:     all .2s cubic-bezier(.4,0,.2,1);
  --bottom-nav-h:   0px; /* overridden on mobile */
}

/* ══ DARK MODE ══════════════════════════════════════════ */
html[data-theme="dark"] {
  --bg:         #0D0D1A;
  --surface:    #16162A;
  --surface-2:  #1E1E36;
  --border:     #2A2A48;
  --border-2:   #222240;
  --text:       #E8E8F4;
  --text-2:     #C4C4D8;
  --text-muted: #7878A0;
  --text-faint: #52527A;
  --primary-10: rgba(232,67,26,.18);
  --primary-20: rgba(232,67,26,.30);
  --gold-10:    rgba(245,158,11,.18);
  --success-10: rgba(16,185,129,.18);
  --warning-10: rgba(245,158,11,.18);
  --danger-10:  rgba(239,68,68,.18);
  --purple-10:  rgba(139,92,246,.18);
  --shadow:     0 1px 3px rgba(0,0,0,.5),  0 4px 16px rgba(0,0,0,.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,.6), 0 8px 32px rgba(0,0,0,.5);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.7);
}
html[data-theme="dark"] .login-card { background: var(--surface); }
html[data-theme="dark"] .data-table thead th { background: var(--surface-2); }
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .search-input,
html[data-theme="dark"] .filter-select { background: var(--surface-2); color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .dropzone { border-color: var(--border); }
html[data-theme="dark"] .reply-input-area textarea { background: var(--surface-2); color: var(--text); border-color: var(--border); }
html[data-theme="dark"] .reply-bubble { background: var(--surface-2); border-color: var(--border); }
html[data-theme="dark"] .danh-muc-vat-lieu  { background: rgba(146,64,14,.25);  color: #FCD34D; }
html[data-theme="dark"] .danh-muc-nhan-cong { background: rgba(30,64,175,.25);   color: #93C5FD; }
html[data-theme="dark"] .danh-muc-dich-vu   { background: rgba(107,33,168,.25);  color: #D8B4FE; }


/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ── Utilities ───────────────────────────────────────────── */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.flex     { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .72rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ════════════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════════════ */
#page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(232,67,26,.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(245,158,11,.10) 0%, transparent 60%),
    #F4F5F7;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 48px 40px 40px;
  animation: slideUp .4s cubic-bezier(.4,0,.2,1);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}
.login-logo img { width: 64px; height: 64px; object-fit: contain; }
.login-logo .brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--primary);
}
.login-logo .brand-sub {
  font-size: .75rem;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: -6px;
}

.login-role-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.login-role-tab {
  flex: 1;
  padding: 8px;
  border-radius: 6px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  text-align: center;
}
.login-role-tab.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  color: var(--text);
  background: var(--surface);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-10);
}

.btn-login {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  margin-top: 8px;
  letter-spacing: .02em;
}
.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(232,67,26,.4);
}
.btn-login:active { transform: translateY(0); }

.login-error {
  background: var(--danger-10);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .82rem;
  font-weight: 500;
  margin-top: 12px;
  display: none;
}
.login-error.show { display: block; }

.login-hint {
  margin-top: 20px;
  text-align: center;
  font-size: .75rem;
  color: var(--text-faint);
}

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

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-2);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo img {
  width: 38px; height: 38px;
  object-fit: contain;
  border-radius: 8px;
}
.sidebar-brand { flex: 1; min-width: 0; }
.sidebar-brand-name {
  font-size: .88rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: .68rem;
  color: var(--text-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}

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

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 12px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--primary-10);
  color: var(--primary);
  font-weight: 600;
}
.nav-item .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .8;
}
.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-2);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  cursor: default;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-info .user-name { font-size: .82rem; font-weight: 600; color: var(--text); }
.user-info .user-role {
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  color: var(--text-muted);
  transition: var(--transition);
  width: 100%;
  margin-top: 4px;
}
.btn-logout:hover { background: var(--danger-10); color: var(--danger); }

/* ── Main content ────────────────────────────────────────── */
#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
}

/* ── Page header ─────────────────────────────────────────── */
.page-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: .83rem; color: var(--text-muted); margin-top: 2px; }

.page-actions { display: flex; gap: 10px; align-items: center; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(232,67,26,.25);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(232,67,26,.35);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 12px;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ── Stats cards ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  padding: 24px 32px;
}
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: var(--transition);
  border: 1px solid var(--border-2);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--primary));
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-bg, var(--primary-10));
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; color: var(--card-color, var(--primary)); }

.stat-body { flex: 1; min-width: 0; }
.stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--card-color, var(--primary));
  line-height: 1.1;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Progress bar ────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--border);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin-top: 10px;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary-dark));
  transition: width .8s cubic-bezier(.4,0,.2,1);
}

/* ── Goal progress card ──────────────────────────────────── */
.goal-banner {
  margin: 0 32px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  padding: 20px 24px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(232,67,26,.3);
  position: relative;
  overflow: hidden;
}
.goal-banner::before {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.goal-banner::after {
  content: '';
  position: absolute;
  right: 40px; bottom: -60px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
}
.goal-banner-icon {
  width: 48px; height: 48px;
  background: rgba(255,255,255,.2);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.goal-banner-icon svg { width: 24px; height: 24px; color: #fff; }
.goal-banner-body { flex: 1; z-index: 1; }
.goal-banner-title { font-size: 1rem; font-weight: 700; }
.goal-banner-sub { font-size: .78rem; opacity: .8; margin-top: 2px; }
.goal-banner-stats {
  display: flex; gap: 24px; align-items: center; z-index: 1;
}
.goal-stat-item { text-align: right; }
.goal-stat-value { font-size: 1.1rem; font-weight: 800; }
.goal-stat-label { font-size: .68rem; opacity: .75; letter-spacing: .05em; text-transform: uppercase; }
.goal-progress-section { z-index: 1; width: 160px; flex-shrink: 0; }
.goal-percent { font-size: 2rem; font-weight: 800; line-height: 1; }
.goal-percent span { font-size: .85rem; font-weight: 500; opacity: .8; }
.goal-progress-bar {
  height: 8px;
  background: rgba(255,255,255,.25);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.goal-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 99px;
  transition: width 1s cubic-bezier(.4,0,.2,1);
}

/* ── Toolbar ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 32px 16px;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}
.search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  width: 15px; height: 15px;
}
.search-input {
  width: 100%;
  padding: 9px 14px 9px 34px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: var(--transition);
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-10); }

.filter-select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .83rem;
  color: var(--text-2);
  background: var(--surface);
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}
.filter-select:focus { border-color: var(--primary); }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap {
  padding: 0 32px 40px;
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.data-table thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

.data-table tbody tr {
  border-bottom: 1px solid var(--border-2);
  transition: var(--transition);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody td { padding: 13px 14px; vertical-align: middle; white-space: nowrap; }

.data-table tbody tr td:first-child {
  color: var(--text-faint);
  font-weight: 500;
  font-size: .8rem;
  width: 40px;
}

/* Table wrapper card */
.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  overflow: visible; /* allow table-wrap to scroll */
}

/* ── Member name cell ────────────────────────────────────── */
.member-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.member-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -.5px;
}
.member-name { font-weight: 600; color: var(--text); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.member-id-tag {
  font-size: .68rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 500;
}

/* ── Status badge ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-success { background: var(--success-10); color: var(--success); }
.badge-warning { background: var(--warning-10); color: var(--warning); }
.badge-danger  { background: var(--danger-10);  color: var(--danger);  }
.badge-purple  { background: var(--purple-10);  color: var(--purple);  }
.badge-gray    { background: var(--bg); color: var(--text-muted); }

/* ── Action button ───────────────────────────────────────── */
.btn-detail {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--primary);
  border: 1.5px solid var(--primary-20);
  transition: var(--transition);
  white-space: nowrap;
}
.btn-detail:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(232,67,26,.3);
}

/* Amount cell */
.amount { font-weight: 700; font-size: .9rem; }
.amount.positive { color: var(--success); }
.amount.zero     { color: var(--text-faint); }

/* ════════════════════════════════════════════════════════════
   MEMBER DETAIL PANEL
   ════════════════════════════════════════════════════════════ */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  opacity: 0;
  pointer-events: none; /* FIX: don't block clicks when invisible */
  transition: opacity .3s ease;
  backdrop-filter: blur(2px);
}
.panel-overlay.show { opacity: 1; pointer-events: all; }

.side-panel {
  position: fixed;
  top: 0; right: 0;
  width: 480px;
  height: 100vh;
  background: var(--surface);
  z-index: 1201;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
.side-panel.show { transform: translateX(0); }

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
}
.panel-close {
  margin-left: auto;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}
.panel-close:hover { background: var(--bg); color: var(--text); }

.panel-member-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.panel-member-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.panel-member-meta { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

.panel-body { flex: 1; overflow-y: auto; padding: 24px; }

.panel-section { margin-bottom: 24px; }
.panel-section-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-2);
}

.panel-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.panel-info-item .label { font-size: .73rem; color: var(--text-muted); font-weight: 500; margin-bottom: 2px; }
.panel-info-item .value { font-size: .88rem; font-weight: 600; color: var(--text); }

.summary-box {
  background: var(--primary-10);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--primary-20);
}
.summary-box-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.02em;
}
.summary-box-label { font-size: .75rem; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
/* QR: natural ratio, full display, no clip */
.qr-img-wrap {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  width: 100%;
  display: block;
}
.qr-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}
.qr-label { font-size: .75rem; color: var(--text-muted); text-align: center; }

.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
}
.tx-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.tx-info { flex: 1; }
.tx-date { font-size: .72rem; color: var(--text-muted); }
.tx-desc { font-size: .82rem; font-weight: 500; color: var(--text-2); margin-top: 1px; }
.tx-amount { font-weight: 700; color: var(--success); font-size: .9rem; }

.tx-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-faint);
  font-size: .83rem;
}

/* ════════════════════════════════════════════════════════════
   GOALS VIEW
   ════════════════════════════════════════════════════════════ */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding: 24px 32px 40px;
}
.goal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  overflow: hidden;
  transition: var(--transition);
}
.goal-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.goal-card-top {
  padding: 20px;
  border-bottom: 1px solid var(--border-2);
}
.goal-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.goal-card-name { font-size: .95rem; font-weight: 700; color: var(--text); }
.goal-card-desc { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.goal-card-amounts {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.goal-amount-item .label { font-size: .68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.goal-amount-item .value { font-size: .95rem; font-weight: 700; margin-top: 2px; }
.goal-card-bottom { padding: 14px 20px; }
.goal-card-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.goal-card-deadline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .73rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ════════════════════════════════════════════════════════════
   UNC UPLOAD VIEW
   ════════════════════════════════════════════════════════════ */
.unc-container {
  padding: 24px 32px 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .unc-container { grid-template-columns: 1fr; } }

.unc-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  padding: 24px;
}
.unc-card-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 40px 24px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-10);
}
.dropzone-icon { color: var(--text-faint); margin: 0 auto 12px; }
.dropzone-text { font-size: .85rem; color: var(--text-muted); }
.dropzone-text strong { color: var(--primary); }
.dropzone-hint { font-size: .75rem; color: var(--text-faint); margin-top: 4px; }

.unc-guide-steps { display: flex; flex-direction: column; gap: 12px; }
.unc-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.unc-step-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.unc-step-text { font-size: .83rem; color: var(--text-2); line-height: 1.5; }
.unc-step-text strong { color: var(--text); font-weight: 600; }

/* ── Preview table ───────────────────────────────────────── */
.preview-card {
  grid-column: 1 / -1;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  overflow: hidden;
  display: none;
}
.preview-card.show { display: block; }
.preview-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ════════════════════════════════════════════════════════════
   ADMIN MANAGE VIEWS
   ════════════════════════════════════════════════════════════ */
.view-container { padding: 24px 32px 40px; }

.info-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  overflow: hidden;
  margin-bottom: 24px;
}
.info-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
  font-weight: 600;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.info-card-body { padding: 20px; }

/* ════════════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 1300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  backdrop-filter: blur(2px);
}
.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(.95);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-2);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ════════════════════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state-icon { color: var(--text-faint); margin-bottom: 16px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: .83rem; text-align: center; }

/* ════════════════════════════════════════════════════════════
   TOAST / NOTIFICATION
   ════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: .83rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight .3s cubic-bezier(.4,0,.2,1);
  min-width: 240px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ════════════════════════════════════════════════════════════
   LOADING
   ════════════════════════════════════════════════════════════ */
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.8);
  z-index: 1500;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}

/* ════════════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════════════ */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.animate-fade { animation: fadeIn .3s ease; }

/* ════════════════════════════════════════════════════════════
   SCROLLBAR
   ════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.mobile-open { transform: translateX(0); }
  #main-content { margin-left: 0; }
  .page-header { padding: 20px 16px 0; }
  .stats-grid { padding: 16px; }
  .toolbar { padding: 0 16px 12px; }
  /* table: full horizontal scroll, min-width forces layout */
  .table-wrap {
    padding: 0 0 80px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-card { border-radius: 0; border-left: none; border-right: none; }
  .data-table { min-width: 640px; }
  /* member name: 1 line, truncate if too long */
  .member-name { max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* note column: truncate at 120px */
  .cell-note {
    display: inline-block;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
  }
  .goal-banner { margin: 0 16px 16px; flex-direction: column; align-items: flex-start; }
  .goal-banner-stats { flex-direction: column; gap: 8px; }
}

/* ════════════════════════════════════════════════════════════
   BADGE EXTRA
   ════════════════════════════════════════════════════════════ */
.badge-primary-solid {
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge-pin {
  background: var(--gold-10);
  color: var(--gold);
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}

/* ════════════════════════════════════════════════════════════
   EXPENSES VIEW
   ════════════════════════════════════════════════════════════ */
.expenses-container { padding: 24px 32px 40px; }

.expense-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .expense-summary-row { grid-template-columns: repeat(2,1fr); } }

.expense-summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  border-top: 3px solid var(--card-color, var(--primary));
}
.expense-summary-card .label {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.expense-summary-card .value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--card-color, var(--primary));
  letter-spacing: -.02em;
}
.expense-summary-card .sub {
  font-size: .73rem;
  color: var(--text-faint);
  margin-top: 4px;
}

.category-breakdown {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.category-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.category-tag:hover { border-color: var(--primary); color: var(--primary); }
.category-tag.active { background: var(--primary-10); border-color: var(--primary); color: var(--primary); }
.category-tag .dot { width: 6px; height: 6px; border-radius: 50%; }

.expense-table-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  overflow: hidden;
}
.expense-table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.expense-table-title { font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: 8px; }

.danh-muc-badge {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 600;
}
.danh-muc-vat-lieu { background: #FEF3C7; color: #92400E; }
.danh-muc-nhan-cong { background: #DBEAFE; color: #1E40AF; }
.danh-muc-dich-vu { background: #F3E8FF; color: #6B21A8; }
.danh-muc-khac { background: var(--bg); color: var(--text-muted); }

.trang-thai-chi { font-size: .75rem; font-weight: 600; }
.trang-thai-da-chi { color: var(--success); }
.trang-thai-tam-ung { color: var(--warning); }

/* ════════════════════════════════════════════════════════════
   DISCUSSIONS VIEW
   ════════════════════════════════════════════════════════════ */
.discussions-container { padding: 24px 32px 40px; }

.discussions-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 1000px) { .discussions-layout { grid-template-columns: 1fr; } }

.post-list { display: flex; flex-direction: column; gap: 12px; }

.post-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  padding: 18px 20px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.post-card:hover { border-color: var(--primary-20); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.post-card.pinned { border-left: 3px solid var(--gold); }
.post-card.active  { border-color: var(--primary); background: var(--primary-10); }

.post-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.post-author-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary-dark));
  color: #fff;
  font-weight: 700;
  font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.post-author-name { font-size: .8rem; font-weight: 600; color: var(--text-2); }
.post-date { font-size: .72rem; color: var(--text-faint); margin-left: auto; }

.post-title {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.35;
}
.post-preview {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-2);
}
.post-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .73rem;
  color: var(--text-faint);
}

/* Post detail panel (right side) */
.post-detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.post-detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
}
.post-detail-title { font-size: .95rem; font-weight: 700; color: var(--text); line-height: 1.4; }
.post-detail-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.post-detail-body {
  padding: 16px 20px;
  flex: 1;
  overflow-y: auto;
  font-size: .85rem;
  color: var(--text-2);
  line-height: 1.65;
  white-space: pre-wrap;
  border-bottom: 1px solid var(--border-2);
}

.replies-section { padding: 12px 20px 16px; overflow-y: auto; }
.replies-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.reply-item {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.reply-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: .65rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.reply-bubble {
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) var(--radius-sm);
  padding: 10px 14px;
  flex: 1;
  font-size: .8rem;
  color: var(--text-2);
  line-height: 1.5;
  border: 1px solid var(--border-2);
  white-space: pre-wrap;
}
.reply-date { font-size: .68rem; color: var(--text-faint); margin-top: 4px; }

.new-post-form-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-2);
  padding: 20px;
  margin-bottom: 20px;
}
.new-post-form-title {
  font-weight: 700;
  font-size: .88rem;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.new-post-form { display: flex; flex-direction: column; gap: 10px; }

.empty-discussion {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--text-muted);
  text-align: center;
}

/* reply input */
.reply-input-area {
  padding: 12px 20px;
  border-top: 1px solid var(--border-2);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.reply-input-area textarea {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: .83rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: var(--transition);
  min-height: 60px;
}
.reply-input-area textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-10); }

/* ════════════════════════════════════════════════════════════
   SIDE PANEL (Member Detail)
   ════════════════════════════════════════════════════════════ */
.panel-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  backdrop-filter: blur(2px);
}
.panel-overlay.show { opacity: 1; pointer-events: all; }

.side-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(420px, 95vw);
  background: var(--surface);
  z-index: 1201;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.side-panel.show { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-2);
  flex-shrink: 0;
}
.panel-member-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  color: #fff; font-weight: 800; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.panel-member-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.panel-member-meta { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.panel-close {
  margin-left: auto; width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: var(--transition);
  flex-shrink: 0;
}
.panel-close:hover { background: var(--surface-2); color: var(--text); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scroll-behavior: smooth;
}

.panel-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-2);
}
.panel-section:last-child { border-bottom: none; }
.panel-section-title {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 12px;
}

.summary-box {
  background: var(--primary-10);
  border: 1px solid var(--primary-20);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
}
.summary-box-value { font-size: 1.15rem; font-weight: 800; color: var(--primary); }
.summary-box-label { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

.panel-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.panel-info-item .label { font-size: .7rem; color: var(--text-faint); margin-bottom: 4px; }
.panel-info-item .value { font-size: .83rem; font-weight: 600; color: var(--text-2); }

/* QR Section — FIXED: no clipping, natural image size */
.qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
/* qr-img-wrap defined globally above — no override here */

/* Transaction timeline in panel */
.tx-list { display: flex; flex-direction: column; gap: 0; }
.tx-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-2);
  position: relative;
}
.tx-item:last-child { border-bottom: none; }
.tx-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0;
  margin-top: 5px;
}
.tx-info { flex: 1; }
.tx-date { font-size: .72rem; color: var(--text-faint); }
.tx-desc { font-size: .82rem; color: var(--text-2); margin-top: 2px; }
.tx-amount { font-weight: 700; font-size: .88rem; color: var(--success); flex-shrink: 0; }
.tx-empty { color: var(--text-faint); font-size: .82rem; text-align: center; padding: 20px 0; }

/* ════════════════════════════════════════════════════════════
   DARK MODE TOGGLE BUTTON
   ════════════════════════════════════════════════════════════ */
.dark-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}
.dark-toggle:hover { background: var(--surface-2); color: var(--text); }

/* ════════════════════════════════════════════════════════════
   FILE ATTACHMENT STYLES
   ════════════════════════════════════════════════════════════ */
.attach-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.attach-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .75rem;
  color: var(--text-2);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  max-width: 180px;
}
.attach-chip:hover { border-color: var(--primary); color: var(--primary); }
.attach-chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-chip svg { flex-shrink: 0; color: var(--text-faint); }
.attach-chip .chip-remove {
  margin-left: 2px; color: var(--text-faint);
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}
.attach-chip .chip-remove:hover { background: var(--danger-10); color: var(--danger); }

.upload-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.upload-label:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-10); }

.expense-comment-section {
  padding: 14px 0 0;
}
.expense-comment-title {
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 10px;
}

/* ════════════════════════════════════════════════════════════
   MOBILE BOTTOM NAVIGATION
   ════════════════════════════════════════════════════════════ */
#mobile-bottom-nav {
  display: none; /* hidden on desktop */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border-2);
  z-index: 150;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
}
.bottom-nav-inner {
  display: flex;
  height: 100%;
  align-items: stretch;
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  transition: var(--transition);
  padding: 6px 4px;
  border: none;
  background: none;
  font-family: inherit;
  position: relative;
}
.bottom-nav-item svg { width: 20px; height: 20px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}
.bottom-nav-badge {
  position: absolute;
  top: 6px; right: calc(50% - 14px);
  background: var(--danger);
  color: #fff;
  font-size: .55rem;
  font-weight: 800;
  min-width: 14px; height: 14px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* Responsive overrides for mobile */
@media (max-width: 768px) {
  :root { --bottom-nav-h: 64px; }
  #sidebar { display: none; }
  #mobile-bottom-nav { display: block; }
  #main-content {
    margin-left: 0;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  .page-header { padding: 16px 16px 0; }
  .stats-grid { grid-template-columns: repeat(2,1fr); padding: 14px 16px; gap: 10px; }
  .toolbar { padding: 0 16px 12px; }
  .table-wrap { padding: 0 0 80px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .goal-banner { margin: 0 16px 16px; flex-direction: column; gap: 12px; }
  .goal-banner-stats { flex-direction: row; gap: 12px; }
  .discussions-layout { grid-template-columns: 1fr; }
  .expenses-container { padding: 16px 16px 32px; }
  .expense-summary-row { grid-template-columns: repeat(2,1fr); }
  .discussions-container { padding: 16px 16px 32px; }
  .post-detail-card { position: static; max-height: none; }
  .side-panel { width: 100%; }
  .goals-grid { padding: 16px !important; }
  .modal { width: 95vw; margin: 16px; }
}

/* Notification Bell */
.notification-bell-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: var(--text-2);
  cursor: pointer;
  transition: var(--transition);
}
.notification-bell-wrap:hover {
  background: var(--surface-2);
  color: var(--text);
}
.notification-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--danger);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: none; /* hidden by default, shown by JS */
  align-items: center; justify-content: center;
  border: 2px solid var(--surface);
}

.bottom-nav-item svg { transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
.bottom-nav-item.active svg { transform: translateY(-3px) scale(1.1); }

/* ══ MEMBER DETAIL PANEL ══════════════════════════════════════ */
.panel-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1100;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.panel-overlay.show { opacity: 1; pointer-events: all; }

.member-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: var(--surface);
  z-index: 1200;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: -4px 0 32px rgba(0,0,0,.18);
  border-left: 1px solid var(--border);
}
.member-panel.show { transform: translateX(0); }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-title { font-size: 1rem; font-weight: 700; color: var(--text-1); }
.panel-close {
  width: 32px; height: 32px;
  border: none; background: var(--surface-2); color: var(--text-2);
  border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.panel-close:hover { background: var(--danger-10); color: var(--danger); }

.panel-body {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

.panel-identity {
  display: flex; align-items: center; gap: 14px;
}
.panel-avatar {
  width: 56px; height: 56px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 1.2rem;
  flex-shrink: 0;
  background: linear-gradient(135deg,var(--primary),var(--purple));
}
.panel-name { font-size: 1.05rem; font-weight: 700; color: var(--text-1); }
.panel-meta { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }

.panel-status-bar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border-radius: 12px;
  padding: 12px 16px;
}
.panel-stat-label { font-size: .75rem; color: var(--text-muted); margin-bottom: 3px; }
.panel-stat-value { font-size: 1.1rem; font-weight: 700; color: var(--primary); }

.panel-info-grid { display: flex; flex-direction: column; gap: 10px; }
.panel-info-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 10px 14px;
  background: var(--surface-2); border-radius: 10px;
  font-size: .875rem;
}
.panel-info-label { color: var(--text-muted); font-size: .8rem; }
.panel-info-row > span:last-child { color: var(--text-1); font-weight: 500; text-align: right; max-width: 60%; }

.panel-section-title {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-muted);
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}

/* QR — defined globally, no override */

/* TX list */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--surface-2); border-radius: 10px;
}
.tx-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--success);
}
.tx-info { flex: 1; min-width: 0; }
.tx-date { font-size: .75rem; color: var(--text-muted); }
.tx-desc { font-size: .85rem; color: var(--text-1); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amount { font-size: .9rem; font-weight: 700; color: var(--success); white-space: nowrap; }
.tx-empty { text-align: center; color: var(--text-muted); font-size: .85rem; padding: 20px 0; }

/* btn-detail */
.btn-detail {
  padding: 5px 12px; font-size: .8rem; font-weight: 600;
  background: var(--primary-10); color: var(--primary);
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-detail:hover { background: var(--primary); color: #fff; }

/* Loading Spinner */
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.goal-card-name { font-size: 1.1rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-card-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.goal-banner-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-banner-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-banner-body { min-width: 0; }

