@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

:root {
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --surface: #22222e;
  --surface2: #2a2a38;
  --border: #32324a;
  --border2: #3e3e5a;
  --accent: #6c63ff;
  --accent2: #8b85ff;
  --accent3: #4f46e5;
  --green: #22c55e;
  --green2: #16a34a;
  --red: #ef4444;
  --red2: #dc2626;
  --orange: #f97316;
  --yellow: #eab308;
  --text: #f0f0f8;
  --text2: #a0a0c0;
  --text3: #6060a0;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-accent: 0 4px 24px rgba(108,99,255,0.25);
  --font: 'DM Sans', sans-serif;
  --font-display: 'Syne', sans-serif;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* --- TYPOGRAPHY --- */
h1,h2,h3,h4,h5 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.2rem; }
p { color: var(--text2); }
a { color: var(--accent2); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text); }

/* --- LAYOUT --- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.page-wrap { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--bg2); border-right: 1px solid var(--border); padding: 24px 0; position: fixed; top: 0; left: 0; height: 100vh; display: flex; flex-direction: column; z-index: 100; transition: transform var(--transition); }
.main-content { margin-left: 240px; flex: 1; padding: 32px 40px; min-height: 100vh; }

/* --- SIDEBAR NAV --- */
.sidebar-logo { padding: 0 24px 28px; border-bottom: 1px solid var(--border); }
.sidebar-logo .logo-text { font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; color: var(--text); }
.sidebar-logo .logo-text span { color: var(--accent2); }
.sidebar-nav { flex: 1; padding: 16px 12px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3); padding: 0 12px; margin: 16px 0 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text2); font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all var(--transition); border: none; background: none; width: 100%; text-align: left; text-decoration: none; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: rgba(108,99,255,0.15); color: var(--accent2); }
.nav-item .icon { width: 20px; text-align: center; font-size: 1rem; }
.nav-item .badge { margin-left: auto; background: var(--accent); color: white; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 6px; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition); }
.user-chip:hover { background: var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.avatar-lg { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar-xl { width: 80px; height: 80px; font-size: 1.8rem; }
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 0.85rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .email { font-size: 0.72rem; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- CARDS --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.card-sm { padding: 16px; }
.card-hover { transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition); cursor: pointer; }
.card-hover:hover { border-color: var(--border2); box-shadow: var(--shadow); transform: translateY(-2px); }
.card-accent { border-color: var(--accent3); background: rgba(108,99,255,0.07); }

/* --- BUTTONS --- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-sm); font-family: var(--font); font-size: 0.9rem; font-weight: 600; cursor: pointer; border: none; transition: all var(--transition); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent2); box-shadow: var(--shadow-accent); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface); border-color: var(--border2); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: var(--red2); }
.btn-green { background: var(--green2); color: white; }
.btn-green:hover { background: var(--green); }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- FORMS --- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text2); margin-bottom: 6px; letter-spacing: 0.02em; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px; color: var(--text);
  font-family: var(--font); font-size: 0.9rem; transition: border-color var(--transition);
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text3); }
.form-select { appearance: none; cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.78rem; color: var(--text3); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--red); margin-top: 4px; }

/* --- BADGES & TAGS --- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-orange { background: rgba(249,115,22,0.15); color: var(--orange); }
.badge-purple { background: rgba(108,99,255,0.15); color: var(--accent2); }
.badge-gray { background: var(--surface2); color: var(--text2); }

/* --- STAT CARDS --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-label { font-size: 0.78rem; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat-sub { font-size: 0.78rem; color: var(--text3); margin-top: 4px; }
.stat-green { color: var(--green); }
.stat-red { color: var(--red); }
.stat-purple { color: var(--accent2); }

/* --- PAGE HEADER --- */
.page-header { margin-bottom: 28px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.page-subtitle { color: var(--text3); font-size: 0.88rem; margin-top: 2px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--text3); margin-bottom: 6px; }
.breadcrumb a { color: var(--text3); }
.breadcrumb a:hover { color: var(--text2); }
.breadcrumb .sep { color: var(--border2); }

/* --- EXPENSE LIST --- */
.expense-list { display: flex; flex-direction: column; gap: 2px; }
.expense-item { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius-sm); transition: background var(--transition); cursor: pointer; }
.expense-item:hover { background: var(--surface2); }
.expense-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.expense-info { flex: 1; min-width: 0; }
.expense-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-meta { font-size: 0.78rem; color: var(--text3); }
.expense-amount { text-align: right; flex-shrink: 0; }
.expense-amount .total { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }
.expense-amount .share { font-size: 0.75rem; color: var(--text3); }
.expense-amount.owe .share { color: var(--red); }
.expense-amount.lent .share { color: var(--green); }

/* --- MEMBER ROW --- */
.member-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member-row:last-child { border-bottom: none; }
.member-info { flex: 1; }
.member-name { font-weight: 600; font-size: 0.9rem; }
.member-role { font-size: 0.75rem; color: var(--text3); }
.member-balance { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }

/* --- MODAL --- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; transform: translateY(20px); transition: transform var(--transition); }
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 1.2rem; transition: color var(--transition); }
.modal-close:hover { color: var(--text); }

/* --- TABS --- */
.tabs { display: flex; gap: 4px; background: var(--bg3); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tab-btn { flex: 1; padding: 8px 16px; border-radius: 6px; border: none; background: none; color: var(--text3); font-family: var(--font); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all var(--transition); }
.tab-btn.active { background: var(--surface); color: var(--text); }

/* --- ALERTS --- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 0.88rem; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.2); color: var(--green); }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: var(--red); }
.alert-info { background: rgba(108,99,255,0.1); border: 1px solid rgba(108,99,255,0.2); color: var(--accent2); }

/* --- DIVIDER --- */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.divider-text { text-align: center; position: relative; color: var(--text3); font-size: 0.82rem; margin: 20px 0; }
.divider-text::before { content:''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--border); }
.divider-text span { background: var(--bg2); padding: 0 12px; position: relative; }

/* --- EMPTY STATE --- */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.empty-desc { color: var(--text3); font-size: 0.88rem; margin-bottom: 20px; }

/* --- PROGRESS BAR --- */
.progress { height: 6px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; transition: width 0.5s ease; }

/* --- TOAST --- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 0.88rem; font-weight: 500; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); transform: translateX(120%); transition: transform 0.3s ease; max-width: 320px; }
.toast.show { transform: translateX(0); }
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }

/* --- TOPBAR --- */
.topbar { display: none; background: var(--bg2); border-bottom: 1px solid var(--border); padding: 12px 20px; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }

/* --- GRID HELPERS --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.text-right { text-align: right; }
.text-muted { color: var(--text3); }
.font-bold { font-weight: 700; }
.font-display { font-family: var(--font-display); }

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .topbar { display: flex; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header-row { flex-direction: column; align-items: flex-start; }
}

/* --- ANIMATIONS --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
.animate-in { animation: fadeIn 0.3s ease forwards; }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%); background-size: 200%; animation: shimmer 1.5s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* --- SPLIT INPUT --- */
.split-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.split-row:last-child { border-bottom: none; }
.split-toggle { width: 36px; height: 36px; border-radius: 8px; border: 2px solid var(--border); background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); color: var(--text3); }
.split-toggle.active { border-color: var(--accent); background: rgba(108,99,255,0.15); color: var(--accent2); }
.split-amount-input { width: 90px; text-align: right; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; color: var(--text); font-family: var(--font); font-size: 0.88rem; }
.split-amount-input:focus { outline: none; border-color: var(--accent); }

/* --- SETTLE UP --- */
.settle-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.settle-arrow { color: var(--text3); font-size: 1.2rem; }
.settle-amount { font-family: var(--font-display); font-weight: 700; color: var(--orange); font-size: 1rem; }
